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


Python BuildPokemonBattleWrapper.setCurrHP方法代码示例

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


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

示例1: damage

# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import setCurrHP [as 别名]
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,代码行数:32,代码来源:onehit_test.py

示例2: calcDamage

# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import setCurrHP [as 别名]
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,代码行数:27,代码来源:halfhealth_test.py

示例3: heal

# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import setCurrHP [as 别名]
class heal(unittest.TestCase):
    """ Test cases of heal """
    
    def  setUp(self):
        """ Build the Pkmn and Delegate for the test """
        self.pkmn = BuildPokemonBattleWrapper()
        
        self.ratio = 2
        self.damage = 10
        self.delegate = HealByDamageRatioDelegate(self.ratio)
        
    def heal(self):
        """ Test that it heals by the ratio of the damage done """
        self.pkmn.setCurrHP(0)
        self.delegate.damage = self.damage
        self.delegate.heal(self.pkmn)
        
        hp = self.pkmn.getCurrHP()
        heal = self.damage/self.ratio
        assert hp == heal, "Should be healed by the ratio of the damage"
开发者ID:cloew,项目名称:Pokemon-Project,代码行数:22,代码来源:heal_damageratio_test.py

示例4: afterTurn

# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import setCurrHP [as 别名]
class afterTurn(unittest.TestCase):
    """ Test that afterTurn works correctly """

    def setUp(self):
        """ Builds the Paralysis status"""
        self.status = Burn()
        self.pkmn = BuildPokemonBattleWrapper()

    def damage(self):
        """ Test that the damage is done correctly """
        self.pkmn.setStat("HP", 32)
        self.pkmn.setCurrHP(32)
        self.status.afterTurn(self.pkmn)
        damage = self.pkmn.getStat("HP") - self.pkmn.getCurrHP()
        assert damage == self.pkmn.getRatioOfHealth(Burn.ratio), "Damage should be Burn Ratio of Health"

    def message(self):
        """ Test that the message is returned correctly """
        messages = self.status.afterTurn(self.pkmn)
        message = self.pkmn.getHeader() + Burn.intermittent
        assert len(messages) == 1, "Should get one message"
        assert messages[0] == message, "Message should be that the Pkmn was damaged by the Burn"
开发者ID:cloew,项目名称:Pokemon-Project,代码行数:24,代码来源:burn_test.py

示例5: afterTurn

# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import setCurrHP [as 别名]
class afterTurn(unittest.TestCase):
    """ Test that afterTurn returns correctly """

    def setUp(self):
        """ Builds the Pkmn and the Leech Effect """
        self.pkmn = BuildPokemonBattleWrapper()

        self.message = " hurt."
        self.pkmn2 = BuildPokemonBattleWrapper()
        self.leech = Leech(self.pkmn2, self.message)

    def message(self):
        """ Test the message is correct """
        message = self.leech.afterTurn(self.pkmn)
        assert message == [
            self.pkmn.getHeader() + self.message
        ], "Message should be the pokemon's name and the message given to the Leech."

    def faint(self):
        """ Test that the messsages returned when the target faints """
        self.pkmn.setCurrHP(self.leech.getAmount(self.pkmn))
        messages = self.leech.afterTurn(self.pkmn)
        assert len(messages) == 2, "Should have 2 messages"
        assert messages[1] == self.pkmn.getHeader() + Faint.start, "Should have a faint message."
开发者ID:cloew,项目名称:Pokemon-Project,代码行数:26,代码来源:leech_test.py

示例6: effectOnMiss

# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import setCurrHP [as 别名]
class effectOnMiss(unittest.TestCase):
    """ Test cases of effectOnMiss """
    
    def  setUp(self):
        """ Build the Pkmn and Delegate for the test """
        self.pkmn = BuildPokemonBattleWrapper()
        self.attack = BuildAttack()
        
        self.damage, messages = self.attack.damageDelegate.damage(self.pkmn, self.pkmn)
        
        self.ratio = 2
        self.delegate = CrashDelegate(self.attack, self.ratio)
        
    def recoil(self):
        """ Test that recoil damage is done """
        self.pkmn.setCurrHP(self.damage*2)
        self.delegate.effectOnMiss(self.pkmn, self.pkmn, None)
        
        damageDone = self.damage*2 - self.pkmn.getCurrHP()
        damage = self.damage/self.ratio
        assert damageDone == damage or damageDone == 2*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.effectOnMiss(self.pkmn, self.pkmn, None)

        message = CrashDelegate.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.effectOnMiss(self.pkmn, self.pkmn, 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"
开发者ID:cloew,项目名称:Pokemon-Project,代码行数:43,代码来源:crash_test.py

示例7: afterTurn

# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import setCurrHP [as 别名]
class afterTurn(unittest.TestCase):
    """ Test that afterTurn returns correctly """
    
    def setUp(self):
        """ Builds the side and trap """
        self.source = BuildPokemonBattleWrapper()
        self.pkmn = BuildPokemonBattleWrapper()
        
        self.message = " hurt."
        self.doneMessage = " done."
        self.trap = Trap(None, self.message, self.doneMessage)
    
    def turnDecreases(self):
        """ Test the turn counter decreases """
        self.trap.turns = 5
        turns = self.trap.turns
        self.trap.afterTurn(self.pkmn)
        assert self.trap.turns == turns - 1, "Turns should decrement"
        
    def effectIsRemoved(self):
        """ Test that the effect is removed when the turn count is reduced to zero """
        self.trap.turns = 1
        self.pkmn.secondaryEffects.append(self.trap)
        self.trap.afterTurn(self.pkmn)
        
        assert self.trap.turns == 0, "Turns should be zero"
        assert not self.trap in self.pkmn.secondaryEffects
        
    def message(self):
        """ Test the message is correct """
        message = self.trap.afterTurn(self.pkmn)
        assert message == [self.pkmn.getHeader() + self.message], "Message should be the pokemon's name and the message given to the Trap."
        
    def doneMessage(self):
        """ Test the done message is correct """
        self.trap.turns = 1
        self.pkmn.secondaryEffects.append(self.trap)
        messages = self.trap.afterTurn(self.pkmn)
        
        assert len(messages) == 2, "Should have two messages"
        assert messages[1] == self.pkmn.getHeader() + self.doneMessage, "Done message should be returned."
        
    def faintMessage(self):
        """ Test the faint message appears if the Pkmn faints """
        self.trap.turns = 3
        self.pkmn.setCurrHP(self.trap.getDamage(self.pkmn))
        
        self.pkmn.secondaryEffects.append(self.trap)
        messages = self.trap.afterTurn(self.pkmn)
        
        assert len(messages) == 2, "Should have two messages"
        assert messages[1] == self.pkmn.getHeader() + Faint.start, "Pkmn should have fainted."
    
    def faintAndDoneMessage(self):
        """ Test the done message is correct """
        self.trap.turns = 1
        self.pkmn.setCurrHP(self.trap.getDamage(self.pkmn))
        
        self.pkmn.secondaryEffects.append(self.trap)
        messages = self.trap.afterTurn(self.pkmn)
        
        assert len(messages) == 2, "Should have two messages"
        assert messages[1] == self.pkmn.getHeader() + Faint.start, "Pkmn should have fainted."
开发者ID:cloew,项目名称:Pokemon-Project,代码行数:65,代码来源:trap_test.py


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