X-Git-Url: https://git.xangelo.ca/?a=blobdiff_plain;ds=sidebyside;f=src%2Frender%2Fland-development.ts;h=d0b5e7f1157460eba318713ce9430a6475e93fb1;hb=23651f2cfe342a32503dec70f56f8ffaf03f2616;hp=935ff74dbdd74868b9dedda76480e209e9467f68;hpb=d56a8ceaf07b5b0848945ba9868a2cdaf3b05111;p=browser-rts.git
diff --git a/src/render/land-development.ts b/src/render/land-development.ts
index 935ff74..d0b5e7f 100644
--- a/src/render/land-development.ts
+++ b/src/render/land-development.ts
@@ -3,7 +3,16 @@ import { CityWithLocation } from "../repository/city";
import { Building } from '../repository/buildings';
import _ from "lodash";
-function progressBar(current, max): string {
+const emptyBuilding: BuildQueue = {
+ id: '',
+ owner: '',
+ amount: 0,
+ created: 0,
+ due: 0,
+ building_type: 'empty',
+};
+
+function progressBar(current: number, max: number): string {
const percent = Math.ceil((current/max) * 100);
return `
Construction
- Free Land |
+ Type |
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 |
${
buildings.map(building => {
@@ -31,13 +45,13 @@ export function renderLandDevelopment(city: CityWithLocation, buildings: Buildin
${building.display} |
${city[building.slug]} |
-
-
|
+ |
`;
}).join("\n")
@@ -46,19 +60,33 @@ export function renderLandDevelopment(city: CityWithLocation, buildings: Buildin
`;
const quickFindBuilding = _.keyBy(buildings, 'slug');
+ const finalBuildQueues = sortedBuildQueues;
+
+ if (finalBuildQueues.length < city.max_construction_queue) {
+ while(finalBuildQueues.length < city.max_construction_queue) {
+ finalBuildQueues.push(emptyBuilding);
+ }
+ }
+
const queues = `
Build Queues
- Building |
- Amount Expected |
- Progress |
+ Building |
+ Amount Expected |
+ Progress |
- ${buildQueues.sort((a, b) => {
- return a.due - b.due;
- }).map(queue => {
+ ${sortedBuildQueues.map(queue => {
+ if(queue.building_type === 'empty') {
+ return `
+
+ You have sufficient capacity to build something. |
+
+ `
+ }
+ else {
const now = Date.now() - queue.created;
const duration = queue.due - queue.created;
@@ -67,12 +95,15 @@ export function renderLandDevelopment(city: CityWithLocation, buildings: Buildin
${quickFindBuilding[queue.building_type].display} |
${queue.amount} |
${progressBar(now, duration)} |
+
+ ×
+ |
`;
+ }
}).join("\n")}
`;
-
return html + queues;
-}
\ No newline at end of file
+}