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


Python Hero.get_health方法代码示例

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


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

示例1: TestHero

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import get_health [as 别名]
class TestHero(unittest.TestCase):
    def setUp(self):
        self.hero1 = Hero("Arthur", "knight", 100, 100, 2)
        self.weapon1 = Weapon(name="The Axe of Destiny", damage=20)
        self.spell1 = Spell(name="Fireball", damage=30, mana_cost=50, cast_range=2)

    def test_init(self):
        self.assertTrue(isinstance(self.hero1, Hero))

    def test_known_as(self):
        self.assertEqual(self.hero1.known_as(), "Arthur the knight")

    def test_is_alive_and_take_damage(self):
        self.assertTrue(self.hero1.is_alive())
        self.hero1.take_damage(70)
        self.assertTrue(self.hero1.is_alive())
        self.assertEqual(self.hero1.get_health(), 30)
        self.hero1.take_damage(40)
        self.assertFalse(self.hero1.is_alive())

    def test_take_healing(self):
        self.hero1.take_damage(50)
        self.hero1.take_healing(20)
        self.assertTrue(self.hero1.get_health() == 70)
        self.assertTrue(self.hero1.take_healing(10))
        self.hero1.take_damage(80)
        self.assertFalse(self.hero1.take_healing(20))

    def test_equip(self):
        self.hero1.equip(self.weapon1)
        self.assertIsInstance(self.hero1.weapon, Weapon)

    def test_learn(self):
        self.hero1.learn(self.spell1)
        self.assertIsInstance(self.hero1.spell, Spell)
开发者ID:anedelcheva,项目名称:Game-Dungeons-and-Pythons,代码行数:37,代码来源:hero_test.py

示例2: TestHero

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import get_health [as 别名]
class TestHero(unittest.TestCase):

    def setUp(self):
        self.bron = Hero("Bron", 100, "DragonSlayer")

    def test_hero_init(self):
        self.assertEqual(self.bron.name, "Bron")
        self.assertEqual(self.bron.health, 100)
        self.assertEqual(self.bron.nickname, "DragonSlayer")

    def test_known_as(self):
        self.assertEqual(self.bron.known_as(), "Bron the DragonSlayer")

    def test_get_health(self):
        self.assertEqual(self.bron.get_health(), 100)

    def test_is_alive(self):
        self.assertTrue(self.bron.is_alive())

    def test_is_alive_with_dead(self):
        self.bron.health = 0
        self.assertFalse(self.bron.is_alive())

    def test_take_damage(self):
        self.bron.take_damage(50)
        self.assertEqual(self.bron.health, 50)

    def test_take_damage_max_dmg(self):
        self.bron.take_damage(200)
        self.assertEqual(self.bron.health, 0)
        self.bron.take_damage(20)
        self.assertEqual(self.bron.health, 0)

    def test_take_healing_on_dead(self):
        self.bron.health = 0
        self.assertFalse(self.bron.take_healing(100))

    def test_take_healing_above_maximum_health(self):
        self.bron.take_healing(1 + self.bron._MAX_HEALTH)
        self.assertTrue(self.bron.take_healing(1 + self.bron._MAX_HEALTH))
        self.assertEqual(self.bron.health, self.bron._MAX_HEALTH)

    def test_take_healing(self):
        self.bron.health = 20
        self.assertTrue(self.bron.take_healing(20))
        self.assertEqual(self.bron.health, 40)
开发者ID:svetlio2,项目名称:hackbg,代码行数:48,代码来源:hero_test.py

示例3: HeroTest

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import get_health [as 别名]
class HeroTest(unittest.TestCase):

    def setUp(self):
        self.bron_hero = Hero("Bron", 100, "DragonSlayer")

    def test_hero_init(self):

        self.assertEqual(self.bron_hero.name, "Bron")
        self.assertEqual(self.bron_hero.health, 100)
        self.assertEqual(self.bron_hero.nickname, "DragonSlayer")

    def test_known_as(self):

        self.assertEqual(self.bron_hero.known_as(), "Bron the DragonSlayer")

    def test_get_health(self):

        self.assertEqual(self.bron_hero.get_health(), 100)

    def test_is_alive_return_false(self):

        self.bron_hero.health = 0
        self.assertFalse(self.bron_hero.is_alive())

    def test_is_alive(self):
        self.assertTrue(self.bron_hero.is_alive())

    def test_take_damage(self):

        self.assertEqual(80, self.bron_hero.take_damage(20))

    def test_take_damage_more_than_health(self):

        self.assertEqual(0, self.bron_hero.take_damage(120))

    def test_take_healing_to_dead_person(self):
        self.bron_hero.health = 0
        self.assertFalse(self.bron_hero.take_healing(20))

    def test_take_healing_more_than_full_health(self):
        self.bron_hero.health = 90
        self.assertFalse(self.bron_hero.take_healing(100))

    def test_take_healing_true(self):
        self.bron_hero.health = 40
