예제 #1
0
 def  setUp(self):
     """ Build the Trainer and Pokemon lists for use in tests """
     self.trainer = Trainer()
     self.pkmnOnBelt = BuildPokemonBattleWrapper()
     self.pkmnWithHealth = BuildPokemon(pkmn = "BULBASAUR")
     self.pkmnWithoutHealth = BuildPokemon(pkmn = "CHARMANDER")
     self.pkmnWithoutHealth.battleDelegate.currHP = 0
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"
예제 #3
0
 def  setUp(self):
     """ Build the Pokemon for use in the test """
     self.pkmn = BuildPokemon()
     self.ratio = 2
     self.hp1 = 50
     self.hp2 = 51
     self.hp3 = 10
     self.hp4 = 1
     self.half = 25
예제 #4
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"
 def  setUp(self):
     """ Build the Trainer and Pokemon lists for use in tests """
     self.pkmn = BuildPokemon()
예제 #6
0
 def  setUp(self):
     """ Build the Pokemon for use in the tests """
     self.pkmn = BuildPokemon()
예제 #7
0
class getRatioOfHealth(unittest.TestCase):
    """ Tests getRatio returns the correct amount of the HP """
    
    def  setUp(self):
        """ Build the Pokemon for use in the test """
        self.pkmn = BuildPokemon()
        self.ratio = 2
        self.hp1 = 50
        self.hp2 = 51
        self.hp3 = 10
        self.hp4 = 1
        self.half = 25
        
    def setHP(self, pkmn, amount):
        """ Sets the HP and currHP of the given Pkmn """
        pkmn.setStat("HP", amount)
        pkmn.setCurrHP(amount)
        
    def getRatio(self):
        """ Test ratio with no truncation"""
        self.setHP(self.pkmn, self.hp1)
        ratio = self.pkmn.getRatioOfHealth(self.ratio)
        ratioForDamage = self.pkmn.getRatioOfHealth(self.ratio, forDamage = True)
        
        assert ratio == self.half, "getRatio result should be hp/ratio"
        assert ratioForDamage == self.half, "getRatio for Damage result should be hp/ratio"
        
    def getRatioTruncated(self):
        """ Test ratio with truncation """
        self.setHP(self.pkmn, self.hp2)
        ratio = self.pkmn.getRatioOfHealth(self.ratio)
        ratioForDamage = self.pkmn.getRatioOfHealth(self.ratio, forDamage = True)
        
        assert ratio == self.half, "getRatio result should be hp/ratio truncated"
        assert ratioForDamage == self.half, "getRatio for Damage result should be hp/ratio"
        
    def getRatioUnderCurrHP(self):
        """ Test ratio returned is equivalent to the Curr HP when CurrHP Is less than """
        self.pkmn.setStat("HP", self.hp1)
        self.pkmn.setCurrHP(self.hp3)
        ratio = self.pkmn.getRatioOfHealth(self.ratio)
        ratioForDamage = self.pkmn.getRatioOfHealth(self.ratio, forDamage = True)
        
        assert ratio == self.half, "getRatio result should be Current HP"
        assert ratioForDamage == self.hp3, "getRatio for Damage result should be hp/ratio"
        
    def getRatioUnder1(self):
        """ Test ratio with result under 1 """
        self.setHP(self.pkmn, self.hp4)
        ratio = self.pkmn.getRatioOfHealth(self.ratio)
        ratioForDamage = self.pkmn.getRatioOfHealth(self.ratio, forDamage = True)
        
        assert ratio == 1, "getRatio result should be 1 if hp/ratio would be under 1"
        assert ratioForDamage == 1, "getRatio for Damage result should be 1 if hp/ratio would be under 1"
예제 #8
0
 def  setUp(self):
     """ Build the *** for the test """
     self.pkmn = BuildPokemon()
     self.copy = PokemonFactory.copy(self.pkmn)