I have been teaching myself python for several months and have started working on an rpg project. Right now I am trying to code an armor class for a basic character. I am not sure if my approach is even a correct way to go about implementing this class. The armor list items consist of a name, armor location, it's stopping power, weight penalty, and its cost.I managed to get the code to keep track of things then I realized if I append a new armor it will of course add it to the end of the list and I really want 3 designated slots to assign to. I would really appreciate some help with the code or even a thought process to help me rework this code. Any help would be appreciated. Thanks in advance.
# Armor
# An armor class
# 12/10/09
import random
# Armor Lists
body_armor = [("Light Leather", "Limbs and Torso", 0, 0, 25),
("Heavy Leather", "Limbs and Torso", 4, 0, 50),
("Kevlar Vest", "Torso", 10, 0, 100),
("Steel Helmet", "Head", 14, 0, 25),
("Light Armor Jacket", "Limbs and Torso", 14, 0, 150),
("Medium Armor Jacket", "Limbs and Torso", 1, 1, 200),
("Flack Vest", "Torso", 20, 1, 200),
("Flack Pants", "Legs", 20, 1, 200),
("Nylon Helmet", "Head", 20, 0, 100),
("Heavy Armor Jacket", "Limbs and Torso", 20, 2, 250),
("Door Gunner's Vest", "Torso", 25, 3, 275),
("Full Metal", "Whole Body", 25, 2, 600)]
class Character(object):
def __init__(self):
self.armor = Armor()
def Get_Armor_Report(self):
print self.armor.armor_list
print self.armor.current_armor
print self.armor.EV_Total()
# NEEDS ---> 3 current armor places need to remain body in 0, body2 in 1, and helmet in 2
class Armor(object):
def __init__(self):
self.armor_list = []
self.current_armor = []
def Add_Armor(self, number):
new_armor = body_armor[number]
self.armor_list.append(new_armor)
def Equip_Armor(self, number):
max_check = self.Max_Armor()
if max_check == 0:
print "Max Armor - Cannot Equip New Armor"
else:
armor_name = self.armor_list[number][0]
armor_sp = self.armor_list[number][2]
armor_ev = self.armor_list[number][3]
current_armor = (armor_name, armor_sp, armor_ev)
self.current_armor.append(current_armor)
def Remove_Armor(self, number):
remove_armor = self.current_armor[number]
self.current_armor.remove(remove_armor)
def Get_SP(self, number):
stop_power = self.current_armor[number][1]
return stop_power
def Get_EV(self, number):
encumberance = self.current_armor[number][2]
return encumberance
def Get_Cover(self, number):
cover = self.armor_list[number][1]
return cover
def EV_Total(self):
ev_total = 0
list_count = self.current_armor
list_count = len(list_count)
for i in range(list_count):
number = i
ev = self.current_armor[number][2]
ev_total += ev
return ev_total
def Max_Armor(self):
all_armor = self.current_armor
armor_total = len(all_armor)
if armor_total >= 3:
return 0
else:
return 1