def save(self, tree_name): tree = Entity.save(self, tree_name) # Save state state = etree.SubElement(tree, 'state') state.text = str(self.interaction is None) # Save sprite sprite = etree.SubElement(tree, 'sprite') sprite.text = self.sprite_name # Save interaction if self.interaction: interaction = etree.SubElement(tree, 'interaction') talks = etree.SubElement(interaction, 'talks') for t in self.interaction['talks']: talk = etree.SubElement(talks, 'talk') talk.text = t if self.interaction['gold'] > 0: gold = etree.SubElement(interaction, 'gold') gold.text = str(self.interaction['gold']) if self.interaction['item'] is not None: item = etree.SubElement(interaction, 'item') item.text = self.interaction['item'].name return tree
def save(self, tree_name): tree = Entity.save(self, tree_name) # Save current hp hp = etree.SubElement(tree, 'current_hp') hp.text = str(self.hp) return tree
def save(self, tree_name): tree = Entity.save(self, tree_name) # Save remaining uses times = etree.SubElement(tree, 'times') times.text = str(self.times) # Save type nature = etree.SubElement(tree, 'type') nature.text = self.name return tree
def save(self, tree_name): tree = Entity.save(self, tree_name) # Save state state = etree.SubElement(tree, 'state') state.text = str(self.opened) # Save sprites closed = etree.SubElement(tree, 'closed') closed_sprite = etree.SubElement(closed, 'sprite') closed_sprite.text = self.sprite_close_link opened = etree.SubElement(tree, 'opened') opened_sprite = etree.SubElement(opened, 'sprite') opened_sprite.text = self.sprite_open_link # Save content content = etree.SubElement(tree, 'contains') item = etree.SubElement(content, 'item') item.text = self.item.name return tree