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


Python Species.setTraits方法代码示例

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


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

示例1: TestUtils

# 需要导入模块: from species import Species [as 别名]
# 或者: from species.Species import setTraits [as 别名]
class TestUtils(unittest.TestCase):
  def setUp(self):
    self.species1 = Species(0, 1, 3, [])
    self.carni2 = Species(0, 2, 3, [Trait.carnivore])
    self.herbavore = Species(0, 1, 1, [])
    self.herbavore2 = Species(0, 1, 1, [])

    self.herbavore3 = Species(1, 1, 1, [])
    self.herbavore4 = Species(2, 1, 2, [])

    self.fat_tissue = Species(0, 1, 1, [])
    self.fat_tissue.setTraits([Trait.fat_tissue])
    self.fat_tissue2 = Species(0, 3, 1, [])
    self.fat_tissue2.setTraits([Trait.fat_tissue])

    self.opherb = Species(0, 1, 1, [])
    self.opfatherb = Species(0, 7, 1, [])

    self.fertileCard = TraitCard(Trait.fertile, 2)
    self.climbingCard = TraitCard(Trait.climbing, 0)
    self.cooperationCard = TraitCard(Trait.cooperation, 0)
    self.carnivoreCard = TraitCard(Trait.carnivore, 0)
    self.longNeckCard = TraitCard(Trait.long_neck, 0)
    self.ambushCard = TraitCard(Trait.ambush, 0)
    self.burrowingCard = TraitCard(Trait.burrowing, 0)
    self.cooperation2Card = TraitCard(Trait.cooperation, -1)

    self.player1 = Player(1, [], 0)
    self.player2 = Player(2, [], 0)
    self.player3 = Player(3, [], 0)

    self.validAction1 = [2, [[2, 6]], [[2, 3]], [[5, 4]], [[2, 0, 0]]]
    self.validAction2 = [2, [[2, 0]], [[2, 1]], [[4, 3]], []]
    self.validAction3 = [2, [[2, 1]], [], [[3, 0]], []]
    self.validAction4 = [2, [], [], [[0, 1]], []]
    self.validAction5 = [0, [], [], [], []]

    self.invalidAction1 = ["hi", 1, [], "so", False]
    self.invalidAction2 = ["hi", 1, []]
    self.invalidAction3 = [False, [["2", 6]], [[2, 3]], [[5, 4]], [[2, 0, 0]]]

    self.validFeeding1 = False
    self.validFeeding2 = 1
    self.validFeeding3 = [1, 9]
    self.validFeeding4 = [0, 0, 1]

    self.invalidFeeding1 = True
    self.invalidFeeding2 = [1, 2, 3, 3, ""]
    self.invalidFeeding3 = ["p", "i", "e"]


  def tearDown(self):
    del self.species1
    del self.carni2
    del self.herbavore
    del self.herbavore2

    del self.herbavore3
    del self.herbavore4

    del self.fat_tissue

    del self.fat_tissue2


    del self.opherb
    del self.opfatherb

    del self.fertileCard
    del self.climbingCard
    del self.cooperationCard
    del self.carnivoreCard
    del self.longNeckCard
    del self.ambushCard
    del self.burrowingCard
    del self.cooperation2Card

    del self.player1
    del self.player2
    del self.player3

    del self.validAction1
    del self.validAction2
    del self.validAction3
    del self.validAction4
    del self.validAction5

  def testValidateAction1(self):
    # test 1
    self.player1.setHand([self.fertileCard, self.longNeckCard, self.ambushCard])
    self.player1.setSpeciesBoards([self.species1, self.carni2])
    self.assertTrue(validateAction4(self.validAction4, self.player1))

  def testValidateAction2(self):
    # test 2
    self.player2.setHand([self.fertileCard, self.longNeckCard, self.ambushCard, self.cooperationCard])
    self.player2.setSpeciesBoards([self.species1, self.carni2])
    self.assertTrue(validateAction4(self.validAction3, self.player2))

  def testValidateAction3(self):
#.........这里部分代码省略.........
开发者ID:mahaalkhairy,项目名称:Evolution,代码行数:103,代码来源:test_validation.py


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