from unittest import TestCase
from naja.constants import BITS
-from naja.gameboard import GameBoard
+from naja.gameboard import GameBoard, LocationCard
from naja.player import Player
from naja import actions
def test_DoNothing(self):
board = GameBoard.new_game([])
state_before = board.export()
- actions.DoNothing(set()).perform_action(board)
+ actions.DoNothing(set()).perform_action(board, None)
state_after = board.export()
self.assertEqual(state_before, state_after)
def test_LoseHealthOrMSB_MSB_clear(self):
board = GameBoard.new_game([])
state_before = board.export()
- actions.LoseHeathOrMSB(set()).perform_action(board)
+ actions.LoseHeathOrMSB(set()).perform_action(board, None)
state_after = board.export()
self.assertEqual(state_after['health'], state_before['health'] - 1)
state_before.pop('health')
state_after.pop('health')
self.assertEqual(state_before, state_after)
+
+ def test_LoseHealthOrMSB_MSB_set(self):
+ board = GameBoard.new_game([])
+ board.player.bits.set_bit(BITS.MSB)
+ state_before = board.export()
+ actions.LoseHeathOrMSB(set()).perform_action(board, None)
+ state_after = board.export()
+ self.assertEqual(board.player.bits.check_bit(BITS.MSB), False)
+
+ state_before['player'].pop('bits')
+ state_after['player'].pop('bits')
+ self.assertEqual(state_before, state_after)
+
+ def test_SetBits(self):
+ board = GameBoard.new_game([])
+ state_before = board.export()
+ location = LocationCard(set([BITS.MSB, BITS.NORTH]), [])
+ actions.SetBits(set()).perform_action(board, location)
+ state_after = board.export()
+ self.assertEqual(
+ board.player.bits.check_bits([BITS.MSB, BITS.NORTH]), True)
+
+ state_before['player'].pop('bits')
+ state_after['player'].pop('bits')
+ self.assertEqual(state_before, state_after)
+
+ def test_ToggleBits(self):
+ board = GameBoard.new_game([])
+ board.player.bits.set_bit(BITS.NORTH)
+ state_before = board.export()
+ location = LocationCard(set([BITS.MSB, BITS.NORTH]), [])
+ actions.ToggleBits(set()).perform_action(board, location)
+ state_after = board.export()
+ self.assertEqual(board.player.bits.check_bit(BITS.MSB), True)
+ self.assertEqual(board.player.bits.check_bit(BITS.NORTH), False)
+
+ state_before['player'].pop('bits')
+ state_after['player'].pop('bits')
+ self.assertEqual(state_before, state_after)