コード例 #1
0
ファイル: spell.py プロジェクト: joshuamundinger/piously
    def cast(self, board):
        self._validate_artwork_status(board)
        board.check_game_over = False

        moving_room = board.screen.choice(1) or choose_from_list(
            board.screen,
            location.linked_rooms(board, self.artwork.hex),
            prompt_text="Choose a linked room to move:"
        )
        if moving_room == None:
            return self._exit_cast(done=False)

        board.screen.info.text = \
            "Use < arrow keys > to move {} room,".format(moving_room) \
            + "  < , . > to rotate, < [ ] > to zoom, and < enter > to end.\n" \
            + "Rooms cannot overlap and each room must touch at least" \
            + " two other rooms. The Shovel must touch at least one room."
        finished_with_stonemason = False

        while not(finished_with_stonemason):
            key = get_keypress(board.screen)
            if key == None:
                return self._exit_cast(done=False)
            elif key == "return" or key == "Enter":
                # check to see if no hexes overlap
                finished_with_stonemason = True
                # check moving_room for collisions
                if board.check_for_collisions(moving_room):
                    finished_with_stonemason = False
                    board.screen.info.error = "Overlaps are death."
                connected, msg = board.connectivity_test()
                if not connected:
                    board.screen.info.error = "Board fails connectivity rules: " + msg
                    finished_with_stonemason = False
            else:
                moving_room.keyboard_movement(key)
            board.flush_hex_data()
            board.flush_gamepieces()

            # For js need to get rid of the old keypress, pygame will give AttributeError
            try:
                if 'current_keypress' in board.screen.data:
                    board.screen.data.pop('current_keypress')
            except AttributeError:
                pass

        board.screen.info.error = ""
        board.check_game_over = True
        return self._exit_cast(done=True)
コード例 #2
0
ファイル: board.py プロジェクト: joshuamundinger/piously
 def is_game_over(self):
     if not self.check_game_over:
         return False
     # for each aura'd hex in a room, check if the linked region has all seven rooms.
     winners = []
     for hex in self.rooms[0].hexes:
         if hex.aura:
             linked = linked_rooms(self, hex, include_shovel=False)
             if len(linked) == 7:
                 winners.append(hex.aura)
     win_set = set(winners)
     if not win_set:
         return None
     elif len(win_set) == 1:
         return winners[0]
     else:
         return "Tie"
コード例 #3
0
ファイル: spell.py プロジェクト: joshuamundinger/piously
    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)
コード例 #4
0
ファイル: spell.py プロジェクト: joshuamundinger/piously
    def cast(self, board):
        validated = board.screen.choice(1)
        if not validated:
            self._validate_spell_status_and_tap(board)
            board.screen.choices.append(True)

        # get a linked room.
        target_room = board.screen.choice(2) or choose_from_list(
            board.screen,
            location.linked_rooms(board, self.artwork.hex),
            prompt_text = 'Choose room to copy to:',
        )
        if target_room == None:
            return self._exit_cast(done=False)
        # get list of auras in artwork's room
        aura_list = [hex.aura for hex in self.artwork.hex.room.hexes if hex.aura]

        # deal with shovel seperately since this could mean trying to put >1 aura on 1 hex
        if target_room.name == 'Shovel':
            if len(aura_list) == 0:
                pass
            elif 'Dark' in aura_list and 'Light' in aura_list:
                aura = choose_from_list(
                    board.screen,
                    ['Dark', 'Light'],
                    prompt_text = 'Choose aura for Shovel:',
                )
                if aura == None:
                    return self._exit_cast(done=False)
                target_room.hexes[0].aura = aura
            else:
                # all the auras are the same (there may only be one)
                target_room.hexes[0].aura = aura_list[0]
            return self._exit_cast(done=True)

        if place_auras_on_hexes(board, self, aura_list, target_room.hexes, 3):
            return self._exit_cast(done=True)
        return self._exit_cast(done=False)
コード例 #5
0
ファイル: spell.py プロジェクト: joshuamundinger/piously
    def cast(self, board):
        self._validate_spell_status_and_tap(board)

        rooms_names = [room.color_name() for room in location.linked_rooms(board, self.artwork.hex)]

        eligible_spells = []
        for spell in board.spells:
            if spell.faction == board.faction and spell.tapped and \
                    spell != self and spell.name[0] in rooms_names:
                eligible_spells.append(spell)

        spell = choose_from_list(
            board.screen,
            eligible_spells,
            prompt_text = 'Choose spell to reuse:',
            error_text = 'There are no linked used spells',
            all_spells = board.spells,
        )
        if not spell:
            return self._exit_cast(done=False)

        spell.untap()

        return self._exit_cast(done=True)