def equipWeapon(player, item): currentShield = player.equipped["shield"] currentWeapon = player.equipped["weapon"] if item.location == "weapon": if not currentWeapon: print "You grip your {} in your weapon hand.\n".format(item.name) equip(player, item) elif currentWeapon: print "You put away your {} and grip your {} in your weapon hand.\n".format(currentWeapon.name, item.name) unequip(player, currentWeapon) equip(player, item) elif item.location == "twohanded": if not currentWeapon and not currentShield: print "You grip your {} with both hands.\n".format(item.name) equip(player, item) elif currentShield and not currentWeapon: print "You put away your {} and grip your {} with both hands.\n".format(currentShield.name, item.name) unequip(player, currentShield) equip(player, item) elif currentWeapon and not currentShield: print "You put away your {} and grip your {} with both hands.\n".format(currentWeapon.name, item.name) unequip(player, currentWeapon) equip(player, item) elif currentWeapon and currentShield: print "You put away your {} and {} and grip your {} with both hands.\n".format(currentWeapon.name, currentShield.name, item.name) unequip(player, currentWeapon) unequip(player, currentShield) equip(player, item) effects.applyList(item.special, player) player.calcStats()
def use(player, item): for carried in player.inventory: if item.lower() in carried.keyword: if carried.uses > 0: effects.applyList(carried.special, player) carried.uses -= 1 if carried.uses == 0: print "The {} is no longer of any use.\n".format(carried.name) player.inventory.remove(carried) break
def equipArmor(player, item): """ Moved items from player's inventory into proper equipment slot and applies any effects :param player: player object that is calling the equip command :param item: item to be equipped :return: None """ if item.location in ("body", "head", "hands", "legs", "feet"): if not player.equipped[item.location]: print "You pull the {} over your {}.\n".format(item.name, item.location) equip(player, item) elif player.equipped[item.location]: print "You remove the {} from your {} and pull on the {}.\n".format(player.equipped[item.location].name, item.location, item.name) unequip(player, player.equipped[item.location]) equip(player, item) elif item.location == "shield": currentShield = player.equipped["shield"] currentWeapon = player.equipped["weapon"] if not currentWeapon and not currentShield: print "You strap your {} to your shield arm.\n".format(item.name) equip(player, item) elif currentShield and not currentWeapon: print "You put away your {} and strap your {} to your shield arm.\n".format(currentShield.name, item.name) unequip(player, currentShield) equip(player, item) elif currentWeapon and not currentShield: if currentWeapon.location == "twohanded": print "You put away your {} and strap your {} to your shield arm.\n".format(currentWeapon.name, item.name) unequip(player, currentWeapon) equip(player, item) elif currentWeapon.location == "weapon": print "You strap your {} to your shield arm.\n".format(item.name) equip(player, item) elif currentWeapon and currentShield: if currentWeapon.location == "twohanded": print "You put away your {} and {} and strap your {} to your shield arm.\n".format(currentWeapon.name, currentShield.name, item.name) unequip(player, currentWeapon) unequip(player, currentShield) equip(player, item) elif currentWeapon.location == "weapon": print "You put away your {} and strap your {} to your shield arm.\n".format(currentShield.name, item.name) unequip(player, currentShield) equip(player, item) effects.applyList(item.special, player) player.calcStats()