开发者ID:vparkov,项目名称:HackBulgaria,代码行数:47,代码来源:hero_test.py

示例4: TestHero

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import get_health [as 别名]
class TestHero(unittest.TestCase):

    def setUp(self):
        self.hero = Hero("Bron", 100, "DragonSlayer")

    def test_hero_init(self):
        self.assertEqual(self.hero.name, "Bron")
        self.assertEqual(self.hero.health, 100)
        self.assertEqual(self.hero.nickname, "DragonSlayer")

    def test_known_as(self):
        self.assertEqual(self.hero.known_as(), "Bron the DragonSlayer")

    def test_get_health(self):
        self.assertEqual(self.hero.get_health(), 100)

    def test_is_alive(self):
        self.assertTrue(self.hero.is_alive())
        self.hero.health = 0
        self.assertFalse(self.hero.is_alive())

    def test_take_damage(self):
        self.hero.take_damage(50)
        self.assertEqual(50, self.hero.get_health())
        self.hero.take_damage(10)
        self.assertEqual(40, self.hero.get_health())
        self.hero.take_damage(25)
        self.assertEqual(15, self.hero.get_health())

    def test_take_healing(self):
        self.assertTrue(self.hero.take_healing(25))
        self.assertEqual(100, self.hero.get_health())
        self.hero.take_damage(40)
        self.assertEqual(60, self.hero.get_health())
        self.assertTrue(self.hero.take_healing(15))
        self.assertEqual(75, self.hero.get_health())
        self.hero.take_damage(100)
        self.assertFalse(self.hero.is_alive())
        self.assertFalse(self.hero.take_healing(100))

    def test_take_healing_dead(self):
        pass

    def test_take_healing_overhealing(self):
        pass
开发者ID:modzozo,项目名称:hack101,代码行数:47,代码来源:heroTest.py

示例5: Test

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import get_health [as 别名]
class Test(unittest.TestCase):
    def setUp(self):
        self.w = Weapon("axe", 20)
        self.spell = Spell("love spell", 70, 2, 4)
        self.h = Hero("Arthur", "great", 100, 100, 100, 2, self.w, self.spell)

    def test_hero_init(self):
        self.assertEqual(self.h.get_name(), "Arthur")
        self.assertEqual(self.h.get_title(), "great")
        self.assertEqual(self.h.get_health(), 100)
        self.assertEqual(self.h.get_start_health(), 100)
        self.assertEqual(self.h.get_mana(), 100)
        self.assertEqual(self.h.get_mana_rate(), 2)
        self.assertEqual(self.h.get_weapon(), "axe")

    def test_hero_init(self):
        self.assertEqual(str(self.h), "Arthur great 100 100 2")

    def test_hero_known_as(self):
        self.assertEqual(self.h.known_as(), "Arthur the great")

    def test_hero_is_alive(self):
        self.assertTrue(self.h.is_alive())

    def test_hero_is_dead(self):
        self.assertFalse(self.h.is_dead())

    def test_hero_can_cast(self):
        self.assertTrue(self.h.can_cast())

    def test_hero_take_damage(self):
        self.assertEqual(self.h.take_damage(70), 30)

    def test_hero_take_healing(self):
        self.h.take_damage(70)
        self.assertEqual(self.h.take_healing(20), 50)

    def test_hero_equip(self):
        self.assertEqual(self.h.equip(self.w), "Equipped with axe, damage: 20")

    def test_hero_attack(self):
        self.assertEqual(self.h.attack("weapon"), 20)
开发者ID:AdelinaMancheva,项目名称:Dungeons-and-Pythons,代码行数:44,代码来源:test_hero.py

