﻿-- Create the AssaultTroop table
CREATE TABLE assault_troop (
    id SERIAL PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    faction INT NOT NULL, -- 0 - Neutral, 1 - Allies, 2 - Axis
    type INT NOT NULL,    -- 1 - Infantry, 4 - Armor
    province INT NOT NULL, -- -1 - Not deployed, Province IDs
    orders JSONB NOT NULL, -- JSON String
    owner INT NOT NULL -- Owner ID
);

INSERT INTO assault_troop (id, name, faction, type, province, orders, owner) VALUES
    (1, 'First Infantry Division', 2, 1, 0, '{"Dep": [], "Mov": []}', 1),
    (2, 'First Infantry Division', 1, 1, 0, '{"Dep": [], "Mov": []}', 2),
    (3, 'Second Infantry Division', 1, 1, 0, '{"Dep": [], "Mov": []}', 2),
    (4, 'Third Infantry Division', 1, 1, 0, '{"Dep": [], "Mov": []}', 2),
    (5, 'Cheeki Breeki Boys', 2, 1, 0, '{"Dep": [], "Mov": []}', 3),
    (6, 'Hitlers Men', 2, 1, 1, '{"Dep": [], "Mov": []}', 4),
    (7, 'Hitlers Men', 2, 1, 1, '{"Dep": [], "Mov": []}', 4),
    (8, 'Hitlers Men', 2, 1, 1, '{"Dep": [], "Mov": []}', 4),
    (9, 'Cheeki Breeki Boys', 2, 1, 1, '{"Dep": [], "Mov": []}', 3),
    (10, 'Hitlers Men', 2, 1, 0, '{"Dep": [], "Mov": []}', 4),
    (11, 'Fifth Infantry Division', 1, 1, -1, '{"Dep": [], "Mov": []}', 5),
    (12, 'Fifth Infantry Division', 1, 1, -1, '{"Dep": [], "Mov": []}', 5),
    (13, 'First Armor Division', 1, 4, 2, '{"Dep": [], "Mov": []}', 2),
    (14, 'Second Armor Division', 1, 4, 2, '{"Dep": [], "Mov": []}', 2),
    (15, 'Cheeki Breeki Tonks', 2, 4, 2, '{"Dep": [], "Mov": []}', 3);


-- Create the Province table
CREATE TABLE province (
    id SERIAL PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    faction INT NOT NULL, -- 0 - Neutral, 1 - Allies, 2 - Axis
    multiplier DECIMAL(3, 2) NOT NULL, -- 0-1
    ats JSONB NOT NULL, -- JSON String
    state INT NOT NULL -- 0 - Peace, 1 - War
);

INSERT INTO province (id, name, faction, multiplier, ats, state) VALUES
    (0, 'Hessen', 2, 1.00, '{"Allies": [2, 3, 4], "Axis": [1, 5, 9, 10]}', 1),
    (1, 'Thuringen', 2, 1.00, '{"Allies": [], "Axis": [6, 7, 8]}', 0),
    (2, 'Rheinland-Pfalz', 1, 1.00, '{"Allies": [13, 14], "Axis": [15]}', 1),
    (4, 'Baden-Wurttemberg', 1, 1.00, '{"Allies": [17, 19], "Axis": []}', 0),
    (3, 'Saarland', 1, 1.00, '{"Allies": [16, 17, 18], "Axis": []}', 0),
    (5, 'Bayern', 1, 1.00, '{"Allies": [20, 21], "Axis": []}', 0),
    (6, 'Sachsen', 1, 1.00, '{"Allies": [23], "Axis": []}', 0),
    (7, 'Brandenburg', 2, 1.00, '{"Allies": [], "Axis": [25, 26, 27, 28]}', 0),
    (8, 'Berlin', 2, 1.00, '{"Allies": [], "Axis": [29, 30, 31]}', 0),
    (9, 'Schleswig-Holstein', 2, 1.00, '{"Allies": [], "Axis": [33]}', 0),
    (10, 'Hamburg', 2, 1.00, '{"Allies": [], "Axis": [34]}', 0),
    (11, 'Niedersachsen', 2, 1.00, '{"Allies": [], "Axis": [35]}', 0),
    (12, 'Nordreihn-Westfalen', 1, 1.00, '{"Allies": [36, 37], "Axis": []}', 0);
