import pygame from engine.types import TYPE_BEATS, type_relations from ui.scaling import draw_type_icon, load_type_icon TYPE_COLORS = { "radiant": (245, 200, 90), "nocturnal": (150, 120, 220), "ice": (130, 200, 235), "garden": (120, 200, 120), "wildflower": (235, 130, 170), } STRONG = (120, 210, 120) WEAK = (225, 130, 130) MUTED = (150, 155, 150) TEXT = (230, 235, 230) def _cycle_types() -> list: order = [] cur = next(iter(TYPE_BEATS)) for _ in range(len(TYPE_BEATS)): order.append(cur) cur = TYPE_BEATS[cur] return order def draw_type_popup(screen, w, h, ptype, bold, small, tiny): """Draw a modal popup explaining a type's strong/weak matchups.""" overlay = pygame.Surface((w, h), pygame.SRCALPHA) overlay.fill((0, 0, 0, 150)) screen.blit(overlay, (0, 0)) pw, ph = 340, 200 panel = pygame.Rect((w - pw) // 2, (h - ph) // 2, pw, ph) pygame.draw.rect(screen, (32, 38, 32), panel, border_radius=12) pygame.draw.rect(screen, (70, 90, 70), panel, 2, border_radius=12) tcol = TYPE_COLORS.get(ptype, TEXT) title = bold.render(ptype.capitalize(), True, tcol) screen.blit(title, title.get_rect(center=(panel.centerx, panel.y + 30))) strong, weak = type_relations(ptype) y = panel.y + 62 if strong: screen.blit(small.render("Strong against", True, MUTED), (panel.x + 36, y)) draw_type_icon(screen, strong, (panel.x + 36, y + 34), small, STRONG, 22) if weak: screen.blit(small.render("Weak against", True, MUTED), (panel.right - 140, y)) draw_type_icon(screen, weak, (panel.right - 140, y + 34), small, WEAK, 22) cyc_y = panel.bottom - 44 segs = [] for t in _cycle_types(): ic = load_type_icon(t, 16) if ic: segs.append((ic, ic.get_width())) else: txt = tiny.render(t.capitalize(), True, MUTED) segs.append((txt, txt.get_width())) gap = tiny.size(">")[0] + 6 total_w = sum(s[1] for s in segs) + (len(segs) - 1) * gap x = panel.centerx - total_w // 2 for i, (surf, w) in enumerate(segs): screen.blit(surf, surf.get_rect(midleft=(x, cyc_y))) x += w if i < len(segs) - 1: gt = tiny.render(">", True, MUTED) screen.blit(gt, (x + 2, cyc_y - gt.get_height() // 2)) x += gap hint = tiny.render("Click anywhere to close", True, MUTED) screen.blit(hint, hint.get_rect(center=(panel.centerx, panel.bottom - 22)))