#Came up with this for
#storing, and equiping items in python
inventory = []
armor = {"head": "rags",
"torso":"rags",
"arms":"rags",
"legs":"cloth",
"feet":"sandals",
"special":"ill-concieved necklace"}
equipment = ["armor_head", "armor_torso", "armor_arms", "armor_legs", "armor_feet", "armor_special"]
item_armor ={
"armor_head":["rags", "leather hat", "diamond plate helm"],
"armor_torso":["rags", "leather armor", "diamond plate armor"],
"armor_arms":["rags", "leather bracers", "diamond bracers"],
"armor_legs":["cloth", "leather pants", "diamond pants"],
"armor_feet":["sandals", "leather shoes", "diamond shoes"],
"armor_special":["ill-concieved necklace", "charming bracelet", "lucky ring"]
}
def store_item(item):
inventory.append(item)
def equip_item(item1, item2):
if equipment.__contains__(item1):
if "armor_head" == item1:
old_item = armor["head"]
store_item(old_item)
armor["head"] = item2
inventory.remove(item2)
if "armor_torso" == item1:
old_item = armor["torso"]
store_item(old_item)
armor["torso"] = item2
inventory.remove(item2)
if "armor_arms" == item1:
old_item = armor["arms"]
store_item(old_item)
armor["arms"] = item2
inventory.remove(item2)
if "armor_legs" == item1:
old_item = armor["legs"]
store_item(old_item)
armor["legs"] = item2
inventory.remove(item2)
else:
print "item is not equipable"
stats = {
"basedefense": 2,
"strength": 3,
"hit": 2,
"armor": 4}
battlestats = {
"defense" : stats["basedefense"] + stats["armor"],
"attack" : stats["strength"] + stats["hit"]
}
def updatestats():
if armor["head"] == "rags":
stats["armor"] = stats["armor"] +1
if armor["head"] == "leather hat":
stats["armor"] = stats["armor"] +3
def updatebattlestats():
battlestats["defense"] = stats["basedefense"] + stats["armor"]
battlestats["attack"] = stats["strength"] + stats["hit"]
#else:
#print "Not Working"
# I can use the 'hashtag' to take out the parts of the test I don't need
def runtest():
store_item( "leather hat")
store_item( "leather armor")
store_item( "leather pants" )
store_item( "leather bracers" )
#print armor
#print inventory
equip_item("armor_head", "leather hat")
equip_item("armor_torso", "leather armor")
#print armor
#print inventory
print stats
print battlestats
#print attack
updatestats()
updatebattlestats()
print stats
print battlestats
runtest()
#storing, and equiping items in python
inventory = []
armor = {"head": "rags",
"torso":"rags",
"arms":"rags",
"legs":"cloth",
"feet":"sandals",
"special":"ill-concieved necklace"}
equipment = ["armor_head", "armor_torso", "armor_arms", "armor_legs", "armor_feet", "armor_special"]
item_armor ={
"armor_head":["rags", "leather hat", "diamond plate helm"],
"armor_torso":["rags", "leather armor", "diamond plate armor"],
"armor_arms":["rags", "leather bracers", "diamond bracers"],
"armor_legs":["cloth", "leather pants", "diamond pants"],
"armor_feet":["sandals", "leather shoes", "diamond shoes"],
"armor_special":["ill-concieved necklace", "charming bracelet", "lucky ring"]
}
def store_item(item):
inventory.append(item)
def equip_item(item1, item2):
if equipment.__contains__(item1):
if "armor_head" == item1:
old_item = armor["head"]
store_item(old_item)
armor["head"] = item2
inventory.remove(item2)
if "armor_torso" == item1:
old_item = armor["torso"]
store_item(old_item)
armor["torso"] = item2
inventory.remove(item2)
if "armor_arms" == item1:
old_item = armor["arms"]
store_item(old_item)
armor["arms"] = item2
inventory.remove(item2)
if "armor_legs" == item1:
old_item = armor["legs"]
store_item(old_item)
armor["legs"] = item2
inventory.remove(item2)
else:
print "item is not equipable"
stats = {
"basedefense": 2,
"strength": 3,
"hit": 2,
"armor": 4}
battlestats = {
"defense" : stats["basedefense"] + stats["armor"],
"attack" : stats["strength"] + stats["hit"]
}
def updatestats():
if armor["head"] == "rags":
stats["armor"] = stats["armor"] +1
if armor["head"] == "leather hat":
stats["armor"] = stats["armor"] +3
def updatebattlestats():
battlestats["defense"] = stats["basedefense"] + stats["armor"]
battlestats["attack"] = stats["strength"] + stats["hit"]
#else:
#print "Not Working"
# I can use the 'hashtag' to take out the parts of the test I don't need
def runtest():
store_item( "leather hat")
store_item( "leather armor")
store_item( "leather pants" )
store_item( "leather bracers" )
#print armor
#print inventory
equip_item("armor_head", "leather hat")
equip_item("armor_torso", "leather armor")
#print armor
#print inventory
print stats
print battlestats
#print attack
updatestats()
updatebattlestats()
print stats
print battlestats
runtest()
No comments:
Post a Comment