Appeared to have improved character cloning.
This commit is contained in:
parent
fdf13c3875
commit
42f55bab97
11
sheditor.py
11
sheditor.py
|
@ -138,6 +138,7 @@ class Character:
|
|||
# How to deep copy the skills/attributes appropriately?
|
||||
new_char = Character(new_name, copy.copy(self.tag))
|
||||
new_char.is_clone = True
|
||||
new_char.tag['name'] = new_name
|
||||
|
||||
new_skills = [s.copy() for s in self.skills]
|
||||
new_attributes = [a.copy() for a in self.attributes]
|
||||
|
@ -301,6 +302,7 @@ class GameData:
|
|||
for character in ship.characters:
|
||||
# Cloned character tags have to be added to the list
|
||||
if character.is_clone:
|
||||
print("ADDING CLONED CHARACTER")
|
||||
charlist_tag = ship.tag.find('characters')
|
||||
charlist_tag.append(character.tag)
|
||||
|
||||
|
@ -343,6 +345,14 @@ class GameData:
|
|||
def add_currency(self, amount):
|
||||
self.player.currency += amount
|
||||
|
||||
def clone_character(self, character_name, new_name):
|
||||
for ship in self.ships:
|
||||
for character in ship.characters:
|
||||
if character.name == character_name:
|
||||
new_char = character.clone(new_name)
|
||||
ship.characters.append(new_char)
|
||||
return
|
||||
|
||||
def print_detailed_character_summary(self):
|
||||
for ship in self.ships:
|
||||
if len(ship.characters) == 0:
|
||||
|
@ -580,6 +590,7 @@ def main():
|
|||
# game_data.add_currency(10000)
|
||||
game_data.print_summary()
|
||||
# game_data.print_detailed_item_summary()
|
||||
game_data.clone_character("Byron", "Anthony")
|
||||
game_data.print_detailed_character_summary()
|
||||
game_data.writeback()
|
||||
|
||||
|
|
Loading…
Reference in New Issue