Exemplo n.º 1
0
 def cast(self, board):
     self._validate_spell_status_and_tap(board)
     # pick two linked hexes to flip
     for i in range(2):
         prev_choice = board.screen.choice(1 + i)
         if prev_choice == None:
             hex_to_flip = choose_hexes(
                 board.screen,
                 location.linked_hexes(board, self.artwork.hex),
                 prompt_text = 'Click a {} aura to flip'.format(self.faction),
             )
             if hex_to_flip == None:
                 return self._exit_cast(done=False)
             hex_to_flip.aura = other_faction(hex_to_flip.aura)
             board.flush_aura_data()
             # check to see if we flipped under the artwork/
             # if so, stop Usurping
             if self.artwork.hex.aura != board.faction:
                 return self._exit_cast(done=True)
     for i in range(2):
         prev_choice = board.screen.choice(3 + i)
         if prev_choice == None:
             hex_to_change = board.screen.choice(3 + i) or choose_hexes(
                 board.screen,
                 location.adjacent_linked_region(board, self.artwork.hex),
                 prompt_text = 'Click a hex on which to grow',
             )
             if hex_to_change == None:
                 return self._exit_cast(done=False)
             hex_to_change.aura = board.faction
             board.flush_aura_data()
     return self._exit_cast(done=True)
Exemplo n.º 2
0
    def cast(self, board):
        self._validate_spell_status_and_tap(board)
        # get list of linked objects
        linked_hexes = location.linked_hexes(board, self.artwork.hex)
        linked_objects = [hex.occupant for hex in linked_hexes if hex.occupant]

        # get list of hexes to move to from the board
        target_hexes = [hex for hex in board.get_all_hexes() if not(hex.occupant)]
        if target_hexes == []:
            # this cannot happen since there are only 9 possible occupants :)
            raise InvalidMove('All hexes are occupied.')

        # choose a linked object to move. There should always be at least one,
        # since we've validated that the Locksmith is on an aura
        target_object = board.screen.choice(1) or choose_from_list(
            board.screen,
            linked_objects,
            prompt_text='Choose object to move:',
        )
        if target_object == None:
            return self._exit_cast(done=False)

        target_hex = choose_hexes(
            board.screen,
            target_hexes,
            prompt_text='Click where to move {}'.format(target_object)
        )
        if target_hex == None:
            return self._exit_cast(done=False)

        board.move_object(target_object, from_hex = target_object.hex, to_hex = target_hex)
        return self._exit_cast(done=True)
Exemplo n.º 3
0
    def cast(self, board, str=[]):
        self._validate_artwork_status(board)

        linked_rooms = location.linked_rooms(board, self.artwork.hex)
        while True:
            # check if user is done casting
            board.screen.info.text = "Press enter to stop casting or any other key to contine" # TODO: remove
            board.flush_gamepieces()
            key = get_keypress(board.screen, enable_buttons = False)
            if key == "return" or key == "Enter":
                board.screen.action_buttons_on = True
                return self._exit_cast(done=True)

            object_locations = [hex for room in linked_rooms for hex in room.hexes if hex.occupant]
            from_hex = board.screen.choice(1) or choose_hexes(
                board.screen,
                object_locations,
                prompt_text = "Click an object to move or press enter to end",
            )
            if from_hex == None:
                return self._exit_cast(done=False)

            obj = from_hex.occupant
            to_hex = choose_hexes(
                board.screen,
                from_hex.room.hexes,
                prompt_text = "Click where to move {}".format(obj),
            )
            if to_hex == None:
                return self._exit_cast(done=False)

            if to_hex.occupant:
                board.swap_object(obj, to_hex.occupant)
            else:
                board.move_object(obj, from_hex, to_hex)

            # clear out stored choices beyond the first one if there are any
            if board.screen.choice(1):
                board.screen.choices = board.screen.choices[:1]

            # if yeoman is no longer on hex stop casting
            if self.artwork.hex.aura != board.faction:
                board.screen.info.error = 'Yeomen no longer on {} aura. Ending cast.'.format(board.faction)
                board.screen.action_buttons_on = True
                return self._exit_cast(done=True)
Exemplo n.º 4
0
    def cast(self, board):
        self._validate_spell_status_and_tap(board)

        # temp room represents all the places that the shovel can be placed
        temp_is_placed = any([room.name == "Temp" for room in board.rooms])
        shovel_room = next((room for room in board.rooms if room.name == "Shovel"), None)
        if not temp_is_placed:
            player_on_shovel = board.get_current_player().hex.room == shovel_room

            if player_on_shovel:
                # shovel can move anywhere - get neighbors of the whole board
                temp_locations = location.find_unoccupied_neighbors(board, board.get_all_hexes())
            else:
                # shovel can move to adjacent spots that are empty - get player's neighbors
                player_hex = board.get_current_player().hex
                temp_locations = location.find_unoccupied_neighbors(board,[player_hex])
                if temp_locations == []:
                    raise InvalidMove("There's nowhere to place the Shovel")

            # make a temporary room with these locations
            board.rooms.append(Room(
                name = "Temp",
                root = None,
                shape = temp_locations,
                a_spell = None,
                b_spell = None,
                relative_shape = False,
            ))

        # get the (possibly first-ever) location for the Shovel
        board.flush_hex_data()
        shovel_hex = choose_hexes(
            board.screen,
            board.rooms[-1].hexes,
            prompt_text = "Choose where the Shovel will go"
        )
        if shovel_hex == None:
            return self._exit_cast(done=False)
        shovel_location = shovel_hex.location

        # get rid of the temporary room
        board.rooms.pop()
        if shovel_room:
            shovel_room.hexes[0].location = shovel_location
        else:
            board.rooms.append(self.create_Shovel_room(shovel_location))

        board.flush_hex_data()
        return self._exit_cast(done=True)
