def fight(attacker: Player, enemy: Player):
        # for p in [attacker, enemy]:
        #     if p.is_dead:
        #         raise ValueError("Player is dead!")
        #     if p.__class__.__name__ == "Beginner":
        #         p.health += 40
        #         for card in p.card_repository:
        #             card.damage_points += 30
        #
        if attacker.is_dead or enemy.is_dead:
            raise ValueError("Player is dead!")

        if attacker.__class__.__name__ == "Beginner":
            attacker.health += 40
            for card in attacker.card_repository.cards:
                card.damage_points += 30

        if enemy.__class__.__name__ == "Beginner":
            enemy.health += 40
            for card in enemy.card_repository.cards:
                card.damage_points += 30

        for card in attacker.card_repository.cards:
            attacker.health += card.health_points

        for card in enemy.card_repository.cards:
            enemy.health += card.health_points

        for card in attacker.card_repository.cards:
            enemy.take_damage(card.damage_points)

        for card in enemy.card_repository.cards:
            attacker.take_damage(card.damage_points)
Example #2
0
    def fight(self, attacker: Player, enemy: Player):
        if self.is_death(attacker, enemy):
            raise ValueError("Player is dead!")

        if attacker.__class__.__name__ == "Beginner":
            attacker.health += 40
            for card in attacker.card_repository.cards:
                card.damage_points += 30

        if enemy.__class__.__name__ == "Beginner":
            enemy.health += 40
            for card in enemy.card_repository.cards:
                card.damage_points += 30

        self.start_of_fight_healt_boost(attacker)
        self.start_of_fight_healt_boost(enemy)

        attacker_damage = [
            card.damage_points for card in attacker.card_repository.cards
        ]
        enemy_damage = [
            card.damage_points for card in enemy.card_repository.cards
        ]

        for attacker_card in attacker_damage:
            if enemy.is_dead:
                return
            enemy.take_damage(attacker_card)

        for enemy_card in enemy_damage:
            if attacker.is_dead:
                return
            attacker.take_damage(enemy_card)
Example #3
0
    def fight(self, attacker: Player, enemy: Player):
        # That's the most interesting method.
        # •	If one of the users is_dead, raise new ValueError with message "Player is dead!"
        # •	If a player is a beginner, increase his health with 40 points and
        #   increase the damage points of each card in the players' deck with 30.
        # •	Before the fight, both players get bonus health points from their deck.
        #   (sum of all health points of his cards)
        # •	Attacker attacks first and after that the enemy attacks
        #   (deal damage points to opponent for each card). If one of the players is dead, you should stop the fight.
        if attacker.is_dead or enemy.is_dead:
            raise ValueError('Player is dead!')

        if isinstance(attacker, Beginner):
            self.increase_health(attacker)
            self.increase_health_with_card_damage(attacker)

        if isinstance(enemy, Beginner):
            self.increase_health(enemy)
            self.increase_health_with_card_damage(enemy)

        attacker.health += self.get_bonus_health_points(attacker)
        enemy.health += self.get_bonus_health_points(enemy)

        for card in attacker.card_repository.cards:
            if enemy.is_dead:
                return
            enemy.take_damage(card.damage_points)

        for card in enemy.card_repository.cards:
            if attacker.is_dead:
                return
            attacker.take_damage(card.damage_points)
    def fight(self, attacker: Player, enemy: Player):
        if attacker.is_dead or enemy.is_dead:
            raise ValueError("Player is dead!")

        if attacker.__class__.__name__ == "Beginner":
            attacker.health += 40
            for c in attacker.card_repository.cards:
                c.damage_points += 30

        if enemy.__class__.__name__ == "Beginner":
            enemy.health += 40
            for c in enemy.card_repository.cards:
                c.damage_points += 30

        attacker.health += sum([c.health_points for c in attacker.card_repository.cards])
        enemy.health += sum([c.health_points for c in enemy.card_repository.cards])

        for c in attacker.card_repository.cards:
            if enemy.is_dead or attacker.is_dead:
                return
            enemy.take_damage(c.damage_points)

        for c in enemy.card_repository.cards:
            if enemy.is_dead or attacker.is_dead:
                return
            attacker.take_damage(c.damage_points)
