aalises / age-of-empires-II-api

API for Age of Empires II Built with Flask-RESTFul + SQLAlchemy
https://age-of-empires-2-api.herokuapp.com
BSD 3-Clause "New" or "Revised" License
120 stars 31 forks source link

Civilizations improvements #24

Closed gvrettos closed 1 month ago

gvrettos commented 7 months ago

Hello. I have made some improvements mostly on the civilizations part:

I have also update the database file, so tests continue to work.

For the database to be updated I had to deactivate the foreign keys and then enable them again in the end. Here is the sequence of SQL scripts I have run against db in order to update it:

// Check if foreign key constraints are valid; they were not
PRAGMA foreign_key_check;
// Check the status of the foreign key constraints (1->ON / 0->OFF) 
PRAGMA foreign_keys; 
// Disable the foreign key constraints to avoid errors during updates
PRAGMA foreign_keys = OFF; 

// Delete duplicate entry for Goths
delete 
from civilizations
where _id=22;

// Delete duplicate entry for Japanese
delete 
from civilizations
where _id=26;

// Update units
insert into units(
    name, description, expansion, age, created_in, cost, 
    build_time, reload_time, movement_rate, line_of_sight, hit_points, range, attack, armor, attack_bonus
)
values(
    'Karambit Warrior', 'Malay unique unit. Cheap and weak infantry unit that only takes half a population slot', 'Rise of Rajas', 'Castle', 'Castle', '{"Food": 30;"Gold": 15}', 
    6, 2, 1.2, 5, 30, 0, 7, '0/1','+2 eagle warrior' 
);

insert into units(
    name, description, expansion, age, created_in, cost, 
    build_time, reload_time, movement_rate, line_of_sight, hit_points, range, attack, armor, attack_bonus
)
values(
    'Elite Karambit Warrior', ' Upgraded Karambit Warrior', 'Rise of Rajas', 'Imperial', 'Castle', '{"Food": 30;"Gold": 15}', 
    6, 2, 1.2, 5, 40, 0, 8, '1/1','+2 eagle warrior;+1 standard building'
);

// Here I should have normally updated technologies as well (with infor about Thalassocracy and Forced Levy), but there was no information in this file other than from "Age of Kings" and "The Conquerors". I decided to follow the existing pattern and leave it as it is.

// Update civilizations
insert into civilizations(name, expansion, army_type, unique_unit, unique_tech, team_bonus, civilization_bonus)
values('Malay', 'Rise of Rajas', 'Naval', 'Karambit Warrior', 'Thalassocracy;Forced Levy', 
'Advancing to ages 80% faster;Fish Traps cost 33% cheaper;Fish Traps provide unlimited food;Battle Elephants 30% cheaper', 'Docks +100% LOS');

// Activate foreign key constraints back again
PRAGMA foreign_keys = ON;