1 import {City} from "../repository/city";
16 function lineItem(display: string, value: number, available: number): string {
19 if(available < value && available >= 0) {
20 className = 'danger-text';
22 else if(available >= value) {
23 className = 'success-text';
28 <span class="text ${className}">${value.toLocaleString()}</span>
33 export function renderCost(cost: Cost, city: City): string {
34 const costAsArray = [];
36 costAsArray.push(lineItem('Credits', cost.credits, city.credits));
37 costAsArray.push(lineItem('Time', cost.time, -1));
40 costAsArray.push(lineItem('Alloys', cost.alloys, city.alloys));
43 costAsArray.push(lineItem('Food', cost.food, city.food));
46 costAsArray.push(lineItem('Energy', cost.energy, city.energy));
49 costAsArray.push(lineItem('Space', cost.land, city.totalSpace - city.usedSpace));
52 costAsArray.push(lineItem('Pop', cost.population, city.population));
55 costAsArray.push(lineItem('Soldiers', cost.soldiers, city.soldiers));
58 costAsArray.push(lineItem('Attackers', cost.attackers, city.attackers));
61 costAsArray.push(lineItem('Defenders', cost.defenders, city.defenders));
65 return `<div class="cost-display">${costAsArray.join("")}</div>`;