class hit(unittest.TestCase): """ Test cases of hit """ def setUp(self): """ Build the Pkmn and Delegate for the test """ self.attack = BuildAttack() self.user = BuildPokemonBattleWrapper() self.target = BuildPokemonBattleWrapper() self.environment = BattleEnvironment() self.toHit = 100.0 self.delegate = HitDelegate(self.attack, self.toHit) def fainted(self): """ Test that if the target is fainted the attack misses """ self.target.faint() hit, message = self.delegate.hit(self.user, self.target, self.environment) assert not hit, "Should miss if the target is fainted" def dodging(self): """ Test that if the target is dodging the attack misses """ self.target.dodge = "DIG" hit, message = self.delegate.hit(self.user, self.target, self.environment) assert not hit, "Should miss if the target is dodging" def otherwise(self): """ Test that the attack hits if the target is not dodging or fainted """ hit, message = self.delegate.hit(self.user, self.target, self.environment) assert hit, "Should hit otherwise"