class checkOver(unittest.TestCase): """ Test cases of checkOver """ def setUp(self): """ Build the Confusion for the test """ self.user = BuildPokemonBattleWrapper() self.confusion = Confusion() self.turns = 2 def overCured(self): """ Test that the Confusion is cured when it is over """ messages = [] self.confusion.turns = 0 self.user.secondaryEffects = [self.confusion] self.confusion.checkOver(self.user, messages) assert self.user.secondaryEffects == [], "Should be cured" def overMessage(self): """ Test that the Message is correct when it is over """ messages = [] self.confusion.turns = 0 self.user.secondaryEffects = [self.confusion] message = self.user.getHeader() + Confusion.over self.confusion.checkOver(self.user, messages) assert len(messages) == 1, "Should receive one message" assert messages[0] == message, "Should receive a message that the confusion is over" def notOverStillConfused(self): """ Test that thePkmn is still confused when it isn't over """ messages = [] self.confusion.turns = self.turns self.user.secondaryEffects = [self.confusion] self.confusion.checkOver(self.user, messages) assert self.user.secondaryEffects == [self.confusion], "Should still be confused" def notOverTurnsDecremented(self): """ Test that the Turns is decremented when it isn't over """ messages = [] self.confusion.turns = self.turns self.confusion.checkOver(self.user, messages) assert self.confusion.turns == self.turns-1, "Should have turns decremented" def notOverMessage(self): """ Test that the Message is correct when it isn't over """ messages = [] self.confusion.turns = self.turns message = self.user.getHeader() + Confusion.start self.confusion.checkOver(self.user, messages) assert len(messages) == 1, "Should receive one message" assert messages[0] == message, "Should receive a message that the Pkmn is still confusion"
class cure(unittest.TestCase): """ Test cases of cure """ def setUp(self): """ Build the Confusion for the test """ self.user = BuildPokemonBattleWrapper() self.confusion = Confusion() def cured(self): """ Test that the Confusion is cured""" self.user.secondaryEffects = [self.confusion] self.confusion.cure(self.user) assert self.user.secondaryEffects == [], "Should be cured"
class confused(unittest.TestCase): """ Test cases of confused """ def setUp(self): """ Build the Confusion for the test """ self.confusion = Confusion() def isConfused(self): """ Test that Pkmn is confused on 1 """ confused = self.confusion.confused(1) assert confused, "Should be confused" def notConfused(self): """ Test that Pkmn is not confused on 1 """ confused = self.confusion.confused(0) assert not confused, "Should be confused"
def alreadyConfused(self): """ Test that confusion is not applied when the target is already confused """ self.user.secondaryEffects = [Confusion()] message = self.user.getHeader() + Confusion.already messages = self.delegate.applyEffect(self.user, self.target, None) assert len(messages) == 1, "Should get one message" assert messages[ 0] == message, "Should say that the Pkmn is already confused" assert len(self.user.secondaryEffects ) == 1, "Pkmn should not get another confusion effect"
def applyEffect(self, user, target, environment): """ Apply the Confusion to the target """ pkmn = self.getEffectedPokemon(user, target) messages = [] message = pkmn.getHeader() if not pkmn.getAbility().canBeConfused(pkmn, messages): """ No need to do anything extra """ elif not self.isConfused(pkmn): pkmn.secondaryEffects.append(Confusion()) messages.append(message + Confusion.start) else: messages.append(message + Confusion.already) return messages
def alreadyConfused(self): """ Test that isConfused returns correctly when the pkmn is Confused """ self.pkmn.secondaryEffects = [Confusion()] confused = self.delegate.isConfused(self.pkmn) assert confused, "Pokemon should be confused if it has a Confusion Effect"
def setUp(self): """ Build the Confusion for the test """ self.confusion = Confusion()
def setUp(self): """ Build the Confusion for the test """ self.user = BuildPokemonBattleWrapper() self.confusion = Confusion() self.turns = 2