from naja.constants import BITS, MOVES
from naja.player import PlayerBits, Player
from naja.constants import BITS, MOVES
from naja.player import PlayerBits, Player
+
+ def setUp(self):
+ self.board = GameBoard.new_game({'cards': [
+ {'card_name': 'card1', 'actions': [
+ {
+ 'action_class': 'LoseHealthOrMSB',
+ 'required_bits': [],
+ }, {
+ 'action_class': 'GainHealth',
+ 'required_bits': [BITS.RED],
+ },
+ ]}
+ ]})
+
self.assertEqual(player.bits.bits, 0x0f)
self.assertEqual(player.position, (0, 1))
self.assertEqual(player.bits.bits, 0x0f)
self.assertEqual(player.position, (0, 1))
self.assertEqual(
player.legal_moves(), [(2, 2), (2, 1), (2, 3), (3, 2), (1, 2)])
def test_legal_moves_some_unavailable(self):
self.assertEqual(
player.legal_moves(), [(2, 2), (2, 1), (2, 3), (3, 2), (1, 2)])
def test_legal_moves_some_unavailable(self):
player.bits.clear_bit(BITS.NORTH)
self.assertEqual(player.legal_moves(), [(0, 2), (0, 3), (1, 2)])
def test_legal_moves_castle(self):
player.bits.clear_bit(BITS.NORTH)
self.assertEqual(player.legal_moves(), [(0, 2), (0, 3), (1, 2)])
def test_legal_moves_castle(self):
- player = Player(0x0f, (1, 3), MOVES.CASTLE)
+ player = Player(0x0f, (1, 3), MOVES.CASTLE, gameboard=self.board)
self.assertEqual(player.legal_moves(), [
(0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, 3), (3, 3),
(4, 3)])
def test_legal_moves_bishop(self):
self.assertEqual(player.legal_moves(), [
(0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, 3), (3, 3),
(4, 3)])
def test_legal_moves_bishop(self):
- player = Player(0x0f, (1, 3), MOVES.BISHOP)
+ player = Player(0x0f, (1, 3), MOVES.BISHOP, gameboard=self.board)
self.assertEqual(player.legal_moves(), [
(0, 2), (0, 4), (1, 3), (2, 2), (2, 4), (3, 1), (4, 0)])
def test_legal_moves_knight(self):
self.assertEqual(player.legal_moves(), [
(0, 2), (0, 4), (1, 3), (2, 2), (2, 4), (3, 1), (4, 0)])
def test_legal_moves_knight(self):
- player = Player(0x0f, (1, 3), MOVES.KNIGHT)
+ player = Player(0x0f, (1, 3), MOVES.KNIGHT, gameboard=self.board)
self.assertEqual(player.legal_moves(), [
(0, 1), (1, 3), (2, 1), (3, 2), (3, 4)])
def test_set_position(self):
self.assertEqual(player.legal_moves(), [
(0, 1), (1, 3), (2, 1), (3, 2), (3, 4)])
def test_set_position(self):
- player = Player(0x0f, (3, 3), MOVES.BISHOP)
+ player = Player(0x0f, (3, 3), MOVES.BISHOP, gameboard=self.board)
player.set_position((4, 4))
self.assertEqual(player.movement_mode, MOVES.ADJACENT)
player.set_position((4, 4))
self.assertEqual(player.movement_mode, MOVES.ADJACENT)