示例#1
0
    def test_advancedTakeDamage_whenPositiveDamagePoints_shouldReduceHealth(
            self):
        username = '******'
        advanced_p = Advanced(username)
        advanced_p.take_damage(50)

        self.assertEqual(200, advanced_p.health)
示例#2
0
    def test_advancedTakeDamage_whenNegativeDamagePoints_shouldRaise(self):
        username = '******'
        advanced_p = Advanced(username)

        with self.assertRaises(ValueError) as context:
            advanced_p.take_damage(-50)

        self.assertIsNotNone(context.exception)
        self.assertEqual(str(context.exception),
                         'Damage points cannot be less than zero.')
示例#3
0
    def test_advancedInit_whenSetHealthToNegative_shouldRaise(self):
        username = '******'
        advanced_p = Advanced(username)

        with self.assertRaises(ValueError) as context:
            advanced_p.health = -250

        self.assertIsNotNone(context.exception)
        self.assertEqual(str(context.exception),
                         "Player's health bonus cannot be less than zero.")
示例#4
0
    def test_battleFieldFight_whenPlayersWithCards_shouldIncreasePointsAndTakeDamage(self):
        attacker = Advanced('attacker test')
        enemy = Advanced('enemy test')
        card = MagicCard('magic card test')
        attacker.card_repository.add(card)

        self.battle_field.fight(attacker, enemy)

        self.assertEqual(250 + 80, attacker.health)
        self.assertEqual(245, enemy.health)
示例#5
0
    def add_player(self, type_p: str, username: str):
        if type_p == 'Beginner':
            self.player_repository.add(Beginner(username))
        elif type_p == 'Advanced':
            self.player_repository.add(Advanced(username))

        return f'Successfully added player of type {type_p} with username: {username}'
示例#6
0
    def test_battleFieldFight_whenEnemyIsBeginnerAndWithoutCards_shouldIncreaseAttr(self):
        attacker = Advanced('attacker test')
        enemy = Beginner('enemy test')

        self.battle_field.fight(attacker, enemy)

        self.assertEqual(250, attacker.health)
        self.assertEqual(50 + 40, enemy.health)
示例#7
0
    def test_advancedInit_whenEmptyStringUsername_shouldRaise(self):
        username = ''

        with self.assertRaises(ValueError) as context:
            Advanced(username)

        self.assertIsNotNone(context.exception)
        self.assertEqual(str(context.exception),
                         "Player's username cannot be an empty string.")
示例#8
0
    def test_battleFieldFight_whenAttackerOrEnemyIsDead_shouldRaise(self):
        attacker = Beginner('attacker test')
        enemy = Advanced('enemy test')
        attacker.health = 0

        with self.assertRaises(ValueError) as context:
            self.battle_field.fight(attacker, enemy)

        self.assertIsNotNone(context.exception)
        self.assertEqual(str(context.exception), 'Player is dead!')
示例#9
0
    def test_advancedInit_whenZeroHealth_shouldSetIsDeadPropertyToTrue(self):
        username = '******'
        advanced_p = Advanced(username)
        advanced_p.health = 0

        self.assertTrue(advanced_p.is_dead)
示例#10
0
    def test_advancedInit_whenValidUsername_shouldIt(self):
        username = '******'
        advanced_p = Advanced(username)

        self.assertEqual('test', advanced_p.username)
示例#11
0
    def test_advancedInit_whenPositiveHealth_shouldSetIsDeadPropertyToFalse(
            self):
        username = '******'
        advanced_p = Advanced(username)

        self.assertFalse(advanced_p.is_dead)
示例#12
0
    def test_advancedInit_shouldInitializeCardRepository(self):
        username = '******'
        advanced_p = Advanced(username)

        self.assertEqual('CardRepository',
                         advanced_p.card_repository.__class__.__name__)
示例#13
0
    def test_advancedInit_shouldSetHealthTo250(self):
        username = '******'
        advanced_p = Advanced(username)

        self.assertEqual(250, advanced_p.health)