class takeDamage(unittest.TestCase):
    """ Tests logic for a Pokemon taking damage"""
    
    def  setUp(self):
        """ Build the Trainer and Pokemon lists for use in tests """
        self.pkmn = BuildPokemon()
        
    def noFaint(self):
        """ Test a Pokemon takes damage appropriately """
        self.pkmn.battleDelegate.currHP = 2
        self.pkmn.battleDelegate.takeDamage(1)
        assert self.pkmn.battleDelegate.currHP == 1, \
                "HP Should decrease by the damage taken"
        
    def faintPerfect(self):
        """ Test a Pokemon faints when it takes damage equal to its health """
        self.pkmn.battleDelegate.currHP = 1
        self.pkmn.battleDelegate.takeDamage(self.pkmn.battleDelegate.currHP)
        assert self.pkmn.battleDelegate.currHP == 0, \
                "When taking damage equivalent to the Pokemon's health the \
                Pokemon should have no health"
        assert self.pkmn.fainted(), "A Pokemon with 0 HP should be fainted"
        
    def faintOver(self):
        """ Test a Pokemon has zero health when taking more damage than it has health """
        self.pkmn.battleDelegate.currHP = 1
        self.pkmn.battleDelegate.takeDamage(self.pkmn.battleDelegate.currHP+1)
        assert self.pkmn.battleDelegate.currHP == 0, \
                "When taking damage greater than the Pokemon's health the \
                Pokemon should have no health"
        assert self.pkmn.fainted(), "A Pokemon with 0 HP should be fainted"
예제 #2
0
class isFainted(unittest.TestCase):
    """ Tests logic for determining if a Pokemon is fainted or not """
    
    def  setUp(self):
        """ Build the Pokemon for use in the tests """
        self.pkmn = BuildPokemon()
        
    def isNotFainted(self):
        """ Test a Pokemon with health is not fainted """
        self.pkmn.battleDelegate.currHP = 1
        assert not self.pkmn.fainted(), "A Pokemon with HP > 0 should not be fainted"
        
    def isFainted(self):
        """ Test a Pokemon is fainted when it has no health """
        self.pkmn.battleDelegate.currHP = 0
        assert self.pkmn.fainted(), "A Pokemon with 0 HP should be fainted"