-- Savunma Sistemleri Tablosu
CREATE TABLE IF NOT EXISTS defense (
    id INT AUTO_INCREMENT PRIMARY KEY,
    planet_id INT NOT NULL,
    defense_type VARCHAR(50) NOT NULL,
    quantity INT DEFAULT 0,
    FOREIGN KEY (planet_id) REFERENCES planets(id) ON DELETE CASCADE,
    UNIQUE KEY unique_defense (planet_id, defense_type),
    INDEX idx_planet_id (planet_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Savunma Tipleri (Referans Tablosu)
CREATE TABLE IF NOT EXISTS defense_types (
    defense_type VARCHAR(50) PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    description TEXT,
    base_metal_cost DECIMAL(15,2) DEFAULT 0,
    base_crystal_cost DECIMAL(15,2) DEFAULT 0,
    base_deuterium_cost DECIMAL(15,2) DEFAULT 0,
    cost_multiplier DECIMAL(5,2) DEFAULT 1.0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Varsayılan Savunma Tipleri
INSERT INTO defense_types (defense_type, name, description, base_metal_cost, base_crystal_cost, base_deuterium_cost) VALUES
('rocket_launcher', 'Roketatar', 'Temel savunma sistemi', 2000, 0, 0),
('light_laser', 'Hafif Lazer', 'Hızlı ateş eden lazer', 1500, 500, 0),
('heavy_laser', 'Ağır Lazer', 'Güçlü lazer savunması', 6000, 2000, 0),
('gauss_cannon', 'Gauss Topu', 'Yüksek hasar veren top', 20000, 15000, 2000),
('ion_cannon', 'İyon Topu', 'İyon teknolojisi ile çalışan top', 50000, 50000, 30000),
('plasma_cannon', 'Plazma Topu', 'En güçlü savunma sistemi', 100000, 100000, 50000),
('small_shield', 'Küçük Kalkan', 'Gezegeni koruyan kalkan', 10000, 10000, 0),
('large_shield', 'Büyük Kalkan', 'Güçlü gezegen kalkanı', 50000, 50000, 0);

