Esempio n. 1
0
class applyEffect(unittest.TestCase):
    """ Test cases of applyEffect """
    def setUp(self):
        """ Build the Pkmn and Delegate for the test """
        self.pkmn = BuildPokemonBattleWrapper()

        self.ratio = 2
        self.damage = 50
        self.delegate = RecoilDelegate(self.ratio)

    def recoil(self):
        """ Test that recoil damage is done """
        self.pkmn.setCurrHP(self.damage)
        self.delegate.damage = self.damage
        self.delegate.applyEffect(self.pkmn, None, None)

        damageDone = self.damage - self.pkmn.getCurrHP()
        damage = self.damage / self.ratio
        assert damageDone == damage, "Should do damage  over ratio as damage"

    def message(self):
        """ Test that the message returned is correct """
        self.pkmn.setCurrHP(self.damage)
        self.delegate.damage = self.damage
        messages = self.delegate.applyEffect(self.pkmn, None, None)

        message = RecoilDelegate.message % self.pkmn.getHeader()
        assert len(messages) == 1, "Should get one message"
        assert messages[
            0] == message, "Message should be Pkmn's header and the Delegate's message"

    def faints(self):
        """ Test that the message is correct when the Pkmn faints """
        self.pkmn.setCurrHP(1)
        self.delegate.damage = self.damage
        messages = self.delegate.applyEffect(self.pkmn, None, None)

        faintMessage = self.pkmn.getHeader() + Faint.start
        assert len(messages) == 2, "Should get 2 messages"
        assert messages[
            1] == faintMessage, "Message should be that the Pkmn Fainted"
Esempio n. 2
0
class applyEffect(unittest.TestCase):
    """ Test cases of applyEffect """
    
    def  setUp(self):
        """ Build the Pkmn and Delegate for the test """
        self.pkmn = BuildPokemonBattleWrapper()
        
        self.ratio = 2
        self.damage = 50
        self.delegate = RecoilDelegate(self.ratio)
        
    def recoil(self):
        """ Test that recoil damage is done """
        self.pkmn.setCurrHP(self.damage)
        self.delegate.damage = self.damage
        self.delegate.applyEffect(self.pkmn, None, None)
        
        damageDone = self.damage - self.pkmn.getCurrHP()
        damage = self.damage/self.ratio
        assert damageDone == damage, "Should do damage  over ratio as damage"
        
    def message(self):
        """ Test that the message returned is correct """
        self.pkmn.setCurrHP(self.damage)
        self.delegate.damage = self.damage
        messages = self.delegate.applyEffect(self.pkmn, None, None)

        message = RecoilDelegate.message % self.pkmn.getHeader()
        assert len(messages) == 1, "Should get one message"
        assert messages[0] == message, "Message should be Pkmn's header and the Delegate's message"
        
    def faints(self):
        """ Test that the message is correct when the Pkmn faints """
        self.pkmn.setCurrHP(1)
        self.delegate.damage = self.damage
        messages = self.delegate.applyEffect(self.pkmn, None, None)

        faintMessage = self.pkmn.getHeader() + Faint.start
        assert len(messages) == 2, "Should get 2 messages"
        assert messages[1] == faintMessage, "Message should be that the Pkmn Fainted"
Esempio n. 3
0
 def effectOnMiss(self, user, target, environment):
     """ Applies the Recoil on Miss """
     self.damage, messages = self.parent.damageDelegate.damage(user, target)
     return RecoilDelegate.applyEffect(self, user, target, environment)