Example #5
0
    def fight(attacker: Player, enemy: Player):
        if attacker.is_dead or enemy.is_dead:
            raise ValueError("Player is dead!")

        if isinstance(attacker, Beginner):
            attacker.health += 40
            for card in attacker.card_repository.cards:
                card.damage_points += 30

        if isinstance(enemy, Beginner):
            enemy.health += 40
            for card in enemy.card_repository.cards:
                card.damage_points += 30

        attacker_bonus = sum([c.health_points for c in attacker.card_repository.cards])
        attacker.health += attacker_bonus

        enemy_bonus = sum([c.health_points for c in enemy.card_repository.cards])
        enemy.health += enemy_bonus

        for card in attacker.card_repository.cards:
            enemy.take_damage(card.damage_points)
            if enemy.is_dead:
                return

        for card in enemy.card_repository.cards:
            attacker.take_damage(card.damage_points)
            if attacker.is_dead:
                return
    def fight(self, attacker: Player, enemy: Player):
        if attacker.is_dead or enemy.is_dead:
            raise ValueError('Player is dead!')

        if attacker.__class__.__name__ == 'Beginner':
            attacker.health += 40
            for card in attacker.card_repository.cards:
                card.damage_points += 30

        if enemy.__class__.__name__ == 'Beginner':
            enemy.health += 40
            for card in enemy.card_repository.cards:
                card.damage_points += 30

        attacker_bonus_points = 0
        for card in attacker.card_repository.cards:
            attacker_bonus_points += card.health_points
        attacker.health += attacker_bonus_points

        enemy_bonus_points = 0
        for card in enemy.card_repository.cards:
            enemy_bonus_points += card.health_points
        enemy.health += enemy_bonus_points

        for card in attacker.card_repository.cards:
            if enemy.is_dead or attacker.is_dead:
                return

            enemy.take_damage(card.damage_points)

        for card in enemy.card_repository.cards:
            if attacker.is_dead or enemy.is_dead:
                return

            attacker.take_damage(card.damage_points)
    def fight(attacker: Player, enemy: Player):
        if attacker.is_dead or enemy.is_dead:
            raise ValueError("Player is dead!")

        # If a player is a beginner, increase his health with 40 points and increase the damage points of each card in the players' deck with 30.
        if attacker.__class__.__name__ == "Beginner":
            attacker.health += 40
            for card in attacker.card_repository.cards:
                card.damage_points += 30

        if enemy.__class__.__name__ == "Beginner":
            attacker.health += 40
            for card in enemy.card_repository.cards:
                card.damage_points += 30

        attacker.health += sum(
            [card.health_points for card in attacker.card_repository.cards])
        enemy.health += sum(
            [card.health_points for card in enemy.card_repository.cards])

        for card in attacker.card_repository.cards:
            enemy.take_damage(card.damage_points)

        for card in enemy.card_repository.cards:
            attacker.take_damage(card.damage_points)
Example #8
0
    def fight(attacker: Player, enemy: Player):
        if attacker.is_dead or enemy.is_dead:
            raise ValueError("Player is dead!")

        #Calculate bonus health and damage:
        attacker.health += BattleField.get_bonus_health_damage(attacker)
        enemy.health += BattleField.get_bonus_health_damage(enemy)

        #Fight:
        for card in attacker.card_repository.cards:
            enemy.take_damage(card.damage_points)

        for card in enemy.card_repository.cards:
            attacker.take_damage(card.damage_points)
Example #9
0
    def fight(attacker: Player, enemy: Player):
        if attacker.is_dead or enemy.is_dead:
            raise ValueError("Player is dead!")
        if attacker.__class__.__name__ == "Beginner":
            BattleField.beginner_player_bonuses(attacker)
        if enemy.__class__.__name__ == 'Beginner':
            BattleField.beginner_player_bonuses(enemy)

        BattleField.bonus_health(attacker)
        BattleField.bonus_health(enemy)

        for card in attacker.card_repository.cards:
            enemy.take_damage(card.damage_points)
            if enemy.is_dead:
                return

        for card in enemy.card_repository.cards:
            attacker.take_damage(card.damage_points)
            if attacker.is_dead:
                return
Example #10
0
    def fight(attacker: Player, enemy: Player):
        if attacker.is_dead or enemy.is_dead:
            raise ValueError("Player is dead!")

        current_fighters = [attacker, enemy]

        for fighter in current_fighters:
            if fighter.__class__.__name__ == "Beginner":
                fighter.health += 40
                for fighter_card in fighter.card_repository.cards:
                    fighter_card.damage_points += 30
            bonus_health_points = 0
            for fighter_card in fighter.card_repository.cards:
                bonus_health_points += fighter_card.health_points
            fighter.health += bonus_health_points

        for card in attacker.card_repository.cards:
            enemy.take_damage(card.damage_points)

        for card in enemy.card_repository.cards:
            attacker.take_damage(card.damage_points)
