Beispiel #1
0
    def __init__(self, player,
                 white_list_category: tuple = (),
                 sort: int = SORT_NONE,
                 target: Optional['player_pokemon.PlayerPokemon'] = None,
                 condition: int = CONDITION_NORMAL,
                 use_callback: Optional[Callable[['item.Item', 'player_pokemon.PlayerPokemon'], NoReturn]] = None
                 ):
        super().__init__(player)
        self.use_callback = use_callback
        self.condition = condition
        self.target = target
        self.sort = sort
        self.cat_image = utils.color_image(utils.get_part_i(utils.MENU_IMAGE, (64, 0, 128, 64)), (0, 0, 0, 255))

        if len(white_list_category) > 0:
            black_list_category = item.CATEGORY.copy()
            for e in white_list_category:
                black_list_category.remove(e)
        else:
            black_list_category = ()
        self.black_list_category = black_list_category
        self.open_time = utils.current_milli_time()
        self.keys = {
            game.get_game_instance().get_message("back"): option.KEY_QUITE,
            game.get_game_instance().get_message("sort"): option.KEY_BIKE,
            game.get_game_instance().get_message("select"): option.KEY_ACTION
        }
        self.action_selected = -1
        self.nb_action = 0
        self.category_select = 0
        self.item_selected = 0
        self.poke_select = -1
        self.categories_surface = []
        for a in range(2):
            line = []
            for i in range(len(item.CATEGORY)):
                if item.CATEGORY[i] not in black_list_category:
                    line.append(utils.get_part_i(utils.MENU_IMAGE, (i * 32, 128 + a * 32, i * 32 + 32, 160 + a * 32)))
            self.categories_surface.append(line)
        self.categories = item.CATEGORY.copy()
        for i in black_list_category:
            self.categories.remove(i)
        self.items: list[tuple[item.Item, int]] = []
        self.set_items()

        self.box_text = [(game.FONT_20.render(game.get_game_instance().get_message(t), True, (0, 0, 0)),
                          game.FONT_20.render(game.get_game_instance().get_message(t), True, (255, 255, 255)))
                         for t in ["give", "use", "back"]]
Beispiel #2
0
    def __init__(self, game_i: 'game.Game'):
        """

        :type game_i: game.Game
        """
        super().__init__((100, 100), (36, 52))
        IMAGE = pygame.image.load('assets/textures/character/main.png')
        self.image: List[pygame.Surface] = [
            utils.get_part_i(IMAGE, cord[0:4], (36, 52), flip=(True, False) if cord[4] else (False, False)) for cord in
            Player.I]

        self.movement = [0, 0]
        self.speed = 10
        self.speed_on_running = 6
        self.speed_cycling = 4
        self.speed_getter = SpeedGetter(utils.current_milli_time())
        self.direction = 2
        self.current_dialogue = None
        self.freeze_time = 0
        self.is_action_press = False
        self.last_close_dialogue = utils.current_milli_time()
        self.current_menu: Optional['menu_calass.Menu'] = None
        self.team = [player_pokemon.PlayerPokemon.from_json(p) for p in game_i.get_save_value("team", [])]
        self.normalize_team()
        self.current_battle: Optional['battle.Battle'] = None
        self.speed_status = [False, False]
        self.is_cycling = False
        self.is_backhoe_loader = False

        self.pc: PC = PC(game_i.get_save_value("pc", []))
Beispiel #3
0
    def __init__(self, player,
                 escape_call_back: Optional[Callable[[], NoReturn]] = None,
                 choice_call_back: Optional[Callable[[int], NoReturn]] = None
                 ):
        super().__init__(player)

        self.escape_call_back = escape_call_back
        self.choice_call_back = choice_call_back
        self.selected = 0
        self.action_type = 0
        self.action_selected = -1
        self.move = -1
        self.keys = {
            game.get_game_instance().get_message("back"): option.KEY_QUITE,
            game.get_game_instance().get_message("move_pokemon"): option.KEY_BIKE,
            game.get_game_instance().get_message("select"): option.KEY_ACTION
        }
        self.arrow = utils.ARROW
        self.open_time = utils.current_milli_time()
        self.text_2 = [(game.FONT_20.render(game.get_game_instance().get_message(t), True, (0, 0, 0)),
                        game.FONT_20.render(game.get_game_instance().get_message(t), True, (255, 255, 255)))
                       for t in ["summary", "move", "heal", "object", "back"]]
        self.box_object = [(game.FONT_20.render(game.get_game_instance().get_message(t), True, (0, 0, 0)),
                            game.FONT_20.render(game.get_game_instance().get_message(t), True, (255, 255, 255)))
                           for t in ["open_bag", "put_in_bag", "back"]]
        self.cat_image = utils.color_image(utils.get_part_i(utils.MENU_IMAGE, (0, 0, 64, 64)), (0, 0, 0, 255))
