Esempio n. 1
0
	def test_start_game_action_is_not_legal_for_less_then_three_players(self):
		for i in range(0,3):
			game = Game()
			for n in range(0,i):
				game.create_player('Player %d' % n)
			with self.assertRaises(IllegalActionException):
				self.action.assert_legal(game)
Esempio n. 2
0
 def test_start_game_action_is_not_legal_for_less_then_three_players(self):
     for i in range(0, 3):
         game = Game()
         for n in range(0, i):
             game.create_player('Player %d' % n)
         with self.assertRaises(IllegalActionException):
             self.action.assert_legal(game)
Esempio n. 3
0
	def test_existing_player_is_enforced(self):
		game = Game()
		pa = PlayerAction('red')
		with self.assertRaises(IllegalActionException):
			pa.assert_legal(game)
		game.create_player('redPlayer', 'red')
		pa.assert_legal(game)
Esempio n. 4
0
 def test_existing_player_is_enforced(self):
     game = Game()
     pa = PlayerAction('red')
     with self.assertRaises(IllegalActionException):
         pa.assert_legal(game)
     game.create_player('redPlayer', 'red')
     pa.assert_legal(game)
Esempio n. 5
0
class TestPlayerAction(unittest.TestCase, TestPlayerActionMixin):
	def setUp(self):
		self.game = Game()
		self.game.create_player('bluePlayer', 'blue')
		self.action = PlayerAction('blue')

	def test_constructor_sets_player(self):
		pa = PlayerAction('red')
		self.assertEqual(pa.player, 'red')

	def test_existing_player_is_enforced(self):
		game = Game()
		pa = PlayerAction('red')
		with self.assertRaises(IllegalActionException):
			pa.assert_legal(game)
		game.create_player('redPlayer', 'red')
		pa.assert_legal(game)
Esempio n. 6
0
class TestPlayerAction(unittest.TestCase, TestPlayerActionMixin):
    def setUp(self):
        self.game = Game()
        self.game.create_player('bluePlayer', 'blue')
        self.action = PlayerAction('blue')

    def test_constructor_sets_player(self):
        pa = PlayerAction('red')
        self.assertEqual(pa.player, 'red')

    def test_existing_player_is_enforced(self):
        game = Game()
        pa = PlayerAction('red')
        with self.assertRaises(IllegalActionException):
            pa.assert_legal(game)
        game.create_player('redPlayer', 'red')
        pa.assert_legal(game)
Esempio n. 7
0
class TestStartGameAction(unittest.TestCase, TestPlayerActionMixin):
	def setUp(self):
		self.game = Game()
		self.game.create_player('playerOne', 'red')
		self.game.create_player('playerTwo')
		self.game.create_player('playerThree')
		self.action = StartGameAction('red')

	def test_start_game_action_initializes_board(self):
		self.action.apply_unchecked(self.game)
		self.assertIsNotNone(self.game.board)

	def test_start_game_action_starts_game(self):
		self.action.apply_unchecked(self.game)
		self.assertEqual('setup', self.game.phase)

	def test_start_game_action_assert_legal_on_init(self):
		self.action.assert_legal(self.game)
		self.action.apply_unchecked(self.game)
		with self.assertRaises(IllegalActionException):
			self.action.assert_legal(self.game)

	def test_start_game_sets_up_turn_order(self):
		self.assertIsNone(self.game.turn_order)
		self.action.apply_unchecked(self.game)
		self.assertIsNotNone(self.game.turn_order)

	def test_start_game_action_is_not_legal_for_less_then_three_players(self):
		for i in range(0,3):
			game = Game()
			for n in range(0,i):
				game.create_player('Player %d' % n)
			with self.assertRaises(IllegalActionException):
				self.action.assert_legal(game)
Esempio n. 8
0
class TestStartGameAction(unittest.TestCase, TestPlayerActionMixin):
    def setUp(self):
        self.game = Game()
        self.game.create_player('playerOne', 'red')
        self.game.create_player('playerTwo')
        self.game.create_player('playerThree')
        self.action = StartGameAction('red')

    def test_start_game_action_initializes_board(self):
        self.action.apply_unchecked(self.game)
        self.assertIsNotNone(self.game.board)

    def test_start_game_action_starts_game(self):
        self.action.apply_unchecked(self.game)
        self.assertEqual('setup', self.game.phase)

    def test_start_game_action_assert_legal_on_init(self):
        self.action.assert_legal(self.game)
        self.action.apply_unchecked(self.game)
        with self.assertRaises(IllegalActionException):
            self.action.assert_legal(self.game)

    def test_start_game_sets_up_turn_order(self):
        self.assertIsNone(self.game.turn_order)
        self.action.apply_unchecked(self.game)
        self.assertIsNotNone(self.game.turn_order)

    def test_start_game_action_is_not_legal_for_less_then_three_players(self):
        for i in range(0, 3):
            game = Game()
            for n in range(0, i):
                game.create_player('Player %d' % n)
            with self.assertRaises(IllegalActionException):
                self.action.assert_legal(game)
Esempio n. 9
0
	def setUp(self):
		self.game = Game()
		self.game.create_player('playerOne', 'red')
		self.game.create_player('playerTwo')
		self.game.create_player('playerThree')
		self.action = StartGameAction('red')
Esempio n. 10
0
	def setUp(self):
		self.game = Game()
		self.game.create_player('bluePlayer', 'blue')
		self.action = PlayerAction('blue')
Esempio n. 11
0
 def setUp(self):
     self.game = Game()
     self.game.create_player('playerOne', 'red')
     self.game.create_player('playerTwo')
     self.game.create_player('playerThree')
     self.action = StartGameAction('red')
Esempio n. 12
0
 def setUp(self):
     self.game = Game()
     self.game.create_player('bluePlayer', 'blue')
     self.action = PlayerAction('blue')