Start of location actions.
[naja.git] / naja / tests / test_gameboard.py
1 from unittest import TestCase
2
3 from naja.constants import BITS
4 from naja.gameboard import GameBoard, LocationCard
5
6
7 class TestGameBoard(TestCase):
8     def test_lose_health(self):
9         board = GameBoard(None, 4, 4, locations={}, state=None)
10         self.assertEqual(board.health, 4)
11         board.lose_health()
12         self.assertEqual(board.health, 3)
13
14
15 class TestLocationCard(TestCase):
16     def test_generate_bitwise_operand(self):
17         # This is testing a random process, so it may fail occasionally.
18         operand_sets = []
19         for _ in range(100):
20             operand_sets.append(LocationCard.generate_bitwise_operand())
21         sizes = {2: 0, 3: 0}
22         bits = set()
23         for operand_set in operand_sets:
24             sizes[len(operand_set)] += 1
25             bits.update(operand_set)
26             # TODO: Test that there's at least one condition and one direction.
27         self.assertTrue(sizes[2] > 0)
28         self.assertTrue(sizes[3] > 0)
29         self.assertTrue(sizes[2] > sizes[3])
30         self.assertEqual(bits, set(BITS.values()))