コード例 #1
0
 def test_play(self):
     game = Game(choice=lambda players: players[-1])
     player1 = game.join('player1')
     player2 = game.join('player2')
     game.start_game()
     self.assertEqual(game.current_player, player1)
     game.casino_bills = {
         1: [90, 80],
         2: [50],
         3: [100, 80, 70],
         4: [],
         5: [],
         6: []
     }
     player1.dice = 2
     player1.white_dice = 1
     player1.rolled_dice = {1: [2, 1]}
     player2.dice = 0
     player2.white_dice = 0
     # list forces evaluation
     list(game.play(1, sleep=lambda x: None))
     # the round should be over now because all the dice have been played
     # player1 started so it should now be player2's turn
     self.assertEqual(game.round, 2)
     self.assertEqual(game.current_player, player2)
     self.assertEqual(player1.bills, [90])
     self.assertEqual(player1.last_played_dice, {1: [2, 1]})
コード例 #2
0
ファイル: test.py プロジェクト: dbravender/casinodicegame
 def test_play(self):
     game = Game(choice=lambda players: players[-1])
     player1 = game.join('player1')
     player2 = game.join('player2')
     game.start_game()
     self.assertEqual(game.current_player, player1)
     game.casino_bills = {
         1: [90, 80],
         2: [50],
         3: [100, 80, 70],
         4: [],
         5: [],
         6: []
     }
     player1.dice = 2
     player1.white_dice = 1
     player1.rolled_dice = {1: [2, 1]}
     player2.dice = 0
     player2.white_dice = 0
     # list forces evaluation
     list(game.play(1, sleep=lambda x: None))
     # the round should be over now because all the dice have been played
     # player1 started so it should now be player2's turn
     self.assertEqual(game.round, 2)
     self.assertEqual(game.current_player, player2)
     self.assertEqual(player1.bills, [90])
     self.assertEqual(player1.last_played_dice, {1: [2, 1]})
コード例 #3
0
ファイル: test.py プロジェクト: dbravender/casinodicegame
 def test_winners_by_casino_and_score_round(self):
     game = Game()
     player1 = game.join('player1')
     player2 = game.join('player2')
     game.start_game()
     game.casino_dice = {
         1: {player1.color: 2},
         2: {player1.color: 2, 'white': 2, player2.color: 1},
         3: {player1.color: 3, 'white': 2, player2.color: 1},
         4: {},
         5: {},
         6: {}
     }
     self.assertEqual(
         game.winners_by_casino(),
         {
             1: [player1.color],
             2: [player2.color],
             3: [player1.color, 'white', player2.color],
             4: [],
             5: [],
             6: []
         })
     game.casino_bills = {
         1: [90, 90],
         2: [90],
         3: [100, 80, 70],
         4: [],
         5: [],
         6: []
     }
     game.score_round()
     self.assertEqual(player1.bills, [90, 100])
     self.assertEqual(player2.bills, [90, 70])
コード例 #4
0
 def test_winners_by_casino_and_score_round(self):
     game = Game()
     player1 = game.join('player1')
     player2 = game.join('player2')
     game.start_game()
     game.casino_dice = {
         1: {
             player1.color: 2
         },
         2: {
             player1.color: 2,
             'white': 2,
             player2.color: 1
         },
         3: {
             player1.color: 3,
             'white': 2,
             player2.color: 1
         },
         4: {},
         5: {},
         6: {}
     }
     self.assertEqual(
         game.winners_by_casino(), {
             1: [player1.color],
             2: [player2.color],
             3: [player1.color, 'white', player2.color],
             4: [],
             5: [],
             6: []
         })
     game.casino_bills = {
         1: [90, 90],
         2: [90],
         3: [100, 80, 70],
         4: [],
         5: [],
         6: []
     }
     game.score_round()
     self.assertEqual(player1.bills, [90, 100])
     self.assertEqual(player2.bills, [90, 70])