示例6: FightsTest

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import get_health [as 别名]
class FightsTest(unittest.TestCase):
    def setUp(self):
        self.h = Hero(name="Bron", title="Dragonslayer", health=100, mana=100, mana_regeneration_rate=2)
        self.e =  Enemy(health=100, mana=100, damage=20)
        self.f = Fights(self.h, self.e)

    def test_starting_fight(self):
        self.assertEqual(self.f.start_fights(), "A fight is started between our Hero(health=100, mana=100) and Enemy(health=100, mana=100, damage=20)")

    def test_enemy_attack(self):
        self.f.enemy_attack()
        self.assertEqual(self.h.get_health(), 80)

    def test_hero_attack_with_weapon_zero_dmg(self):
        self.f.hero_attack(by='weapon')
        self.assertEqual(self.e.health, 100)

    def test_hero_attack_with_weapon_non_zero_dmg(self):
        self.h.weapon_equipment[0] = Weapon("Pistol", damage=10)
        f2 = Fights(self.h, self.e)
        f2.hero_attack(by='weapon')
        self.assertEqual(self.e.health, 100)
开发者ID:stoianivanov,项目名称:TheBestGameEver,代码行数:24,代码来源:fights_test.py

示例7: HeroTest

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import get_health [as 别名]
class HeroTest(unittest.TestCase):

    def setUp(self):
        self.hunter = Hero("Lagerta", "Arrow", 120, 120, 2)

    def test_create_new_instance(self):
        self.assertTrue(isinstance(self.hunter, Hero))

    def test_valid_members(self):
        self.assertEqual(self.hunter.name, "Lagerta")
        self.assertEqual(self.hunter.title, "Arrow")
        self.assertEqual(self.hunter.health, 120)
        self.assertEqual(self.hunter.mana, 120)
        self.assertEqual(self.hunter.mana_regeneration_rate, 2)

        self.assertEqual(self.hunter.max_health, 120)
        self.assertEqual(self.hunter.max_mana, 120)

    def test_known_as(self):
        self.assertEqual(self.hunter.known_as(), "Lagerta the Arrow")

    def test_get_health(self):
        self.assertEqual(self.hunter.get_health(), 120)

    def test_get_mana(self):
        self.assertEqual(self.hunter.get_mana(), 120)

    def test_is_alive(self):
        self.assertTrue(self.hunter.is_alive())
        self.hunter.health = 0
        self.assertFalse(self.hunter.is_alive())

    def test_can_cast_without_spell(self):
        self.assertFalse(self.hunter.can_cast())

    def test_can_cast_with_more_mana(self):
        self.hunter.spell = Spell("Chilling Poison", 20, 20, 2)
        self.assertTrue(self.hunter.can_cast())

    def test_can_cast_with_less_mana(self):
        self.hunter.spell = Spell("Chilling Poison", 20, 20, 2)
        self.hunter.mana = 0
        self.assertFalse(self.hunter.can_cast())

    def test_take_damage_more_than_health(self):
        self.hunter.take_damage(150)
        self.assertEqual(self.hunter.health, 0)

    def test_take_damage_less_than_health(self):
        self.hunter.take_damage(100)
        self.assertEqual(self.hunter.health, 20)

    def test_take_healing_dead_hero(self):
        self.hunter.health = 0
        self.assertFalse(self.hunter.take_healing(200))

    def test_take_healing_with_more_points_than_max_health(self):
        self.hunter.health = 80
        self.assertTrue(self.hunter.take_healing(200))
        self.assertEqual(self.hunter.health, 120)

    def test_take_healing_with_less_points_than_max_health(self):
        self.hunter.health = 90
        self.assertTrue(self.hunter.take_healing(20))
        self.assertEqual(self.hunter.health, 110)

    def test_take_mana_with_more_points_than_max_mana(self):
        self.hunter.mana = 80
        self.hunter.take_mana(200)
        self.assertEqual(self.hunter.mana, 120)

    def test_take_mana_with_negative_mana(self):
        self.hunter.mana = 50
        self.hunter.take_mana(-60)
        self.assertEqual(self.hunter.mana, 0)

    def test_take_mana_with_less_points_than_max_mana(self):
        self.hunter.mana = 65
        self.hunter.take_mana(20)
        self.assertEqual(self.hunter.mana, 85)

    def test_equip(self):
        knife = Weapon("Knife", 10)
        self.hunter.equip(knife)
        self.assertEqual(self.hunter.weapon, knife)

    def test_learn(self):
        mind_blast = Spell("Mind Blast", 20, 35, 5)
        self.hunter.learn(mind_blast)
        self.assertEqual(self.hunter.spell, mind_blast)

    def test_attack_without_equiped_weapon(self):
        self.assertEqual(self.hunter.attack(by="weapon"), 0)

    def test_attack_with_equiped_weapon(self):
        knife = Weapon("Sword", 30)
        self.hunter.equip(knife)
        self.assertEqual(self.hunter.attack(by="weapon"), 30)

    def test_attack_without_learned_spell(self):
