当前位置: 首页>>代码示例>>Python>>正文


Python test_helper.BuildPokemonBattleWrapper类代码示例

本文整理汇总了Python中Test.test_helper.BuildPokemonBattleWrapper的典型用法代码示例。如果您正苦于以下问题:Python BuildPokemonBattleWrapper类的具体用法?Python BuildPokemonBattleWrapper怎么用?Python BuildPokemonBattleWrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BuildPokemonBattleWrapper类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: cantHandle

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"
开发者ID:cloew,项目名称:Pokemon-Project,代码行数:35,代码来源:affect_user_faint_test.py

示例2: applyEffect

class applyEffect(unittest.TestCase):
    """ Test cases of applyEffect """
    
    def  setUp(self):
        """ Build the Pkmn and Delegate for the test """
        self.user = BuildPokemonBattleWrapper()
        self.target = BuildPokemonBattleWrapper()
        self.delegate = ConfuseDelegate(1)
        
    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 notConfused(self):
        """ Test that confusion is applied when the target is not confused """
        self.user.secondaryEffects = []
        message = self.user.getHeader() + Confusion.start
        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 now confused"
        
        assert len(self.user.secondaryEffects) == 1, "Pkmn should get a confusion effect"
        assert self.delegate.isConfused(self.user), "The Pkmn should now be confused"
开发者ID:cloew,项目名称:Pokemon-Project,代码行数:31,代码来源:confuse_test.py

示例3: calcDamage

class calcDamage(unittest.TestCase):
    """ Test cases of calcDamage """
    
    def  setUp(self):
        """ Build the Pkmn and Delegate for the test """
        self.user = BuildPokemonBattleWrapper()
        self.target = BuildPokemonBattleWrapper()
        
        self.delegate = HalfHealthDelegate(None, 1)
        
    def halfHealth(self):
        """ Test that the damage is Half the Health of the target """
        hp = 100
        self.target.setCurrHP(hp)
        
        damage = self.delegate.calcDamage(self.user, self.target)
        assert damage == hp/2, "Damage should be half the targets health"
        
    def halfHealthNotFloored(self):
        """ Test that the damage is Half the Health of the target """
        hp = 101
        self.target.setCurrHP(hp)
        
        damage = self.delegate.calcDamage(self.user, self.target)
        assert damage == hp/2.0, "Damage should be half the targets health, not floored"
开发者ID:cloew,项目名称:Pokemon-Project,代码行数:25,代码来源:halfhealth_test.py

示例4: damage

class damage(unittest.TestCase):
    """ Test cases of damage """
    
    def  setUp(self):
        """ Build the Pkmn and Delegate for the test """
        self.user = BuildPokemonBattleWrapper()
        self.target = BuildPokemonBattleWrapper()
        attack = AttackFactory.getAttackAsNew("TACKLE")
        
        self.hp = 100
        self.target.setCurrHP(self.hp)
        
        self.delegate = OneHitDelegate(attack, 1)
        
    def oneHitKO(self):
        """ Test that the attack is a one-hit KO """
        self.target.setCurrHP(self.hp)
        self.target.pkmn.battleDelegate.types = ["NORMAL"]
        
        damage, messages = self.delegate.damage(self.user, self.target)
        assert damage == self.hp, "The damage should be the targets health"
        assert len(messages) == 1, "Should only get one message"
        assert messages[0] == OneHitDelegate.message, "Should get the One Hit KO message"
        
    def noDamage(self):
        """ Test that the attack does no damage when the effectiveness is 0 """
        self.target.pkmn.battleDelegate.types = ["GHOST"]
        
        damage, messages = self.delegate.damage(self.user, self.target)
        assert damage == 0, "The damage should be zero"
开发者ID:cloew,项目名称:Pokemon-Project,代码行数:30,代码来源:onehit_test.py

示例5: hit

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"
开发者ID:cloew,项目名称:Pokemon-Project,代码行数:29,代码来源:hit_test.py


注:本文中的Test.test_helper.BuildPokemonBattleWrapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。