Exemple #1
0
 def show_changes(self, other_player):
     """
     Creates a string representation of the changed attributes between a PlayerState before and after
     an imperative function is called on it.
     :param other_player: The PlayerState after it has been modified
     :return: String of attribute changes, or "" if unchanged.
     """
     changes = []
     if self.name != other_player.name:
         changes.append(CHANGE_TEMPLATE %
                        ("name", str(self.name), str(other_player.name)))
     if self.food_bag != other_player.food_bag:
         changes.append(
             CHANGE_TEMPLATE %
             ("food_bag", str(self.food_bag), str(other_player.food_bag)))
     hand_changes = TraitCard.show_all_changes(self.hand, other_player.hand)
     if hand_changes:
         changes.append(hand_changes)
     species_changes = Species.show_all_changes(self.species,
                                                other_player.species)
     if species_changes:
         changes.append(species_changes)
     if self.active != other_player.active:
         changes.append(CHANGE_TEMPLATE %
                        ("active", self.active, other_player.active))
     return ", ".join(changes)
Exemple #2
0
    def show_changes(self, species2):
        """
        Shows a string representation of the differences between this Species and the given Species.
        :param species2: The Species we are comparing to this Species
        :return: String representing the differences
        """

        changes = []
        if self.population != species2.population:
            changes.append(CHANGE_TEMPLATE % (POPULATION, self.population, species2.population))
        if self.food != species2.food:
            changes.append(CHANGE_TEMPLATE % (FOOD, self.food, species2.food))
        if self.body != species2.body:
            changes.append(CHANGE_TEMPLATE % (BODY, self.body, species2.body))
        trait_changes = TraitCard.show_all_changes(self.traits, species2.traits)
        if trait_changes:
            changes.append('[traits: ' + trait_changes + ']')
        if self.fat_storage != species2.fat_storage:
            changes.append(CHANGE_TEMPLATE % (FATTISSUE, self.fat_storage, species2.fat_storage))
        return '[' + ", ".join(changes) + ']' if changes else ''
 def show_changes(self, dealer2):
     """
     Shows a string representation of the differences between this Dealer and the given Dealer.
     :param dealer2: The Dealer we are comparing to this Dealer
     :return: String
     """
     changes = []
     old_players = self.players_to_dict()
     new_players = dealer2.players_to_dict()
     for i in range(0, len(self.list_of_players)):
         name = self.list_of_players[i].name
         old_player = old_players.get(name)
         new_player = new_players.get(name)
         if not old_player.equal_attributes(new_player):
             changes.append('Player ' + str(name) + ': ' +
                            old_player.show_changes(new_player))
     if self.watering_hole != dealer2.watering_hole:
         changes.append(
             CHANGE_TEMPLATE %
             ('watering_hole', self.watering_hole, dealer2.watering_hole))
     deck_changes = TraitCard.show_all_changes(self.deck, dealer2.deck)
     if deck_changes:
         changes.append('deck: ' + deck_changes)
     return ", ".join(changes)