#.........这里部分代码省略.........
开发者ID:stilyantanev,项目名称:Dungeons-And-Pythons,代码行数:103,代码来源:hero_test.py

示例8: print

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import get_health [as 别名]
        else:
            print('The hero can use only spell or weapon')





map = Dungeon('dungeon.txt')
hero = Hero(name = 'Django', title = 'The Unchained', health = 100, mana = 100, mana_regen  = 2)
enemy = Enemy(health = 80, mana = 100, damage = 20)
w = Weapon('Axe', 20)
s = Spell('Magic', 20, 50, 2)
hero.equip(w)
hero.learn(s)

print(hero.get_health())
print(enemy.get_health())

map._pick_treasure()


map._print_map()
map._spawn('Batman')
map._move_hero('right')
map._print_map()
map._move_hero('down')
map._print_map()
map._move_hero('down')
map._print_map()
map._move_hero('down')
map._print_map()
开发者ID:ggchilev,项目名称:hack_bulgaria,代码行数:33,代码来源:Dungeon.py

示例9: HeroTests

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import get_health [as 别名]
class HeroTests(unittest.TestCase):
    def setUp(self):
        self.hero = Hero("Ahri", "Kingslayer", 100, 100, 2)
        self.enemy = Enemy(100, 100, 20)
        self.dungeon = Dungeon("level1.txt")
        self.weapon = Weapon("The Axe of Destiny", damage=20)
        self.spell = Spell(
            name="Fireball", damage=30, mana_cost=50, cast_range=1)

    def test_known_as(self):
        self.assertEqual(self.hero.known_as(), "Ahri the Kingslayer")

    def test_take_damage(self):
        self.hero.take_damage(150)
        self.assertEqual(self.hero.get_health(), 0)

    def test_take_healing(self):
        self.hero.take_damage(50)
        self.assertTrue(self.hero.take_healing(55))
        self.assertEqual(self.hero.get_health(), 100)

    def test_take_mana_with_potion(self):
        pass

        # Test enemy who can not regenerate mana
    def test_mana_regeneration_while_moving(self):
        pass

    def test_can_cast(self):
        self.hero.learn(self.spell)
        self.assertTrue(self.hero.can_cast())

    def test_can_cast_with_no_spells_learned(self):
        self.assertFalse(self.hero.can_cast())

    def test_attack_not_being_specified(self):
        with self.assertRaises(ValueError):
            self.hero.attack(by="gun")

    def test_attack_without_weapon_or_spell(self):
        self.assertEqual(self.hero.attack(by="weapon"), 0)
        self.assertEqual(self.hero.attack(by="magic"), 0)
        # Test for enemy (base damage= = 20)
        self.assertEqual(self.enemy.attack(by="weapon"), 20)
        self.assertEqual(self.enemy.attack(by="magic"), 20)

    def test_attack(self):
        self.hero.equip(self.weapon)
        self.assertEqual(self.hero.attack(by="weapon"), 20)
        self.hero.learn(self.spell)
        self.assertEqual(self.hero.attack(by="magic"), 30)

    def test_dungeon_map(self):
        self.assertEqual(self.dungeon.map, [['S', '.', '#', '#', '.', '.', '.', '.', '.', 'T'], ['#', 'T', '#', '#', '.', '.', '#', '#', '#', '.'], ['#', '.', '#', '#', '#', 'E', '#', '#', '#', 'E'], ['#', '.', 'E', '.', '.', '.', '#', '#', '#', '.'], ['#', '#', '#', 'T', '#', '#', '#', '#', '#', 'G']])
        # self.dungeon.print_map()

    def test_spawn_hero(self):
        self.dungeon.spawn(self.hero)
        self.dungeon.spawn(self.hero)
        self.dungeon.spawn(self.hero)
        # self.dungeon.print_map()

    def test_get_position(self):
        self.dungeon.spawn(self.hero)
        self.assertEqual(self.dungeon.get_position(), (0, 0))

    def test_move_right(self):
        self.dungeon.spawn(self.hero)
        self.dungeon.move_hero("right")
        # self.dungeon.print_map()
        self.assertFalse(self.dungeon.move_hero("right"))

    def test_move_left(self):
        self.dungeon.spawn(self.hero)
        self.dungeon.move_hero("right")
        self.assertTrue(self.dungeon.move_hero("left"))
        # self.dungeon.print_map()

    def test_move_up(self):
        self.dungeon.spawn(self.hero)
        self.assertFalse(self.dungeon.move_hero("up"))

    def test_move_down(self):
        self.dungeon.spawn(self.hero)
        self.assertFalse(self.dungeon.move_hero("down"))

    def test_moving_around_the_map(self):
        dungeon = Dungeon("level2.txt")
        dungeon.spawn(self.hero)
        dungeon.move_hero("right")
        dungeon.move_hero("down")
        self.assertFalse(dungeon.move_hero("right"))
        dungeon.move_hero("down")
        self.assertFalse(dungeon.move_hero("left"))
        # dungeon.print_map()
        self.assertTrue(dungeon.move_hero("down"))

    def test_the_game(self):
        h = Hero(name="Bron", title="Dragonslayer",
                 health=100, mana=100, mana_regeneration_rate=2)
