Ejemplo n.º 1
0
class getChanceToHit(unittest.TestCase):
    """ Test cases of getChanceToHit """
    
    def  setUp(self):
        """ Build the Pkmn and Delegate for the test """
        self.user = BuildPokemonBattleWrapper()
        self.target = BuildPokemonBattleWrapper()
        
        self.toHit = 100.0
        self.delegate = HitDelegate(None, self.toHit)
        
    def accuracyMods(self):
        """ Test that accuracy mods correctly change the accuracy """
        length = len(HitDelegate.accMods)/2
        for i in range(-length, length+1):
            self.user.statMods["ACC"] = i
            
            chance = self.delegate.getChanceToHit(self.user, self.target)
            assert chance == self.toHit*HitDelegate.accMods[i], "Chance should be accuracy modded by acc mod"
        
    def evasionMods(self):
        """ Test that evasion mods correctly change the accuracy """
        length = len(HitDelegate.accMods)/2
        for i in range(-1*length, length+1):
            self.target.statMods["EVAS"] = i
            
            chance = self.delegate.getChanceToHit(self.user, self.target)
            assert chance == self.toHit*HitDelegate.accMods[-i], "Chance should be accuracy modded by evas mod"
            
    def balanced(self):
        """ Test that evasion and accuracy mods balance each other out """
        length = len(HitDelegate.accMods)/2
        for i in range(-1*length, length+1):
            self.user.statMods["ACC"] = i
            self.target.statMods["EVAS"] = i
            
            chance = self.delegate.getChanceToHit(self.user, self.target)
            assert chance == self.toHit, "Chance should be accuracy when evas and acc are the same"