def __init__(self, name): # does not try loading a family if name is not passed # ONLY do this during family creation if not name: return path = os.path.join("data", "actors", "families", name) familyini = Configuration(os.path.join("..", path, "family.ini")).family # family's last name, all members of the family will have this last name self.name = name # all the members in your party path = os.path.join("..", path) members = [n.split("/")[-1] for n in glob.glob(os.path.join(path, "*.ini"))] exclude = ["family.ini", "bestiary.ini", "inventory.ini"] for item in exclude: if item in members: members.remove(item) self.members = [Character(self, n.replace(".ini", "")) for n in members] # the party used in battle is the first 3 members you have ordered if len(self.members) >= 3: self.party = Party(self.members[0:3]) # party should only be 0 during character creation elif len(self.members) == 0: self.party = None else: self.party = Party(self.members[0 : len(self.members)]) # the items your family has self.inventory = Inventory(self) print self.inventory # amount of money your family possesses self.gold = familyini.__getattr__("gold", int) # gameplay difficulty (0 - easy, 1- normal, 2 - hard) self.difficulty = familyini.__getattr__("difficulty", int) # family bestiary self.bestiary = Bestiary(self)
class Family: def __init__(self, name): # does not try loading a family if name is not passed # ONLY do this during family creation if not name: return path = os.path.join("data", "actors", "families", name) familyini = Configuration(os.path.join("..", path, "family.ini")).family # family's last name, all members of the family will have this last name self.name = name # all the members in your party path = os.path.join("..", path) members = [n.split("/")[-1] for n in glob.glob(os.path.join(path, "*.ini"))] exclude = ["family.ini", "bestiary.ini", "inventory.ini"] for item in exclude: if item in members: members.remove(item) self.members = [Character(self, n.replace(".ini", "")) for n in members] # the party used in battle is the first 3 members you have ordered if len(self.members) >= 3: self.party = Party(self.members[0:3]) # party should only be 0 during character creation elif len(self.members) == 0: self.party = None else: self.party = Party(self.members[0 : len(self.members)]) # the items your family has self.inventory = Inventory(self) print self.inventory # amount of money your family possesses self.gold = familyini.__getattr__("gold", int) # gameplay difficulty (0 - easy, 1- normal, 2 - hard) self.difficulty = familyini.__getattr__("difficulty", int) # family bestiary self.bestiary = Bestiary(self) # creates a new family .ini # by default a family starts with 100 gold and five potions and 1 ether def create(self, name, difficulty, gold=100): path = os.path.join("..", "data", "actors", "families", name) if not os.path.exists(path): os.mkdir(path) Configuration(os.path.join(path, "family.ini")).save() familyini = Configuration(os.path.join(path, "family.ini")) familyini.family.__setattr__("difficulty", difficulty) familyini.family.__setattr__("gold", int(gold)) familyini.save() # this updates the family's .ini file def update(self): self.create(self.name, self.difficulty, self.gold) self.inventory.update() self.bestiary.update() def refresh(self): self.__init__(self.name)