From: xangelo Date: Mon, 16 May 2022 18:48:31 +0000 (-0400) Subject: Resource fixes! X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=944376c3f73772268ec774ccc2a3fa0788fc246e;p=browser-rts.git Resource fixes! A large rework of resources and how they interact Fixes: - ignore db files - transfer gold -> credits - transfer ore -> alloys - transfer bushels -> food - transfer logs -> energy - add symbols to topbar - transer land -> space - fix cost display - Display rate of change for food/energy since they are consumed per tick --- diff --git a/.gitignore b/.gitignore index bfef57f..51f4dbe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.js *.log node_modules/ +*.db diff --git a/dump.sql b/dump.sql index 9330aa6..44ee692 100644 --- a/dump.sql +++ b/dump.sql @@ -11,10 +11,10 @@ CREATE TABLE IF NOT EXISTS "cities" ( "icon" string, "totalSpace" int, "usedSpace" int, - "gold" int, - "ore" int, - "logs" int, - "bushels" int, + "credits" int, + "alloys" int, + "energy" int, + "food" int, "population" int, "soliders" int, "attackers" int, @@ -64,9 +64,9 @@ CREATE TABLE IF NOT EXISTS "unit_training_queue" ( CREATE TABLE IF NOT EXISTS "buildings" ( "slug" text, "display" text UNIQUE, - "gold" int, - "ore" int, - "logs" int, + "credits" int, + "alloys" int, + "energy" int, "land" int, "time" int, PRIMARY KEY("slug") @@ -74,8 +74,8 @@ CREATE TABLE IF NOT EXISTS "buildings" ( CREATE TABLE IF NOT EXISTS "units" ( "slug" , "display" , - "gold" , - "bushels" , + "credits" , + "food" , "population" , "soldiers" , "attackers" , diff --git a/public/game.html b/public/game.html index 3596ad2..054be5f 100644 --- a/public/game.html +++ b/public/game.html @@ -44,9 +44,10 @@
- Gold: 10,000,0000 - Ore: 10,000,000 - Logs: 10,000,0000 + Credits: 10,000,0000 + Alloys: 10,000,000 + Food: 10,000,0000 + Energy: 10,000,0000
diff --git a/public/scifi.css b/public/scifi.css index c9e6da2..3c6c0b7 100644 --- a/public/scifi.css +++ b/public/scifi.css @@ -5,6 +5,7 @@ --green-bg: #193818; --green-border: #32821c; --red-border: #821c1c; + --red-bg: #381818; } input { @@ -89,12 +90,18 @@ button::after, .btn::after { color: var(--border); } .danger { - background-color: #381818; + background-color: var(--red-bg); border-color: var(--red-border); } .danger::after { color: #821c1c } +.danger-text { + color: var(--red-border); +} +.success-text { + color: var(--green-border); +} .success { background-color: var(--green-bg); border-color: var(--green-border); @@ -252,6 +259,21 @@ form > div { justify-content: space-evenly; } +#info-bar > span { + display: inline-block; + line-height: 1.5rem; +} +#info-bar b { + --aug-border-all: 1px; + --aug-border-bg: var(--border); + display: inline-block; + line-height: 2rem; + width: 30px; + text-align: center; + background-color: #0d2329; + cursor: default; +} + #overworld-map { width: auto; margin: 0 auto; @@ -295,3 +317,18 @@ form > div { #sector-selector select { margin-left: 20px; } + +.cost-display { + display: flex; + flex-wrap: wrap; + justify-content: flex-start; +} +.cost-display > div { + margin: 0 0.5rem; +} +.rate-of-change.success-text::before { + content: '\25B2 '; +} +.rate-of-change.danger::before { + content: '\25BC '; +} diff --git a/src/api.ts b/src/api.ts index aba677b..f59ec0e 100644 --- a/src/api.ts +++ b/src/api.ts @@ -15,7 +15,9 @@ import { launchOffensive, listOperations, renderOverworldMap } from './render/ma import { createBullBoard } from '@bull-board/api'; import { BullAdapter } from '@bull-board/api/bullAdapter'; import _ from 'lodash'; -import { renderMailroom, renderMessage } from './render/mail'; +import { renderCost } from './render/costs'; +import {renderMailroom, renderMessage} from './render/mail'; +import {topbar} from './render/topbar'; const server = new HttpServer(config.API_PORT); @@ -95,7 +97,17 @@ server.get<{}, string>('/poll/overview', async req => { const account = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token); const city = await cityRepo.getUsersCity(account.id); - return renderKingomOverview(city, account); + const usage = { + foodUsagePerTick: await cityRepo.foodUsagePerTick(city), + foodProductionPerTick: await cityRepo.foodProductionPerTick(city), + energyUsagePerTick: 0, + energyProductionPerTick: 0 + } + + return renderKingomOverview({ + ...city, + ...usage + }, account) + topbar({...city, ...usage}); }); server.get<{}, string>('/poll/construction', async req => { @@ -104,7 +116,13 @@ server.get<{}, string>('/poll/construction', async req => { const buildings = await cityRepo.buildingRepository.list(); const buildQueues = await cityRepo.getBuildQueues(account.id); - return renderLandDevelopment(city, buildings, buildQueues); + const usage = { + foodUsagePerTick: await cityRepo.foodUsagePerTick(city), + foodProductionPerTick: await cityRepo.foodProductionPerTick(city), + energyUsagePerTick: 0, + energyProductionPerTick: 0 + } + return renderLandDevelopment(city, buildings, buildQueues) + topbar({...city, ...usage}); }); server.get<{}, string>('/poll/unit-training', async req => { @@ -113,8 +131,17 @@ server.get<{}, string>('/poll/unit-training', async req => { const unitTrainingQueues = await cityRepo.getUnitTrainingQueues(account.id); const units = await cityRepo.unitRepository.list(); + const usage = { + foodUsagePerTick: await cityRepo.foodUsagePerTick(city), + foodProductionPerTick: await cityRepo.foodProductionPerTick(city), + energyUsagePerTick: 0, + energyProductionPerTick: 0 + } - return renderUnitTraining(city, units, unitTrainingQueues); + return renderUnitTraining(city, units, unitTrainingQueues) + topbar({ + ...city, + ...usage + }); }); server.post<{body: {sector: string}}, string>('/poll/map', async req => { @@ -131,15 +158,34 @@ server.post<{body: {sector: string}}, string>('/poll/map', async req => { } } - console.log('Checking cities in sector', sector); + const usage = { + foodUsagePerTick: await cityRepo.foodUsagePerTick(city), + foodProductionPerTick: await cityRepo.foodProductionPerTick(city), + energyUsagePerTick: 0, + energyProductionPerTick: 0 + } - return renderOverworldMap(await cityRepo.findAllInSector(sector), city, sector); + return renderOverworldMap(await cityRepo.findAllInSector(sector), city, sector) + topbar({ + ...city, + ...usage + }); }); server.get<{}, string>('/poll/mailroom', async req => { const account = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token); + const city = await cityRepo.getUsersCity(account.id); - return renderMailroom(await mailRepo.listReceivedMessages(account.id)); + const usage = { + foodUsagePerTick: await cityRepo.foodUsagePerTick(city), + foodProductionPerTick: await cityRepo.foodProductionPerTick(city), + energyUsagePerTick: 0, + energyProductionPerTick: 0 + } + + return renderMailroom(await mailRepo.listReceivedMessages(account.id)) + topbar({ + ...city, + ...usage + }); }); @@ -150,7 +196,6 @@ server.post<{ } }, string>('/cost/construction', async req => { const amount = parseInt(req.body.amount.trim(), 10); - console.log('checking amount', amount); if(isNaN(amount) || amount < 1) { return ''; @@ -161,13 +206,15 @@ server.post<{ throw new NotFoundError(`Invalid building type ${req.body.building_type}`, ERROR_CODE.INVALID_BUILDING); } - return JSON.stringify({ - gold: building.gold * amount, - ore: building.ore * amount, - logs: building.logs * amount, + const cost = { + credits: building.credits * amount, + alloys: building.alloys * amount, + energy: building.energy * amount, land: building.land * amount, time: building.time - }); + }; + + return renderCost(cost); }); server.post<{ @@ -177,19 +224,24 @@ server.post<{ } }, string>('/cost/training', async req => { const amount = parseInt(req.body.amount, 10); - const unit = await cityRepo.unitRepository.findBySlug(req.body.type); + if(isNaN(amount) || amount < 1) { + return ''; + } + + const unit = await cityRepo.unitRepository.findBySlug(req.body.type); if(!unit) { throw new NotFoundError(`Invalid unit type ${req.body.type}`, ERROR_CODE.INVALID_UNIT); } - return JSON.stringify({ + return renderCost({ population: unit.population * amount, soldiers: unit.soldiers * amount, attackers: unit.attackers * amount, defenders: unit.defenders * amount, - gold: unit.gold * amount, - bushels: unit.bushels * amount + credits: unit.credits * amount, + food: unit.food * amount, + time: unit.time * amount }); }); @@ -199,17 +251,17 @@ server.post<{ building_type: string, } }, void>('/build', async req => { - const account = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token); - const city = await cityRepo.getUsersCity(account.id); + const account = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token); + const city = await cityRepo.getUsersCity(account.id); - const amount = parseInt(req.body.amount, 10); - const building = await cityRepo.buildingRepository.findBySlug(req.body.building_type); + const amount = parseInt(req.body.amount, 10); + const building = await cityRepo.buildingRepository.findBySlug(req.body.building_type); - if(!building) { - throw new NotFoundError(`Invalid building type ${req.body.building_type}`, ERROR_CODE.INVALID_BUILDING); - } + if(!building) { + throw new NotFoundError(`Invalid building type ${req.body.building_type}`, ERROR_CODE.INVALID_BUILDING); + } - const queueData = await cityRepo.buildBuilding(building, amount ,city); + const queueData = await cityRepo.buildBuilding(building, amount, city); construction.trigger(queueData, { delay: queueData.due }); }, 'reload-construction-queue'); diff --git a/src/render/costs.ts b/src/render/costs.ts new file mode 100644 index 0000000..03082a3 --- /dev/null +++ b/src/render/costs.ts @@ -0,0 +1,56 @@ +type Cost = { + credits: number, + time: number, + alloys?: number, + energy?: number, + land?: number, + food?: number, + population?: number, + soldiers?: number + attackers?: number, + defenders?: number +} + +function lineItem(display: string, value: number): string { + return ` +
+ ${display}: + ${value.toLocaleString()} +
+ `; +} + +export function renderCost(cost: Cost): string { + const costAsArray = []; + + costAsArray.push(lineItem('Credits', cost.credits)); + costAsArray.push(lineItem('Time', cost.time)); + + if(cost.alloys) { + costAsArray.push(lineItem('Alloys', cost.alloys)); + } + if(cost.food) { + costAsArray.push(lineItem('Food', cost.food)); + } + if(cost.energy) { + costAsArray.push(lineItem('Energy', cost.energy)); + } + if(cost.land) { + costAsArray.push(lineItem('Space', cost.land)); + } + if(cost.population) { + costAsArray.push(lineItem('Pop', cost.population)); + } + if(cost.soldiers) { + costAsArray.push(lineItem('Soldiers', cost.soldiers)); + } + if(cost.attackers) { + costAsArray.push(lineItem('Attackers', cost.attackers)); + } + if(cost.defenders) { + costAsArray.push(lineItem('Defenders', cost.defenders)); + } + + + return `
${costAsArray.join("")}
`; +} diff --git a/src/render/kingdom-overview.ts b/src/render/kingdom-overview.ts index c6b5964..c035f7c 100644 --- a/src/render/kingdom-overview.ts +++ b/src/render/kingdom-overview.ts @@ -1,54 +1,62 @@ import { Account } from "../repository/accounts"; import { CityWithLocation } from "../repository/city"; import * as _ from 'lodash'; -import { topbar } from "./topbar"; -export function renderKingomOverview(city: CityWithLocation, account: Account): string { +type Usage = { + foodUsagePerTick: number; + foodProductionPerTick: number; + energyUsagePerTick: number; + energyProductionPerTick: number; +} + +export function renderKingomOverview(city: CityWithLocation & Usage, account: Account): string { + const foodRateOfChange = city.foodProductionPerTick - city.foodUsagePerTick; + const energyRateOfChange = city.energyProductionPerTick - city.energyUsagePerTick; return `
-

Kingdom Overview

+

Overview

- + - + - + - - + + - - + + - - + + - - + +
LordCaptain ${account.username} Population ${city.population.toLocaleString()}/${_.max([city.farms * 70, city.population])}
LandSpace ${city.totalSpace.toLocaleString()} (${Math.ceil(city.usedSpace/city.totalSpace * 100)}% used) Soldiers ${city.soldiers.toLocaleString()}
Location${city.sector_id} - (${city.location_x},${city.location_y})Sector ${city.sector_id} - (${city.location_x},${city.location_y}) Attackers ${city.attackers.toLocaleString()}
Gold${city.gold.toLocaleString()}Credits${city.credits.toLocaleString()} Defenders ${city.defenders.toLocaleString()}
Ore${city.ore.toLocaleString()}Alloys${city.alloys.toLocaleString()} Special Attackers ${city.sp_attackers.toLocaleString()}
Logs${city.logs.toLocaleString()}Energy${city.energy.toLocaleString()} (${energyRateOfChange.toLocaleString()}) Special Defenders ${city.sp_defenders.toLocaleString()}
Bushels${city.bushels.toLocaleString()}Food${city.food.toLocaleString()} (${foodRateOfChange.toLocaleString()})
- ${topbar(city)}`; + `; } diff --git a/src/render/land-development.ts b/src/render/land-development.ts index d5cc4e3..0c1fad9 100644 --- a/src/render/land-development.ts +++ b/src/render/land-development.ts @@ -2,7 +2,6 @@ import { BuildQueue } from "../repository/build-queue"; import { CityWithLocation } from "../repository/city"; import { Building } from '../repository/buildings'; import _ from "lodash"; -import { topbar } from "./topbar"; function progressBar(current, max): string { const percent = Math.ceil((current/max) * 100); @@ -21,9 +20,10 @@ export function renderLandDevelopment(city: CityWithLocation, buildings: Buildin

Construction

- + - + + ${ buildings.map(building => { @@ -37,8 +37,8 @@ export function renderLandDevelopment(city: CityWithLocation, buildings: Buildin - + `; }).join("\n") @@ -74,5 +74,5 @@ export function renderLandDevelopment(city: CityWithLocation, buildings: Buildin
Free LandType Current${(city.totalSpace - city.usedSpace).toLocaleString()} (${Math.ceil(freeSpace/city.totalSpace * 100)}% available)Space Available: ${(city.totalSpace - city.usedSpace).toLocaleString()} (${Math.ceil(freeSpace/city.totalSpace * 100)}% available)Cost
`; - return html + queues + topbar(city); -} \ No newline at end of file + return html + queues; +} diff --git a/src/render/mail.ts b/src/render/mail.ts index 271eed9..a0b3b75 100644 --- a/src/render/mail.ts +++ b/src/render/mail.ts @@ -1,6 +1,5 @@ import { DateTime } from "luxon"; import { MessageWithNames } from "../repository/mail"; -import { topbar } from "./topbar"; export function renderMailroom(mail: MessageWithNames[]): string { return ` @@ -52,4 +51,4 @@ export function renderMessage(msg: MessageWithNames): string { `; -} \ No newline at end of file +} diff --git a/src/render/map.ts b/src/render/map.ts index 219103d..a9e8349 100644 --- a/src/render/map.ts +++ b/src/render/map.ts @@ -2,10 +2,8 @@ import _ from "lodash"; import { DateTime } from "luxon"; import { Account } from "../repository/accounts"; import { ArmyQueueWithAttackedOwner } from "../repository/army"; -import { City, CityRepository, CityWithLocation } from "../repository/city"; -import { topbar } from "./topbar"; +import { CityRepository, CityWithLocation } from "../repository/city"; import { AVAILABLE_SECTORS } from '../config'; -import {initArray} from "../lib/util"; const cityRepo = new CityRepository(); @@ -181,5 +179,5 @@ export async function launchOffensive(city: CityWithLocation, owner: Account, yo `; - return html + topbar(yourCity); + return html; } diff --git a/src/render/topbar.ts b/src/render/topbar.ts index e126137..94313c5 100644 --- a/src/render/topbar.ts +++ b/src/render/topbar.ts @@ -1,13 +1,42 @@ import { City } from "../repository/city"; -export function topbar(city: City): string { +type Usage = { + foodUsagePerTick: number; + foodProductionPerTick: number; + energyUsagePerTick: number; + energyProductionPerTick: number; +} + + +export function topbar(city: City & Usage): string { + const foodRateOfChange = city.foodProductionPerTick - city.foodUsagePerTick; + const energyRateOfChange = city.energyProductionPerTick - city.energyUsagePerTick; const oob = `
- Gold: ${city.gold.toLocaleString()} - Ore: ${city.ore.toLocaleString()} - Logs: ${city.logs.toLocaleString()} + + + ${city.credits.toLocaleString()} + + + A + ${city.alloys.toLocaleString()} + + + F + + ${city.food.toLocaleString()} + ${foodRateOfChange.toLocaleString()} + + + + E + + ${city.energy.toLocaleString()} + ${energyRateOfChange.toLocaleString()} + +
`; return oob; -} \ No newline at end of file +} diff --git a/src/render/unit-training.ts b/src/render/unit-training.ts index bfed36e..0214bfe 100644 --- a/src/render/unit-training.ts +++ b/src/render/unit-training.ts @@ -2,7 +2,6 @@ import _ from "lodash"; import { CityWithLocation } from "../repository/city"; import { UnitTrainingQueue } from "../repository/training-queue"; import { Unit } from "../repository/unit"; -import { topbar } from "./topbar"; function progressBar(current, max): string { const percent = Math.ceil((current/max) * 100); @@ -24,18 +23,19 @@ export function renderUnitTraining(city: CityWithLocation, units: Unit[], traini Unit Avail. + Cost Soldiers ${city.population}
- +
- + Attackers @@ -46,8 +46,8 @@ export function renderUnitTraining(city: CityWithLocation, units: Unit[], traini - + Defenders @@ -58,8 +58,8 @@ export function renderUnitTraining(city: CityWithLocation, units: Unit[], traini - + Special Attackers @@ -72,6 +72,7 @@ export function renderUnitTraining(city: CityWithLocation, units: Unit[], traini + Special Defenders @@ -82,8 +83,8 @@ export function renderUnitTraining(city: CityWithLocation, units: Unit[], traini - + `; @@ -115,5 +116,5 @@ export function renderUnitTraining(city: CityWithLocation, units: Unit[], traini `; - return html + queues + topbar(city); -} \ No newline at end of file + return html + queues; +} diff --git a/src/repository/buildings.ts b/src/repository/buildings.ts index 291abb1..d478e5e 100644 --- a/src/repository/buildings.ts +++ b/src/repository/buildings.ts @@ -3,9 +3,9 @@ import { Repository } from "./base"; export type Building = { slug: string; display: string; - gold: number; - ore: number; - logs: number; + credits: number; + alloys: number; + energy: number; land: number; time: number; } @@ -22,4 +22,4 @@ export class BuildingRepository extends Repository { async list(): Promise { return this.FindAll(); } -} \ No newline at end of file +} diff --git a/src/repository/city.ts b/src/repository/city.ts index 7b88185..43e1b7a 100644 --- a/src/repository/city.ts +++ b/src/repository/city.ts @@ -16,10 +16,10 @@ export type City = { owner: string; totalSpace: number; usedSpace: number; - gold: number; - ore: number; - logs: number; - bushels: number; + credits: number; + alloys: number; + energy: number; + food: number; population: number; soldiers: number; attackers: number; @@ -62,10 +62,10 @@ export class CityRepository extends Repository { owner: accountId, totalSpace: 100, usedSpace: 0, - gold: 10000, - ore: 10000, - logs: 10000, - bushels: 10000, + credits: 10000, + alloys: 10000, + energy: 10000, + food: 10000, population: 1000, soldiers: 100, attackers: 0, @@ -161,22 +161,22 @@ where l.sector_id = ?`, [sector_id]); throw new InsufficientResourceError('land', building.land, freeSpace); } - if(city.gold < building.gold) { - throw new InsufficientResourceError('gold', building.gold, city.gold); + if(city.credits < building.credits) { + throw new InsufficientResourceError('credits', building.credits, city.credits); } - if(city.ore < building.ore) { - throw new InsufficientResourceError('ore', building.ore, city.ore); + if(city.alloys < building.alloys) { + throw new InsufficientResourceError('alloys', building.alloys, city.alloys); } - if(city.logs < building.logs) { - throw new InsufficientResourceError('logs', building.logs, city.logs); + if(city.energy < building.energy) { + throw new InsufficientResourceError('energy', building.energy, city.energy); } city.usedSpace += (building.land * amount); - city.gold -= (building.gold * amount); - city.ore -= (building.ore * amount); - city.logs -= (building.logs * amount); + city.credits -= (building.credits * amount); + city.alloys -= (building.alloys * amount); + city.energy -= (building.energy * amount); await this.save(city); @@ -215,12 +215,12 @@ where l.sector_id = ?`, [sector_id]); } async train(unit: Unit, amount: number, city: City): Promise { - if(city.gold < unit.gold) { - throw new InsufficientResourceError('gold', unit.gold, city.gold); + if(city.credits < unit.credits) { + throw new InsufficientResourceError('credits', unit.credits, city.credits); } - if(city.bushels < unit.bushels) { - throw new InsufficientResourceError('bushels', unit.bushels, city.bushels); + if(city.food < unit.food) { + throw new InsufficientResourceError('food', unit.food, city.food); } if(city.population < coalesce(unit.population, 0)) { @@ -244,8 +244,8 @@ where l.sector_id = ?`, [sector_id]); // ok they have everything, lets update their city // and create the entry in the training queue - city.gold -= unit.gold * amount; - city.bushels -= unit.bushels * amount; + city.credits -= unit.credits * amount; + city.food -= unit.food * amount; city.population -= coalesce(unit.population, 0) * amount; city.soldiers -= coalesce(unit.soldiers, 0) * amount; city.attackers -= coalesce(unit.attackers, 0) * amount; @@ -279,6 +279,33 @@ where l.sector_id = ?`, [sector_id]); return power } + async foodProductionPerTick(city: City): Promise { + // eventually we should supply the warehouse formula + // to calculate the max amount of food created per tick + return _.max([ + city.population + _.round(city.farms * 50) + ]) + } + + async foodUsagePerTick(city: City): Promise { + return ( + (city.soldiers * 0.5) + + (city.population * 0.25) + + (city.attackers * 0.75) + + (city.attackers * 0.75) + + (city.sp_attackers * 1.3) + + (city.sp_defenders * 1.3) + ) + } + + async energyProductionPerTic(city: City): Promise { + return 0; + } + + async energyUsagePerTick(city: City): Promise { + return 0; + } + async attack(attacker: CityWithLocation, attacked: CityWithLocation, army: Army): Promise { // validate the user has enough of a military! if(attacker.soldiers < army.soldiers) { diff --git a/src/repository/unit.ts b/src/repository/unit.ts index bfbe4c8..3d4ff7a 100644 --- a/src/repository/unit.ts +++ b/src/repository/unit.ts @@ -3,8 +3,8 @@ import { Repository } from "./base"; export type Unit = { slug: string; display: string; - gold: number; - bushels: number; + credits: number; + food: number; population: number; soldiers: number; attackers: number; @@ -26,4 +26,4 @@ export class UnitRepository extends Repository { async list(): Promise { return this.FindAll(); } -} \ No newline at end of file +} diff --git a/src/tasks/fight.ts b/src/tasks/fight.ts index 7be73a6..484c07c 100644 --- a/src/tasks/fight.ts +++ b/src/tasks/fight.ts @@ -54,16 +54,16 @@ export const fight = new Task('fights', async (task, job) => { defenders: Math.floor(attacked.defenders * 0.05), sp_attackers: Math.floor(attacked.sp_attackers * 0.05), sp_defenders: Math.floor(attacked.sp_defenders * 0.05), - gold: Math.floor(attacked.gold * 0.2), - logs: Math.floor(attacked.logs * 0.2), - ore: Math.floor(attacked.ore * 0.2), + credits: Math.floor(attacked.credits * 0.2), + energy: Math.floor(attacked.energy * 0.2), + alloys: Math.floor(attacked.alloys * 0.2), land: Math.floor(attacked.totalSpace * 0.15), }; // ok you have everything, lets return you home - attacker.gold += defenderLosses.gold; - attacker.logs += defenderLosses.gold; - attacker.ore += defenderLosses.ore; + attacker.credits += defenderLosses.credits; + attacker.energy += defenderLosses.credits; + attacker.alloys += defenderLosses.alloys; attacker.totalSpace += defenderLosses.land; attacker.soldiers += (army.soldiers - attackerLosses.soldiers); @@ -77,9 +77,9 @@ export const fight = new Task('fights', async (task, job) => { attacked.defenders -= defenderLosses.defenders; attacked.sp_attackers -= defenderLosses.sp_attackers; attacked.sp_defenders -= defenderLosses.sp_defenders; - attacked.gold -= defenderLosses.gold; - attacked.logs -= defenderLosses.logs; - attacked.ore -= defenderLosses.ore; + attacked.credits -= defenderLosses.credits; + attacked.energy -= defenderLosses.energy; + attacked.alloys -= defenderLosses.alloys; attacked.totalSpace -= defenderLosses.land; await Promise.all([ @@ -95,16 +95,16 @@ export const fight = new Task('fights', async (task, job) => { You pillaged: - + - + - + - + @@ -138,16 +138,16 @@ export const fight = new Task('fights', async (task, job) => { You Lost:
Gold${defenderLosses.gold}Credits${defenderLosses.credits}
Logs${defenderLosses.logs}Energy${defenderLosses.energy}
Ore${defenderLosses.ore}Alloys${defenderLosses.alloys}
Land${defenderLosses.land}Space${defenderLosses.land}
- + - + - + - + @@ -259,4 +259,4 @@ export const fight = new Task('fights', async (task, job) => { ]); } -}); \ No newline at end of file +}); diff --git a/src/tasks/tick.ts b/src/tasks/tick.ts index 8160e9a..e448713 100644 --- a/src/tasks/tick.ts +++ b/src/tasks/tick.ts @@ -12,10 +12,10 @@ export const tick = new Task('tick', async (task, job) => { // +population*1.1 is where we take into account farms for bonus food production let sql = `update cities set - gold = gold + population * 2, - bushels = round( + credits = credits + population * 2, + food = round( max( - bushels - ( + food - ( (soldiers*0.5)+ (population*0.25)+ (attackers*0.75)+ @@ -29,7 +29,7 @@ export const tick = new Task('tick', async (task, job) => { ), population = max( min( - population + round(coalesce(bushels/bushels, 0) * population*0.08), + population + round(coalesce(food/food, 0) * population*0.08), farms * 70 ), population @@ -55,4 +55,4 @@ export const tick = new Task('tick', async (task, job) => { }, { delay: 60000 * nextTickAt}); } -}); \ No newline at end of file +});
Gold${defenderLosses.gold}Credits${defenderLosses.credits}
Logs${defenderLosses.logs}Energy${defenderLosses.energy}
Ore${defenderLosses.ore}Alloys${defenderLosses.alloys}
Land${defenderLosses.land}Space${defenderLosses.land}
Soldiers${attackerLosses.soldiers}