#.........这里部分代码省略.........
开发者ID:kobso1245,项目名称:Programming101-v3,代码行数:103,代码来源:dungeons_and_pythons_tests.py

示例10: EntityTest

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import get_health [as 别名]
class EntityTest(unittest.TestCase):
    def setUp(self):
        self.hero = Hero("Bron", 100, "DragonSlayer")
        self.orc = Ork("BronOrk", 100, 1.1)
        self.axe = Weapon("Axe", 12.45, 0.2)
        self.sword = Weapon("Sword of Arthur", 13, 0.5)
        self.battle = Fight(self.hero, self.orc)
        self.dungeon = Dungeon("dungeon.txt")

    def test_hero_init(self):
        self.assertEqual("Bron", self.hero.name)
        self.assertEqual(100, self.hero.health)
        self.assertEqual("DragonSlayer", self.hero.nickname)

    def test_known_as(self):
        self.assertEqual(self.hero.known_as(), "Bron the DragonSlayer")

    def test_get_health(self):
        self.assertEqual(100, self.hero.get_health())
        self.assertEqual(100, self.orc.get_health())

    def test_is_alive(self):
        self.assertTrue(self.hero.is_alive())
        self.hero.health = 0
        self.orc.health = -1
        self.assertFalse(self.orc.is_alive())
        self.assertFalse(self.hero.is_alive())

    def test_take_damage(self):
        self.assertTrue(self.hero.take_damage(30.0))
        result = self.hero.get_health()
        self.assertEqual(70.0, result)
        self.assertFalse(self.hero.take_damage(70))

    def test_take_more_damage_that_he_can(self):
        self.assertFalse(self.hero.take_damage(101))

    def test_take_healing(self):
        self.assertTrue(self.hero.take_healing(10))
        self.hero.health = 10
        self.assertTrue(self.hero.take_healing(10.0))
        self.hero.health = 0
        self.assertFalse(self.hero.take_healing(10.0))

    def test_orc_init(self):
        self.assertEqual("BronOrk", self.orc.name)
        self.assertEqual(100, self.orc.health)

    def test_ork_berseker(self):
        self.orc._Ork__set_berserk_factor(3)
        self.assertEqual(2, self.orc.berserk_factor)
        self.orc._Ork__set_berserk_factor(0.5)
        self.assertEqual(1, self.orc.berserk_factor)

    def test_has_weapon(self):
        self.assertFalse(self.orc.has_weapon())
        self.orc.equip_weapon(self.axe)
        self.assertTrue(self.orc.has_weapon())

    def test_equip_weapon(self):
        new_weapon = Weapon("Bazuka", 15, 3)
        self.orc.equip_weapon(new_weapon)
        self.assertEqual(new_weapon, self.orc.weapon)

    def test_attack(self):
        self.assertFalse(self.orc.has_weapon())
        self.assertEqual(0, self.orc.attack())
        self.orc.equip_weapon(self.axe)
        self.assertEqual(self.axe.damage, self.orc.attack())

    def test_fight_init(self):
        self.assertEqual(self.battle.hero, self.hero)
        self.assertEqual(self.battle.orc, self.orc)

    def test_simulate_fight(self):
        self.orc.weapon = self.axe
        self.hero.weapon = self.sword
        self.battle.simulate_fight()

    def test_spawn(self):
        self.assertTrue(self.dungeon.spawn('Bron', self.hero))
        self.assertTrue(self.dungeon.spawn('BronOrk', self.orc))
        # self.dungeon.print_map()

    def test_move(self):
        self.dungeon.spawn('Bron', self.hero)
        self.dungeon.spawn('Undead', self.orc)
        self.assertFalse(self.dungeon.move('Bron', 'left'))
        self.assertFalse(self.dungeon.move('Bron', 'up'))
        self.assertTrue(self.dungeon.move('Bron', 'right'))
        self.assertFalse(self.dungeon.move('Undead', 'down'))
        self.assertTrue(self.dungeon.move('Undead', 'up'))
        self.dungeon.print_map()
