Created
August 4, 2011 09:27
-
-
Save aragaer/1124829 to your computer and use it in GitHub Desktop.
item equip subroutine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def equip(name): | |
name = ' '.join(name) | |
item = get_inv_item(name, False) | |
if item.equipped: | |
print "%s is already equipped", name | |
return | |
if item.slot is None: | |
print "You equip %s" % name | |
power += item.bonus | |
return | |
if item.need_hands == 0: | |
other = getattr(slots, item.slot) | |
if other: | |
print "You can't equip %s since you already got %s as %s" % (name, other.name, item.slot) | |
else: | |
print "You equip %s as %s" % (name, item.slot) | |
power += item.bonus | |
return | |
if slots.free_hands < item.need_hands: | |
if item.need_hands == 1: | |
print "You need a free hand to hold %s" % name | |
else | |
print "You need %d free hands to hold %s and you have %d" % (item.need_hands, name, slots.free_hands) | |
return | |
slots.free_hands -= item.need_hands | |
print "You equip %s" % name | |
power += item.bonus |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment