From: xangelo Date: Wed, 25 May 2022 15:17:03 +0000 (-0400) Subject: final commit including final db schema X-Git-Url: https://git.xangelo.ca/?p=browser-rts.git;a=commitdiff_plain;h=c8be7767524bb249b44cc05bb2cd8be15ae7bc85 final commit including final db schema Everything should work at this point and the game just needs balancing... --- diff --git a/dump.sql b/dump.sql index 44ee692..1f170fc 100644 --- a/dump.sql +++ b/dump.sql @@ -5,10 +5,43 @@ CREATE TABLE IF NOT EXISTS "accounts" ( "password" text, PRIMARY KEY("id") ); +CREATE TABLE IF NOT EXISTS "army_queue" ( + "id" text, + "owner" text, + "your_city" text, + "created" int, + "due" int, + "soldiers" int, + "attackers" int, + "defenders" int, + "sp_attackers" int, + "sp_defenders" int, + "attacked_city" text, + PRIMARY KEY("id") +); +CREATE TABLE IF NOT EXISTS "build_queues" ( + "id" text, + "building_type" text, + "owner" text, + "created" int, + "due" int, + "amount" int, + PRIMARY KEY("id") +); +CREATE TABLE IF NOT EXISTS "buildings" ( + "slug" text, + "display" text UNIQUE, + "credits" int, + "alloys" int, + "energy" int, + "land" int, + "time" int, + PRIMARY KEY("slug") +); CREATE TABLE IF NOT EXISTS "cities" ( "id" string, "owner" string, - "icon" string, + "icon" string, "totalSpace" int, "usedSpace" int, "credits" int, @@ -26,31 +59,39 @@ CREATE TABLE IF NOT EXISTS "cities" ( "barracks" int, "special_attacker_trainer" int, "special_defender_trainer" int, + "homes" int after sp_defenders, + "warehouses" int, + "solar_panels" int, + "accumulators" int, + "mining_facilities" int, + "ore_refinery" int, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "locations" ( - "sector_id" int, - "city_id" text unique, + "sector_id" int, + "city_id" text UNIQUE, "location_x" int, "location_y" int ); -CREATE TABLE IF NOT EXISTS "ticks" ( - "current_tick" int, - "last_tick_at" int +CREATE TABLE IF NOT EXISTS "mail" ( + "id" text, + "to_account" text, + "from_account" text, + "type" text, + "sent_at" int, + "read_at" int, + "subject" text, + "message" text, + PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "sessions" ( "id" text, "account_id" TEXT, PRIMARY KEY("id") ); -CREATE TABLE IF NOT EXISTS "build_queues" ( - "id" text, - "building_type" text, - "owner" text, - "created" int, - "due" int, - "amount" int, - PRIMARY KEY("id") +CREATE TABLE IF NOT EXISTS "ticks" ( + "current_tick" int, + "last_tick_at" int ); CREATE TABLE IF NOT EXISTS "unit_training_queue" ( "id" string, @@ -61,16 +102,6 @@ CREATE TABLE IF NOT EXISTS "unit_training_queue" ( "amount" int, PRIMARY KEY("id") ); -CREATE TABLE IF NOT EXISTS "buildings" ( - "slug" text, - "display" text UNIQUE, - "credits" int, - "alloys" int, - "energy" int, - "land" int, - "time" int, - PRIMARY KEY("slug") -); CREATE TABLE IF NOT EXISTS "units" ( "slug" , "display" , @@ -84,39 +115,21 @@ CREATE TABLE IF NOT EXISTS "units" ( "attack" int, "defence" int ); -CREATE TABLE IF NOT EXISTS "army_queue" ( - "id" text, - "owner" text, - "your_city" text, - "created" int, - "due" int, - "soldiers" int, - "attackers" int, - "defenders" int, - "sp_attackers" int, - "sp_defenders" int, - "attacked_city" text, - PRIMARY KEY("id") -); -CREATE TABLE IF NOT EXISTS "mail" ( - "id" text, - "to_account" text, - "from_account" text, - "type" text, - "sent_at" int, - "read_at" int, - "subject" text, - "message" text, - PRIMARY KEY("id") -); INSERT INTO "accounts" VALUES ('-','Advisor','xos'); -INSERT INTO "locations" VALUES (1, '-', -1, -1); INSERT INTO "buildings" VALUES ('farms','Farms',20,0,40,1,14); INSERT INTO "buildings" VALUES ('barracks','Barracks',40,10,60,1,16); INSERT INTO "buildings" VALUES ('special_attacker_trainer','Sp. Attacker Trainer',80,40,100,2,20); INSERT INTO "buildings" VALUES ('special_defender_trainer','Sp. Defender Trainer',100,60,80,2,20); +INSERT INTO "buildings" VALUES ('homes','Homes',40,10,10,1,6); +INSERT INTO "buildings" VALUES ('warehouses','Warehouses',40,70,30,1,5); +INSERT INTO "buildings" VALUES ('solar_panels','Solar Panels',100,80,10,1,10); +INSERT INTO "buildings" VALUES ('accumulators','Accumulators',150,60,100,1,12); +INSERT INTO "buildings" VALUES ('mining_facilities','Droid Mining Facilities',120,120,80,1,12); +INSERT INTO "buildings" VALUES ('ore_refinery','Ore Refinery',80,60,40,1,8); +INSERT INTO "locations" VALUES (1,'-',-1,-1); INSERT INTO "units" VALUES ('soldiers','Soldiers',2,1,1,0,0,0,2,2.1,1); INSERT INTO "units" VALUES ('attackers','Attackers',5,2,0,1,0,0,3,4,1); INSERT INTO "units" VALUES ('defenders','Defenders',4,2,0,1,0,0,5,1,4); INSERT INTO "units" VALUES ('sp_attackers','Sp. Attacker',9,4,0,0,1,0,7,7,3); INSERT INTO "units" VALUES ('sp_defenders','Sp. Defender',11,5,0,0,0,1,10,2,9); +COMMIT; diff --git a/src/tasks/tick.ts b/src/tasks/tick.ts index e448713..d12f1af 100644 --- a/src/tasks/tick.ts +++ b/src/tasks/tick.ts @@ -27,12 +27,29 @@ export const tick = new Task('tick', async (task, job) => { ) + farms * 50 ), - population = max( - min( - population + round(coalesce(food/food, 0) * population*0.08), - farms * 70 - ), - population + energy = min( + max( + energy - ( + farms * 40 + + barracks * 60 + + special_attacker_trainer * 100 + + special_defender_trainer * 80 + + homes * 10 + + warehouses * 30 + + solar_panels * 10 + + accumulators * 100 + ), + 0 + ), + accumulators * 150 + ), + alloys = min( + (alloys + mining_facilities * 20), + ore_refinery * 75 + ), + population = min( + (population + round(population * 0.08)), + homes * 25 )`; try {