开发者ID:IvanAlexandrov,项目名称:HackBulgaria-Tasks,代码行数:95,代码来源:test_entity.py

示例11: __init__

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import get_health [as 别名]
class Game:
    def __init__(self):
        self.parser = CommandParser()
        self.load_functions()
        self.run()

    def initialize_game(self):
        name = input("Character Name> ")
        health = 100
        nickname = input("Character Nickname> ")
        self.hero = Hero(name, health, nickname)
        self.level = 1
        self.map = Dungeon()
        self.map.spawn(self.hero)

    def run(self):
        running = True
        system('clear')
        print("Welcome to Dungeons & Pythons!")
        print("What are you waiting for? Create your character and start slaying...")
        self.initialize_game()
        print("Loading Level " + str(self.level) + '...')
        sleep(3)

        while running:
            system('clear')
            if not self.hero.is_alive():
                print("\n\nGAME OVER!")
                sleep(3)
                self.run()

            print("Character: {0}".format(str(self.hero)))
            print("Health: {0}".format(str(self.hero.get_health())))
            print("Weapon: {0}".format(str(self.hero.weapon)))
            print("Level: {0}".format(str(self.level)))
            print("\n")

            self.map.print_map()
            command = input("\nEnter direction <u, d, r, l>: ")
            self.parser.take_command(command)
            self.hero = self.map.hero
            if self.map.game_ended:
                system('clear')
                self.level += 1
                self.map = Dungeon(self.level)
                if not self.map.map:
                    print("YOU WON!!! Congratulations, Dungeon Master! ;)")
                self.map.spawn(self.hero)
                print("Loading Level " + str(self.level) + '...')
                sleep(3)

    def move_up(self, arguments):
        self.map.move('up')

    def move_down(self, arguments):
        self.map.move('down')

    def move_right(self, arguments):
        self.map.move('right')

    def move_left(self, arguments):
        self.map.move('left')

    def load_functions(self):
        self.parser.add_function('u', self.move_up)
        self.parser.add_function('d', self.move_down)
        self.parser.add_function('r', self.move_right)
        self.parser.add_function('l', self.move_left)
开发者ID:tdhris,项目名称:HackBulgaria,代码行数:70,代码来源:game.py

示例12: test_Hero_take_healing_dead

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import get_health [as 别名]
 def test_Hero_take_healing_dead(self):
     my_Hero = Hero("Ivan", 100, "bad ass")
     my_Hero.health = 0
     self.assertFalse(my_Hero.take_healing(30))
     self.assertEqual(my_Hero.get_health(), 0)
开发者ID:Hristiyan-Andreev,项目名称:HackBuglaria,代码行数:7,代码来源:heroTest.py

示例13: test_Hero_take_damage_float

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import get_health [as 别名]
 def test_Hero_take_damage_float(self):
     my_Hero = Hero("Ivan", 100, "bad ass")
     my_Hero.take_damage(50.5)
     self.assertEqual(my_Hero.get_health(), 49.5)
开发者ID:Hristiyan-Andreev,项目名称:HackBuglaria,代码行数:6,代码来源:heroTest.py

示例14: test_hero_get_health

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import get_health [as 别名]
 def test_hero_get_health(self):
     my_Hero = Hero("Ivan", 100, "bad ass")
     self.assertEqual(my_Hero.get_health(), 100)
开发者ID:Hristiyan-Andreev,项目名称:HackBuglaria,代码行数:5,代码来源:heroTest.py

示例15: test_get_health

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import get_health [as 别名]
 def test_get_health(self):
     bron_hero = Hero("Bron", 100, "DragonSyler")
     self.assertEqual(100, bron_hero.get_health())
开发者ID:kal0ian,项目名称:HackBulgaria,代码行数:5,代码来源:hero-test.py


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