module TK.SpaceTac.UI { /** * Displays and maintain a battle plan */ export class PlanDisplay { readonly container: UIContainer constructor(builder: UIBuilder) { this.container = builder.container("battleplan"); } update(plan: BattlePlan): void { this.updateBattle(plan, this.container); } private updateBattle(plan: BattlePlan, parent: UIContainer) { const builder = parent.getBuilder(); if (parent.list.length > plan.fleets.length) { builder.clear(); } while (parent.list.length < plan.fleets.length) { builder.container("fleetplan"); } iforeach(izip(plan.fleets, ifilterclass(parent.list, UIContainer)), ([fleetplan, child]) => { this.updateFleet(fleetplan, child); }); } private updateFleet(plan: FleetPlan, parent: UIContainer) { const builder = parent.getBuilder(); if (parent.list.length > plan.ships.length) { builder.clear(); } while (parent.list.length < plan.ships.length) { builder.container("shipplan"); } iforeach(izip(plan.ships, ifilterclass(parent.list, UIContainer)), ([shipplan, child]) => { this.updateShip(shipplan, child); }); } private updateShip(plan: ShipPlan, parent: UIContainer) { } } }