本文整理汇总了Python中Test.test_helper.BuildPokemonBattleWrapper.faint方法的典型用法代码示例。如果您正苦于以下问题:Python BuildPokemonBattleWrapper.faint方法的具体用法?Python BuildPokemonBattleWrapper.faint怎么用?Python BuildPokemonBattleWrapper.faint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Test.test_helper.BuildPokemonBattleWrapper
的用法示例。
在下文中一共展示了BuildPokemonBattleWrapper.faint方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: hit
# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import faint [as 别名]
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"
示例2: cantHandle
# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import faint [as 别名]
class cantHandle(unittest.TestCase):
""" Test cases of cantHandle """
def setUp(self):
""" Build the FaintDelegate for the test """
self.handler = AffectUserFaintDelegate()
self.user = BuildPokemonBattleWrapper()
self.target = BuildPokemonBattleWrapper()
self.effect = BuildEffectDelegate()
def userFainted(self):
""" Test that it can't handle the user fainting """
self.user.faint()
self.effect.affectUser = 1
cantHandle = self.handler.cantHandle(user = self.user, effect = self.effect)
assert cantHandle, "Shouldn't handle when the user is fainted"
def userNotFainted(self):
""" Test that it can handle when the user is not fainted """
self.effect.affectUser = 1
cantHandle = self.handler.cantHandle(user = self.user, effect = self.effect)
assert not cantHandle, "Should handle when the user is not fainted"
def targetFainted(self):
""" Test that it can't handle the target fainting """
self.target.faint()
self.effect.affectUser = 0
cantHandle = self.handler.cantHandle(target = self.target, effect = self.effect)
assert cantHandle, "Shouldn't handle when the target is fainted"
def targetNotFainted(self):
""" Test that it can handle when the target is not fainted """
self.effect.affectUser = 0
cantHandle = self.handler.cantHandle(target = self.target, effect = self.effect)
assert not cantHandle, "Should handle when the target is not fainted"
示例3: tryToApplyEffect
# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import faint [as 别名]
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"
示例4: cantHandle
# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import faint [as 别名]
class cantHandle(unittest.TestCase):
""" Test cases of cantHandle """
def setUp(self):
""" Build the FaintDelegate for the test """
self.handler = EitherFaintDelegate()
self.user = BuildPokemonBattleWrapper()
self.target = BuildPokemonBattleWrapper()
def user(self):
""" Test that it can handle the user fainting """
self.user.faint()
cantHandle = self.handler.cantHandle(user = self.user, target = self.target)
assert cantHandle, "Shouldn't handle when the user faints"
def target(self):
""" Test that it can't handle the target fainting """
self.target.faint()
cantHandle = self.handler.cantHandle(user = self.user, target = self.target)
assert cantHandle, "Shouldn't handle when the target faints"
def both(self):
""" Test that it can't handle both pkmn fainting """
self.user.faint()
self.target.faint()
cantHandle = self.handler.cantHandle(user = self.user, target = self.target)
assert cantHandle, "Shouldn't handle when both pkmn faints"
def neither(self):
""" Test that it can handle neither pkmn fainting """
cantHandle = self.handler.cantHandle(user = self.user, target = self.target)
assert not cantHandle, "Should handle when neither faints"
示例5: cantHandle
# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import faint [as 别名]
class cantHandle(unittest.TestCase):
""" Test cases of cantHandle """
def setUp(self):
""" Build the FaintDelegate for the test """
self.handler = UserFaintDelegate()
self.user = BuildPokemonBattleWrapper()
def userFainted(self):
""" Test that it can't handle the user fainting """
self.user.faint()
cantHandle = self.handler.cantHandle(user = self.user)
assert cantHandle, "Shouldn't handle when the user is fainted"
def userNotFainted(self):
""" Test that it can handle when the user is not fainted """
cantHandle = self.handler.cantHandle(user = self.user)
assert not cantHandle, "Should handle when the user is not fainted"
示例6: attemptAfterTurn
# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import faint [as 别名]
class attemptAfterTurn(unittest.TestCase):
""" Test cases of attemptAfterTurn """
def setUp(self):
""" Build the Pkmn and AfterTurnEffect for the test """
self.effect = AfterTurnEffect()
self.effect.faintHandler = BuildFaintHandler("USER")
self.pkmn = BuildPokemonBattleWrapper()
def fainted(self):
""" Test that the Effect is not performed when the pkmn has fainted """
self.pkmn.faint()
messages = self.effect.attemptAfterTurn(self.pkmn)
assert messages == [], "Should receive no messages since nothing was performed"
def notFainted(self):
""" Test that the Effect is performed when the pkmn has fainted """
messages = self.effect.attemptAfterTurn(self.pkmn)
assert messages == [AfterTurnEffect.message], "Should receive messages from afterTurn function"
示例7: cantHandle
# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import faint [as 别名]
class cantHandle(unittest.TestCase):
""" Test cases of cantHandle """
def setUp(self):
""" Build the FaintDelegate for the test """
self.handler = SourceFaintDelegate()
self.source = BuildPokemonBattleWrapper()
self.user = BuildPokemonBattleWrapper()
self.effect = BuildEffectDelegate()
self.effect.source = self.source
self.user.secondaryEffects.append(self.effect)
def userFainted(self):
""" Test that it can't handle the user fainting """
self.user.faint()
cantHandle = self.handler.cantHandle(user = self.user, effect = self.effect)
assert cantHandle, "Shouldn't handle when the user is fainted"
assert self.effect in self.user.secondaryEffects, "The effect shouldnot be removed from the user"
def userNotFainted(self):
""" Test that it can handle when the user is not fainted """
cantHandle = self.handler.cantHandle(user = self.user, effect = self.effect)
assert not cantHandle, "Should handle when the user is not fainted"
assert self.effect in self.user.secondaryEffects, "The effect should not be removed from the user"
def sourceFainted(self):
""" Test that it can't handle the source fainting """
self.source.faint()
cantHandle = self.handler.cantHandle(user = self.user, effect = self.effect)
assert cantHandle, "Shouldn't handle when the source is fainted"
assert not self.effect in self.user.secondaryEffects, "The effect should be removed from the user"
def sourceNotFainted(self):
""" Test that it can handle when the user is not fainted """
cantHandle = self.handler.cantHandle(user = self.user, effect = self.effect)
assert not cantHandle, "Should handle when the source is not fainted"
assert self.effect in self.user.secondaryEffects, "The effect should not be removed from the user"
示例8: diverge
# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import faint [as 别名]
class diverge(unittest.TestCase):
""" Test cases of diverge """
def setUp(self):
""" Build the Pkmn and Effects for the test """
self.user = BuildPokemonBattleWrapper()
self.target = BuildPokemonBattleWrapper()
self.divergeEffects = [BuildEffectDelegate(), BuildEffectDelegate()]
self.normalEffects = [BuildEffectDelegate()]
self.message = BuildEffectDelegate().message
self.delegate = DivergeOnFaintDelegate(self.divergeEffects, self.normalEffects)
def fainted(self):
""" Test that the diverge effects are called when the target has fainted """
self.target.faint()
diverge = self.delegate.diverge(self.user, self.target)
assert diverge, "Should diverge"
def notFainted(self):
""" Test that the regular effects are called when the target is not fainted """
diverge = self.delegate.diverge(self.user, self.target)
assert not diverge, "Should not diverge when the target is not fainted"