def tick(self, display: Surface) -> bool: if not self._init: self._init = True ask = game.game_instance.get_message("yes"), \ game.game_instance.get_message("no") game.game_instance.player.open_dialogue( hud.QuestionDialog('battle.evolution_ask', self.callback, ask, speed=20, need_morph_text=True, style=2, text_var=[self.poke.get_name(True)])) if self.question_answer is not None: # no if self.question_answer == 1: return True # yes else: ps_t = utils.current_milli_time() - self._start # if ps_t < 10_000: display.blit(self.bg, (0, 0)) if ps_t < 8_000: x = ps_t / (8000 / 10) f = lambda x: math.cos(x * 10) + 0.2 * x - 1 img = displayer.get_poke( PATH( str(self.new_base_poke.id_ if f(x) >= 0 else self. base_poke.id_)), 3) display.blit(img, (530 - img.get_size()[0] // 2, 300 - img.get_size()[1] // 2)) else: img = displayer.get_poke(PATH(str(self.new_base_poke.id_)), 3) display.blit(img, (530 - img.get_size()[0] // 2, 300 - img.get_size()[1] // 2)) if not self.action: sound_manager.start_in_first_empty_taunt( sounds.EVOLUTION) self.action = True game.game_instance.player.open_dialogue( hud.Dialog("battle.evolution", speed=100, need_morph_text=True, callback=self.end_callback, text_var=[ self.poke.get_name(True), self.new_base_poke.get_name(True) ])) self.poke.set_id(self.new_id) elif self.need_end: game.game_instance.player.close_dialogue() del self.bg sounds.EVOLUTION.un_load() return True return False
def get_back_image_colored(self, color: Union[tuple[int, int, int], tuple[int, int, int, int]], scale=1) -> pygame.Surface: surface = displayer.get_poke(self.back_image, 1).copy() utils.color_image(surface, color) size = surface.get_size() if scale != 1: surface = pygame.transform.scale(surface, (int(size[0] * scale), int(size[1] * scale))) return surface
def get_first_color(self, path): poke = displayer.get_poke(path) for y in range(poke.get_size()[1] - 1, -1, -1): for x in range(0, poke.get_size()[1]): if poke.get_at((x, y))[3] != 0: return y return 0
def draw_pokemon(self, display: pygame.Surface, id_: int, y: int) -> NoReturn: r_id_ = id_ + 1 status = game.get_game_instance().get_pokedex_status(r_id_) color = (100, 100, 100) if status == game.POKEDEX_NEVER_SEEN else (255, 255, 255) if self.selected == id_ else (0, 0, 0) poke = pokemon.get_pokemon(r_id_ if status != game.POKEDEX_NEVER_SEEN else 0) if status != game.POKEDEX_NEVER_SEEN and self.selected == id_: utils.draw_split_rond_rectangle(display, (650, y + 8, 355, 31), 0.5, 0.45, "#f0501e", "#000000") big_im = displayer.get_poke(PokeDex.PATH(str(poke.id_)), 3) s_x, s_y = big_im.get_size() display.blit(big_im, (250 - s_x // 2, 300 - s_y // 2)) im = displayer.get_poke(PokeDex.PATH(str(poke.id_)), 0.5) delta_x, delta_y = utils.get_first_color(im) display.blit(im, (636, y + 30 - delta_y)) display.blit(game.FONT_24.render(f"N° {pokemon.to_3_digit(r_id_)}", True, color), (680, y + 12)) display.blit(game.FONT_24.render(poke.get_name(True) if poke.id_ != 0 else "???", True, color), (840, y + 12)) if status != game.POKEDEX_NEVER_SEEN: display.blit( (self.white_pokeball if self.selected == id_ else self.black_pokeball) if status == game.POKEDEX_CATCH else (utils.POINT_POKEBALL if self.selected == id_ else self.light_orange_point), (980, y + 8) )
def get_back_image(self, scale=1) -> pygame.Surface: return displayer.get_poke(self.back_image, scale)
def get_front_image(self, scale=1) -> pygame.Surface: return displayer.get_poke(self.front_image, scale)
def render(self, display: pygame.Surface): display.fill("#ecdcdf") pygame.draw.polygon(display, "#f4523b", PokeDexInfo.poly_1) pygame.draw.polygon(display, "#fa7248", PokeDexInfo.poly_2) pygame.draw.polygon(display, "#f4523b", PokeDexInfo.poly_3) utils.draw_button_info(display, **self.keys) poke = pokemon.get_pokemon(self.selected + 1) # big big_im = displayer.get_poke(PokeDex.PATH(str(poke.id_)), 3) s_x, s_y = big_im.get_size() display.blit(big_im, (250 - s_x // 2, 300 - s_y // 2)) utils.draw_split_rectangle(display, (477, 60, 530, 50), 0.4, 0.35, "#f0501e", "#000000") utils.draw_arrow(display, True, 742, 56, (255, 255, 255), size=2) utils.draw_arrow(display, False, 742, 114, (255, 255, 255), size=2) y = 62 im = displayer.get_poke(PokeDex.PATH(str(poke.id_)), 0.7) delta_x, delta_y = utils.get_first_color(im) x = 480 display.blit(im, (x, y + 30 - delta_y)) status = game.get_game_instance().get_pokedex_status(self.selected + 1) display.blit(game.FONT_24.render(f"N° {pokemon.to_3_digit(self.selected + 1)}", True, (255, 255, 255)), (x + 50, y + 10)) display.blit(game.FONT_24.render(poke.get_name(True) if poke.id_ != 0 else "???", True, (255, 255, 255)), (689, y + 10)) if status != game.POKEDEX_NEVER_SEEN: display.blit( self.white_pokeball if status == game.POKEDEX_CATCH else utils.POINT_POKEBALL, (950, y + 8) ) x, y = 530, 150 l = 424 h = 40 s = 3 pygame.draw.rect(display, "#dbdbd9", (x, y, l, h,)) display.blit(tx := game.FONT_24.render(poke.get_japan_name(), True, (0, 0, 0)), (x + (l - tx.get_size()[0]) // 2, y + (h - tx.get_size()[1]) // 2)) y += h + s tx = ("type", "size", "weight", "view") tx2 = (None, f'{poke.size} m', f'{poke.weight} Kg', str(game.get_game_instance().get_nb_view(self.selected + 1))) for i in range(4): pygame.draw.rect(display, "#dbdbd9", (x, y, l // 2, h)) pygame.draw.rect(display, "#ffffff", (x + l // 2, y, l // 2, h)) display.blit(sur := game.FONT_24.render(game.get_game_instance().get_message(tx[i]), True, (0, 0, 0)), utils.get_center(sur, (x, y, l // 2, h))) if i != 0: display.blit(sur := game.FONT_24.render(tx2[i], True, (0, 0, 0)), utils.get_center(sur, (x + l // 2 + 5, y, l // 2, h), center_x=False)) else: _x_ = x + l // 2 + 10 for ii in range(len(poke.types)): utils.draw_type(display, _x_, y + h // 2 - 8, poke.types[ii]) _x_ += 106 y += h if i != 3: pygame.draw.rect(display, "#d2d2d2", (x, y, l // 2, s)) pygame.draw.rect(display, "#f3f3f3", (x + l // 2, y, l // 2, h)) y += s pygame.draw.rect(display, "#ffffff", (x, y, l, int(h * 4.5))) x += 5 y += 10 for p_l in hud.Dialog.split(poke.get_pokedex(), 40): display.blit(game.FONT_20.render(p_l, True, (0, 0, 0)), (x, y)) y += game.FONT_SIZE_20[1] + 5