Exemplo n.º 5
0
    def cast(self, board):
        self._validate_spell_status_and_tap(board)

        # choose the hex to bless
        adjacent_linked_hexes = location.adjacent_linked_region(board, board.artworks[0].hex)
        target_hex = choose_hexes(
            board.screen,
            adjacent_linked_hexes,
            prompt_text = 'Click hex to grow linked region',
            error_text = 'There are no hexes which the Priestess may bless',
        )
        if not target_hex:
            return self._exit_cast(done=False)

        target_hex.aura = board.faction
        return self._exit_cast(done=True)
Exemplo n.º 6
0
    def cast(self, board):
        self._validate_spell_status_and_tap(board)
        current_player = board.get_current_player()

        # get target object for yoking
        target_object = board.screen.choice(1) or choose_from_list(
            board.screen,
            board.get_placed_non_player_objects(),
            'Pick an object to Yoke with:',
            'There is no other object to Yoke',
        )
        if target_object == None:
            return self._exit_cast(done=False)

        # get directions for yolking
        # elements are: (player_destination, target_destination)
        possible_location_data = []
        for u in location.unit_directions:
            player_destination = location.find_neighbor_hex(board, current_player.hex, u)
            target_destination = location.find_neighbor_hex(board, target_object.hex, u)
            player_can_move = player_destination and (
                not(player_destination.occupant) or player_destination.occupant == target_object
            )
            target_can_move = target_destination and (
                not(target_destination.occupant) or target_destination.occupant == current_player
            )
            if (player_can_move and target_can_move):
                possible_location_data.append((player_destination, target_destination))
        # if there's more than one direction, ask user for input
        player_direction = choose_hexes(
            board.screen,
            [x[0] for x in possible_location_data],
            prompt_text = "Choose the destination of the player:",
            error_text = 'These two objects have no common direction to move',
        )
        if player_direction == None:
            return self._exit_cast(done=False)

        # get the directions of both player and target by finding the entry
        # whose first entry is the player
        movement_data = [x for x in possible_location_data if x[0] == player_direction][0]

        # move the player and object
        board.move_object(current_player, current_player.hex, movement_data[0])
        board.move_object(target_object, target_object.hex, movement_data[1])
        return self._exit_cast(done=True)
Exemplo n.º 7
0
    def cast(self, board):
        self._validate_spell_status_and_tap(board)
        adj_hexes = location.find_adjacent_hexes(board, board.get_current_player().hex)
        # get list of occupied neighbors which are the wrong aura
        purifiable_hexes = [h for h in adj_hexes if (h.occupant and h.aura != board.faction)]
        # choose from neighbors which are occupied
        hex = choose_hexes(
            board.screen,
            purifiable_hexes,
            prompt_text = 'Click hex to bless',
            error_text = 'No hexes to Purify',
        )
        if not hex:
            return self._exit_cast(done=False)

        hex.aura = board.faction
        return self._exit_cast(done=True)
Exemplo n.º 8
0
def place_auras_on_hexes(board, spell, aura_list, hex_list, choice_idx):
    # If all auras match just fill all the hexes
    if len(aura_list) == len(hex_list) and len(set(aura_list)) == 1:
        for hex in hex_list:
            hex.aura = aura_list[0]
        return spell._exit_cast(done=True)

    auras_to_place = board.screen.choice(choice_idx)
    if not auras_to_place:
         auras_to_place = [aura for aura in aura_list if aura] # remove Nones
         auras_to_place.sort() # place all Dark auras then all Light auras
         board.screen.choices.append(auras_to_place)

         # clear out existing auras on the hexes
         for hex in hex_list:
             hex.aura = None
         board.flush_aura_data()

    if len(auras_to_place) > len(hex_list):
        raise RuntimeError('Pidgeonhole Problem: tried to put too many auras on a set of hexes')

    all_auras = deepcopy(auras_to_place)
    for aura in all_auras:
        auras_to_place.remove(aura)
        new_hex = choose_hexes(
            board.screen,
            [hex for hex in hex_list if not hex.aura],
            prompt_text = "Click a hex for aura {}.\nAfter this you will place {}".format(
                aura,
                ', '.join(auras_to_place),
            ),
        )
        if new_hex == None:
            auras_to_place.insert(0, aura) # add aura back to beginning since it wasn't placed
            return spell._exit_cast(done=False)

        new_hex.aura = aura
        board.flush_aura_data()

    return spell._exit_cast(done=True)