WIP: update to include sectors!
[browser-rts.git] / src / render / fight.ts
index 833341e17db62654aa698fc68257c9fad1b1ca6e..a4864a2e240033a3dcb4456ec5b9de256182ee4f 100644 (file)
@@ -2,24 +2,24 @@ import _ from "lodash";
 import { DateTime } from "luxon";
 import { Account } from "../repository/accounts";
 import { ArmyQueueWithAttackedOwner } from "../repository/army";
-import { City, CityRepository } from "../repository/city";
+import { City, CityRepository, CityWithLocation } from "../repository/city";
 
 const cityRepo = new CityRepository();
 
-export function renderOverworldMap(cities: City[], yourCity: City): string {
-    let map: City[][] = new Array(100);
+export function renderOverworldMap(cities: CityWithLocation[], yourCity: CityWithLocation): string {
+    let map: CityWithLocation[][] = new Array(25);
     for(let i = 0; i < cities.length; ++i) {
         if(!map[cities[i].location_y]) {
-            map[cities[i].location_y] = new Array(100);
+            map[cities[i].location_y] = new Array(25);
         }
 
         map[cities[i].location_y][cities[i].location_x] = cities[i];
     }
 
     let rows: string[] = [];
-    for(let y = 0; y < 100; ++y) {
+    for(let y = 0; y < 25; ++y) {
         rows[y] = '<tr>';
-        for(let x = 0; x < 100; ++x) {
+        for(let x = 0; x < 25; ++x) {
             if(!map[y] || !map[y][x]) {
                 rows[y] += '<td><div class="empty"></div></td>' ;
             }
@@ -36,7 +36,7 @@ export function renderOverworldMap(cities: City[], yourCity: City): string {
         rows[y] += '</tr>';
     }
     let html = `
-    <h2>Map</h2>
+    <h2 data-augmented-ui="tl-clip bl-clip none">Map</h2>
     <div id="city-offence"></div>
     <div id="outgoing-attacks" hx-trigger="reload-outgoing-attacks, every 600s, load" hx-get="/attacks/outgoing"></div>
     <table id="overworld-map">
@@ -82,7 +82,7 @@ export function listOperations(outgoingOps: ArmyQueueWithAttackedOwner[]): strin
     return html;
 }
 
-export async function launchOffensive(city: City, owner: Account, yourCity: City, you: Account): Promise<string> {
+export async function launchOffensive(city: CityWithLocation, owner: Account, yourCity: CityWithLocation, you: Account): Promise<string> {
     const distance = cityRepo.distanceInHours(city, yourCity);
     const power = await cityRepo.power({
         soldiers: yourCity.soldiers,
@@ -92,7 +92,7 @@ export async function launchOffensive(city: City, owner: Account, yourCity: City
         sp_defenders: yourCity.sp_defenders
     })
     let html = `
-    <h3>Viewing (${city.location_x},${city.location_y}) owned by ${owner.username}</h3>
+    <h3 data-augmented-ui="tl-clip bl-clip none">Viewing (${city.location_x},${city.location_y}) owned by ${owner.username}</h3>
     <h4>Report</h4>
     <p>This city is ${distance} hours away.</p>
     <form hx-post="/attack">