def test_start_frames(self): game = Game() game.add_player(0, 'p0') game.add_player(1, 'p1') game.start() self.encode_decode_compare_game(game)
def test_add_player_after_start(self): """Attempting to add a player after the game has started throws a GTRError. """ g = Game() g.add_player(uuid4(), 'p1') g.add_player(uuid4(), 'p2') g.start() with self.assertRaises(GTRError): g.add_player(uuid4(), 'p3')
def test_start_again(self): """Starting an already-started game raises a GTRError. """ g = Game() g.add_player(uuid4(), 'p1') g.add_player(uuid4(), 'p2') g.start() with self.assertRaises(GTRError): g.start()
def test_frame(self): game = Game() game.add_player(0, 'p0') game.add_player(1, 'p1') game.start() frame = game._current_frame frame_dict = encode.encode(frame) frame_recovered = encode.decode_frame(frame_dict) frame_dict2 = encode.encode(frame_recovered) self.assertEqual(str(frame_dict), str(frame_dict2)) for frame in game.stack.stack: frame_dict = encode.encode(frame) frame_recovered = encode.decode_frame(frame_dict) frame_dict2 = encode.encode(frame_recovered) self.assertEqual(str(frame_dict), str(frame_dict2))
def test_start(self): """Starting a game puts orders and jacks in the hands of the players, populates the pool, and sets the turn number to 1 """ g = Game() g.add_player(uuid4(), 'p1') g.add_player(uuid4(), 'p2') g.start() self.assertEqual(len(g.jacks), 4) # We don't know how many cards because of tiebreakers in determining # who goes first but each player at least needs 4 cards + 1 in the pool self.assertTrue(len(g.library) <= 134) self.assertTrue(len(g.library) > 0) for p in g.players: self.assertIn('Jack', p.hand) self.assertTrue(g.started) self.assertEqual(g.expected_action, message.THINKERORLEAD)