1 import { Account } from "../repository/accounts";
2 import { CityWithLocation, CityRepository } from "../repository/city";
3 import * as _ from 'lodash';
5 function percent(curr: number, max: number, cap?: number): number {
6 const val = Math.ceil((curr/max) * 100);
15 foodUsagePerTick: number;
16 foodProductionPerTick: number;
17 energyUsagePerTick: number;
18 energyProductionPerTick: number;
21 const cityRepo = new CityRepository();
23 export function renderKingomOverview(city: CityWithLocation & Usage, account: Account): string {
24 const foodRateOfChange = city.foodProductionPerTick - city.foodUsagePerTick;
25 const energyRateOfChange = city.energyProductionPerTick - city.energyUsagePerTick;
27 <div hx-trigger="every 600s" hx-get="/poll/overview">
28 <h2 data-augmented-ui="tl-clip bl-clip none">Overview</h2>
32 <td>${account.username}</td>
34 <td>${city.population.toLocaleString()}/${cityRepo.maxPopulation(city)}</td>
38 <td>${city.totalSpace.toLocaleString()} (${Math.ceil(city.usedSpace/city.totalSpace * 100)}% used)</td>
40 <td>${city.soldiers.toLocaleString()}</td>
44 <td>Sector ${city.sector_id} - (${city.location_x},${city.location_y})</td>
46 <td>${city.attackers.toLocaleString()}</td>
50 <td>${city.credits.toLocaleString()}</td>
52 <td>${city.defenders.toLocaleString()}</td>
56 <td>${city.alloys.toLocaleString()}</td>
57 <th>Special Attackers</th>
58 <td>${city.sp_attackers.toLocaleString()}</td>
63 ${city.energy.toLocaleString()} (<span class="rate-of-change ${energyRateOfChange < 0 ? 'danger-text' : 'success-text'}">${energyRateOfChange.toLocaleString()}</span>)
64 @ 0% Battery Utilization
66 <th>Special Defenders</th>
67 <td>${city.sp_defenders.toLocaleString()}</td>
72 ${city.food.toLocaleString()} (<span class="rate-of-change ${foodRateOfChange < 0 ? 'danger-text' : 'success-text'}">${foodRateOfChange.toLocaleString()}</span>) @ ${percent(city.food, city.warehouses, 100)}% Warehouse utilization