import pygame
import math
import os

def create_glow(surface, color, radius):
    glow = pygame.Surface((radius * 2, radius * 2), pygame.SRCALPHA)
    pygame.draw.circle(glow, (*color, 50), (radius, radius), radius)
    pygame.draw.circle(glow, (*color, 100), (radius, radius), int(radius * 0.8))
    pygame.draw.circle(glow, (*color, 150), (radius, radius), int(radius * 0.6))
    surface.blit(glow, (surface.get_width()//2 - radius, surface.get_height()//2 - radius))

def make_weapon_icon(name, base_color, accent_color, shape_type):
    surf = pygame.Surface((32, 32), pygame.SRCALPHA)
    pygame.draw.rect(surf, (40, 40, 40), (4, 4, 24, 24), border_radius=4)
    if shape_type == "rect":
        pygame.draw.rect(surf, base_color, (8, 12, 16, 8))
        pygame.draw.rect(surf, accent_color, (24, 12, 4, 8))
    elif shape_type == "circle":
        pygame.draw.circle(surf, base_color, (16, 16), 8)
        pygame.draw.circle(surf, accent_color, (16, 16), 4)
    elif shape_type == "triangle":
        pygame.draw.polygon(surf, base_color, [(8, 8), (24, 16), (8, 24)])
        pygame.draw.polygon(surf, accent_color, [(12, 12), (20, 16), (12, 20)])
    elif shape_type == "wide":
        pygame.draw.rect(surf, base_color, (4, 14, 24, 4))
    
    pygame.draw.rect(surf, (150, 150, 150), (4, 4, 24, 24), 2, border_radius=4)
    pygame.image.save(surf, f"icon_w_{name}.png")

def make_projectile(name, base_color, glow_size, shape_type):
    surf = pygame.Surface((32, 32), pygame.SRCALPHA)
    create_glow(surf, base_color, glow_size)
    if shape_type == "beam":
        pygame.draw.rect(surf, (255,255,255), (8, 14, 16, 4))
    elif shape_type == "orb":
        pygame.draw.circle(surf, (255,255,255), (16, 16), 5)
    elif shape_type == "star":
        pygame.draw.polygon(surf, (255,255,255), [(16,8), (19,13), (24,13), (20,17), (21,22), (16,19), (11,22), (12,17), (8,13), (13,13)])
    elif shape_type == "pellet":
        pygame.draw.circle(surf, (255,255,255), (16, 16), 3)
    elif shape_type == "missile":
        pygame.draw.polygon(surf, (255,255,255), [(10,12), (22,16), (10,20)])
    pygame.image.save(surf, f"proj_{name}.png")

def make_gem_icon(name, color, shape_level):
    surf = pygame.Surface((24, 24), pygame.SRCALPHA)
    create_glow(surf, color, 12)
    if shape_level == 1: # Diamond
        pts = [(12,4), (20,12), (12,20), (4,12)]
    elif shape_level == 2: # Hexagon
        pts = [(12,4), (19,8), (19,16), (12,20), (5,16), (5,8)]
    elif shape_level == 3: # Octagon
        pts = [(9,5), (15,5), (19,9), (19,15), (15,19), (9,19), (5,15), (5,9)]
    else: # Circle
        pts = None
        
    if pts:
        pygame.draw.polygon(surf, (255,255,255), pts)
        pygame.draw.polygon(surf, color, pts, 2)
    else:
        pygame.draw.circle(surf, (255,255,255), (12,12), 8)
        pygame.draw.circle(surf, color, (12,12), 8, 2)
        
    pygame.image.save(surf, f"gem_{name}.png")

if __name__ == "__main__":
    pygame.init()
    pygame.display.set_mode((100, 100), pygame.HIDDEN)
    os.chdir("c:\\Users\\leopo\\Desktop\\site_internet\\neon_nebula_survivor\\assets")
    
    # 10 WEAPONS
    weapons = [
        ("laser", (0,255,255), (255,255,255), "rect", "beam", 10),
        ("plasma", (255,0,255), (100,0,100), "circle", "orb", 14),
        ("railgun", (255,100,0), (255,255,255), "wide", "beam", 8),
        ("blaster", (0,255,0), (0,100,0), "triangle", "orb", 10),
        ("cannon", (255,50,50), (100,0,0), "circle", "orb", 16),
        ("shotgun", (200,200,200), (50,50,50), "wide", "pellet", 6),
        ("sniper", (0,100,255), (0,0,100), "rect", "beam", 6),
        ("flamethrower", (255,150,0), (255,0,0), "wide", "orb", 12),
        ("missile", (200,0,0), (255,255,0), "triangle", "missile", 10),
        ("starburst", (255,255,0), (255,255,255), "circle", "star", 12)
    ]
    for w in weapons:
        make_weapon_icon(w[0], w[1], w[2], w[3])
        make_projectile(w[0], w[1], w[5], w[4])

    # 20 GEMS (5 colors x 4 shapes)
    colors = {
        "red": (255,50,50),     # Dégâts/Feu
        "green": (50,255,50),   # Perçage/Poison
        "blue": (50,50,255),    # Vitesse
        "yellow": (255,255,50), # Critique/Rebond
        "purple": (200,50,255)  # Multitir/Magie
    }
    
    gem_idx = 1
    for color_name, color_val in colors.items():
        for shape in range(1, 5):
            make_gem_icon(f"{color_name}_{shape}", color_val, shape)
            gem_idx += 1
            
    pygame.quit()
    print("Nouvelles armes et gemmes générées avec succès !")
