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


Python BuildPokemonBattleWrapper.getCurrHP方法代码示例

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


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

示例1: normalize

# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import getCurrHP [as 别名]
class normalize(unittest.TestCase):
    """ Tests that Normalize normalizes correctly """
    
    def setUp(self):
        """ Build the Damage Delegate """
        self.target = BuildPokemonBattleWrapper()
        self.delegate = NoFaintDelegate(None, 0, 1)
        
    def lessThanTargetHP(self):
        """ Test that damage is normalized correctly when less than the target's HP """
        damage = self.target.getCurrHP()-1
        newDamage = self.delegate.normalize(damage, self.target)
        assert newDamage == damage, "Should return the original damage"
        
    def targetHP(self):
        """ Test that damage is normalized correctly when equal to the target's HP """
        damage = self.target.getCurrHP()
        newDamage = self.delegate.normalize(damage, self.target)
        assert newDamage == self.target.getCurrHP() -1 , "Should return one less than the target's HP as damage"
        
    def greaterThanTargetHP(self):
        """ Test that damage is normalized correctly when greater than the target's HP """
        damage = self.target.getCurrHP()+1
        newDamage = self.delegate.normalize(damage, self.target)
        assert newDamage == self.target.getCurrHP() -1, "Should return one less than the target's HP as damage"
开发者ID:cloew,项目名称:Pokemon-Project,代码行数:27,代码来源:no_faint_test.py

示例2: takeDamage

# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import getCurrHP [as 别名]
class takeDamage(unittest.TestCase):
    """ Test cases of takeDamage """
    
    def  setUp(self):
        """ Build the Pkmn """
        self.pkmn = BuildPokemonBattleWrapper()
    
    def faints(self):
        """ Test that Faint Exception is thrown """
        messages = self.pkmn.takeDamage(self.pkmn.getCurrHP())
        assert messages == [self.pkmn.getHeader() + Faint.start], "The Pkmn should have fainted"
        
    def noFaint(self):
        """ Test that Faint Exception is not thrown if the pkmn doesn't faint """
        messages = self.pkmn.takeDamage(self.pkmn.getCurrHP()-1)
        assert messages == [], "Should receive any empty list when the Pkmn has not fainted"
开发者ID:cloew,项目名称:Pokemon-Project,代码行数:18,代码来源:pkmn_battle_wrapper_test.py

示例3: normalize

# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import getCurrHP [as 别名]
class normalize(unittest.TestCase):
    """ Tests that Normalize normalizes correctly """
    
    def setUp(self):
        """ Build the Damage Delegate """
        self.target = BuildPokemonBattleWrapper()
        self.delegate = DamageDelegate(None, 0, 1)
        
    def zero(self):
        """ Test that 0 is normalized correctly """
        damage = 0
        newDamage = self.delegate.normalize(damage, self.target)
        assert newDamage == 0, "Should return zero"
        
    def lessThanOne(self):
        """ Test that < 1 is normalized correctly """
        damage = 0.1
        newDamage = self.delegate.normalize(damage, self.target)
        assert newDamage == 1, "Should return one if between 0 and 1"
        
    def normalizeInt(self):
        """ Test that normalizing an int returns the int """
        damage = 3
        newDamage = self.delegate.normalize(damage, self.target)
        assert newDamage == damage, "Should return the number if its an int"
        
    def normalizeFloat(self):
        """ Test that normalizing a float returns the int """
        damage = 3.3
        newDamage = self.delegate.normalize(damage, self.target)
        assert newDamage == int(damage), "Should return the floored number if its an int"
        
    def greaterThanTargetHP(self):
        """ Test that damage is normalized correctly when greater than the target's HP """
        damage = self.target.getCurrHP()+1
        newDamage = self.delegate.normalize(damage, self.target)
        assert newDamage == int(self.target.getCurrHP()), "Should return the target's HP as damage"
开发者ID:cloew,项目名称:Pokemon-Project,代码行数:39,代码来源:damage_test.py

示例4: heal

# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import getCurrHP [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

示例5: effectOnMiss

# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import getCurrHP [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

示例6: applyEffect

# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import getCurrHP [as 别名]
class applyEffect(unittest.TestCase):
    """ Test cases of applyEffect """
    
    def  setUp(self):
        """ Build the Pkmn and Delegate for the test """
        self.user = BuildPokemonBattleWrapper()
        self.delegate = SelfDestructDelegate()
        
    def selfDestructed(self):
        """ Test that the user self destructs (aka dies) """
        self.delegate.applyEffect(self.user, None, None)
        assert self.user.getCurrHP() == 0, "Pkmn should have fainted"
    
    def message(self):
        """ Test that the user self destructs (aka dies) """
        messages = self.delegate.applyEffect(self.user, None, None)
        message = self.user.getHeader() + SelfDestructDelegate.message
        faintMessage = self.user.getHeader() + Faint.start
        assert len(messages) == 2, "Should get 1 message"
        assert messages[0] == message, "Should get the Pkmn's header and the Delegate's message"
        assert messages[1] == faintMessage, "Should have the Pkmn faint"
开发者ID:cloew,项目名称:Pokemon-Project,代码行数:23,代码来源:selfdestruct_test.py

示例7: afterTurn

# 需要导入模块: from Test.test_helper import BuildPokemonBattleWrapper [as 别名]
# 或者: from Test.test_helper.BuildPokemonBattleWrapper import getCurrHP [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


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