Beispiel #4
0
    def __init__(self, data: Dict[str, Any]):
        super().__init__(data, (38, 50))
        self.__facing = utils.min_max(0, NPC.get_args(data, "facing", 0, int), 3)
        heal_facing = utils.min_max(0, NPC.get_args(data, "heal_facing", 0, int), 3)
        self.__heal_machine = NPC.get_args(data, "heal_machine", type_check=list)
        self.__heal_machine = self.__heal_machine[0] * game.CASE_SIZE, self.__heal_machine[1] * game.CASE_SIZE

        self.facing_image = utils.get_part_i(char.character.NPC_IMAGE, JoyNPC.IMAGE_LOC[self.__facing], (38, 50))
        self.__heal_facing_image = utils.get_part_i(char.character.NPC_IMAGE, JoyNPC.IMAGE_LOC[heal_facing], (38, 50))
        # 0 nothing, 1 talk
        self.__status = 0
        self.__action: Optional[int] = None
        self.__image_to_show: pygame.Surface = self.facing_image
        self.__player: 'char_p.Player' = game.game_instance.player
        self.__glow = pygame.Surface((16, 16), pygame.SRCALPHA)
        self.__glow.set_alpha(200)
        # pygame.draw.rect(self.__glow, (33, 191, 62), pygame.Rect(0, 0, 16, 16), border_radius=4)
        pygame.draw.circle(self.__glow, (33, 191, 62), (8, 8), 8, 1)
        self.have_start_song = False
Beispiel #5
0
 def __init__(self, player):
     super().__init__(player)
     coord = ((320, 0, 684, 64), (0, 0, 64, 64), (64, 0, 128, 64),
              (256, 0, 320, 64), (128, 0, 195, 64), (192, 0, 256, 64))
     self.image = [utils.get_part_i(utils.MENU_IMAGE, c) for c in coord]
     # self.arrow = utils.get_part_i(MENU_IMAGE, (0, 64, 22, 91))
     self.arrow = utils.ARROW
     self.selected = 0
     self.text = [
         game.get_game_instance().get_message(t).upper()
         for t in ["pokedex", "pokemon", "bag", "map", "save", "options"]
     ]
     self.keys = {
         game.get_game_instance().get_message("back"): option.KEY_QUITE,
         game.get_game_instance().get_message("save"): option.KEY_BIKE,
         game.get_game_instance().get_message("select"): option.KEY_ACTION
     }
Beispiel #6
0
 def __init__(self, player):
     super().__init__(player)
     self.selected = 0
     # self.arrow = utils.get_part_i(MENU_IMAGE, (0, 64, 22, 91), (12, 14))
     self.arrow = utils.ARROW
     self.text = [game.get_game_instance().get_message(t) for t in ["save_game", "back"]]
     self.text_2 = [
         game.FONT_16.render(game.get_game_instance().get_message(t) + " :", True, (0, 0, 0)) for t in
         ["date_hour", "actual_position", "time_play", "pokedex", ]]
     self.last_save_f = game.FONT_16.render(game.get_game_instance().get_message("last_save"), True, (255, 255, 255))
     self.last_save_size = game.FONT_SIZE_16[0] * len(game.get_game_instance().get_message("last_save"))
     self.time_play = game.FONT_16.render(
         utils.time_to_string(game.get_game_instance().get_save_value("time_played", 0)),
         True, (0, 0, 0))
     self.pokedex = game.FONT_16.render(
         str(sum(map(game.POKEDEX_CATCH.__eq__, game.get_game_instance().get_pokedex_catch_status_values()))), True,
         (0, 0, 0))
     self.last_save = game.FONT_16.render(
         str(datetime.fromtimestamp(game.get_game_instance().get_save_value("last_save", 0))
             .strftime('%d/%m/%y  %H:%M')), True, (255, 255, 255))
     self.open_time = time.time()
     self.cat_image = utils.color_image(utils.get_part_i(utils.MENU_IMAGE, (128, 0, 195, 64)), (0, 0, 0, 255))
Beispiel #7
0
def load_hud_item():
    global load, DIALOGUE_BOX, RIGHT_ARROW, DOWN_ARROW, SELECT_TOP, SELECT_DOWN, SELECT_MID
    if not load:
        load = True
        HUD: pygame.Surface = pygame.image.load("assets/textures/hud/HUD.png")
        DIALOGUE_BOX = utils.get_part_i(
            HUD, (0, 25, 280, 78),
            (game.SURFACE_SIZE[0] * 0.9, game.SURFACE_SIZE[1] * 0.2))
        RIGHT_ARROW = utils.get_part_i(HUD, (0, 0, 6, 10), (12, 20))
        DOWN_ARROW = utils.get_part_i(HUD, (6, 0, 16, 6), (20, 12))
        SELECT_TOP = utils.get_part_i(
            HUD, (0, 10, 74, 15),
            (game.SURFACE_SIZE[0] * 0.2, game.SURFACE_SIZE[1] * 0.05))
        SELECT_DOWN = utils.get_part_i(
            HUD, (0, 19, 74, 25),
            (game.SURFACE_SIZE[0] * 0.2, game.SURFACE_SIZE[1] * 0.05))
        SELECT_MID = utils.get_part_i(
            HUD, (74, 10, 149, 25),
            (game.SURFACE_SIZE[0] * 0.2, game.SURFACE_SIZE[1] * 0.08))
        # DIALOGUE_MAX_CHAR_LINES = int(game.SURFACE_SIZE[0] * 0.85) // game.FONT_SIZE_16[0]
        del HUD