def test_export_new_board(self):
board = GameBoard.new_game({'cards': [
{'card_name': 'card1', 'actions': [
- {
- 'action_class': 'LoseHealthOrMSB',
- 'required_bits': [],
- }, {
- 'action_class': 'GainHealth',
- 'required_bits': [BITS.RED],
- },
- ]}]})
+ {
+ 'action_class': 'LoseHealthOrMSB',
+ 'required_bits': [],
+ }, {
+ 'action_class': 'GainHealth',
+ 'required_bits': [BITS.RED],
+ },
+ ]}]})
exported_state = board.export()
board_locations = exported_state.pop('board_locations')
self.assertEqual(exported_state, {
+ 'clock_count': 0,
'max_health': 4,
'health': 4,
'wins_required': 4,
'player': board.player.export(),
'puzzle': False,
'player_mode': EXAMINE,
+ 'replacement_params': None,
})
positions = []
for position, location_state in board_locations:
positions.append(position)
- self.assertEqual(
- sorted(location_state.keys()), ['actions', 'bitwise_operand',
- 'card_name', 'max_number'])
+ self.assertEqual(sorted(location_state.keys()), [
+ 'actions', 'bitwise_operand', 'card_name', 'max_number',
+ 'replacement_time'])
self.assertEqual(location_state['actions'], [
{
'action_class': 'LoseHealthOrMSB',
self.assertEqual(bits, set(BITS.values()))
def test_new_location_no_actions(self):
- location = LocationCard.new_location({'card_name': 'card',
- 'actions': []})
+ location = LocationCard.new_location(
+ {'card_name': 'card', 'actions': []}, None)
[action] = location.actions
self.assertEqual(type(action), actions.DoNothing)
self.assertEqual(action.required_bits, set())
+ self.assertEqual(location.replacement_time, None)
- def test_new_location_one_action(self):
- location = LocationCard.new_location({'card_name': 'card1',
- 'actions': [{'required_bits': [], 'action_class': 'DoNothing'},
- ]})
+ def test_new_location_replacement_params(self):
+ location = LocationCard.new_location(
+ {'card_name': 'card', 'actions': []},
+ {'chance': 1, 'min': 2, 'max': 2})
[action] = location.actions
self.assertEqual(type(action), actions.DoNothing)
self.assertEqual(action.required_bits, set())
+ self.assertEqual(location.replacement_time, 2)
- def test_parse_bits(self):
- self.assertEqual(
- LocationCard.parse_bits([]), frozenset([]))
- self.assertEqual(
- LocationCard.parse_bits(['RED']), frozenset([BITS.RED]))
- self.assertEqual(
- LocationCard.parse_bits([BITS.BLUE]), frozenset([BITS.BLUE]))
- self.assertEqual(
- LocationCard.parse_bits([BITS.NORTH, 'MSB']),
- frozenset([BITS.NORTH, BITS.MSB]))
+ def test_new_location_one_action(self):
+ location = LocationCard.new_location({
+ 'card_name': 'card1',
+ 'actions': [
+ {'required_bits': [], 'action_class': 'DoNothing'},
+ ]}, None)
+ [action] = location.actions
+ self.assertEqual(type(action), actions.DoNothing)
+ self.assertEqual(action.required_bits, set())
+ self.assertEqual(location.replacement_time, None)