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


Python Hero.known_as方法代码示例

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


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

示例1: TestHero

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import known_as [as 别名]
class TestHero(unittest.TestCase):
    def test_hero_known_as_not_Jenkins(self):
        self.bron_hero = Hero("Bron", 100, "Dragon Slayer")
        self.assertEqual(self.bron_hero.known_as(), "Bron the Dragon Slayer")

    def test_hero_known_as_Jenkins(self):
        self.leeroy = Hero("Leeroy", 100, "Jenkins")
        self.assertEqual(self.leeroy.known_as(), "Leeroy Jenkins")
开发者ID:kazuohirai,项目名称:HackBulgaria,代码行数:10,代码来源:hero_test.py

示例2: HeroTest

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

    def setUp(self):
        self.shosh_hero = Hero('Shosh', 100, 'GraveRobber')

    def test_hero_known_as(self):
        self.assertEqual(self.shosh_hero.known_as(), 'Shosh the GraveRobber')
开发者ID:Shosh,项目名称:hackBulgaria_programming101,代码行数:9,代码来源:hero_test.py

示例3: TestHero

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import known_as [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

示例4: HeroTest

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

    def setUp(self):
        self.test_hero = Hero("Ivan", "Ricar", 80, 70, 2)

    def test_known_as(self):
        self.assertEqual("Ivan the Ricar", self.test_hero.known_as())
开发者ID:ivannborisov,项目名称:Dungeons,代码行数:9,代码来源:hero_test.py

示例5: Test_hero

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

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

    def test_know_as_method(self):
        output = "Bron the DragonSlayer"
        result = self.hero.known_as()
        self.assertEqual(result, output)
开发者ID:VasilVasilev93,项目名称:HackBulgaria,代码行数:11,代码来源:hero_test.py

示例6: TestHero

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import known_as [as 别名]
class TestHero(unittest.TestCase):
    def setUp(self):
        self.bron_hero = Hero("Bron", 100, "DragonSlayer")

    def test_hero_init(self):
        self.assertEqual(self.bron_hero.nickname, "DragonSlayer")

    def test_known_as(self):
        self.assertEqual(self.bron_hero.known_as(), "Bron the DragonSlayer")
开发者ID:AlexanderTankov,项目名称:HackBulgaria-Programming-101,代码行数:11,代码来源:hero_test.py

示例7: HeroTests

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

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

    def test_hero_init(self):
        self.assertEqual("DragonSlayer", self.the_hero.nickname)

    def test_known_as(self):
        self.assertEqual("Bron the DragonSlayer", self.the_hero.known_as())
开发者ID:Fusl,项目名称:Hack-Bulgaria-Programming-101,代码行数:12,代码来源:hero_test.py

示例8: TestHero

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

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

    def test_attributes(self):
        self.assertEqual("Dragonslayer", self.bron_hero.nickname)

    def test_known_as(self):
        self.assertEqual("Bron the Dragonslayer", self.bron_hero.known_as())
开发者ID:maieutiquer,项目名称:dungeons-and-pythons,代码行数:12,代码来源:test_hero.py

示例9: TestHero

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

    def setUp(self):
        self.h = Hero(name="Bron", title="Dragonslayer", health=100, mana=100, mana_regeneration_rate=2)
        self.w = Weapon(name="The Axe of Destiny", damage=20)
        self.s = Spell(name="Fireball", damage=30, mana_cost=50, cast_range=2)

    def test_init(self):
        self.assertEqual(self.h.name, "Bron")
        self.assertEqual(self.h.title, "Dragonslayer")
        self.assertEqual(self.h.health, 100)
        self.assertEqual(self.h.mana, 100)
        self.assertEqual(self.h.mana_regeneration_rate, 2)
        self.assertEqual(self.h.start_mana, 100)
        self.assertEqual(self.h.damage, 0)

    def test_known_as(self):
        result = "Bron the Dragonslayer"
        self.assertEqual(self.h.known_as(), result)

    def test_is_alive(self):
        self.assertTrue(self.h.is_alive() is True)

    def test_take_damage(self):
        damage = self.h.take_damage(40)
        self.assertTrue(self.h.health is 60)

    def test_can_cast(self):
        self.assertTrue(self.h.can_cast() is True)

    def test_take_healing(self):
        self.h.take_damage(100)
        self.new_health = self.h.take_healing(30)
        self.assertTrue(self.h.health is 0)

    def test_take_mana(self):
        self.h.learn(self.s)
        self.h.attack(by="spell")
        self.h.take_mana(10)
        self.assertEqual(self.h.mana, 60)

    def test_attack(self):
        self.h.equip(self.w)
        self.assertEqual(self.h.attack(by="weapon"), 20)
        self.h.learn(self.s)
        self.assertEqual(self.h.attack(by="spell"), 30)

    def test_exception(self):
        self.h.learn(self.s)
        self.assertEqual(self.h.attack(by="spell"), 30)
        with self.assertRaises(NotEnaughMana):
            self.s.mana_cost = 50
            self.h.attack(by="spell")
开发者ID:pgenev,项目名称:HackBG-Programing-101-v3,代码行数:55,代码来源:test_hero.py

示例10: Test_Hero

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import known_as [as 别名]
class Test_Hero(unittest.TestCase):
    def setUp(self):
        self.barny = Hero("Barny", "PyMag", 100, 100, 5)

    def test_Born_Hero(self):
        self.assertIsInstance(self.barny, Hero)
        self.assertEqual(self.barny.mana, 100)
        self.assertEqual(self.barny.health, 100)
        self.assertEqual(self.barny.name, "Barny")
        self.assertEqual(self.barny.title, "PyMag")

    # def test_Get_Health(self):
    #     self.assertEqual(self.barny.get_health(), 100)

    def test_Known_As(self):
        self.assertEqual(self.barny.known_as(), "Barny the PyMag")
开发者ID:sevgo,项目名称:PyCraft,代码行数:18,代码来源:hero_test.py

示例11: TestHero

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import known_as [as 别名]
class TestHero(unittest.TestCase):
	def setUp(self):
		self.hero = Hero("Martin", "Manqk", 200, 300, 3)

	def test_hero_init_(self):
		self.assertEqual(self.hero.health, 200)
		self.assertEqual(self.hero.mana, 300)
		self.assertEqual(self.hero.damage, 0)

		self.assertEqual(self.hero.name, "Martin")
		self.assertEqual(self.hero.title, "Manqk")
		self.assertEqual(self.hero.mana_regen, 3)

	def test_hero_known_as(self):
		self.assertEqual(self.hero.known_as(), "Martin the Manqk")

	def test_hero_equip(self):
		w = Weapon('noj', 20)
		self.hero.equip(w)
		self.assertEqual(self.hero.damage, self.hero.phisical_damage + w.damage)
		self.assertEqual(self.hero.max_equiped_weapons, 1)

		self.assertFalse(self.hero.equip(w))

	def test_hero_learn(self):
		s = Spell("BatkaAttack", 30, 50, 2)
		self.hero.learn(s)
		self.assertEqual(self.hero.magic_damage, s.damage)
		self.assertEqual(self.hero.max_learned_spells, 1)

		self.assertFalse(self.hero.learn(s))

	def test_hero_attack(self):
		w = Weapon('noj', 20)
		self.hero.equip(w)
		self.hero.attack(by='weapon')
		self.assertTrue(self.hero.can_attack())
		self.assertEqual(self.hero.damage, self.hero.phisical_damage + self.hero.damage)

		s = Spell("BatkaAttack", 30, 50, 2)
		self.hero.learn(s)
		self.hero.attack(by='magic')
		self.assertEqual(self.hero.damage, self.hero.magic_damage)

		self.hero.attack(by='RKO')
		self.assertRaises(Exception)
开发者ID:Martin95056,项目名称:Dungeons,代码行数:48,代码来源:test_hero.py

示例12: TestHero

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import known_as [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

示例13: TestHero

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import known_as [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

示例14: HeroTest

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import known_as [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

示例15: Test

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import known_as [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


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