def  setUp(self):
     """ Build the Pkmn and Effect for the test """
     self.delegate = EffectDelegate()
     self.delegate.faintHandler = BuildFaintHandler("EITHER")
     
     self.user = BuildPokemonBattleWrapper()
     self.target = BuildPokemonBattleWrapper()
class tryToApplyEffect(unittest.TestCase):
    """ Test cases of tryToApplyEffect """
    
    def  setUp(self):
        """ Build the Pkmn and Effect for the test """
        self.delegate = EffectDelegate()
        self.delegate.faintHandler = BuildFaintHandler("EITHER")
        
        self.user = BuildPokemonBattleWrapper()
        self.target = BuildPokemonBattleWrapper()
        
    def userFainted(self):
        """ Test that if the user is fainted the effect does nothing """
        self.user.faint()
        messages = self.delegate.tryToApplyEffect(self.user, self.target, None)
        assert messages == [], "Effect should do nothing if the user has fainted"
        
    def targetFainted(self):
        """ Test that if the target is fainted the effect does nothing """
        self.target.faint()
        messages = self.delegate.tryToApplyEffect(self.user, self.target, None)
        assert messages == [], "Effect should do nothing if the target has fainted"
        
    def applyEffectCalled(self):
        """ Test that applyEffect is called otherwise """
        messages = self.delegate.tryToApplyEffect(self.user, self.target, None)
        assert messages == [EffectDelegate.message], "Effect should call applyEffect"
class getEffectedPokemon(unittest.TestCase):
    """ Test cases of getEffectedPokemon """
    
    def  setUp(self):
        """ Build the Pkmn and Effect for the test """
        self.delegate = EffectDelegate()
        
        self.user = BuildPokemonBattleWrapper()
        self.target = BuildPokemonBattleWrapper()
        
    def user(self):
        """ Test that if affectUser is True, the Pkmn returned is the user """
        self.delegate.affectUser = True
        pkmn = self.delegate.getEffectedPokemon(self.user, self.target)
        assert pkmn is  self.user, "Pkmn should be the user"
        
    def target(self):
        """ Test that if the target is fainted the effect does nothing """
        self.delegate.affectUser = False
        pkmn = self.delegate.getEffectedPokemon(self.user, self.target)
        assert pkmn is  self.target, "Pkmn should be the target"
Ejemplo n.º 4
0
def BuildEffectDelegate():
    """ Builds an Effect Delegate """
    delegate = EffectDelegate()
    delegate.faintHandler = BuildFaintHandler(FaintHandlerFactory.REGULAR)
    return delegate
Ejemplo n.º 5
0
def BuildEffectDelegate():
    """ Builds an Effect Delegate """
    delegate = EffectDelegate()
    delegate.faintHandler = BuildFaintHandler(FaintHandlerFactory.REGULAR)
    return delegate