X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Fgameboard.py;h=d70a49890f99fc4a183aed48813ca6b7d53b8378;hb=0d7c75c57d85f809aad2db5c740341e2c3db011c;hp=2ed511afeb81eab12875286c3506899ecb49ec9b;hpb=873bfafe4856636d2ac3ca9dfed4d2992d03fdb5;p=naja.git diff --git a/naja/gameboard.py b/naja/gameboard.py index 2ed511a..d70a498 100644 --- a/naja/gameboard.py +++ b/naja/gameboard.py @@ -77,7 +77,9 @@ class GameBoard(object): player = Player(initial_bits, initial_pos) board_locations = cls.import_board_locations( cls.generate_board(deck)) - return cls(state, player, board_locations) + board = cls(state, player, board_locations) + player.set_gameboard(board) + return board @classmethod def import_game(cls, definition): @@ -138,7 +140,7 @@ class GameBoard(object): board_locations = [ [(i % 5, i // 5), LocationCard.new_location( - card.copy(), replacement_params).export()] + card.copy(), replacement_params, puzzle=True).export()] for i, card in enumerate(deck['cards']) ] return board_locations @@ -297,12 +299,11 @@ class LocationCard(object): """ def __init__(self, card_name, bitwise_operand, location_actions, - replacement_time, max_number=25): + replacement_time=None, max_number=25): self.card_name = card_name self.bitwise_operand = bitwise_operand self.actions = location_actions self.max_number = max_number - self.check_actions() self.replacement_time = replacement_time @classmethod @@ -321,7 +322,7 @@ class LocationCard(object): return action_class(required_bits, **data) @classmethod - def new_location(cls, definition, replacement_params): + def new_location(cls, definition, replacement_params=None, puzzle=False): if 'bits' in definition: bits = cls.parse_bits(definition['bits']) else: @@ -335,13 +336,16 @@ class LocationCard(object): max_number = definition.get('max_number', 25) card_name = definition['card_name'] - return cls.import_location({ + location = cls.import_location({ 'bitwise_operand': bits, 'actions': definition['actions'], 'max_number': max_number, 'card_name': card_name, 'replacement_time': replacement_time, }) + if not puzzle: + location.check_actions() + return location @classmethod def parse_bits(self, bit_list):