本文整理汇总了Python中species.Species.trait_names方法的典型用法代码示例。如果您正苦于以下问题:Python Species.trait_names方法的具体用法?Python Species.trait_names怎么用?Python Species.trait_names使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类species.Species
的用法示例。
在下文中一共展示了Species.trait_names方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestDealer
# 需要导入模块: from species import Species [as 别名]
# 或者: from species.Species import trait_names [as 别名]
#.........这里部分代码省略.........
self.species_2.traits.append(TraitCard("climbing"))
self.species_4.traits.append(TraitCard("climbing"))
self.species_5.traits.append(TraitCard("climbing"))
self.dealer.feed1()
self.assertEqual(self.species_3.food, 4)
self.assertEqual(self.species_4.food, 4)
self.assertEqual(self.species_1.population, 3)
self.assertEqual(self.dealer.watering_hole, 8)
def test_feed_1_double_foraging(self):
self.species_3.traits.append(TraitCard("foraging"))
self.species_3.food = 1
self.dealer.feed1()
self.assertEqual(self.species_3.food, 3)
def test_feed_1_foraging(self):
self.species_3.traits.append(TraitCard("foraging"))
self.species_3.food = 3
self.dealer.feed1()
self.assertEqual(self.species_3.food, 4)
def test_feed_1_cooperation(self):
self.dealer.current_player_index = 3
self.species_4.traits.append(TraitCard("cooperation"))
self.species_5.food = 1
self.dealer.feed1()
self.assertEqual(self.species_4.food, 4)
self.assertEqual(self.species_5.food, 2)
def test_feed_1_scavenger_cooperation(self):
self.species_3.traits.append(TraitCard("carnivore"))
self.species_4.traits.append(TraitCard("climbing"))
self.species_4.traits.append(TraitCard("cooperation"))
self.species_4.traits.append(TraitCard("scavenger"))
self.species_2.traits.append(TraitCard("climbing"))
self.species_5.traits.append(TraitCard("climbing"))
self.species_5.food = 2
self.dealer.feed1()
self.assertTrue("cooperation" in self.species_4.trait_names())
self.assertEqual(self.species_4.food, 4)
self.assertEqual(self.species_5.food, 3)
def test_feed_1_cooperation_chain(self):
self.dealer.player_sets[3]['state'].species.append(self.species_3)
self.dealer.current_player_index = 3
self.species_4.traits.append(TraitCard("cooperation"))
self.species_5.traits.append(TraitCard("cooperation"))
self.species_5.food = 1
self.species_3.food = 0
self.dealer.feed1()
self.assertEqual(self.species_4.food, 4)
self.assertEqual(self.species_5.food, 2)
self.assertEqual(self.species_3.food, 1)
def test_feed_1_carnivore_foraging(self):
self.species_3.food = 0
self.species_3.traits.append(TraitCard("carnivore"))
self.species_3.traits.append(TraitCard("foraging"))
self.species_2.traits.append(TraitCard("climbing"))
self.species_4.traits.append(TraitCard("climbing"))
self.species_5.traits.append(TraitCard("climbing"))
self.dealer.feed1()
self.assertEqual(self.species_3.food, 2)
def test_feed_1_horns(self):
self.species_3.food = 0
self.species_3.traits.append(TraitCard("carnivore"))
self.species_1.traits.append(TraitCard("horns"))
self.species_2.traits.append(TraitCard("climbing"))
self.species_4.traits.append(TraitCard("climbing"))
self.species_5.traits.append(TraitCard("climbing"))
self.dealer.feed1()
self.assertEqual(self.species_3.population, 3)
self.assertEqual(self.species_3.food, 1)
def test_feed_1_horns_no_food(self):
self.species_3.traits.append(TraitCard("carnivore"))
self.species_1.traits.append(TraitCard("horns"))
self.species_2.traits.append(TraitCard("climbing"))
self.species_4.traits.append(TraitCard("climbing"))
self.species_5.traits.append(TraitCard("climbing"))
self.dealer.feed1()
self.assertEqual(self.species_3.population, 3)
self.assertEqual(self.species_3.food, 3)
def test_player_can_feed(self):
self.assertFalse(self.dealer.player_can_feed(self.dealer.player_state(0)))
self.assertTrue(self.dealer.player_can_feed(self.dealer.player_state(2)))
self.species_4.traits.append(TraitCard("carnivore"))
self.species_1.traits.append(TraitCard("climbing"))
self.species_2.traits.append(TraitCard("climbing"))
self.species_3.traits.append(TraitCard("climbing"))
self.species_5.traits.append(TraitCard("climbing"))
self.assertFalse(self.dealer.player_can_feed(self.dealer.player_state(3)))
示例2: TestSpecies
# 需要导入模块: from species import Species [as 别名]
# 或者: from species.Species import trait_names [as 别名]
class TestSpecies(unittest.TestCase):
def setUp(self):
self.attacker = Species()
self.attacker.traits = [TraitCard("carnivore")]
self.defender = Species()
self.left_neighbor = Species()
self.right_neighbor = Species()
self.species_1 = Species(4, 4, 4)
self.species_2 = Species(4, 4, 4)
self.species_3 = Species(4, 4, 3)
self.species_4 = Species(4, 3, 3)
self.species_5 = Species(3, 3, 3)
self.species_list = [self.species_2, self.species_4, self.species_3, self.species_5, self.species_1]
def test_can_eat(self):
self.assertFalse(self.species_1.can_eat())
self.assertTrue(self.species_4.can_eat())
fat_tissue = Species(4, 3, 4, [TraitCard("fat-tissue")], 3)
self.assertTrue(fat_tissue.can_eat())
fat_tissue.fat_storage = 4
self.assertFalse(fat_tissue.can_eat())
def test_trait_names(self):
self.assertEqual(self.defender.trait_names(), [])
self.assertEqual(self.attacker.trait_names(), ["carnivore"])
def test_attackable(self):
self.assertTrue(self.defender.is_attackable(self.attacker))
def test_no_carnivore(self):
self.attacker.traits = []
self.assertFalse(self.defender.is_attackable(self.attacker))
def test_burrowing(self):
self.defender.traits = [TraitCard("burrowing")]
self.defender.population, self.defender.food = (4, 4)
self.assertFalse(self.defender.is_attackable(self.attacker))
self.defender.food = 3
self.assertTrue(self.defender.is_attackable(self.attacker))
def test_climbing(self):
self.defender.traits = [TraitCard("climbing")]
self.assertFalse(self.defender.is_attackable(self.attacker))
self.attacker.traits.append(TraitCard("climbing"))
self.assertTrue(self.defender.is_attackable(self.attacker))
def test_hard_shell(self):
self.defender.traits = [TraitCard("hard-shell")]
self.defender.body = 3
self.attacker.body = 6
self.assertFalse(self.defender.is_attackable(self.attacker))
self.attacker.body = 7
self.assertTrue(self.defender.is_attackable(self.attacker))
def test_herding(self):
self.defender.traits = [TraitCard("herding")]
self.defender.population = 4
self.attacker.population = 3
self.assertFalse(self.defender.is_attackable(self.attacker))
self.attacker.population = 5
self.assertTrue(self.defender.is_attackable(self.attacker))
def test_symbiosis(self):
self.defender.traits = [TraitCard("symbiosis")]
self.defender.body = 3
self.right_neighbor.body = 5
self.assertFalse(self.defender.is_attackable(self.attacker, right_neighbor=self.right_neighbor))
self.right_neighbor.body = 2
self.assertTrue(self.defender.is_attackable(self.attacker, right_neighbor=self.right_neighbor))
def test_warning_call(self):
self.left_neighbor.traits = [TraitCard("warning-call")]
self.right_neighbor.traits = [TraitCard("warning-call")]
self.assertFalse(self.defender.is_attackable(self.attacker, left_neighbor=self.left_neighbor))
self.assertFalse(self.defender.is_attackable(self.attacker, right_neighbor=self.right_neighbor))
self.attacker.traits.append(TraitCard("ambush"))
self.assertTrue(self.defender.is_attackable(self.attacker, left_neighbor=self.left_neighbor))
def test_is_larger(self):
# Population different
self.defender.population = 2
self.attacker.population = 1
self.assertEqual(Species.is_larger(self.defender, self.attacker), 1)
self.assertEqual(Species.is_larger(self.attacker, self.defender), -1)
# Same population different food
self.attacker.population = 2
self.defender.food = 2
self.attacker.food = 1
self.assertEqual(Species.is_larger(self.defender, self.attacker), 1)
self.assertEqual(Species.is_larger(self.attacker, self.defender), -1)
# Same population and food different body
self.attacker.food = 2
self.defender.body = 4
self.attacker.body = 3
self.assertEqual(Species.is_larger(self.defender, self.attacker), 1)
self.assertEqual(Species.is_larger(self.attacker, self.defender), -1)
# Equal population, food, and body
#.........这里部分代码省略.........
示例3: TestSpecies
# 需要导入模块: from species import Species [as 别名]
# 或者: from species.Species import trait_names [as 别名]
class TestSpecies(unittest.TestCase):
def setUp(self):
self.attacker = Species()
self.attacker.traits = [TraitCard("carnivore")]
self.defender = Species()
self.left_neighbor = Species()
self.right_neighbor = Species()
self.species_1 = Species(4, 4, 4)
self.species_2 = Species(4, 4, 4)
self.species_3 = Species(4, 4, 3)
self.species_4 = Species(4, 3, 3)
self.species_5 = Species(3, 3, 3)
self.species_list = [self.species_2, self.species_4, self.species_3, self.species_5, self.species_1]
def test_can_eat(self):
self.assertFalse(self.species_1.can_eat())
self.assertTrue(self.species_4.can_eat())
fat_tissue = Species(4, 3, 4, [TraitCard("fat-tissue")], 3)
self.assertTrue(fat_tissue.can_eat())
fat_tissue.fat_storage = 4
self.assertTrue(fat_tissue.can_eat())
fat_tissue.food = 4
self.assertFalse(fat_tissue.can_eat())
def test_trait_names(self):
self.assertEqual(self.defender.trait_names(), [])
self.assertEqual(self.attacker.trait_names(), ["carnivore"])
def test_attackable(self):
self.assertTrue(self.defender.is_attackable(self.attacker))
def test_no_carnivore(self):
self.attacker.traits = []
self.assertFalse(self.defender.is_attackable(self.attacker))
def test_burrowing(self):
self.defender.traits = [TraitCard("burrowing")]
self.defender.population, self.defender.food = (4, 4)
self.assertFalse(self.defender.is_attackable(self.attacker))
self.defender.food = 3
self.assertTrue(self.defender.is_attackable(self.attacker))
def test_climbing(self):
self.defender.traits = [TraitCard("climbing")]
self.assertFalse(self.defender.is_attackable(self.attacker))
self.attacker.traits.append(TraitCard("climbing"))
self.assertTrue(self.defender.is_attackable(self.attacker))
def test_hard_shell(self):
self.defender.traits = [TraitCard("hard-shell")]
self.defender.body = 3
self.attacker.body = 6
self.assertFalse(self.defender.is_attackable(self.attacker))
self.attacker.body = 7
self.assertTrue(self.defender.is_attackable(self.attacker))
def test_herding(self):
self.defender.traits = [TraitCard("herding")]
self.defender.population = 4
self.attacker.population = 3
self.assertFalse(self.defender.is_attackable(self.attacker))
self.attacker.population = 5
self.assertTrue(self.defender.is_attackable(self.attacker))
def test_symbiosis(self):
self.defender.traits = [TraitCard("symbiosis")]
self.defender.body = 3
self.right_neighbor.body = 5
self.assertFalse(self.defender.is_attackable(self.attacker, right_neighbor=self.right_neighbor))
self.right_neighbor.body = 2
self.assertTrue(self.defender.is_attackable(self.attacker, right_neighbor=self.right_neighbor))
def test_warning_call(self):
self.left_neighbor.traits = [TraitCard("warning-call")]
self.right_neighbor.traits = [TraitCard("warning-call")]
self.assertFalse(self.defender.is_attackable(self.attacker, left_neighbor=self.left_neighbor))
self.assertFalse(self.defender.is_attackable(self.attacker, right_neighbor=self.right_neighbor))
self.attacker.traits.append(TraitCard("ambush"))
self.assertTrue(self.defender.is_attackable(self.attacker, left_neighbor=self.left_neighbor))