WIP: update to include sectors!
[browser-rts.git] / src / repository / army.ts
index d5e47e6014401f4f1623665abaa24ca830553ef0..46ddf570dbbaa49d28aa6d771cf015a12970b37d 100644 (file)
@@ -1,6 +1,6 @@
 import { Repository } from "./base";
 import { v4 as uuid } from 'uuid';
-import { City } from "./city";
+import { CityWithLocation } from "./city";
 
 export type Army = {
     soldiers: number;
@@ -30,7 +30,7 @@ export class ArmyRepository extends Repository<ArmyQueue> {
         super('army_queue');
     }
 
-    async create(owner: string, city: City, attacked_city: City, army: Army, distance: number): Promise<ArmyQueue> {
+    async create(owner: string, city: CityWithLocation, attacked_city: CityWithLocation, army: Army, distance: number): Promise<ArmyQueue> {
         // figure out the distance to the attacked city
 
         const info: ArmyQueue = {
@@ -50,9 +50,10 @@ export class ArmyRepository extends Repository<ArmyQueue> {
 
     async listOutgoing(city_id: string): Promise<ArmyQueueWithAttackedOwner[]> {
         return await (this.db.raw(`select 
-        aq.*, o.username as attacked_account, c.location_x, c.location_y
+        aq.*, o.username as attacked_account, l.location_x, l.location_y, l.sector_id 
         from army_queue aq
         join cities c on c.id = aq.attacked_city 
+        join locations l on l.city_id = aq.attacked_city 
         join accounts o on o.id = c.owner 
         order by due asc`)) as ArmyQueueWithAttackedOwner[];
     }