Exemplo n.º 1
0
    def test_roll_attribs(self):
        player = Player('Betsy ')
        print('Initial')
        print(player.attributes)

        str0 = player.attributes.strength
        int0 = player.attributes.intelligence
        wis0 = player.attributes.wisdom
        dex0 = player.attributes.dexterity
        con0 = player.attributes.constitution
        chra0 = player.attributes.charisma

        player.attributes = pu.roll_attributes(4)
        print('Second')
        print(player.attributes)

        str1 = player.attributes.strength
        int1 = player.attributes.intelligence
        wis1 = player.attributes.wisdom
        dex1 = player.attributes.dexterity
        con1 = player.attributes.constitution
        chra1 = player.attributes.charisma

        self.assertGreater(str1, str0, "Strength is not set properly")
        self.assertGreater(int1, int0, "Intelligence is not set properly")
        self.assertGreater(wis1, wis0, "Wisdom is not set properly")
        self.assertGreater(dex1, dex0, "Dexterity is not set properly")
        self.assertGreater(con1, con0, "Constitution is not set properly")
        self.assertGreater(chra1, chra0, "Chra is not set properly")
Exemplo n.º 2
0
 def test_Damage(self):
     play = Player('Greg')
     bp = play.backpack
     bp.weapons.append(Weapon('sword', 20, lambda: Dice.eight_sided(),
                              True))
     dam = play.get_damage_inflicted()
     print(str.format("Damage: {}", dam))
     self.assertTrue(1 <= dam <= 8)
Exemplo n.º 3
0
    def test_Armor(self):
        play = Player('Greg')
        bp = play.backpack
        bp.armors.append(Armor("mail", 10, 5, True))
        bp.armors.append(Armor("Platemail", 10, 3, False))
        bp.armors.append(Armor('shield', 30, -2, True))

        self.assertEqual(3, bp.get_armor_class(), "AC is not correct")
        play.attributes.dexterity = 18
        self.assertEqual(1, play.get_armor_class(), "AC is not correct")
        play.attributes.dexterity = 3
        self.assertEqual(6, play.get_armor_class(), "AC is not correct")
Exemplo n.º 4
0
    def get_fighter(char: Player):
        fighter = Fighter(char.get_name(), char.attributes)
        fighter.wallet = char.wallet
        fighter.backpack = char.backpack

        return fighter
Exemplo n.º 5
0
 def test_player_good(self):
     greg = Player('greg')
     self.assertEqual('greg - None', greg.get_name(), 'Name doesn\'t match')
Exemplo n.º 6
0
 def test_player_fail_empty(self):
     with self.assertRaises(AssertionError):
         Player('')
Exemplo n.º 7
0
 def test_player_fail_type(self):
     with self.assertRaises(AssertionError):
         Player(1)
Exemplo n.º 8
0
 def test_player_fail(self):
     with self.assertRaises(TypeError):
         Player()
Exemplo n.º 9
0
    def test_get(self):
        player = Player('Betsy ')
        player.attributes = pu.roll_attributes(4)
        fighter = Fighter.get_fighter(player)

        self.assertTrue(player.attributes.equals(fighter.attributes))