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


Python Game.playerCount方法代码示例

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


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

示例1: Test

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import playerCount [as 别名]
class Test(unittest.TestCase):

    def setUp(self):
        self.game = Game()
        self.redPlayer = Player(PlayerColor.Red, Strategy())
        self.bluePlayer = Player(PlayerColor.Blue, Strategy())
        self.yellowPlayer = Player(PlayerColor.Yellow, Strategy())
        self.greenPlayer = Player(PlayerColor.Green, Strategy())
        for p in [self.redPlayer, self.bluePlayer, self.yellowPlayer, self.greenPlayer]:                
            self.game.addPlayer(p)
    
    def testAddingPlayer(self):
        self.game = Game()  
        self.assertEqual(self.game.playerCount(), 0, "no player at start")
          
        self.game.addPlayer(self.redPlayer)
        self.assertEqual(self.game.playerCount(), 1, "one player added")
  
        self.game.addPlayer(self.bluePlayer)
        self.assertEqual(self.game.playerCount(), 2, "two players added")
  
    def testGameFinished(self):
        self.assertFalse(self.game.finished(), "game should not be finished at start")
          
    def testPlayerOrderAtStart(self):
        self.assertEqual(self.game.playerCount(), 4, "all four players added")
        self.assertListEqual([self.redPlayer, self.bluePlayer, self.yellowPlayer, self.greenPlayer], 
                             self.game.getPlayers())
 
    def testPlayerOrderScore(self):
        self.redPlayer.addScore(3)
        self.bluePlayer.addScore(2)
        self.yellowPlayer.addScore(4)
        self.greenPlayer.addScore(2)
        self.assertListEqual([self.yellowPlayer, self.redPlayer, self.bluePlayer, self.greenPlayer], 
                             self.game.getPlayers())
         
    def testPlayerOrderSecondCriteria(self):
        self.bluePlayer.addResources([3])
        self.assertEqual(self.game.playerCount(), 4, "all four players added")
        self.assertListEqual([self.bluePlayer, self.redPlayer, self.yellowPlayer, self.greenPlayer], 
                             self.game.getPlayers())
        
    def testMixedScores(self):
        self.redPlayer.addResources([3,3,3,3,4,5,5])
        self.redPlayer.buyHut(SimpleHut(4,5,5),[4,5,5])
        
        self.yellowPlayer.addResources([3,3,4,4,4,4,6,6,8,9])
        
        self.bluePlayer.addResources([3,3,4,4,4,4,6,6,9])
      
        self.greenPlayer.addResources([3,3,4,4,4,4,6,6,9])
        self.assertListEqual([self.redPlayer, self.yellowPlayer, self.bluePlayer, self.greenPlayer], 
                             self.game.getPlayers())
开发者ID:dennisdjensen,项目名称:python-proj,代码行数:56,代码来源:GameTest.py

示例2: Test

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import playerCount [as 别名]
class Test(unittest.TestCase):

    def setUp(self):
        self.game = Game()

    def testAddingPlayer(self):
        self.assertEqual(self.game.playerCount(), 0, "no player at start")
        
        self.game.addPlayer(Player("Red", Strategy()))
        self.assertEqual(self.game.playerCount(), 1, "one player added")

    def testGameFinished(self):
        self.assertFalse(self.game.finished(), "game should not be finished at start")
开发者ID:supas072,项目名称:python-proj,代码行数:15,代码来源:GameTest.py


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