本文整理汇总了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())
示例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")