Example #11
0
    def fight(self, attacker: Player, enemy: Player):
        if attacker.is_dead or enemy.is_dead:
            raise ValueError('Player is dead!')

        for player in (attacker, enemy):
            if player.__class__.__name__ == 'Beginner':
                player.health += 40
                for card in player.card_repository.cards:
                    card.damage_points += 30

            player.health += sum(
                [card.health_points for card in player.card_repository.cards])

        for card in attacker.card_repository.cards:
            if enemy.is_dead:
                return
            enemy.take_damage(card.damage_points)

        for card in enemy.card_repository.cards:
            if attacker.is_dead:
                return
            attacker.take_damage(card.damage_points)
Example #12
0
    def fight(self, attacker: Player, enemy: Player):

        if attacker.is_dead or enemy.is_dead:
            raise ValueError("Player is dead!")

        for player in (attacker, enemy):
            if player.__class__.__name__ == 'Beginner':
                player.health += 40
                for card in player.card_repository.cards:
                    card.damage_points += 30

            bonus = sum(
                [card.health_points for card in player.card_repository.cards])
            player.health += bonus

        damage_points_attacker = sum(
            [card.damage_points for card in attacker.card_repository.cards])
        enemy.take_damage(damage_points_attacker)

        damage_points_enemy = sum(
            [card.damage_points for card in enemy.card_repository.cards])
        attacker.take_damage(damage_points_enemy)
Example #13
0
    def fight(attacker: Player, enemy: Player) -> None:
        if attacker.is_dead or enemy.is_dead:
            raise ValueError("Player is dead!")

        attacker.apply_bonus(), enemy.apply_bonus()

        attacker.attack(enemy)
        if enemy.is_dead:
            return

        enemy.attack(attacker)
        if attacker.is_dead:
            return
Example #14
0
    def fight(attacker: Player, enemy: Player):
        if attacker.is_dead or enemy.is_dead:
            raise ValueError("Player is dead!")

        if attacker.__class__.__name__ == 'Beginner':
            attacker.health += 40
            for card in attacker.card_repository.cards:
                card.damage_points += 30

        if enemy.__class__.__name__ == 'Beginner':
            enemy.health += 40
            for card in enemy.card_repository.cards:
                card.damage_points += 30

        attacker.health += sum(
            [card.health_points for card in attacker.card_repository.cards])
        enemy.health += sum(
            [card.health_points for card in enemy.card_repository.cards])

        for card in attacker.card_repository.cards:
            enemy.take_damage(card.damage_points)

        for card in enemy.card_repository.cards:
            attacker.take_damage(card.damage_points)
Example #15
0
    def fight(self, attacker: Player, enemy: Player):
        if attacker.is_dead or enemy.is_dead:
            raise ValueError("Player is dead!")

        if attacker.__class__.__name__ == "Beginner":
            self.increase_beginner_attr(attacker)

        if enemy.__class__.__name__ == "Beginner":
            self.increase_beginner_attr(enemy)

        attacker.health += self.get_bonus_points(attacker)
        enemy.health += self.get_bonus_points(enemy)

        for card in attacker.card_repository.cards:
            if attacker.is_dead or enemy.is_dead:
                return

            enemy.take_damage(card.damage_points)

        for card in enemy.card_repository.cards:
            if attacker.is_dead or enemy.is_dead:
                return

            attacker.take_damage(card.damage_points)
Example #16
0
    def fight(self, attacker: Player, enemy: Player):
        if attacker.is_dead or enemy.is_dead:
            raise ValueError("Player is dead!")

        if self.is_beginner(attacker):
            attacker.beginner_upgrade()
        if self.is_beginner(enemy):
            enemy.beginner_upgrade()

        # attacker.health += sum([card.health_points for card in attacker.card_repository.cards])
        # enemy.health += sum([card.health_points for card in enemy.card_repository.cards])
        attacker.health += self.get_bonus_health_points(attacker)
        enemy.health += self.get_bonus_health_points(enemy)

        for card in attacker.card_repository.cards:
            enemy.take_damage(card.damage_points)
            if enemy.is_dead:
                return

        for card in enemy.card_repository.cards:
            if attacker.is_dead or enemy.is_dead:
                return
            attacker.take_damage(card.damage_points)
Example #17
0
    def attack(attacker: Player, enemy: Player):
        for card in attacker.card_repository.cards:
            enemy.take_damage(card.damage_points)

            if BattleField.check_dead(enemy):
                raise ValueError('Player is dead!')
Example #18
0
 def __init__(self, username):
     Player.__init__(self, username, health=50)
Example #19
0
 def __init__(self, username):
     Player.__init__(self, username, 50)