diff --git a/client/demo.js b/client/demo.js index d7fcebf0..a996916d 100644 --- a/client/demo.js +++ b/client/demo.js @@ -69,6 +69,7 @@ const DEMO_UNIT_DATA = { class DemoDataGenerator { constructor(app) { + this.startTime = Date.now(); app.get('/demo/units', (req, res) => this.units(req, res)); app.get('/demo/logs', (req, res) => this.logs(req, res)); app.get('/demo/bullseyes', (req, res) => this.bullseyes(req, res)); @@ -343,20 +344,37 @@ class DemoDataGenerator { }; mission(req, res){ - var ret = {mission: {theatre: "Syria"}}; - ret.time = Date.now(); + var ret = {theatre: "Nevada"}; + ret.dateAndTime = { + time: Date.now(), + date: "", + elapsedTime: (Date.now() - this.startTime) / 1000, + startTime: 0 + } + + ret.RTSOptions = { + restrictSpawns: true, + restrictToCoalition: true, + setupTime: 0, + spawnPoints: { + red: 1000, + blue: 500 + }, + eras: ["WW2", "Early Cold War", "Mid Cold War", "Late Cold War", "Modern"] + } + var auth = req.get("Authorization"); if (auth) { var username = atob(auth.replace("Basic ", "")).split(":")[0]; switch (username) { case "admin": - ret.mission.visibilityMode = "Game master"; + ret.RTSOptions.commandMode = "Game master"; break case "blue": - ret.mission.visibilityMode = "Blue commander"; + ret.RTSOptions.commandMode = "Blue commander"; break; case "red": - ret.mission.visibilityMode = "Red commander"; + ret.RTSOptions.commandMode = "Red commander"; break; } } diff --git a/client/public/stylesheets/layout/layout.css b/client/public/stylesheets/layout/layout.css index 7ae3c7b5..74680159 100644 --- a/client/public/stylesheets/layout/layout.css +++ b/client/public/stylesheets/layout/layout.css @@ -5,13 +5,24 @@ width: 100%; } -#primary-toolbar { +#toolbar-container { align-items: center; display: flex; left: 10px; position: absolute; top: 10px; z-index: 9999; + column-gap: 10px; +} + +#primary-toolbar { + align-items: center; + display: flex; +} + +#rts-toolbar { + align-items: center; + display: flex; } #app-icon>.ol-select-options { diff --git a/client/public/stylesheets/olympus.css b/client/public/stylesheets/olympus.css index f35985db..7761835e 100644 --- a/client/public/stylesheets/olympus.css +++ b/client/public/stylesheets/olympus.css @@ -865,17 +865,37 @@ nav.ol-panel> :last-child { translate: 0% -300%; } -#visibiliy-mode { +#command-mode { + font-size: 14px; + font-weight: bolder; + padding-left: 10px; +} + +#command-mode[data-mode="Blue commander"] { + color: var(--primary-blue); +} + +#command-mode[data-mode="Red commander"] { + color: var(--primary-red); +} + +#spawn-points-container { font-size: 14px; font-weight: bolder; } -#visibiliy-mode[data-mode="Blue commander"] { - color: var(--primary-blue); +#spawn-points { + background-color: var(--background-grey); + padding: 5px 15px; + margin: 5px; + border: 1px white solid; + font-size: 14px; + border-radius: var(--border-radius-sm); } -#visibiliy-mode[data-mode="Red commander"] { - color: var(--primary-red); +#rts-phase { + font-size: 14px; + font-weight: bolder; } .ol-destination-preview-icon { diff --git a/client/public/stylesheets/other/contextmenus.css b/client/public/stylesheets/other/contextmenus.css index 7e812f74..8ba49bbd 100644 --- a/client/public/stylesheets/other/contextmenus.css +++ b/client/public/stylesheets/other/contextmenus.css @@ -69,6 +69,10 @@ width: 100%; } +.deploy-unit-button[data-points]:not([data-points='']):not([data-points='0'])::after { + content: " (" attr(data-points) " points)"; +} + .upper-bar svg>* { fill: white; } diff --git a/client/src/@types/dom.d.ts b/client/src/@types/dom.d.ts index 9d260bb8..58b58175 100644 --- a/client/src/@types/dom.d.ts +++ b/client/src/@types/dom.d.ts @@ -19,6 +19,7 @@ interface CustomEventMap { "mapStateChanged": CustomEvent, "mapContextMenu": CustomEvent<>, "visibilityModeChanged": CustomEvent, + "RTSOptionsChanged": CustomEvent<>, } declare global { diff --git a/client/src/@types/server.d.ts b/client/src/@types/server.d.ts index 1f17211d..c8a5f7b6 100644 --- a/client/src/@types/server.d.ts +++ b/client/src/@types/server.d.ts @@ -1,11 +1,44 @@ interface AirbasesData { airbases: {[key: string]: any}, + sessionHash: string; + time: number; } interface BullseyesData { bullseyes: {[key: string]: {latitude: number, longitude: number, coalition: string}}, + sessionHash: string; + time: number; +} + +interface RTSOptions { + commandMode: string; + restrictSpawns: boolean; + restrictToCoalition: boolean; + setupTime: number; + spawnPoints: { + red: number, + blue: number + }, + eras: string[] +} + +interface DateAndTime { + date: {Year: number, Month: number, Day: number}; + time: {h: number, m: number, s: number}; + elapsedTime: number; + startTime: number; +} + +interface MissionData { + theatre: string, + dateAndTime: DateAndTime; + RTSOptions: RTSOptions; + time: number; + sessionHash: string; } interface LogData { logs: {[key: string]: string}, + sessionHash: string; + time: number; } \ No newline at end of file diff --git a/client/src/atc/atc.ts b/client/src/atc/atc.ts index 1597ca7e..2e5241af 100644 --- a/client/src/atc/atc.ts +++ b/client/src/atc/atc.ts @@ -1,4 +1,5 @@ -import { getMissionData } from ".."; +import { getMissionHandler } from ".."; +import { convertDateAndTimeToDate } from "../other/utils"; import { getConnected } from "../server/server"; import { ATCBoard } from "./atcboard"; import { ATCBoardGround } from "./board/ground"; @@ -140,11 +141,10 @@ export class ATC { } - getMissionDateTime() : Date { - return new Date( getMissionData().getNowDate() ); + getMissionDate() : Date { + return convertDateAndTimeToDate(getMissionHandler().getDateAndTime()); } - lookForBoards() { document.querySelectorAll( ".ol-strip-board" ).forEach( board => { diff --git a/client/src/atc/atcboard.ts b/client/src/atc/atcboard.ts index 832cd691..8ec4fd69 100644 --- a/client/src/atc/atcboard.ts +++ b/client/src/atc/atcboard.ts @@ -2,7 +2,7 @@ import { Dropdown } from "../controls/dropdown"; import { zeroAppend } from "../other/utils"; import { ATC } from "./atc"; import { Unit } from "../units/unit"; -import { getMissionData, getUnitsManager } from ".."; +import { getMissionHandler, getUnitsManager } from ".."; import Sortable from "sortablejs"; import { FlightInterface } from "./atc"; import { getConnected } from "../server/server"; @@ -442,7 +442,7 @@ export abstract class ATCBoard { timeToGo( timestamp:number ) { - const timeData = this.calculateTimeToGo( this.getATC().getMissionDateTime().getTime(), timestamp ); + const timeData = this.calculateTimeToGo( this.getATC().getMissionDate().getTime(), timestamp ); return ( timestamp === -1 ) ? "-" : timeData.elapsedMarker + timeData.time; @@ -455,8 +455,8 @@ export abstract class ATCBoard { updateClock() { - const missionTime = this.#atc.getMissionDateTime().getTime(); - const timeDiff = new Date().getTime() - getMissionData().getUpdateTime(); + const missionTime = this.#atc.getMissionDate().getTime(); + const timeDiff = new Date().getTime() - getMissionHandler().getDateAndTime().elapsedTime; const nowDate = new Date( missionTime + timeDiff ); diff --git a/client/src/atc/board/ground.ts b/client/src/atc/board/ground.ts index 2baf4862..4e5dba3d 100644 --- a/client/src/atc/board/ground.ts +++ b/client/src/atc/board/ground.ts @@ -17,7 +17,7 @@ export class ATCBoardGround extends ATCBoard { const flights = this.sortFlights( Object.values( this.getATC().getDataHandler().getFlights( this.getBoardId() ) ) ); const stripBoard = this.getStripBoardElement(); - const missionTime = this.getATC().getMissionDateTime().getTime(); + const missionTime = this.getATC().getMissionDate().getTime(); for( const strip of stripBoard.children ) { strip.toggleAttribute( "data-updating", true ); diff --git a/client/src/atc/board/tower.ts b/client/src/atc/board/tower.ts index 8800dfc2..9afcf7db 100644 --- a/client/src/atc/board/tower.ts +++ b/client/src/atc/board/tower.ts @@ -17,7 +17,7 @@ export class ATCBoardTower extends ATCBoard { update() { const flights = this.sortFlights( Object.values( this.getATC().getDataHandler().getFlights( this.getBoardId() ) ) ); - const missionTime = this.getATC().getMissionDateTime().getTime(); + const missionTime = this.getATC().getMissionDate().getTime(); const selectableUnits = getUnitsManager().getSelectableAircraft(); const stripBoard = this.getStripBoardElement(); diff --git a/client/src/controls/airbasecontextmenu.ts b/client/src/controls/airbasecontextmenu.ts index 434217bc..06f74c65 100644 --- a/client/src/controls/airbasecontextmenu.ts +++ b/client/src/controls/airbasecontextmenu.ts @@ -1,4 +1,5 @@ import { getMap, getUnitsManager, setActiveCoalition } from ".."; +import { BLUE_COMMANDER, GAME_MASTER, RED_COMMANDER } from "../constants/constants"; import { Airbase } from "../missionhandler/airbase"; import { ContextMenu } from "./contextmenu"; @@ -24,7 +25,8 @@ export class AirbaseContextMenu extends ContextMenu { this.setProperties(airbase.getProperties()); this.setParkings(airbase.getParkings()); this.setCoalition(airbase.getCoalition()); - this.enableLandButton(getUnitsManager().getSelectedUnitsTypes().length == 1 && getUnitsManager().getSelectedUnitsTypes()[0] === "Aircraft" && (getUnitsManager().getSelectedUnitsCoalition() === airbase.getCoalition() || airbase.getCoalition() === "neutral")) + this.enableLandButton(getUnitsManager().getSelectedUnitsTypes().length == 1 && ["Aircraft", "Helicopter"].includes(getUnitsManager().getSelectedUnitsTypes()[0]) && (getUnitsManager().getSelectedUnitsCoalition() === airbase.getCoalition() || airbase.getCoalition() === "neutral")) + this.enableSpawnButton(getUnitsManager().getCommandMode() == GAME_MASTER || this.#airbase.getCoalition() == getUnitsManager().getCommandedCoalition()); } setName(airbaseName: string) { @@ -53,6 +55,10 @@ export class AirbaseContextMenu extends ContextMenu { (this.getContainer()?.querySelector("#spawn-airbase-aircraft-button")).dataset.coalition = coalition; } + enableSpawnButton(enableSpawnButton: boolean) { + this.getContainer()?.querySelector("#spawn-airbase-aircraft-button")?.classList.toggle("hide", !enableSpawnButton); + } + enableLandButton(enableLandButton: boolean) { this.getContainer()?.querySelector("#land-here-button")?.classList.toggle("hide", !enableLandButton); } diff --git a/client/src/controls/coalitionareacontextmenu.ts b/client/src/controls/coalitionareacontextmenu.ts index 61e253f0..4273cf9c 100644 --- a/client/src/controls/coalitionareacontextmenu.ts +++ b/client/src/controls/coalitionareacontextmenu.ts @@ -58,6 +58,11 @@ export class CoalitionAreaContextMenu extends ContextMenu { if (area) getUnitsManager().createIADS(area, this.#getCheckboxOptions(this.#iadsTypesDropdown), this.#getCheckboxOptions(this.#iadsErasDropdown), this.#getCheckboxOptions(this.#iadsRangesDropdown), this.#iadsDensitySlider.getValue(), this.#iadsDistributionSlider.getValue()); }) + this.hide(); + } + + show(x: number, y: number, latlng: LatLng) { + super.show(x, y, latlng); /* Create the checkboxes to select the unit roles */ this.#iadsTypesDropdown.setOptionsElements(IADSTypes.map((role: string) => { @@ -75,11 +80,6 @@ export class CoalitionAreaContextMenu extends ContextMenu { return this.#createCheckboxOption(range); })); - this.hide(); - } - - show(x: number, y: number, latlng: LatLng) { - super.show(x, y, latlng); if (getUnitsManager().getCommandMode() !== GAME_MASTER) this.#coalitionSwitch.hide() } diff --git a/client/src/controls/contextmenu.ts b/client/src/controls/contextmenu.ts index 8e3261bb..11db0ed6 100644 --- a/client/src/controls/contextmenu.ts +++ b/client/src/controls/contextmenu.ts @@ -6,6 +6,7 @@ export class ContextMenu { #x: number = 0; #y: number = 0; #visibleSubMenu: string | null = null; + #hidden: boolean = true; constructor(id: string) { this.#container = document.getElementById(id); @@ -18,10 +19,12 @@ export class ContextMenu { this.#x = x; this.#y = y; this.clip(); + this.#hidden = false; } hide() { this.#container?.classList.toggle("hide", true); + this.#hidden = true; } getContainer() { @@ -40,6 +43,10 @@ export class ContextMenu { return this.#y; } + getHidden() { + return this.#hidden; + } + clip() { if (this.#container != null) { if (this.#x + this.#container.offsetWidth < window.innerWidth) diff --git a/client/src/controls/dropdown.ts b/client/src/controls/dropdown.ts index b8f490ea..e02b611b 100644 --- a/client/src/controls/dropdown.ts +++ b/client/src/controls/dropdown.ts @@ -33,6 +33,10 @@ export class Dropdown { setOptions(optionsList: string[], sortAlphabetically: boolean = true) { this.#optionsList = optionsList.sort(); + if (this.#optionsList.length == 0) { + optionsList = ["No options available"] + this.#value.innerText = "No options available"; + } this.#options.replaceChildren(...optionsList.map((option: string, idx: number) => { var div = document.createElement("div"); var button = document.createElement("button"); diff --git a/client/src/controls/mapcontextmenu.ts b/client/src/controls/mapcontextmenu.ts index b2cf335c..f91d19ed 100644 --- a/client/src/controls/mapcontextmenu.ts +++ b/client/src/controls/mapcontextmenu.ts @@ -1,6 +1,6 @@ import { LatLng } from "leaflet"; -import { getActiveCoalition, getMap, getUnitsManager, setActiveCoalition } from ".."; -import { spawnAircrafts, spawnExplosion, spawnGroundUnits, spawnHelicopters, spawnNavyUnits, spawnSmoke } from "../server/server"; +import { getActiveCoalition, getMap, getMissionHandler, getUnitsManager, setActiveCoalition } from ".."; +import { spawnExplosion, spawnSmoke } from "../server/server"; import { aircraftDatabase } from "../units/aircraftdatabase"; import { groundUnitDatabase } from "../units/groundunitdatabase"; import { helicopterDatabase } from "../units/helicopterdatabase"; @@ -16,20 +16,20 @@ import { CoalitionArea } from "../map/coalitionarea"; export class MapContextMenu extends ContextMenu { #coalitionSwitch: Switch; #aircraftRoleDropdown: Dropdown; - #aircraftNameDropdown: Dropdown; + #aircraftLabelDropdown: Dropdown; #aircraftCountDropdown: Dropdown; #aircraftLoadoutDropdown: Dropdown; #aircraftSpawnAltitudeSlider: Slider; #helicopterRoleDropdown: Dropdown; - #helicopterNameDropdown: Dropdown; + #helicopterLabelDropdown: Dropdown; #helicopterCountDropdown: Dropdown; #helicopterLoadoutDropdown: Dropdown; #helicopterSpawnAltitudeSlider: Slider; #groundUnitTypeDropdown: Dropdown; - #groundUnitNameDropdown: Dropdown; + #groundUnitLabelDropdown: Dropdown; #groundUnitCountDropdown: Dropdown; #navyUnitTypeDropdown: Dropdown; - #navyUnitNameDropdown: Dropdown; + #navyUnitLabelDropdown: Dropdown; #navyUnitCountDropdown: Dropdown; #spawnOptions = { role: "", name: "", latlng: new LatLng(0, 0), coalition: "blue", loadout: "", airbaseName: "", altitude: 0, count: 1 }; #coalitionArea: CoalitionArea | null = null; @@ -43,7 +43,7 @@ export class MapContextMenu extends ContextMenu { /* Aircraft menu */ this.#aircraftRoleDropdown = new Dropdown("aircraft-role-options", (role: string) => this.#setAircraftRole(role)); - this.#aircraftNameDropdown = new Dropdown("aircraft-type-options", (type: string) => this.#setAircraftName(type)); + this.#aircraftLabelDropdown = new Dropdown("aircraft-label-options", (type: string) => this.#setAircraftLabel(type)); this.#aircraftCountDropdown = new Dropdown("aircraft-count-options", (type: string) => this.#setAircraftCount(type)); this.#aircraftCountDropdown.setOptions(["1", "2", "3", "4"]); this.#aircraftCountDropdown.setValue("1"); @@ -55,7 +55,7 @@ export class MapContextMenu extends ContextMenu { /* Helicopter menu */ this.#helicopterRoleDropdown = new Dropdown("helicopter-role-options", (role: string) => this.#setHelicopterRole(role)); - this.#helicopterNameDropdown = new Dropdown("helicopter-type-options", (type: string) => this.#setHelicopterName(type)); + this.#helicopterLabelDropdown = new Dropdown("helicopter-label-options", (type: string) => this.#setHelicopterLabel(type)); this.#helicopterCountDropdown = new Dropdown("helicopter-count-options", (type: string) => this.#setHelicopterCount(type)); this.#helicopterCountDropdown.setOptions(["1", "2", "3", "4"]); this.#helicopterCountDropdown.setValue("1"); @@ -70,14 +70,14 @@ export class MapContextMenu extends ContextMenu { /* Ground unit menu */ this.#groundUnitTypeDropdown = new Dropdown("groundunit-type-options", (type: string) => this.#setGroundUnitType(type)); - this.#groundUnitNameDropdown = new Dropdown("groundunit-name-options", (name: string) => this.#setGroundUnitName(name)); + this.#groundUnitLabelDropdown = new Dropdown("groundunit-label-options", (name: string) => this.#setGroundUnitLabel(name)); this.#groundUnitCountDropdown = new Dropdown("groundunit-count-options", (count: string) => this.#setGroundUnitCount(count)); this.#groundUnitCountDropdown.setOptions(count); this.#groundUnitCountDropdown.setValue("1"); /* Navy unit menu */ this.#navyUnitTypeDropdown = new Dropdown("navyunit-type-options", (type: string) => this.#setNavyUnitType(type)); - this.#navyUnitNameDropdown = new Dropdown("navyunit-name-options", (name: string) => this.#setNavyUnitName(name)); + this.#navyUnitLabelDropdown = new Dropdown("navyunit-label-options", (name: string) => this.#setNavyUnitLabel(name)); this.#navyUnitCountDropdown = new Dropdown("navyunit-count-options", (count: string) => this.#setNavyUnitCount(count)); this.#navyUnitCountDropdown.setOptions(count); this.#navyUnitCountDropdown.setValue("1"); @@ -90,60 +90,65 @@ export class MapContextMenu extends ContextMenu { }); document.addEventListener("contextMenuDeployAircrafts", () => { - this.hide(); + this.#spawnOptions.coalition = getActiveCoalition(); if (this.#spawnOptions) { - getMap().addTemporaryMarker(this.#spawnOptions.latlng, this.#spawnOptions.name, getActiveCoalition()); var unitTable = {unitType: this.#spawnOptions.name, location: this.#spawnOptions.latlng, altitude: this.#spawnOptions.altitude, loadout: this.#spawnOptions.loadout}; var units = []; for (let i = 1; i < parseInt(this.#aircraftCountDropdown.getValue()) + 1; i++) { units.push(unitTable); } - spawnAircrafts(units, getActiveCoalition(), this.#spawnOptions.airbaseName, false); + if (getUnitsManager().spawnUnits("Aircraft", units, getActiveCoalition(), false, this.#spawnOptions.airbaseName)) { + getMap().addTemporaryMarker(this.#spawnOptions.latlng, this.#spawnOptions.name, getActiveCoalition()); + this.hide(); + } } }); document.addEventListener("contextMenuDeployHelicopters", () => { - this.hide(); this.#spawnOptions.coalition = getActiveCoalition(); if (this.#spawnOptions) { - getMap().addTemporaryMarker(this.#spawnOptions.latlng, this.#spawnOptions.name, getActiveCoalition()); var unitTable = {unitType: this.#spawnOptions.name, location: this.#spawnOptions.latlng, altitude: this.#spawnOptions.altitude, loadout: this.#spawnOptions.loadout}; var units = []; for (let i = 1; i < parseInt(this.#helicopterCountDropdown.getValue()) + 1; i++) { units.push(unitTable); } - spawnHelicopters(units, getActiveCoalition(), this.#spawnOptions.airbaseName, false); + if (getUnitsManager().spawnUnits("Helicopter", units, getActiveCoalition(), false, this.#spawnOptions.airbaseName)) { + getMap().addTemporaryMarker(this.#spawnOptions.latlng, this.#spawnOptions.name, getActiveCoalition()); + this.hide(); + } } }); document.addEventListener("contextMenuDeployGroundUnits", () => { - this.hide(); this.#spawnOptions.coalition = getActiveCoalition(); if (this.#spawnOptions) { - getMap().addTemporaryMarker(this.#spawnOptions.latlng, this.#spawnOptions.name, getActiveCoalition()); var unitTable = {unitType: this.#spawnOptions.name, location: this.#spawnOptions.latlng}; var units = []; for (let i = 1; i < parseInt(this.#groundUnitCountDropdown.getValue()) + 1; i++) { units.push(JSON.parse(JSON.stringify(unitTable))); unitTable.location.lat += 0.0001; } - spawnGroundUnits(units, getActiveCoalition(), false); + if (getUnitsManager().spawnUnits("GroundUnit", units, getActiveCoalition(), false)) { + getMap().addTemporaryMarker(this.#spawnOptions.latlng, this.#spawnOptions.name, getActiveCoalition()); + this.hide(); + } } }); document.addEventListener("contextMenuDeployNavyUnits", () => { - this.hide(); this.#spawnOptions.coalition = getActiveCoalition(); if (this.#spawnOptions) { - getMap().addTemporaryMarker(this.#spawnOptions.latlng, this.#spawnOptions.name, getActiveCoalition()); var unitTable = {unitType: this.#spawnOptions.name, location: this.#spawnOptions.latlng}; var units = []; for (let i = 1; i < parseInt(this.#navyUnitCountDropdown.getValue()) + 1; i++) { units.push(JSON.parse(JSON.stringify(unitTable))); unitTable.location.lat += 0.0001; } - spawnNavyUnits(units, getActiveCoalition(), false); + if (getUnitsManager().spawnUnits("NavyUnit", units, getActiveCoalition(), false)) { + getMap().addTemporaryMarker(this.#spawnOptions.latlng, this.#spawnOptions.name, getActiveCoalition()); + this.hide(); + } } }); @@ -165,17 +170,22 @@ export class MapContextMenu extends ContextMenu { } }); + document.addEventListener("RTSOptionsChanged", (e: any) => { + this.#refreshOptions(); + }); + this.hide(); } show(x: number, y: number, latlng: LatLng) { - this.#spawnOptions.airbaseName = ""; super.show(x, y, latlng); - this.#spawnOptions.latlng = latlng; this.showUpperBar(); this.showAltitudeSlider(); + this.#spawnOptions.airbaseName = ""; + this.#spawnOptions.latlng = latlng; + this.getContainer()?.querySelectorAll('[data-coalition]').forEach((element: any) => { element.setAttribute("data-coalition", getActiveCoalition()) }); if (getActiveCoalition() == "blue") this.#coalitionSwitch.setValue(false); @@ -210,13 +220,13 @@ export class MapContextMenu extends ContextMenu { this.getContainer()?.querySelector("#explosion-spawn-button")?.classList.toggle("is-open", type === "explosion"); this.#resetAircraftRole(); - this.#resetAircraftName(); + this.#resetAircraftLabel(); this.#resetHelicopterRole(); - this.#resetHelicopterName(); + this.#resetHelicopterLabel(); this.#resetGroundUnitType(); - this.#resetGroundUnitName(); + this.#resetGroundUnitLabel(); this.#resetNavyUnitType(); - this.#resetNavyUnitName(); + this.#resetNavyUnitLabel(); this.#aircraftCountDropdown.setValue("1"); this.#helicopterCountDropdown.setValue("1"); this.#groundUnitCountDropdown.setValue("1"); @@ -248,15 +258,15 @@ export class MapContextMenu extends ContextMenu { this.getContainer()?.querySelector("#explosion-spawn-button")?.classList.toggle("is-open", false); this.#resetAircraftRole(); - this.#resetAircraftName(); + this.#resetAircraftLabel(); this.#resetHelicopterRole(); - this.#resetHelicopterName(); + this.#resetHelicopterLabel(); this.#resetHelicopterRole(); - this.#resetHelicopterName(); + this.#resetHelicopterLabel(); this.#resetGroundUnitType(); - this.#resetGroundUnitName(); + this.#resetGroundUnitLabel(); this.#resetNavyUnitType(); - this.#resetNavyUnitName(); + this.#resetNavyUnitLabel(); this.clip(); this.setVisibleSubMenu(null); @@ -310,26 +320,49 @@ export class MapContextMenu extends ContextMenu { this.getContainer()?.querySelectorAll('[data-coalition]').forEach((element: any) => { element.setAttribute("data-coalition", getActiveCoalition()) }); } + #refreshOptions() { + if (!aircraftDatabase.getRoles().includes(this.#aircraftRoleDropdown.getValue())) + this.#resetAircraftRole(); + if (!aircraftDatabase.getByRole(this.#aircraftRoleDropdown.getValue()).map((blueprint) => { return blueprint.label }).includes(this.#aircraftLabelDropdown.getValue())) + this.#resetAircraftLabel(); + + if (!helicopterDatabase.getRoles().includes(this.#helicopterRoleDropdown.getValue())) + this.#resetHelicopterRole(); + if (!helicopterDatabase.getByRole(this.#helicopterRoleDropdown.getValue()).map((blueprint) => { return blueprint.label }).includes(this.#helicopterLabelDropdown.getValue())) + this.#resetHelicopterLabel(); + + if (!groundUnitDatabase.getRoles().includes(this.#groundUnitTypeDropdown.getValue())) + this.#resetGroundUnitType(); + if (!groundUnitDatabase.getByType(this.#groundUnitTypeDropdown.getValue()).map((blueprint) => { return blueprint.label }).includes(this.#groundUnitLabelDropdown.getValue())) + this.#resetGroundUnitLabel(); + + if (!navyUnitDatabase.getRoles().includes(this.#navyUnitTypeDropdown.getValue())) + this.#resetNavyUnitType(); + if (!navyUnitDatabase.getByType(this.#navyUnitTypeDropdown.getValue()).map((blueprint) => { return blueprint.label }).includes(this.#aircraftLabelDropdown.getValue())) + this.#resetNavyUnitLabel(); + } + /********* Aircraft spawn menu *********/ #setAircraftRole(role: string) { this.#spawnOptions.role = role; - this.#resetAircraftName(); - this.#aircraftNameDropdown.setOptions(aircraftDatabase.getByRole(role).map((blueprint) => { return blueprint.label })); - this.#aircraftNameDropdown.selectValue(0); + this.#resetAircraftLabel(); + this.#aircraftLabelDropdown.setOptions(aircraftDatabase.getByRole(role).map((blueprint) => { return blueprint.label })); + this.#aircraftLabelDropdown.selectValue(0); this.clip(); + this.#computeSpawnPoints(); } #resetAircraftRole() { (this.getContainer()?.querySelector("#aircraft-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = true; (this.getContainer()?.querySelector("#aircraft-loadout-list")).replaceChildren(); this.#aircraftRoleDropdown.reset(); - this.#aircraftNameDropdown.reset(); + this.#aircraftLabelDropdown.reset(); this.#aircraftRoleDropdown.setOptions(aircraftDatabase.getRoles()); this.clip(); } - #setAircraftName(label: string) { - this.#resetAircraftName(); + #setAircraftLabel(label: string) { + this.#resetAircraftLabel(); var name = aircraftDatabase.getByLabel(label)?.name || null; if (name != null) { this.#spawnOptions.name = name; @@ -340,9 +373,10 @@ export class MapContextMenu extends ContextMenu { image.classList.toggle("hide", false); } this.clip(); + this.#computeSpawnPoints(); } - #resetAircraftName() { + #resetAircraftLabel() { (this.getContainer()?.querySelector("#aircraft-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = true; (this.getContainer()?.querySelector("#aircraft-loadout-list")).replaceChildren(); this.#aircraftLoadoutDropdown.reset(); @@ -353,6 +387,7 @@ export class MapContextMenu extends ContextMenu { #setAircraftCount(count: string) { this.#spawnOptions.count = parseInt(count); this.clip(); + this.#computeSpawnPoints(); } #setAircraftLoadout(loadoutName: string) { @@ -376,23 +411,24 @@ export class MapContextMenu extends ContextMenu { /********* Helicopter spawn menu *********/ #setHelicopterRole(role: string) { this.#spawnOptions.role = role; - this.#resetHelicopterName(); - this.#helicopterNameDropdown.setOptions(helicopterDatabase.getByRole(role).map((blueprint) => { return blueprint.label })); - this.#helicopterNameDropdown.selectValue(0); + this.#resetHelicopterLabel(); + this.#helicopterLabelDropdown.setOptions(helicopterDatabase.getByRole(role).map((blueprint) => { return blueprint.label })); + this.#helicopterLabelDropdown.selectValue(0); this.clip(); + this.#computeSpawnPoints(); } #resetHelicopterRole() { (this.getContainer()?.querySelector("#helicopter-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = true; (this.getContainer()?.querySelector("#helicopter-loadout-list")).replaceChildren(); this.#helicopterRoleDropdown.reset(); - this.#helicopterNameDropdown.reset(); + this.#helicopterLabelDropdown.reset(); this.#helicopterRoleDropdown.setOptions(helicopterDatabase.getRoles()); this.clip(); } - #setHelicopterName(label: string) { - this.#resetHelicopterName(); + #setHelicopterLabel(label: string) { + this.#resetHelicopterLabel(); var name = helicopterDatabase.getByLabel(label)?.name || null; if (name != null) { this.#spawnOptions.name = name; @@ -403,9 +439,10 @@ export class MapContextMenu extends ContextMenu { image.classList.toggle("hide", false); } this.clip(); + this.#computeSpawnPoints(); } - #resetHelicopterName() { + #resetHelicopterLabel() { (this.getContainer()?.querySelector("#helicopter-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = true; (this.getContainer()?.querySelector("#helicopter-loadout-list")).replaceChildren(); this.#helicopterLoadoutDropdown.reset(); @@ -416,6 +453,7 @@ export class MapContextMenu extends ContextMenu { #setHelicopterCount(count: string) { this.#spawnOptions.count = parseInt(count); this.clip(); + this.#computeSpawnPoints(); } #setHelicopterLoadout(loadoutName: string) { @@ -438,35 +476,37 @@ export class MapContextMenu extends ContextMenu { /********* Groundunit spawn menu *********/ #setGroundUnitType(role: string) { - this.#resetGroundUnitName(); + this.#resetGroundUnitLabel(); const types = groundUnitDatabase.getByType(role).map((blueprint) => { return blueprint.label }); - this.#groundUnitNameDropdown.setOptions(types); - this.#groundUnitNameDropdown.selectValue(0); + this.#groundUnitLabelDropdown.setOptions(types); + this.#groundUnitLabelDropdown.selectValue(0); this.clip(); + this.#computeSpawnPoints(); } #resetGroundUnitType() { (this.getContainer()?.querySelector("#groundunit-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = true; this.#groundUnitTypeDropdown.reset(); - this.#groundUnitNameDropdown.reset(); + this.#groundUnitLabelDropdown.reset(); const types = groundUnitDatabase.getTypes(); this.#groundUnitTypeDropdown.setOptions(types); this.clip(); } - #setGroundUnitName(label: string) { - this.#resetGroundUnitName(); + #setGroundUnitLabel(label: string) { + this.#resetGroundUnitLabel(); var type = groundUnitDatabase.getByLabel(label)?.name || null; if (type != null) { this.#spawnOptions.name = type; (this.getContainer()?.querySelector("#groundunit-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = false; } this.clip(); + this.#computeSpawnPoints(); } - #resetGroundUnitName() { + #resetGroundUnitLabel() { (this.getContainer()?.querySelector("#groundunit-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = true; this.clip(); } @@ -474,39 +514,42 @@ export class MapContextMenu extends ContextMenu { #setGroundUnitCount(count: string) { this.#spawnOptions.count = parseInt(count); this.clip(); + this.#computeSpawnPoints(); } /********* Navyunit spawn menu *********/ #setNavyUnitType(role: string) { - this.#resetNavyUnitName(); + this.#resetNavyUnitLabel(); const types = navyUnitDatabase.getByType(role).map((blueprint) => { return blueprint.label }); - this.#navyUnitNameDropdown.setOptions(types); - this.#navyUnitNameDropdown.selectValue(0); + this.#navyUnitLabelDropdown.setOptions(types); + this.#navyUnitLabelDropdown.selectValue(0); this.clip(); + this.#computeSpawnPoints(); } #resetNavyUnitType() { (this.getContainer()?.querySelector("#navyunit-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = true; this.#navyUnitTypeDropdown.reset(); - this.#navyUnitNameDropdown.reset(); + this.#navyUnitLabelDropdown.reset(); const types = navyUnitDatabase.getTypes(); this.#navyUnitTypeDropdown.setOptions(types); this.clip(); } - #setNavyUnitName(label: string) { - this.#resetNavyUnitName(); + #setNavyUnitLabel(label: string) { + this.#resetNavyUnitLabel(); var type = navyUnitDatabase.getByLabel(label)?.name || null; if (type != null) { this.#spawnOptions.name = type; (this.getContainer()?.querySelector("#navyunit-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = false; } this.clip(); + this.#computeSpawnPoints(); } - #resetNavyUnitName() { + #resetNavyUnitLabel() { (this.getContainer()?.querySelector("#navyunit-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = true; this.clip(); } @@ -514,5 +557,30 @@ export class MapContextMenu extends ContextMenu { #setNavyUnitCount(count: string) { this.#spawnOptions.count = parseInt(count); this.clip(); + this.#computeSpawnPoints(); + } + + #computeSpawnPoints() { + if (getMissionHandler()){ + var aircraftCount = parseInt(this.#aircraftCountDropdown.getValue()); + var aircraftSpawnPoints = aircraftCount * aircraftDatabase.getSpawnPointsByLabel(this.#aircraftLabelDropdown.getValue()); + (this.getContainer()?.querySelector("#aircraft-spawn-menu")?.querySelector(".deploy-unit-button")).dataset.points = `${aircraftSpawnPoints}`; + (this.getContainer()?.querySelector("#aircraft-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = aircraftSpawnPoints > getMissionHandler().getAvailableSpawnPoints(); + + var helicopterCount = parseInt(this.#helicopterCountDropdown.getValue()); + var helicopterSpawnPoints = helicopterCount * helicopterDatabase.getSpawnPointsByLabel(this.#helicopterLabelDropdown.getValue()); + (this.getContainer()?.querySelector("#helicopter-spawn-menu")?.querySelector(".deploy-unit-button")).dataset.points = `${helicopterSpawnPoints}`; + (this.getContainer()?.querySelector("#helicopter-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = helicopterSpawnPoints > getMissionHandler().getAvailableSpawnPoints(); + + var groundUnitCount = parseInt(this.#groundUnitCountDropdown.getValue()); + var groundUnitSpawnPoints = groundUnitCount * groundUnitDatabase.getSpawnPointsByLabel(this.#groundUnitLabelDropdown.getValue()); + (this.getContainer()?.querySelector("#groundunit-spawn-menu")?.querySelector(".deploy-unit-button")).dataset.points = `${groundUnitSpawnPoints}`; + (this.getContainer()?.querySelector("#groundunit-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = groundUnitSpawnPoints > getMissionHandler().getAvailableSpawnPoints(); + + var navyUnitCount = parseInt(this.#navyUnitCountDropdown.getValue()); + var navyUnitSpawnPoints = navyUnitCount * navyUnitDatabase.getSpawnPointsByLabel(this.#navyUnitLabelDropdown.getValue()); + (this.getContainer()?.querySelector("#navyunit-spawn-menu")?.querySelector(".deploy-unit-button")).dataset.points = `${navyUnitSpawnPoints}`; + (this.getContainer()?.querySelector("#navyunit-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = navyUnitSpawnPoints > getMissionHandler().getAvailableSpawnPoints(); + } } } \ No newline at end of file diff --git a/client/src/index.ts b/client/src/index.ts index 07787e68..97a8718e 100644 --- a/client/src/index.ts +++ b/client/src/index.ts @@ -211,10 +211,6 @@ export function getMap() { return map; } -export function getMissionData() { - return missionHandler; -} - export function getUnitDataTable() { return unitDataTable; } diff --git a/client/src/map/coalitionarea.ts b/client/src/map/coalitionarea.ts index 10efb786..102413ad 100644 --- a/client/src/map/coalitionarea.ts +++ b/client/src/map/coalitionarea.ts @@ -23,11 +23,8 @@ export class CoalitionArea extends Polygon { this.#setColors(); this.#registerCallbacks(); - if (getUnitsManager().getCommandMode() == BLUE_COMMANDER) - this.setCoalition("blue"); - else if (getUnitsManager().getCommandMode() == RED_COMMANDER) - this.setCoalition("red"); - + if ([BLUE_COMMANDER, RED_COMMANDER].includes(getUnitsManager().getCommandMode())) + this.setCoalition(getUnitsManager().getCommandedCoalition()); } setCoalition(coalition: string) { diff --git a/client/src/missionhandler/missionhandler.ts b/client/src/missionhandler/missionhandler.ts index 48fd98d5..426051c5 100644 --- a/client/src/missionhandler/missionhandler.ts +++ b/client/src/missionhandler/missionhandler.ts @@ -2,91 +2,74 @@ import { LatLng } from "leaflet"; import { getInfoPopup, getMap, getUnitsManager } from ".."; import { Airbase } from "./airbase"; import { Bullseye } from "./bullseye"; +import { BLUE_COMMANDER, GAME_MASTER, RED_COMMANDER } from "../constants/constants"; export class MissionHandler { #bullseyes: { [name: string]: Bullseye } = {}; #airbases: { [name: string]: Airbase } = {}; #theatre: string = ""; - - #airbaseData: { [name: string]: object } = {}; - - // Time - #date: any; - #elapsedTime: any; - #startTime: any; - #time: any; - - #updateTime: any; + #dateAndTime: DateAndTime = {date: {Year: 0, Month: 0, Day: 0}, time: {h: 0, m: 0, s: 0}, startTime: 0, elapsedTime: 0}; + #RTSOptions: RTSOptions = {commandMode: "Hide all", restrictSpawns: false, restrictToCoalition: false, setupTime: Infinity, spawnPoints: {red: Infinity, blue: Infinity}, eras: []}; + #remainingSetupTime: number = 0; + #spentSpawnPoint: number = 0; constructor() { } - update(data: BullseyesData | AirbasesData | any) { - if ("bullseyes" in data) { - for (let idx in data.bullseyes) { - const bullseye = data.bullseyes[idx]; - if (!(idx in this.#bullseyes)) - this.#bullseyes[idx] = new Bullseye([0, 0]).addTo(getMap()); + updateBullseyes(data: BullseyesData) { + for (let idx in data.bullseyes) { + const bullseye = data.bullseyes[idx]; + if (!(idx in this.#bullseyes)) + this.#bullseyes[idx] = new Bullseye([0, 0]).addTo(getMap()); - if (bullseye.latitude && bullseye.longitude && bullseye.coalition) { - this.#bullseyes[idx].setLatLng(new LatLng(bullseye.latitude, bullseye.longitude)); - this.#bullseyes[idx].setCoalition(bullseye.coalition); - } + if (bullseye.latitude && bullseye.longitude && bullseye.coalition) { + this.#bullseyes[idx].setLatLng(new LatLng(bullseye.latitude, bullseye.longitude)); + this.#bullseyes[idx].setCoalition(bullseye.coalition); } } + } - if ("mission" in data) { - if (data.mission != null && data.mission.theatre != this.#theatre) { - this.#theatre = data.mission.theatre; - getMap().setTheatre(this.#theatre); - - getInfoPopup().setText("Map set to " + this.#theatre); - } - } - - if ("airbases" in data) { - for (let idx in data.airbases) { - var airbase = data.airbases[idx] - if (this.#airbases[idx] === undefined && airbase.callsign != '') { - this.#airbases[idx] = new Airbase({ - position: new LatLng(airbase.latitude, airbase.longitude), - name: airbase.callsign - }).addTo(getMap()); - this.#airbases[idx].on('contextmenu', (e) => this.#onAirbaseClick(e)); - } - - if (this.#airbases[idx] != undefined && airbase.latitude && airbase.longitude && airbase.coalition) { - this.#airbases[idx].setLatLng(new LatLng(airbase.latitude, airbase.longitude)); - this.#airbases[idx].setCoalition(airbase.coalition); - } - //this.#airbases[idx].setProperties(["Runway 1: 31L / 13R", "Runway 2: 31R / 13L", "TCN: 17X", "ILS: ---" ]); - //this.#airbases[idx].setParkings(["2x big", "5x small"]); - } - } - - if ("mission" in data && data.mission != null) { - if (data.mission != null && data.mission.theatre != this.#theatre) { - this.#theatre = data.mission.theatre; - getMap().setTheatre(this.#theatre); - getInfoPopup().setText("Map set to " + this.#theatre); + updateAirbases(data: AirbasesData) { + for (let idx in data.airbases) { + var airbase = data.airbases[idx] + if (this.#airbases[idx] === undefined && airbase.callsign != '') { + this.#airbases[idx] = new Airbase({ + position: new LatLng(airbase.latitude, airbase.longitude), + name: airbase.callsign + }).addTo(getMap()); + this.#airbases[idx].on('contextmenu', (e) => this.#onAirbaseClick(e)); } - if ("visibilityMode" in data.mission) - getUnitsManager().setVisibilityMode(data.mission.visibilityMode); + if (this.#airbases[idx] != undefined && airbase.latitude && airbase.longitude && airbase.coalition) { + this.#airbases[idx].setLatLng(new LatLng(airbase.latitude, airbase.longitude)); + this.#airbases[idx].setCoalition(airbase.coalition); + } + } + } - if ("date" in data.mission) - this.#date = data.mission.date; - if ("elapsedTime" in data.mission) - this.#elapsedTime = data.mission.elapsedTime; - if ("startTime" in data.mission) - this.#startTime = data.mission.startTime; - if ("time" in data.mission) - this.#time = data.mission.time; + updateMission(data: MissionData) { + if (data.theatre != this.#theatre) { + this.#theatre = data.theatre; + getMap().setTheatre(this.#theatre); + getInfoPopup().setText("Map set to " + this.#theatre); } - if ("time" in data) - this.#updateTime = data.time; + this.#dateAndTime = data.dateAndTime; + + this.#setRTSOptions(data.RTSOptions); + getUnitsManager().setCommandMode(this.#RTSOptions.commandMode); + + this.#remainingSetupTime = this.#RTSOptions.setupTime - this.getDateAndTime().elapsedTime; + var RTSPhaseEl = document.querySelector("#rts-phase"); + if (RTSPhaseEl) { + if (this.#remainingSetupTime > 0) { + var remainingTime = `Time to start: -${new Date(this.#remainingSetupTime * 1000).toISOString().substring(14, 19)}`; + RTSPhaseEl.textContent = remainingTime; + } else { + RTSPhaseEl.textContent = "FIGHT"; + } + } } getBullseyes() { @@ -97,36 +80,54 @@ export class MissionHandler { return this.#airbases; } - getDate() { - return this.#date; + getRTSOptions() { + return this.#RTSOptions; } - getNowDate() { + getDateAndTime() { + return this.#dateAndTime; + } - const date = this.getDate(); - const time = this.getTime(); + getRemainingSetupTime() { + return this.#remainingSetupTime; + } - if (!date) { - return new Date(); + getAvailableSpawnPoints() { + if (getUnitsManager().getCommandMode() === GAME_MASTER) + return Infinity; + else if (getUnitsManager().getCommandMode() === BLUE_COMMANDER) + return this.getRTSOptions().spawnPoints.blue - this.#spentSpawnPoint; + else if (getUnitsManager().getCommandMode() === RED_COMMANDER) + return this.getRTSOptions().spawnPoints.red - this.#spentSpawnPoint; + else + return 0; + } + + refreshSpawnPoints() { + var spawnPointsEl = document.querySelector("#spawn-points"); + if (spawnPointsEl) { + spawnPointsEl.textContent = `${this.getAvailableSpawnPoints()}`; } - - let year = date.Year; - let month = date.Month - 1; - - if (month < 0) { - month = 11; - year--; - } - - return new Date(year, month, date.Day, time.h, time.m, time.s); } - getTime() { - return this.#time; + setSpentSpawnPoints(spawnPoints: number) { + this.#spentSpawnPoint = spawnPoints; + this.refreshSpawnPoints(); } - getUpdateTime() { - return this.#updateTime; + #setRTSOptions(RTSOptions: RTSOptions) { + var RTSOptionsChanged = (!RTSOptions.eras.every((value: string, idx: number) => {return value === this.#RTSOptions.eras[idx]}) || + RTSOptions.spawnPoints.red !== this.#RTSOptions.spawnPoints.red || + RTSOptions.spawnPoints.blue !== this.#RTSOptions.spawnPoints.blue || + RTSOptions.restrictSpawns !== this.#RTSOptions.restrictSpawns || + RTSOptions.restrictToCoalition !== this.#RTSOptions.restrictToCoalition); + + this.#RTSOptions = RTSOptions; + this.setSpentSpawnPoints(0); + this.refreshSpawnPoints(); + + if (RTSOptionsChanged) + document.dispatchEvent(new CustomEvent("RTSOptionsChanged", { detail: this })); } #onAirbaseClick(e: any) { diff --git a/client/src/other/utils.ts b/client/src/other/utils.ts index de64dab7..510db6b8 100644 --- a/client/src/other/utils.ts +++ b/client/src/other/utils.ts @@ -264,9 +264,7 @@ export function randomUnitBlueprint(unitDatabase: UnitDatabase, options: {type?: if (options.eras) { unitBlueprints = unitBlueprints.filter((unitBlueprint: UnitBlueprint) => { //@ts-ignore - return options.eras.reduce((value, era) => { - return value? value: unitBlueprint.era.includes(era); - }, false); + return unitBlueprint.era? options.eras.includes(unitBlueprint.era): true; }); } @@ -338,4 +336,23 @@ export function enumToCoalition(coalitionID: number) { case 2: return "blue"; } return ""; +} + +export function convertDateAndTimeToDate(dateAndTime: DateAndTime) { + const date = dateAndTime.date; + const time = dateAndTime.time; + + if (!date) { + return new Date(); + } + + let year = date.Year; + let month = date.Month - 1; + + if (month < 0) { + month = 11; + year--; + } + + return new Date(year, month, date.Day, time.h, time.m, time.s); } \ No newline at end of file diff --git a/client/src/panels/mouseinfopanel.ts b/client/src/panels/mouseinfopanel.ts index 3a09436f..d1beeaef 100644 --- a/client/src/panels/mouseinfopanel.ts +++ b/client/src/panels/mouseinfopanel.ts @@ -1,5 +1,5 @@ import { Icon, LatLng, Marker, Polyline } from "leaflet"; -import { getMap, getMissionData, getUnitsManager } from ".."; +import { getMap, getMissionHandler, getUnitsManager } from ".."; import { distance, bearing, zeroAppend, mToNm, nmToFt } from "../other/utils"; import { Unit } from "../units/unit"; import { Panel } from "./panel"; @@ -44,7 +44,7 @@ export class MouseInfoPanel extends Panel { this.getElement().querySelector(`#measuring-tool`)?.classList.toggle("hide", this.#measurePoint === null && selectedUnitPosition === null); - var bullseyes = getMissionData().getBullseyes(); + var bullseyes = getMissionHandler().getBullseyes(); for (let idx in bullseyes) this.#drawMeasure(null, `bullseye-${idx}`, bullseyes[idx].getLatLng(), mousePosition); diff --git a/client/src/server/server.ts b/client/src/server/server.ts index 26841dfb..f4d0624a 100644 --- a/client/src/server/server.ts +++ b/client/src/server/server.ts @@ -1,5 +1,5 @@ import { LatLng } from 'leaflet'; -import { getConnectionStatusPanel, getInfoPopup, getMissionData, getUnitDataTable, getUnitsManager, setLoginStatus } from '..'; +import { getConnectionStatusPanel, getInfoPopup, getMissionHandler, getUnitDataTable, getUnitsManager, setLoginStatus } from '..'; import { GeneralSettings, Radio, TACAN } from '../@types/unit'; import { ROEs, emissionsCountermeasures, reactionsToThreat } from '../constants/constants'; @@ -145,26 +145,26 @@ export function spawnExplosion(intensity: number, latlng: LatLng) { POST(data, () => { }); } -export function spawnAircrafts(units: any, coalition: string, airbaseName: string, immediate: boolean) { - var command = { "units": units, "coalition": coalition, "airbaseName": airbaseName, "immediate": immediate }; +export function spawnAircrafts(units: any, coalition: string, airbaseName: string, immediate: boolean, spawnPoints: number) { + var command = { "units": units, "coalition": coalition, "airbaseName": airbaseName, "immediate": immediate, "spawnPoints": spawnPoints }; var data = { "spawnAircrafts": command } POST(data, () => { }); } -export function spawnHelicopters(units: any, coalition: string, airbaseName: string, immediate: boolean) { - var command = { "units": units, "coalition": coalition, "airbaseName": airbaseName, "immediate": immediate }; +export function spawnHelicopters(units: any, coalition: string, airbaseName: string, immediate: boolean, spawnPoints: number) { + var command = { "units": units, "coalition": coalition, "airbaseName": airbaseName, "immediate": immediate, "spawnPoints": spawnPoints }; var data = { "spawnHelicopters": command } POST(data, () => { }); } -export function spawnGroundUnits(units: any, coalition: string, immediate: boolean) { - var command = { "units": units, "coalition": coalition, "immediate": immediate }; +export function spawnGroundUnits(units: any, coalition: string, immediate: boolean, spawnPoints: number) { + var command = { "units": units, "coalition": coalition, "immediate": immediate, "spawnPoints": spawnPoints };; var data = { "spawnGroundUnits": command } POST(data, () => { }); } -export function spawnNavyUnits(units: any, coalition: string, immediate: boolean) { - var command = { "units": units, "coalition": coalition, "immediate": immediate }; +export function spawnNavyUnits(units: any, coalition: string, immediate: boolean, spawnPoints: number) { + var command = { "units": units, "coalition": coalition, "immediate": immediate, "spawnPoints": spawnPoints }; var data = { "spawnNavyUnits": command } POST(data, () => { }); } @@ -320,13 +320,6 @@ export function setAdvacedOptions(ID: number, isTanker: boolean, isAWACS: boolea } export function startUpdate() { - /* On the first connection, force request of full data */ - getAirbases((data: AirbasesData) => getMissionData()?.update(data)); - getBullseye((data: BullseyesData) => getMissionData()?.update(data)); - getMission((data: any) => { - getMissionData()?.update(data); - checkSessionHash(data.sessionHash); - }); getUnits((buffer: ArrayBuffer) => getUnitsManager()?.update(buffer), true /* Does a full refresh */); requestUpdate(); @@ -346,11 +339,17 @@ export function requestUpdate() { export function requestRefresh() { /* Main refresh rate = 5000ms. */ if (!getPaused()) { - getAirbases((data: AirbasesData) => getMissionData()?.update(data)); - getBullseye((data: BullseyesData) => getMissionData()?.update(data)); - getMission((data: any) => { + getAirbases((data: AirbasesData) => { checkSessionHash(data.sessionHash); - getMissionData()?.update(data) + getMissionHandler()?.updateAirbases(data); + }); + getBullseye((data: BullseyesData) => { + checkSessionHash(data.sessionHash); + getMissionHandler()?.updateBullseyes(data); + }); + getMission((data: MissionData) => { + checkSessionHash(data.sessionHash); + getMissionHandler()?.updateMission(data); }); // Update the list of existing units diff --git a/client/src/units/aircraftdatabase.ts b/client/src/units/aircraftdatabase.ts index 3ddbb643..9d1fa206 100644 --- a/client/src/units/aircraftdatabase.ts +++ b/client/src/units/aircraftdatabase.ts @@ -1,12 +1,15 @@ +import { getUnitsManager } from ".."; +import { GAME_MASTER } from "../constants/constants"; import { UnitDatabase } from "./unitdatabase" export class AircraftDatabase extends UnitDatabase { constructor() { super(); + this.blueprints = { "A-10C_2": { "name": "A-10C_2", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "A-10C Warthog", "shortLabel": "10", @@ -109,7 +112,7 @@ export class AircraftDatabase extends UnitDatabase { }, "AJS37": { "name": "AJS37", - "coalition": "Blue", + "coalition": "blue", "label": "AJS37 Viggen", "era": "Mid Cold War", "shortLabel": "37", @@ -192,7 +195,7 @@ export class AircraftDatabase extends UnitDatabase { }, "AV8BNA": { "name": "AV8BNA", - "coalition": "Blue", + "coalition": "blue", "label": "AV8BNA Harrier", "era": "Late Cold War", "shortLabel": "8", @@ -261,7 +264,7 @@ export class AircraftDatabase extends UnitDatabase { }, "C-101CC": { "name": "C-101CC", - "coalition": "Blue", + "coalition": "blue", "label": "C-101CC", "era": "Late Cold War", "shortLabel": "101", @@ -326,7 +329,7 @@ export class AircraftDatabase extends UnitDatabase { }, "H-6J": { "name": "H-6J", - "coalition": "Red", + "coalition": "red", "label": "H-6J Badger", "era": "Mid Cold War", "shortLabel": "H6", @@ -364,7 +367,7 @@ export class AircraftDatabase extends UnitDatabase { }, "J-11A": { "name": "J-11A", - "coalition": "Red", + "coalition": "red", "label": "J-11A Flaming Dragon", "era": "Modern", "shortLabel": "11", @@ -439,7 +442,7 @@ export class AircraftDatabase extends UnitDatabase { }, "JF-17": { "name": "JF-17", - "coalition": "Red", + "coalition": "red", "label": "JF-17 Thunder", "era": "Modern", "shortLabel": "17", @@ -534,7 +537,7 @@ export class AircraftDatabase extends UnitDatabase { }, "F-16C_50": { "name": "F-16C_50", - "coalition": "Blue", + "coalition": "blue", "label": "F-16C Viper", "era": "Late Cold War", "shortLabel": "16", @@ -645,7 +648,7 @@ export class AircraftDatabase extends UnitDatabase { }, "F-5E-3": { "name": "F-5E-3", - "coalition": "Blue", + "coalition": "blue", "label": "F-5E Tiger", "era": "Mid Cold War", "shortLabel": "5", @@ -706,7 +709,7 @@ export class AircraftDatabase extends UnitDatabase { }, "F-86F Sabre": { "name": "F-86F Sabre", - "coalition": "Blue", + "coalition": "blue", "label": "F-86F Sabre", "era": "Early Cold War", "shortLabel": "86", @@ -769,7 +772,7 @@ export class AircraftDatabase extends UnitDatabase { }, "F-14A-135-GR": { "name": "F-14A-135-GR", - "coalition": "Blue", + "coalition": "blue", "label": "F-14A-135-GR Tomcat", "era": "Mid Cold War", "shortLabel": "14A", @@ -868,7 +871,7 @@ export class AircraftDatabase extends UnitDatabase { }, "F-14B": { "name": "F-14B", - "coalition": "Blue", + "coalition": "blue", "label": "F-14B Tomcat", "era": "Late Cold War", "shortLabel": "14B", @@ -967,7 +970,7 @@ export class AircraftDatabase extends UnitDatabase { }, "FA-18C_hornet": { "name": "FA-18C_hornet", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "F/A-18C", "shortLabel": "18", @@ -1135,7 +1138,7 @@ export class AircraftDatabase extends UnitDatabase { }, "L-39ZA": { "name": "L-39ZA", - "coalition": "Red", + "coalition": "red", "label": "L-39ZA", "era": "Mid Cold War", "shortLabel": "39", @@ -1198,7 +1201,7 @@ export class AircraftDatabase extends UnitDatabase { }, "M-2000C": { "name": "M-2000C", - "coalition": "Blue", + "coalition": "blue", "label": "M-2000C Mirage", "era": "Late Cold War", "shortLabel": "M2KC", @@ -1289,7 +1292,7 @@ export class AircraftDatabase extends UnitDatabase { }, "MB-339A": { "name": "MB-339A", - "coalition": "Blue", + "coalition": "blue", "label": "MB-339A", "era": "Mid Cold War", "shortLabel": "339A", @@ -1358,7 +1361,7 @@ export class AircraftDatabase extends UnitDatabase { }, "MiG-19P": { "name": "MiG-19P", - "coalition": "Red", + "coalition": "red", "label": "MiG-19 Farmer", "era": "Early Cold War", "shortLabel": "19", @@ -1429,7 +1432,7 @@ export class AircraftDatabase extends UnitDatabase { }, "MiG-21Bis": { "name": "MiG-21Bis", - "coalition": "Red", + "coalition": "red", "label": "MiG-21 Fishbed", "era": "Mid Cold War", "shortLabel": "21", @@ -1550,7 +1553,7 @@ export class AircraftDatabase extends UnitDatabase { }, "Mirage-F1EE": { "name": "Mirage-F1EE", - "coalition": "Blue", + "coalition": "blue", "label": "Mirage-F1EE", "era": "Mid Cold War", "shortLabel": "F1EE", @@ -1938,7 +1941,7 @@ export class AircraftDatabase extends UnitDatabase { }, "A-50": { "name": "A-50", - "coalition": "Red", + "coalition": "red", "label": "A-50 Mainstay", "era": "Late Cold War", "shortLabel": "A50", @@ -1970,7 +1973,7 @@ export class AircraftDatabase extends UnitDatabase { }, "An-26B": { "name": "An-26B", - "coalition": "Red", + "coalition": "red", "label": "An-26B Curl", "era": "Mid Cold War", "shortLabel": "26", @@ -1991,7 +1994,7 @@ export class AircraftDatabase extends UnitDatabase { }, "An-30M": { "name": "An-30M", - "coalition": "Red", + "coalition": "red", "label": "An-30M Clank", "era": "Mid Cold War", "shortLabel": "30", @@ -2012,7 +2015,7 @@ export class AircraftDatabase extends UnitDatabase { }, "B-1B": { "name": "B-1B", - "coalition": "Blue", + "coalition": "blue", "label": "B-1B Lancer", "era": "Late Cold War", "shortLabel": "1", @@ -2047,7 +2050,7 @@ export class AircraftDatabase extends UnitDatabase { }, "B-52H": { "name": "B-52H", - "coalition": "Blue", + "coalition": "blue", "label": "B-52H Stratofortress", "era": "Early Cold War", "shortLabel": "52", @@ -2082,7 +2085,7 @@ export class AircraftDatabase extends UnitDatabase { }, "C-130": { "name": "C-130", - "coalition": "Blue", + "coalition": "blue", "label": "C-130 Hercules", "era": "Early Cold War", "shortLabel": "130", @@ -2103,7 +2106,7 @@ export class AircraftDatabase extends UnitDatabase { }, "C-17A": { "name": "C-17A", - "coalition": "Blue", + "coalition": "blue", "label": "C-17A Globemaster", "era": "Modern", "shortLabel": "C17", @@ -2124,7 +2127,7 @@ export class AircraftDatabase extends UnitDatabase { }, "E-3A": { "name": "E-3A", - "coalition": "Blue", + "coalition": "blue", "label": "E-3A Sentry", "era": "Mid Cold War", "shortLabel": "E3", @@ -2145,7 +2148,7 @@ export class AircraftDatabase extends UnitDatabase { }, "E-2C": { "name": "E-2C", - "coalition": "Blue", + "coalition": "blue", "label": "E-2C Hawkeye", "era": "Mid Cold War", "shortLabel": "2C", @@ -2166,7 +2169,7 @@ export class AircraftDatabase extends UnitDatabase { }, "F-117A": { "name": "F-117A", - "coalition": "Blue", + "coalition": "blue", "label": "F-117A Nighthawk", "era": "Late Cold War", "shortLabel": "117", @@ -2201,7 +2204,7 @@ export class AircraftDatabase extends UnitDatabase { }, "F-15C": { "name": "F-15C", - "coalition": "Blue", + "coalition": "blue", "label": "F-15C Eagle", "era": "Late Cold War", "shortLabel": "15", @@ -2266,7 +2269,7 @@ export class AircraftDatabase extends UnitDatabase { }, "F-15E": { "name": "F-15E", - "coalition": "Blue", + "coalition": "blue", "label": "F-15E Strike Eagle", "era": "Late Cold War", "shortLabel": "15", @@ -2347,7 +2350,7 @@ export class AircraftDatabase extends UnitDatabase { }, "F-4E": { "name": "F-4E", - "coalition": "Blue", + "coalition": "blue", "label": "F-4E Phantom II", "era": "Mid Cold War", "shortLabel": "4", @@ -2438,7 +2441,7 @@ export class AircraftDatabase extends UnitDatabase { }, "IL-76MD": { "name": "IL-76MD", - "coalition": "Red", + "coalition": "red", "label": "IL-76MD Candid", "era": "Mid Cold War", "shortLabel": "76", @@ -2459,7 +2462,7 @@ export class AircraftDatabase extends UnitDatabase { }, "IL-78M": { "name": "IL-78M", - "coalition": "Red", + "coalition": "red", "label": "IL-78M Midas", "era": "Late Cold War", "shortLabel": "78", @@ -2480,7 +2483,7 @@ export class AircraftDatabase extends UnitDatabase { }, "KC-135": { "name": "KC-135", - "coalition": "Blue", + "coalition": "blue", "label": "KC-135 Stratotanker", "era": "Early Cold War", "shortLabel": "135", @@ -2501,7 +2504,7 @@ export class AircraftDatabase extends UnitDatabase { }, "KC135MPRS": { "name": "KC135MPRS", - "coalition": "Blue", + "coalition": "blue", "label": "KC-135 MPRS Stratotanker", "era": "Early Cold War", "shortLabel": "135M", @@ -2522,7 +2525,7 @@ export class AircraftDatabase extends UnitDatabase { }, "S-3B Tanker": { "name": "S-3B Tanker", - "coalition": "Blue", + "coalition": "blue", "label": "S-3B Tanker", "era": "Early Cold War", "shortLabel": "S3B", @@ -2543,7 +2546,7 @@ export class AircraftDatabase extends UnitDatabase { }, "MiG-15bis": { "name": "MiG-15bis", - "coalition": "Red", + "coalition": "red", "label": "MiG-15 Fagot", "era": "Early Cold War", "shortLabel": "M15", @@ -2592,7 +2595,7 @@ export class AircraftDatabase extends UnitDatabase { }, "MiG-23MLD": { "name": "MiG-23MLD", - "coalition": "Red", + "coalition": "red", "label": "MiG-23 Flogger", "era": "Mid Cold War", "shortLabel": "23", @@ -2657,7 +2660,7 @@ export class AircraftDatabase extends UnitDatabase { }, "MiG-25RBT": { "name": "MiG-25RBT", - "coalition": "Red", + "coalition": "red", "label": "MiG-25RBT Foxbat", "era": "Mid Cold War", "shortLabel": "25", @@ -2710,7 +2713,7 @@ export class AircraftDatabase extends UnitDatabase { }, "MiG-25PD": { "name": "MiG-25PD", - "coalition": "Red", + "coalition": "red", "label": "MiG-25PD Foxbat", "era": "Mid Cold War", "shortLabel": "25", @@ -2749,7 +2752,7 @@ export class AircraftDatabase extends UnitDatabase { }, "MiG-27K": { "name": "MiG-27K", - "coalition": "Red", + "coalition": "red", "label": "MiG-27K Flogger-D", "era": "Mid Cold War", "shortLabel": "27", @@ -2820,7 +2823,7 @@ export class AircraftDatabase extends UnitDatabase { }, "MiG-29A": { "name": "MiG-29A", - "coalition": "Red", + "coalition": "red", "label": "MiG-29A Fulcrum", "era": "Late Cold War", "shortLabel": "29A", @@ -2907,7 +2910,7 @@ export class AircraftDatabase extends UnitDatabase { }, "MiG-29S": { "name": "MiG-29S", - "coalition": "Red", + "coalition": "red", "label": "MiG-29S Fulcrum", "era": "Late Cold War", "shortLabel": "29", @@ -3016,7 +3019,7 @@ export class AircraftDatabase extends UnitDatabase { }, "MiG-31": { "name": "MiG-31", - "coalition": "Red", + "coalition": "red", "label": "MiG-31 Foxhound", "era": "Late Cold War", "shortLabel": "31", @@ -3055,7 +3058,7 @@ export class AircraftDatabase extends UnitDatabase { }, "MQ-9 Reaper": { "name": "MQ-9 Reaper", - "coalition": "Blue", + "coalition": "blue", "label": "MQ-9 Reaper", "era": "Modern", "shortLabel": "9", @@ -3090,7 +3093,7 @@ export class AircraftDatabase extends UnitDatabase { }, "Su-17M4": { "name": "Su-17M4", - "coalition": "Red", + "coalition": "red", "label": "Su-17M4 Fitter", "era": "Mid Cold War", "shortLabel": "17M4", @@ -3133,7 +3136,7 @@ export class AircraftDatabase extends UnitDatabase { }, "Su-24M": { "name": "Su-24M", - "coalition": "Red", + "coalition": "red", "label": "Su-24M Fencer", "era": "Mid Cold War", "shortLabel": "24", @@ -3172,7 +3175,7 @@ export class AircraftDatabase extends UnitDatabase { }, "Su-25": { "name": "Su-25", - "coalition": "Red", + "coalition": "red", "label": "Su-25A Frogfoot", "era": "Late Cold War", "shortLabel": "S25", @@ -3245,7 +3248,7 @@ export class AircraftDatabase extends UnitDatabase { }, "Su-25T": { "name": "Su-25", - "coalition": "Red", + "coalition": "red", "label": "Su-25T Frogfoot", "era": "Late Cold War", "shortLabel": "S25T", @@ -3352,7 +3355,7 @@ export class AircraftDatabase extends UnitDatabase { }, "Su-27": { "name": "Su-27", - "coalition": "Red", + "coalition": "red", "label": "Su-27 Flanker", "era": "Late Cold War", "shortLabel": "27", @@ -3453,7 +3456,7 @@ export class AircraftDatabase extends UnitDatabase { }, "Su-30": { "name": "Su-30", - "coalition": "Red", + "coalition": "red", "label": "Su-30 Super Flanker", "era": "Late Cold War", "shortLabel": "30", @@ -3544,7 +3547,7 @@ export class AircraftDatabase extends UnitDatabase { }, "Su-33": { "name": "Su-33", - "coalition": "Red", + "coalition": "red", "label": "Su-33 Navy Flanker", "era": "Late Cold War", "shortLabel": "33", @@ -3635,7 +3638,7 @@ export class AircraftDatabase extends UnitDatabase { }, "Su-34": { "name": "Su-34", - "coalition": "Red", + "coalition": "red", "label": "Su-34 Hellduck", "era": "Modern", "shortLabel": "34", @@ -3682,7 +3685,7 @@ export class AircraftDatabase extends UnitDatabase { }, "Tornado IDS": { "name": "Tornado IDS", - "coalition": "Blue", + "coalition": "blue", "label": "Tornado IDS", "era": "Late Cold War", "shortLabel": "IDS", @@ -3725,7 +3728,7 @@ export class AircraftDatabase extends UnitDatabase { }, "Tornado GR4": { "name": "Tornado GR4", - "coalition": "Blue", + "coalition": "blue", "label": "Tornado GR4", "era": "Late Cold War", "shortLabel": "GR4", @@ -3820,7 +3823,7 @@ export class AircraftDatabase extends UnitDatabase { }, "Tu-142": { "name": "Tu-142", - "coalition": "Red", + "coalition": "red", "label": "Tu-142 Bear", "era": "Mid Cold War", "shortLabel": "142", @@ -3855,7 +3858,7 @@ export class AircraftDatabase extends UnitDatabase { }, "Tu-160": { "name": "Tu-160", - "coalition": "Red", + "coalition": "red", "label": "Tu-160 Blackjack", "era": "Late Cold War", "shortLabel": "160", @@ -3890,7 +3893,7 @@ export class AircraftDatabase extends UnitDatabase { }, "Tu-22M3": { "name": "Tu-22M3", - "coalition": "Red", + "coalition": "red", "label": "Tu-22M3 Backfire", "era": "Late Cold War", "shortLabel": "T22", @@ -3939,7 +3942,7 @@ export class AircraftDatabase extends UnitDatabase { }, "Tu-95MS": { "name": "Tu-95MS", - "coalition": "Red", + "coalition": "red", "label": "Tu-95MS Bear", "era": "Mid Cold War", "shortLabel": "95", @@ -3977,6 +3980,24 @@ export class AircraftDatabase extends UnitDatabase { getCategory() { return "Aircraft"; } + + getSpawnPointsByName(name: string) { + if (getUnitsManager().getCommandMode() == GAME_MASTER) + return 0; + + const blueprint = this.getByName(name); + if (blueprint?.era == "WW2") + return 20; + else if (blueprint?.era == "Early Cold War") + return 50; + else if (blueprint?.era == "Mid Cold War") + return 100; + else if (blueprint?.era == "Late Cold War") + return 200; + else if (blueprint?.era == "Modern") + return 400; + return 0; + } } export var aircraftDatabase = new AircraftDatabase(); diff --git a/client/src/units/groundunitdatabase.ts b/client/src/units/groundunitdatabase.ts index acc10dcc..0a661f85 100644 --- a/client/src/units/groundunitdatabase.ts +++ b/client/src/units/groundunitdatabase.ts @@ -1,12 +1,15 @@ +import { getUnitsManager } from ".."; +import { GAME_MASTER } from "../constants/constants"; import { UnitDatabase } from "./unitdatabase" export class GroundUnitDatabase extends UnitDatabase { constructor() { super(); + this.blueprints = { "SA-2 SAM Battery": { "name": "SA-2 SAM Battery", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "SA-2 SAM Battery", "shortLabel": "SA-2 SAM Battery", @@ -16,7 +19,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "SA-3 SAM Battery": { "name": "SA-3 SAM Battery", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "SA-3 SAM Battery", "shortLabel": "SA-3 SAM Battery", @@ -26,7 +29,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "SA-6 SAM Battery": { "name": "SA-6 SAM Battery", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "SA-6 SAM Battery", "shortLabel": "SA-6 SAM Battery", @@ -36,7 +39,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "SA-10 SAM Battery": { "name": "SA-10 SAM Battery", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-10 SAM Battery", "shortLabel": "SA-10 SAM Battery", @@ -46,7 +49,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "SA-11 SAM Battery": { "name": "SA-11 SAM Battery", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-11 SAM Battery", "shortLabel": "SA-11 SAM Battery", @@ -56,7 +59,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Patriot site": { "name": "Patriot site", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Patriot site", "shortLabel": "Patriot site", @@ -66,7 +69,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Hawk SAM Battery": { "name": "Hawk SAM Battery", - "coalition": "Blue", + "coalition": "blue", "era": "Early Cold War", "label": "Hawk SAM Battery", "shortLabel": "Hawk SAM Battery", @@ -76,7 +79,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "2B11 mortar": { "name": "2B11 mortar", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "2B11 mortar", "shortLabel": "2B11 mortar", @@ -85,7 +88,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "SAU Gvozdika": { "name": "SAU Gvozdika", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "SAU Gvozdika", "shortLabel": "SAU Gvozdika", @@ -94,7 +97,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "SAU Msta": { "name": "SAU Msta", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SAU Msta", "shortLabel": "SAU Msta", @@ -103,7 +106,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "SAU Akatsia": { "name": "SAU Akatsia", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "SAU Akatsia", "shortLabel": "SAU Akatsia", @@ -112,7 +115,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "SAU 2-C9": { "name": "SAU 2-C9", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "SAU Nona", "shortLabel": "SAU Nona", @@ -121,7 +124,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "M-109": { "name": "M-109", - "coalition": "Blue", + "coalition": "blue", "era": "Early Cold War", "label": "M-109 Paladin", "shortLabel": "M-109", @@ -130,7 +133,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "AAV7": { "name": "AAV7", - "coalition": "Blue", + "coalition": "blue", "era": "Mid Cold War", "label": "AAV7", "shortLabel": "AAV7", @@ -139,7 +142,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "BMD-1": { "name": "BMD-1", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "BMD-1", "shortLabel": "BMD-1", @@ -148,7 +151,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "BMP-1": { "name": "BMP-1", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "BMP-1", "shortLabel": "BMP-1", @@ -157,7 +160,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "BMP-2": { "name": "BMP-2", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "BMP-2", "shortLabel": "BMP-2", @@ -166,7 +169,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "BMP-3": { "name": "BMP-3", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "BMP-3", "shortLabel": "BMP-3", @@ -175,7 +178,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Boman": { "name": "Boman", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Grad Fire Direction Manager", "shortLabel": "Boman", @@ -184,7 +187,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "BRDM-2": { "name": "BRDM-2", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "BRDM-2", "shortLabel": "BRDM-2", @@ -193,7 +196,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "BTR-80": { "name": "BTR-80", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "BTR-80", "shortLabel": "BTR-80", @@ -202,7 +205,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "BTR_D": { "name": "BTR_D", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "BTR_D", "shortLabel": "BTR_D", @@ -220,7 +223,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Cobra": { "name": "Cobra", - "coalition": "Blue", + "coalition": "blue", "era": "Modern", "label": "Otokar Cobra", "shortLabel": "Cobra", @@ -229,7 +232,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "LAV-25": { "name": "LAV-25", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "LAV-25", "shortLabel": "LAV-25", @@ -238,7 +241,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "M1043 HMMWV Armament": { "name": "M1043 HMMWV Armament", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "HMMWV M2 Browning", "shortLabel": "HMMWV M2", @@ -247,7 +250,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "M1045 HMMWV TOW": { "name": "M1045 HMMWV TOW", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "HMMWV TOW", "shortLabel": "HMMWV TOW", @@ -256,7 +259,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "M1126 Stryker ICV": { "name": "M1126 Stryker ICV", - "coalition": "Blue", + "coalition": "blue", "era": "Modern", "label": "Stryker MG", "shortLabel": "Stryker MG", @@ -265,7 +268,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "M-113": { "name": "M-113", - "coalition": "Blue", + "coalition": "blue", "era": "Early Cold War", "label": "M-113", "shortLabel": "M-113", @@ -274,7 +277,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "M1134 Stryker ATGM": { "name": "M1134 Stryker ATGM", - "coalition": "Blue", + "coalition": "blue", "era": "Modern", "label": "Stryker ATGM", "shortLabel": "Stryker ATGM", @@ -283,7 +286,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "M-2 Bradley": { "name": "M-2 Bradley", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "M-2A2 Bradley", "shortLabel": "M-2 Bradley", @@ -292,7 +295,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Marder": { "name": "Marder", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Marder", "shortLabel": "Marder", @@ -301,7 +304,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "MCV-80": { "name": "MCV-80", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Warrior IFV", "shortLabel": "Warrior", @@ -310,7 +313,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "MTLB": { "name": "MTLB", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "MT-LB", "shortLabel": "MT-LB", @@ -319,7 +322,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Paratrooper RPG-16": { "name": "Paratrooper RPG-16", - "coalition": "Red", + "coalition": "red", "era": "Modern", "label": "Paratrooper RPG-16", "shortLabel": "Paratrooper RPG-16", @@ -328,7 +331,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Paratrooper AKS-74": { "name": "Paratrooper AKS-74", - "coalition": "Red", + "coalition": "red", "era": "Modern", "label": "Paratrooper AKS-74", "shortLabel": "Paratrooper AKS-74", @@ -346,7 +349,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Soldier AK": { "name": "Soldier AK", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "Soldier AK", "shortLabel": "Soldier AK", @@ -355,7 +358,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Infantry AK": { "name": "Infantry AK", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "Infantry AK", "shortLabel": "Infantry AK", @@ -364,7 +367,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Soldier M249": { "name": "Soldier M249", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Soldier M249", "shortLabel": "Soldier M249", @@ -373,7 +376,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Soldier M4": { "name": "Soldier M4", - "coalition": "Blue", + "coalition": "blue", "era": "Mid Cold War", "label": "Soldier M4", "shortLabel": "Soldier M4", @@ -382,7 +385,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Soldier M4 GRG": { "name": "Soldier M4 GRG", - "coalition": "Blue", + "coalition": "blue", "era": "Mid Cold War", "label": "Soldier M4 GRG", "shortLabel": "Soldier M4 GRG", @@ -391,7 +394,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Soldier RPG": { "name": "Soldier RPG", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "Soldier RPG", "shortLabel": "Soldier RPG", @@ -400,7 +403,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "TPZ": { "name": "TPZ", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "TPz Fuchs", "shortLabel": "TPz Fuchs", @@ -409,7 +412,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Grad-URAL": { "name": "Grad-URAL", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "Grad", "shortLabel": "Grad", @@ -418,7 +421,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Uragan_BM-27": { "name": "Uragan_BM-27", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "Uragan", "shortLabel": "Uragan", @@ -427,7 +430,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Smerch": { "name": "Smerch", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "Smerch", "shortLabel": "Smerch", @@ -436,7 +439,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "MLRS": { "name": "MLRS", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "M270", "shortLabel": "M270", @@ -445,7 +448,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "2S6 Tunguska": { "name": "2S6 Tunguska", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-19 Tunguska", "shortLabel": "SA-19", @@ -455,7 +458,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Kub 2P25 ln": { "name": "Kub 2P25 ln", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-6 Kub 2P25 ln", "shortLabel": "Kub 2P25 ln", @@ -465,7 +468,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "5p73 s-125 ln": { "name": "5p73 s-125 ln", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "SA-3 5p73 s-125 ln", "shortLabel": "5p73 s-125 ln", @@ -475,7 +478,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "S-300PS 5P85C ln": { "name": "S-300PS 5P85C ln", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-10 S-300PS 5P85C ln", "shortLabel": "S-300PS 5P85C ln", @@ -485,7 +488,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "S-300PS 5P85D ln": { "name": "S-300PS 5P85D ln", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-10 S-300PS 5P85D ln", "shortLabel": "S-300PS 5P85D ln", @@ -495,7 +498,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "SA-11 Buk LN 9A310M1": { "name": "SA-11 Buk LN 9A310M1", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-11 Buk LN 9A310M1", "shortLabel": "SA-11 Buk LN 9A310M1", @@ -505,7 +508,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Osa 9A33 ln": { "name": "Osa 9A33 ln", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "SA-8 Osa 9A33 ln", "shortLabel": "Osa 9A33 ln", @@ -515,7 +518,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Tor 9A331": { "name": "Tor 9A331", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-15 Tor 9A331", "shortLabel": "Tor 9A331", @@ -525,7 +528,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Strela-10M3": { "name": "Strela-10M3", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-13 Strela-10M3", "shortLabel": "Strela-10M3", @@ -535,7 +538,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Strela-1 9P31": { "name": "Strela-1 9P31", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-9 Strela-1 9P31", "shortLabel": "Strela-1 9P31", @@ -545,7 +548,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "SA-11 Buk CC 9S470M1": { "name": "SA-11 Buk CC 9S470M1", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-11 Buk CC 9S470M1", "shortLabel": "SA-11 Buk CC 9S470M1", @@ -555,7 +558,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "SA-8 Osa LD 9T217": { "name": "SA-8 Osa LD 9T217", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-8 Osa LD 9T217", "shortLabel": "SA-8 Osa LD 9T217", @@ -565,7 +568,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Patriot AMG": { "name": "Patriot AMG", - "coalition": "Blue", + "coalition": "blue", "era": "Modern", "label": "Patriot AMG", "shortLabel": "Patriot AMG", @@ -575,7 +578,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Patriot ECS": { "name": "Patriot ECS", - "coalition": "Blue", + "coalition": "blue", "era": "Modern", "label": "Patriot ECS", "shortLabel": "Patriot ECS", @@ -585,7 +588,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Gepard": { "name": "Gepard", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Gepard", "shortLabel": "Gepard", @@ -594,7 +597,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Hawk pcp": { "name": "Hawk pcp", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Hawk pcp", "shortLabel": "Hawk pcp", @@ -604,7 +607,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "SA-18 Igla manpad": { "name": "SA-18 Igla manpad", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-18 Igla manpad", "shortLabel": "SA-18 Igla manpad", @@ -614,7 +617,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Igla manpad INS": { "name": "Igla manpad INS", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-18 Igla manpad INS", "shortLabel": "Igla manpad INS", @@ -624,7 +627,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "SA-18 Igla-S manpad": { "name": "SA-18 Igla-S manpad", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-18 Igla-S manpad", "shortLabel": "SA-18 Igla-S manpad", @@ -634,7 +637,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Vulcan": { "name": "Vulcan", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Vulcan", "shortLabel": "Vulcan", @@ -643,7 +646,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Hawk ln": { "name": "Hawk ln", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Hawk ln", "shortLabel": "Hawk ln", @@ -652,7 +655,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "M48 Chaparral": { "name": "M48 Chaparral", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "M48 Chaparral", "shortLabel": "M48 Chaparral", @@ -661,7 +664,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "M6 Linebacker": { "name": "M6 Linebacker", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "M6 Linebacker", "shortLabel": "M6 Linebacker", @@ -670,7 +673,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Patriot ln": { "name": "Patriot ln", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Patriot ln", "shortLabel": "Patriot ln", @@ -680,7 +683,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "M1097 Avenger": { "name": "M1097 Avenger", - "coalition": "Blue", + "coalition": "blue", "era": "Modern", "label": "M1097 Avenger", "shortLabel": "M1097 Avenger", @@ -689,7 +692,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Patriot EPP": { "name": "Patriot EPP", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Patriot EPP", "shortLabel": "Patriot EPP", @@ -699,7 +702,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Patriot cp": { "name": "Patriot cp", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Patriot cp", "shortLabel": "Patriot cp", @@ -709,7 +712,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Roland ADS": { "name": "Roland ADS", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Roland ADS", "shortLabel": "Roland ADS", @@ -718,7 +721,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "S-300PS 54K6 cp": { "name": "S-300PS 54K6 cp", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-10 S-300PS 54K6 cp", "shortLabel": "S-300PS 54K6 cp", @@ -728,7 +731,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Stinger manpad GRG": { "name": "Stinger manpad GRG", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Stinger manpad GRG", "shortLabel": "Stinger manpad GRG", @@ -738,7 +741,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Stinger manpad dsr": { "name": "Stinger manpad dsr", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Stinger manpad dsr", "shortLabel": "Stinger manpad dsr", @@ -748,7 +751,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Stinger comm dsr": { "name": "Stinger comm dsr", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "Stinger comm dsr", "shortLabel": "Stinger comm dsr", @@ -758,7 +761,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Stinger manpad": { "name": "Stinger manpad", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Stinger manpad", "shortLabel": "Stinger manpad", @@ -768,7 +771,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Stinger comm": { "name": "Stinger comm", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Stinger comm", "shortLabel": "Stinger comm", @@ -778,7 +781,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "ZSU-23-4 Shilka": { "name": "ZSU-23-4 Shilka", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "ZSU-23-4 Shilka", "shortLabel": "ZSU-23-4 Shilka", @@ -787,7 +790,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "ZU-23 Emplacement Closed": { "name": "ZU-23 Emplacement Closed", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "ZU-23 Emplacement Closed", "shortLabel": "ZU-23 Emplacement Closed", @@ -796,7 +799,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "ZU-23 Emplacement": { "name": "ZU-23 Emplacement", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "ZU-23 Emplacement", "shortLabel": "ZU-23 Emplacement", @@ -805,7 +808,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "ZU-23 Closed Insurgent": { "name": "ZU-23 Closed Insurgent", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "ZU-23 Closed Insurgent", "shortLabel": "ZU-23 Closed Insurgent", @@ -814,7 +817,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Ural-375 ZU-23 Insurgent": { "name": "Ural-375 ZU-23 Insurgent", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "Ural-375 ZU-23 Insurgent", "shortLabel": "Ural-375 ZU-23 Insurgent", @@ -823,7 +826,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "ZU-23 Insurgent": { "name": "ZU-23 Insurgent", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "ZU-23 Insurgent", "shortLabel": "ZU-23 Insurgent", @@ -832,7 +835,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Ural-375 ZU-23": { "name": "Ural-375 ZU-23", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "Ural-375 ZU-23", "shortLabel": "Ural-375 ZU-23", @@ -841,7 +844,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "1L13 EWR": { "name": "1L13 EWR", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "1L13 EWR", "shortLabel": "1L13 EWR", @@ -850,7 +853,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Kub 1S91 str": { "name": "Kub 1S91 str", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "SA-6 Kub 1S91 str", "shortLabel": "Kub 1S91 str", @@ -860,7 +863,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "S-300PS 40B6M tr": { "name": "S-300PS 40B6M tr", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-10 S-300PS 40B6M tr", "shortLabel": "S-300PS 40B6M tr", @@ -870,7 +873,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "S-300PS 40B6MD sr": { "name": "S-300PS 40B6MD sr", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-10 S-300PS 40B6MD sr", "shortLabel": "S-300PS 40B6MD sr", @@ -880,7 +883,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "55G6 EWR": { "name": "55G6 EWR", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "55G6 EWR", "shortLabel": "55G6 EWR", @@ -889,7 +892,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "S-300PS 64H6E sr": { "name": "S-300PS 64H6E sr", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "SA-10 S-300PS 64H6E sr", "shortLabel": "S-300PS 64H6E sr", @@ -899,7 +902,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "SA-11 Buk SR 9S18M1": { "name": "SA-11 Buk SR 9S18M1", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "SA-11 Buk SR 9S18M1", "shortLabel": "SA-11 Buk SR 9S18M1", @@ -909,7 +912,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Dog Ear radar": { "name": "Dog Ear radar", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "Dog Ear radar", "shortLabel": "Dog Ear radar", @@ -918,7 +921,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Hawk tr": { "name": "Hawk tr", - "coalition": "Blue", + "coalition": "blue", "era": "Early Cold War", "label": "Hawk tr", "shortLabel": "Hawk tr", @@ -928,7 +931,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Hawk sr": { "name": "Hawk sr", - "coalition": "Blue", + "coalition": "blue", "era": "Early Cold War", "label": "Hawk sr", "shortLabel": "Hawk sr", @@ -938,7 +941,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Patriot str": { "name": "Patriot str", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Patriot str", "shortLabel": "Patriot str", @@ -948,7 +951,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Hawk cwar": { "name": "Hawk cwar", - "coalition": "Blue", + "coalition": "blue", "era": "Early Cold War", "label": "Hawk cwar", "shortLabel": "Hawk cwar", @@ -958,7 +961,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "p-19 s-125 sr": { "name": "p-19 s-125 sr", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "SA-3 p-19 s-125 sr", "shortLabel": "p-19 s-125 sr", @@ -967,7 +970,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Roland Radar": { "name": "Roland Radar", - "coalition": "Blue", + "coalition": "blue", "era": "Mid Cold War", "label": "Roland Radar", "shortLabel": "Roland Radar", @@ -976,7 +979,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "snr s-125 tr": { "name": "snr s-125 tr", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "SA-3 snr s-125 tr", "shortLabel": "snr s-125 tr", @@ -1031,7 +1034,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Challenger2": { "name": "Challenger2", - "coalition": "Blue", + "coalition": "blue", "era": "Modern", "label": "Challenger2", "shortLabel": "Challenger2", @@ -1040,7 +1043,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Leclerc": { "name": "Leclerc", - "coalition": "Blue", + "coalition": "blue", "era": "Modern", "label": "Leclerc", "shortLabel": "Leclerc", @@ -1049,7 +1052,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Leopard1A3": { "name": "Leopard1A3", - "coalition": "Blue", + "coalition": "blue", "era": "Mid Cold War", "label": "Leopard1A3", "shortLabel": "Leopard1A3", @@ -1058,7 +1061,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Leopard-2": { "name": "Leopard-2", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Leopard-2", "shortLabel": "Leopard-2", @@ -1067,7 +1070,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "M-60": { "name": "M-60", - "coalition": "Blue", + "coalition": "blue", "era": "Early Cold War", "label": "M-60", "shortLabel": "M-60", @@ -1076,7 +1079,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "M1128 Stryker MGS": { "name": "M1128 Stryker MGS", - "coalition": "Blue", + "coalition": "blue", "era": "Modern", "label": "M1128 Stryker MGS", "shortLabel": "M1128 Stryker MGS", @@ -1085,7 +1088,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "M-1 Abrams": { "name": "M-1 Abrams", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "M-1 Abrams", "shortLabel": "M-1 Abrams", @@ -1094,7 +1097,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "T-55": { "name": "T-55", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "T-55", "shortLabel": "T-55", @@ -1103,7 +1106,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "T-72B": { "name": "T-72B", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "T-72B", "shortLabel": "T-72B", @@ -1112,7 +1115,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "T-80UD": { "name": "T-80UD", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "T-80UD", "shortLabel": "T-80UD", @@ -1121,7 +1124,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "T-90": { "name": "T-90", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "T-90", "shortLabel": "T-90", @@ -1130,7 +1133,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Ural-4320 APA-5D": { "name": "Ural-4320 APA-5D", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "Ural-4320 APA-5D", "shortLabel": "Ural-4320 APA-5D", @@ -1139,7 +1142,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "ATMZ-5": { "name": "ATMZ-5", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "ATMZ-5", "shortLabel": "ATMZ-5", @@ -1148,7 +1151,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "ATZ-10": { "name": "ATZ-10", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "ATZ-10", "shortLabel": "ATZ-10", @@ -1157,7 +1160,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "GAZ-3307": { "name": "GAZ-3307", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "GAZ-3307", "shortLabel": "GAZ-3307", @@ -1166,7 +1169,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "GAZ-3308": { "name": "GAZ-3308", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "GAZ-3308", "shortLabel": "GAZ-3308", @@ -1175,7 +1178,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "GAZ-66": { "name": "GAZ-66", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "GAZ-66", "shortLabel": "GAZ-66", @@ -1184,7 +1187,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "M978 HEMTT Tanker": { "name": "M978 HEMTT Tanker", - "coalition": "Blue", + "coalition": "blue", "era": "Mid Cold War", "label": "M978 HEMTT Tanker", "shortLabel": "M978 HEMTT Tanker", @@ -1193,7 +1196,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "HEMTT TFFT": { "name": "HEMTT TFFT", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "HEMTT TFFT", "shortLabel": "HEMTT TFFT", @@ -1202,7 +1205,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "IKARUS Bus": { "name": "IKARUS Bus", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "IKARUS Bus", "shortLabel": "IKARUS Bus", @@ -1211,7 +1214,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "KAMAZ Truck": { "name": "KAMAZ Truck", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "KAMAZ Truck", "shortLabel": "KAMAZ Truck", @@ -1220,7 +1223,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "LAZ Bus": { "name": "LAZ Bus", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "LAZ Bus", "shortLabel": "LAZ Bus", @@ -1229,7 +1232,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Hummer": { "name": "Hummer", - "coalition": "Blue", + "coalition": "blue", "era": "Mid Cold War", "label": "Hummer", "shortLabel": "Hummer", @@ -1238,7 +1241,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "M 818": { "name": "M 818", - "coalition": "Blue", + "coalition": "blue", "era": "Early Cold War", "label": "M 818", "shortLabel": "M 818", @@ -1247,7 +1250,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "MAZ-6303": { "name": "MAZ-6303", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "MAZ-6303", "shortLabel": "MAZ-6303", @@ -1256,7 +1259,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Predator GCS": { "name": "Predator GCS", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Predator GCS", "shortLabel": "Predator GCS", @@ -1265,7 +1268,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Predator TrojanSpirit": { "name": "Predator TrojanSpirit", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Predator TrojanSpirit", "shortLabel": "Predator TrojanSpirit", @@ -1283,7 +1286,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Tigr_233036": { "name": "Tigr_233036", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "Tigr_233036", "shortLabel": "Tigr_233036", @@ -1292,7 +1295,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Trolley bus": { "name": "Trolley bus", - "coalition": "Blue", + "coalition": "blue", "era": "Late Cold War", "label": "Trolley bus", "shortLabel": "Trolley bus", @@ -1301,7 +1304,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "UAZ-469": { "name": "UAZ-469", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "UAZ-469", "shortLabel": "UAZ-469", @@ -1310,7 +1313,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Ural ATsP-6": { "name": "Ural ATsP-6", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "Ural ATsP-6", "shortLabel": "Ural ATsP-6", @@ -1319,7 +1322,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Ural-375 PBU": { "name": "Ural-375 PBU", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "Ural-375 PBU", "shortLabel": "Ural-375 PBU", @@ -1328,7 +1331,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Ural-375": { "name": "Ural-375", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "Ural-375", "shortLabel": "Ural-375", @@ -1337,7 +1340,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Ural-4320-31": { "name": "Ural-4320-31", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "Ural-4320-31", "shortLabel": "Ural-4320-31", @@ -1346,7 +1349,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "Ural-4320T": { "name": "Ural-4320T", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "Ural-4320T", "shortLabel": "Ural-4320T", @@ -1355,7 +1358,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "VAZ Car": { "name": "VAZ Car", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "VAZ Car", "shortLabel": "VAZ Car", @@ -1364,7 +1367,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "ZiL-131 APA-80": { "name": "ZiL-131 APA-80", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "ZiL-131 APA-80", "shortLabel": "ZiL-131 APA-80", @@ -1373,7 +1376,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "SKP-11": { "name": "SKP-11", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "SKP-11", "shortLabel": "SKP-11", @@ -1382,7 +1385,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "ZIL-131 KUNG": { "name": "ZIL-131 KUNG", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "ZIL-131 KUNG", "shortLabel": "ZIL-131 KUNG", @@ -1391,7 +1394,7 @@ export class GroundUnitDatabase extends UnitDatabase { }, "ZIL-4331": { "name": "ZIL-4331", - "coalition": "Red", + "coalition": "red", "era": "Early Cold War", "label": "ZIL-4331", "shortLabel": "ZIL-4331", @@ -1401,6 +1404,24 @@ export class GroundUnitDatabase extends UnitDatabase { } } + getSpawnPointsByName(name: string) { + if (getUnitsManager().getCommandMode() == GAME_MASTER) + return 0; + + const blueprint = this.getByName(name); + if (blueprint?.era == "WW2") + return 20; + else if (blueprint?.era == "Early Cold War") + return 50; + else if (blueprint?.era == "Mid Cold War") + return 100; + else if (blueprint?.era == "Late Cold War") + return 200; + else if (blueprint?.era == "Modern") + return 400; + return 0; + } + getCategory() { return "GroundUnit"; } diff --git a/client/src/units/helicopterdatabase.ts b/client/src/units/helicopterdatabase.ts index 299fafc2..7ef89a98 100644 --- a/client/src/units/helicopterdatabase.ts +++ b/client/src/units/helicopterdatabase.ts @@ -1,12 +1,15 @@ +import { getUnitsManager } from ".."; +import { GAME_MASTER } from "../constants/constants"; import { UnitDatabase } from "./unitdatabase" export class HelicopterDatabase extends UnitDatabase { constructor() { super(); + this.blueprints = { "AH-64D_BLK_II": { "name": "AH-64D_BLK_II", - "coalition": "Blue", + "coalition": "blue", "era": "Modern", "label": "AH-64D Apache", "shortLabel": "AH64", @@ -59,7 +62,7 @@ export class HelicopterDatabase extends UnitDatabase { }, "Ka-50_3": { "name": "Ka-50_3", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "Ka-50 Hokum A", "shortLabel": "K50", @@ -182,7 +185,7 @@ export class HelicopterDatabase extends UnitDatabase { }, "Mi-24P": { "name": "Mi-24P", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "Mi-24P Hind", "shortLabel": "Mi24", @@ -257,7 +260,7 @@ export class HelicopterDatabase extends UnitDatabase { }, "SA342L": { "name": "SA342L", - "coalition": "Blue", + "coalition": "blue", "era": "Mid Cold War", "label": "SA342L Gazelle", "shortLabel": "342", @@ -285,7 +288,7 @@ export class HelicopterDatabase extends UnitDatabase { }, "SA342M": { "name": "SA342M", - "coalition": "Blue", + "coalition": "blue", "era": "Mid Cold War", "label": "SA342M Gazelle", "shortLabel": "342", @@ -309,7 +312,7 @@ export class HelicopterDatabase extends UnitDatabase { }, "SA342Mistral": { "name": "SA342Mistral", - "coalition": "Blue", + "coalition": "blue", "era": "Mid Cold War", "label": "SA342Mistral Gazelle", "shortLabel": "342", @@ -344,7 +347,7 @@ export class HelicopterDatabase extends UnitDatabase { }, "AH-1W": { "name": "AH-1W", - "coalition": "Blue", + "coalition": "blue", "era": "Mid Cold War", "label": "AH-1W Cobra", "shortLabel": "AH1", @@ -397,7 +400,7 @@ export class HelicopterDatabase extends UnitDatabase { }, "Mi-26": { "name": "Mi-26", - "coalition": "Red", + "coalition": "red", "era": "Late Cold War", "label": "Mi-26 Halo", "shortLabel": "M26", @@ -418,7 +421,7 @@ export class HelicopterDatabase extends UnitDatabase { }, "Mi-28N": { "name": "Mi-28N", - "coalition": "Red", + "coalition": "red", "era": "Modern", "label": "Mi-28N Havoc", "shortLabel": "M28", @@ -457,7 +460,7 @@ export class HelicopterDatabase extends UnitDatabase { }, "Mi-8MT": { "name": "Mi-8MT", - "coalition": "Red", + "coalition": "red", "era": "Mid Cold War", "label": "Mi-8MT Hip", "shortLabel": "Mi8", @@ -496,7 +499,7 @@ export class HelicopterDatabase extends UnitDatabase { }, "SH-60B": { "name": "SH-60B", - "coalition": "Blue", + "coalition": "blue", "era": "Mid Cold War", "label": "SH-60B Seahawk", "shortLabel": "S60", @@ -531,7 +534,7 @@ export class HelicopterDatabase extends UnitDatabase { }, "UH-60A": { "name": "UH-60A", - "coalition": "Blue", + "coalition": "blue", "era": "Mid Cold War", "label": "UH-60A Blackhawk", "shortLabel": "U60", @@ -552,7 +555,7 @@ export class HelicopterDatabase extends UnitDatabase { }, "UH-1H": { "name": "UH-1H", - "coalition": "Blue", + "coalition": "blue", "era": "Early Cold War", "label": "UH-1H Huey", "shortLabel": "UH1", @@ -591,6 +594,24 @@ export class HelicopterDatabase extends UnitDatabase { } } + getSpawnPointsByName(name: string) { + if (getUnitsManager().getCommandMode() == GAME_MASTER) + return 0; + + const blueprint = this.getByName(name); + if (blueprint?.era == "WW2") + return 20; + else if (blueprint?.era == "Early Cold War") + return 50; + else if (blueprint?.era == "Mid Cold War") + return 100; + else if (blueprint?.era == "Late Cold War") + return 200; + else if (blueprint?.era == "Modern") + return 400; + return 0; + } + getCategory() { return "Helicopter"; } diff --git a/client/src/units/navyunitdatabase.ts b/client/src/units/navyunitdatabase.ts index 50076ae9..023787fe 100644 --- a/client/src/units/navyunitdatabase.ts +++ b/client/src/units/navyunitdatabase.ts @@ -1,12 +1,15 @@ +import { getUnitsManager } from ".."; +import { GAME_MASTER } from "../constants/constants"; import { UnitDatabase } from "./unitdatabase" export class NavyUnitDatabase extends UnitDatabase { constructor() { super(); + this.blueprints = { "Type_052B": { "name": "Type_052B", - "coalition": "Red", + "coalition": "red", "type": "Destroyer", "era": "Modern", "label": "052B DDG-168 Guangzhou", @@ -16,7 +19,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "Type_052C": { "name": "Type_052C", - "coalition": "Red", + "coalition": "red", "type": "Destroyer", "era": "Modern", "label": "052C DDG-171 Haikou", @@ -26,7 +29,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "Type_054A": { "name": "", - "coalition": "Red", + "coalition": "red", "type": "Frigate", "era": "Modern", "label": "054A FFG-538 Yantai", @@ -36,7 +39,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "Type_071": { "name": "Type_071", - "coalition": "Red", + "coalition": "red", "type": "Transport", "era": "Modern", "label": "Type 071", @@ -46,7 +49,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "Type_093": { "name": "Type_093", - "coalition": "Red", + "coalition": "red", "type": "Submarine", "era": "Modern", "label": "Type 093", @@ -76,7 +79,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "kuznecow": { "name": "kuznecow", - "coalition": "Red", + "coalition": "red", "type": "Aircraft Carrier", "era": "Late Cold War", "label": "Admiral Kuznetsov", @@ -86,7 +89,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "albatros": { "name": "albatros", - "coalition": "Red", + "coalition": "red", "type": "Aircraft Carrier", "era": "Early Cold War", "label": "Albatros (Grisha-5)", @@ -116,7 +119,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "HandyWind": { "name": "HandyWind", - "coalition": "Blue", + "coalition": "blue", "type": "Cargoship", "era": "Late Cold War", "label": "Bulker Handy Wind", @@ -126,7 +129,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "CV_1143_5": { "name": "CV_1143_5", - "coalition": "Red", + "coalition": "red", "type": "Aircraft Carrier", "era": "Modern", "label": "CV Admiral Kuznetsov(2017)", @@ -136,7 +139,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "CV_59": { "name": "CV_59", - "coalition": "Blue", + "coalition": "blue", "type": "Aircraft Carrier", "era": "Early Cold War", "label": "CV-59 Forrestal", @@ -146,7 +149,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "CVN_71": { "name": "CVN_71", - "coalition": "Blue", + "coalition": "blue", "type": "Super Aircraft Carrier", "era": "Late Cold War", "label": "CVN-71 Theodore Roosevelt", @@ -156,7 +159,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "CVN_72": { "name": "CVN_72", - "coalition": "Blue", + "coalition": "blue", "type": "Super Aircraft Carrier", "era": "Late Cold War", "label": "CVN-72 Abraham Lincoln", @@ -166,7 +169,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "CVN_73": { "name": "CVN_73", - "coalition": "Blue", + "coalition": "blue", "type": "Super Aircraft Carrier", "era": "Late Cold War", "label": "CVN-73 George Washington", @@ -176,7 +179,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "Stennis": { "name": "Stennis", - "coalition": "Blue", + "coalition": "blue", "type": "Aircraft Carrier", "era": "Late Cold War", "label": "CVN-74 John C. Stennis", @@ -186,7 +189,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "CVN_75": { "name": "CVN_75", - "coalition": "Blue", + "coalition": "blue", "type": "Aircraft Carrier", "era": "Late Cold War", "label": "CVN-75 Harry S. Truman", @@ -196,7 +199,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "CastleClass_01": { "name": "CastleClass_01", - "coalition": "Blue", + "coalition": "blue", "type": "Patrol", "era": "Mid Cold War", "label": "HMS Leeds Castle (P-258)", @@ -206,7 +209,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "USS_Arleigh_Burke_IIa": { "name": "USS_Arleigh_Burke_IIa", - "coalition": "Blue", + "coalition": "blue", "type": "Destroyer", "era": "Late Cold War", "label": "DDG Arleigh Burke lla", @@ -216,7 +219,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "barge-1": { "name": "barge-1", - "coalition": "Red", + "coalition": "red", "type": "Cargoship", "era": "Late Cold War", "label": "Dry cargo ship Ivanov", @@ -226,7 +229,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "barge-2": { "name": "barge-2", - "coalition": "Red", + "coalition": "red", "type": "Cargoship", "era": "Late Cold War", "label": "Dry cargo ship Yakushev", @@ -236,7 +239,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "elnya": { "name": "elnya", - "coalition": "Red", + "coalition": "red", "type": "Tanker", "era": "Late Cold War", "label": "Elnya tanker", @@ -246,7 +249,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "La_Combattante_II": { "name": "La_Combattante_II", - "coalition": "Blue", + "coalition": "blue", "type": "Fast Attack Craft", "era": "Mid Cold War", "label": "FAC La Combattante lla", @@ -256,7 +259,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "leander-gun-achilles": { "name": "leander-gun-achilles", - "coalition": "Blue", + "coalition": "blue", "type": "Frigate", "era": "Mid Cold War", "label": "HMS Achilles (F12)", @@ -266,7 +269,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "leander-gun-andromeda": { "name": "leander-gun-andromeda", - "coalition": "Blue", + "coalition": "blue", "type": "Frigate", "era": "Mid Cold War", "label": "HMS Andromeda (F57)", @@ -276,7 +279,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "leander-gun-ariadne": { "name": "leander-gun-ariadne", - "coalition": "Blue", + "coalition": "blue", "type": "Frigate", "era": "Mid Cold War", "label": "HMS Ariadne (F72)", @@ -296,7 +299,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "hms_invincible": { "name": "hms_invincible", - "coalition": "Blue", + "coalition": "blue", "type": "Aircraft Carrier", "era": "Mid Cold War", "label": "HMS Invincible (R05)", @@ -316,7 +319,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "kilo_636": { "name": "kilo_636", - "coalition": "Red", + "coalition": "red", "type": "Submarine", "era": "Late Cold War", "label": "Project 636 Varshavyanka Improved", @@ -326,7 +329,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "kilo": { "name": "kilo", - "coalition": "Red", + "coalition": "red", "type": "Submarine", "era": "Late Cold War", "label": "Project 636 Varshavyanka Basic", @@ -336,7 +339,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "LHA_Tarawa": { "name": "LHA_Tarawa", - "coalition": "Blue", + "coalition": "blue", "type": "Aircraft Carrier", "era": "Mid Cold War", "label": "LHA-1 Tarawa", @@ -346,7 +349,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "BDK-775": { "name": "BDK-775", - "coalition": "Blue", + "coalition": "blue", "type": "Landing Craft", "era": "Mid Cold War", "label": "LS Ropucha", @@ -366,7 +369,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "moscow": { "name": "moscow", - "coalition": "Red", + "coalition": "red", "type": "Cruiser", "era": "Late Cold War", "label": "Moscow", @@ -376,7 +379,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "neustrash": { "name": "neustrash", - "coalition": "Red", + "coalition": "red", "type": "Frigate", "era": "Late Cold War", "label": "Neustrashimy", @@ -386,7 +389,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "perry": { "name": "perry", - "coalition": "Blue", + "coalition": "blue", "type": "Frigate", "era": "Mid Cold War", "label": "Oliver H. Perry", @@ -396,7 +399,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "piotr_velikiy": { "name": "piotr_velikiy", - "coalition": "Red", + "coalition": "red", "type": "Cruiser", "era": "Late Cold War", "label": "Pyotr Velikiy", @@ -406,7 +409,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "rezky": { "name": "Rezky (Krivak-2)", - "coalition": "Red", + "coalition": "red", "type": "Frigate", "era": "Early Cold War", "label": "Rezky (Krivak-2)", @@ -416,7 +419,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "Ship_Tilde_Supply": { "name": "Ship_Tilde_Supply", - "coalition": "Blue", + "coalition": "blue", "type": "Transport", "era": "Late Cold War", "label": "Supply Ship MV Tilde", @@ -426,7 +429,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "Seawise_Giant": { "name": "Seawise_Giant", - "coalition": "Blue", + "coalition": "blue", "type": "Tanker", "era": "Late Cold War", "label": "Tanker Seawise Giant", @@ -436,7 +439,7 @@ export class NavyUnitDatabase extends UnitDatabase { }, "TICONDEROG": { "name": "TICONDEROG", - "coalition": "Blue", + "coalition": "blue", "type": "Cruiser", "era": "Late Cold War", "label": "Ticonderoga", @@ -457,6 +460,24 @@ export class NavyUnitDatabase extends UnitDatabase { } } + getSpawnPointsByName(name: string) { + if (getUnitsManager().getCommandMode() == GAME_MASTER) + return 0; + + const blueprint = this.getByName(name); + if (blueprint?.era == "WW2") + return 20; + else if (blueprint?.era == "Early Cold War") + return 50; + else if (blueprint?.era == "Mid Cold War") + return 100; + else if (blueprint?.era == "Late Cold War") + return 200; + else if (blueprint?.era == "Modern") + return 400; + return 0; + } + getCategory() { return "NavyUnit"; } diff --git a/client/src/units/unit.ts b/client/src/units/unit.ts index fc5f13a8..2c68ec0e 100644 --- a/client/src/units/unit.ts +++ b/client/src/units/unit.ts @@ -369,9 +369,7 @@ export class Unit extends CustomMarker { belongsToCommandedCoalition() { if (getUnitsManager().getCommandMode() === HIDE_ALL) return false; - if (getUnitsManager().getCommandMode() === BLUE_COMMANDER && this.#coalition !== "blue") - return false; - if (getUnitsManager().getCommandMode() === RED_COMMANDER && this.#coalition !== "red") + if (getUnitsManager().getCommandedCoalition() !== this.#coalition) return false; return true; } diff --git a/client/src/units/unitdatabase.ts b/client/src/units/unitdatabase.ts index b7baebe9..55f802f1 100644 --- a/client/src/units/unitdatabase.ts +++ b/client/src/units/unitdatabase.ts @@ -1,5 +1,6 @@ import { LatLng } from "leaflet"; -import { getUnitsManager } from ".."; +import { getMissionHandler, getUnitsManager } from ".."; +import { GAME_MASTER } from "../constants/constants"; export class UnitDatabase { blueprints: { [key: string]: UnitBlueprint } = {}; @@ -12,60 +13,6 @@ export class UnitDatabase { return ""; } - getBlueprints() { - return this.blueprints; - } - - /* Returns a list of all possible roles in a database */ - getRoles() { - var roles: string[] = []; - for (let unit in this.blueprints) { - var loadouts = this.blueprints[unit].loadouts; - if (loadouts) { - for (let loadout of loadouts) { - for (let role of loadout.roles) { - if (role !== "" && !roles.includes(role)) - roles.push(role); - } - } - } - } - return roles; - } - - /* Returns a list of all possible types in a database */ - getTypes() { - var types: string[] = []; - for (let unit in this.blueprints) { - var type = this.blueprints[unit].type; - if (type && type !== "" && !types.includes(type)) - types.push(type); - } - return types; - } - - /* Returns a list of all possible periods in a database */ - getEras() { - var eras: string[] = []; - for (let unit in this.blueprints) { - var era = this.blueprints[unit].era; - if (era && era !== "" && !eras.includes(era)) - eras.push(era); - } - return eras; - } - - /* Returns a list of all possible ranges in a database */ - getRanges() { - var ranges: string[] = []; - for (let unit in this.blueprints) { - var range = this.blueprints[unit].range; - if (range && range !== "" && !ranges.includes(range)) - ranges.push(range); - } - return ranges; - } - /* Gets a specific blueprint by name */ getByName(name: string) { if (name in this.blueprints) @@ -82,12 +29,85 @@ export class UnitDatabase { return null; } + getBlueprints() { + if (getUnitsManager().getCommandMode() == GAME_MASTER || !getMissionHandler().getRTSOptions().restrictSpawns) + return this.blueprints; + else { + var filteredBlueprints: { [key: string]: UnitBlueprint } = {}; + for (let unit in this.blueprints) { + const blueprint = this.blueprints[unit]; + console.log(blueprint.era) + if (this.getSpawnPointsByName(blueprint.name) < getMissionHandler().getAvailableSpawnPoints() && + getMissionHandler().getRTSOptions().eras.includes(blueprint.era) && + (!getMissionHandler().getRTSOptions().restrictToCoalition || blueprint.coalition === getUnitsManager().getCommandedCoalition())) { + filteredBlueprints[unit] = blueprint; + } + } + return filteredBlueprints; + } + } + + /* Returns a list of all possible roles in a database */ + getRoles() { + var roles: string[] = []; + var filteredBlueprints = this.getBlueprints(); + for (let unit in filteredBlueprints) { + var loadouts = filteredBlueprints[unit].loadouts; + if (loadouts) { + for (let loadout of loadouts) { + for (let role of loadout.roles) { + if (role !== "" && !roles.includes(role)) + roles.push(role); + } + } + } + } + return roles; + } + + /* Returns a list of all possible types in a database */ + getTypes() { + var filteredBlueprints = this.getBlueprints(); + var types: string[] = []; + for (let unit in filteredBlueprints) { + var type = filteredBlueprints[unit].type; + if (type && type !== "" && !types.includes(type)) + types.push(type); + } + return types; + } + + /* Returns a list of all possible periods in a database */ + getEras() { + var filteredBlueprints = this.getBlueprints(); + var eras: string[] = []; + for (let unit in filteredBlueprints) { + var era = filteredBlueprints[unit].era; + if (era && era !== "" && !eras.includes(era)) + eras.push(era); + } + return eras; + } + + /* Returns a list of all possible ranges in a database */ + getRanges() { + var filteredBlueprints = this.getBlueprints(); + var ranges: string[] = []; + for (let unit in filteredBlueprints) { + var range = filteredBlueprints[unit].range; + if (range && range !== "" && !ranges.includes(range)) + ranges.push(range); + } + return ranges; + } + /* Get all blueprints by range */ getByRange(range: string) { + var filteredBlueprints = this.getBlueprints(); var unitswithrange = []; - for (let unit in this.blueprints) { - if (this.blueprints[unit].range === range) { - unitswithrange.push(this.blueprints[unit]); + for (let unit in filteredBlueprints) { + if (filteredBlueprints[unit].range === range) { + unitswithrange.push(filteredBlueprints[unit]); } } return unitswithrange; @@ -95,10 +115,11 @@ export class UnitDatabase { /* Get all blueprints by type */ getByType(type: string) { + var filteredBlueprints = this.getBlueprints(); var units = []; - for (let unit in this.blueprints) { - if (this.blueprints[unit].type === type) { - units.push(this.blueprints[unit]); + for (let unit in filteredBlueprints) { + if (filteredBlueprints[unit].type === type) { + units.push(filteredBlueprints[unit]); } } return units; @@ -106,13 +127,14 @@ export class UnitDatabase { /* Get all blueprints by role */ getByRole(role: string) { + var filteredBlueprints = this.getBlueprints(); var units = []; - for (let unit in this.blueprints) { - var loadouts = this.blueprints[unit].loadouts; + for (let unit in filteredBlueprints) { + var loadouts = filteredBlueprints[unit].loadouts; if (loadouts) { for (let loadout of loadouts) { if (loadout.roles.includes(role) || loadout.roles.includes(role.toLowerCase())) { - units.push(this.blueprints[unit]) + units.push(filteredBlueprints[unit]) break; } } @@ -123,8 +145,9 @@ export class UnitDatabase { /* Get the names of all the loadouts for a specific unit and for a specific role */ getLoadoutNamesByRole(name: string, role: string) { + var filteredBlueprints = this.getBlueprints(); var loadoutsByRole = []; - var loadouts = this.blueprints[name].loadouts; + var loadouts = filteredBlueprints[name].loadouts; if (loadouts) { for (let loadout of loadouts) { if (loadout.roles.includes(role) || loadout.roles.includes("")) { @@ -148,14 +171,27 @@ export class UnitDatabase { } generateTestGrid(initialPosition: LatLng) { + var filteredBlueprints = this.getBlueprints(); const step = 0.01; - var nUnits = Object.values(this.blueprints).length; + var nUnits = Object.values(filteredBlueprints).length; var gridSize = Math.ceil(Math.sqrt(nUnits)); - Object.values(this.blueprints).forEach((unitBlueprint: UnitBlueprint, idx: number) => { + Object.values(filteredBlueprints).forEach((unitBlueprint: UnitBlueprint, idx: number) => { var row = Math.floor(idx / gridSize); var col = idx - row * gridSize; var location = new LatLng(initialPosition.lat + col * step, initialPosition.lng + row * step) - getUnitsManager().spawnUnit(this.getCategory(), [{unitType: unitBlueprint.name, location: location, altitude: 1000, loadout: ""}]); + getUnitsManager().spawnUnits(this.getCategory(), [{unitType: unitBlueprint.name, location: location, altitude: 1000, loadout: ""}]); }) } + + getSpawnPointsByLabel(label: string) { + var blueprint = this.getByLabel(label); + if (blueprint) + return this.getSpawnPointsByName(blueprint.name); + else + return 0; + } + + getSpawnPointsByName(name: string) { + return 0; + } } \ No newline at end of file diff --git a/client/src/units/unitsmanager.ts b/client/src/units/unitsmanager.ts index 0041aa0d..bbc4f82f 100644 --- a/client/src/units/unitsmanager.ts +++ b/client/src/units/unitsmanager.ts @@ -1,14 +1,17 @@ import { LatLng, LatLngBounds } from "leaflet"; -import { getHotgroupPanel, getInfoPopup, getMap } from ".."; +import { getHotgroupPanel, getInfoPopup, getMap, getMissionHandler, getUnitsManager } from ".."; import { Unit } from "./unit"; -import { cloneUnit, setLastUpdateTime, spawnAircrafts, spawnGroundUnits } from "../server/server"; +import { cloneUnit, setLastUpdateTime, spawnAircrafts, spawnGroundUnits, spawnHelicopters, spawnNavyUnits } from "../server/server"; import { bearingAndDistanceToLatLng, deg2rad, keyEventWasInInput, latLngToMercator, mToFt, mercatorToLatLng, msToKnots, polyContains, polygonArea, randomPointInPoly, randomUnitBlueprint } from "../other/utils"; import { CoalitionArea } from "../map/coalitionarea"; import { groundUnitDatabase } from "./groundunitdatabase"; -import { DataIndexes, HIDE_ALL, IADSDensities, IDLE, MOVE_UNIT } from "../constants/constants"; +import { BLUE_COMMANDER, DataIndexes, GAME_MASTER, HIDE_ALL, IADSDensities, IDLE, MOVE_UNIT, RED_COMMANDER } from "../constants/constants"; import { DataExtractor } from "./dataextractor"; import { Contact } from "../@types/unit"; import { citiesDatabase } from "./citiesdatabase"; +import { aircraftDatabase } from "./aircraftdatabase"; +import { helicopterDatabase } from "./helicopterdatabase"; +import { navyUnitDatabase } from "./navyunitdatabase"; export class UnitsManager { #units: { [ID: number]: Unit }; @@ -118,15 +121,15 @@ export class UnitsManager { return this.#hiddenTypes; } - setVisibilityMode(newVisibilityMode: string) { - if (newVisibilityMode !== this.#commandMode) { - document.dispatchEvent(new CustomEvent("visibilityModeChanged", { detail: this })); - const el = document.getElementById("visibiliy-mode"); + setCommandMode(newCommandMode: string) { + if (newCommandMode !== this.#commandMode) { + document.dispatchEvent(new CustomEvent("commandModeChanged", { detail: this })); + const el = document.getElementById("command-mode"); if (el) { - el.dataset.mode = newVisibilityMode; - el.textContent = newVisibilityMode.toUpperCase(); + el.dataset.mode = newCommandMode; + el.textContent = newCommandMode.toUpperCase(); } - this.#commandMode = newVisibilityMode; + this.#commandMode = newCommandMode; for (let ID in this.#units) this.#units[ID].updateVisibility(); } @@ -136,6 +139,15 @@ export class UnitsManager { return this.#commandMode; } + getCommandedCoalition() { + if (this.getCommandMode() === BLUE_COMMANDER) + return "blue"; + else if (this.getCommandMode() === RED_COMMANDER) + return "red"; + else + return "all"; + } + selectUnit(ID: number, deselectAllUnits: boolean = true) { if (deselectAllUnits) this.getSelectedUnits().filter((unit: Unit) => unit.ID !== ID).forEach((unit: Unit) => unit.setSelected(false)); @@ -536,7 +548,7 @@ export class UnitsManager { } pasteUnits() { - if (!this.#pasteDisabled) { + if (!this.#pasteDisabled && getUnitsManager().getCommandMode() == GAME_MASTER) { for (let idx in this.#copiedUnits) { var unit = this.#copiedUnits[idx]; //getMap().addTemporaryMarker(getMap().getMouseCoordinates()); @@ -546,6 +558,9 @@ export class UnitsManager { this.#pasteDisabled = true; window.setTimeout(() => this.#pasteDisabled = false, 250); } + else { + getInfoPopup().setText(`Unit cloning is disabled in ${getUnitsManager().getCommandMode()} mode`); + } } createIADS(coalitionArea: CoalitionArea, types: {[key: string]: boolean}, eras: {[key: string]: boolean}, ranges: {[key: string]: boolean}, density: number, distribution: number) { @@ -565,7 +580,7 @@ export class UnitsManager { if (Math.random() < IADSDensities[type]) { const unitBlueprint = randomUnitBlueprint(groundUnitDatabase, {type: type, eras: activeEras, ranges: activeRanges}); if (unitBlueprint) { - spawnGroundUnits([{unitType: unitBlueprint.name, location: latlng}], coalitionArea.getCoalition(), true); + this.spawnUnits("GroundUnit", [{unitType: unitBlueprint.name, location: latlng}], coalitionArea.getCoalition(), true); getMap().addTemporaryMarker(latlng, unitBlueprint.name, coalitionArea.getCoalition()); } } @@ -610,7 +625,7 @@ export class UnitsManager { for (let groupName in groups) { if (groupName !== "" && groups[groupName].length > 0 && groups[groupName].every((unit: any) => {return unit.category == "GroundUnit";})) { var units = groups[groupName].map((unit: any) => {return {unitType: unit.name, location: unit.position}}); - spawnGroundUnits(units, groups[groupName][0].coalition, true); + getUnitsManager().spawnUnits("GroundUnit", units, groups[groupName][0].coalition, true); } } }; @@ -619,11 +634,43 @@ export class UnitsManager { input.click(); } - spawnUnit(category: string, units: any, coalition: string = "blue", immediate: boolean = true) { + spawnUnits(category: string, units: any, coalition: string = "blue", immediate: boolean = true, airbase: string = "") { + var spawnPoints = 0; if (category === "Aircraft") { - spawnAircrafts(units, coalition, "", immediate); + if (airbase == "" && getMissionHandler().getRemainingSetupTime() < 0) { + getInfoPopup().setText("Aircrafts can be air spawned during the SETUP phase only"); + return false; + } + spawnPoints = units.reduce((points: number, unit: any) => {return points + aircraftDatabase.getSpawnPointsByName(unit.unitType)}, 0); + spawnAircrafts(units, coalition, airbase, immediate, spawnPoints); + } else if (category === "Helicopter") { + if (airbase == "" && getMissionHandler().getRemainingSetupTime() < 0) { + getInfoPopup().setText("Helicopters can be air spawned during the SETUP phase only"); + return false; + } + spawnPoints = units.reduce((unit: any, points: number) => {return points + helicopterDatabase.getSpawnPointsByName(unit.unitType)}, 0); + spawnHelicopters(units, coalition, airbase, immediate, spawnPoints); } else if (category === "GroundUnit") { - spawnGroundUnits(units, coalition, immediate); + if (getMissionHandler().getRemainingSetupTime() < 0) { + getInfoPopup().setText("Ground units can be spawned during the SETUP phase only"); + return false; + } + spawnPoints = units.reduce((unit: any, points: number) => {return points + groundUnitDatabase.getSpawnPointsByName(unit.unitType)}, 0); + spawnGroundUnits(units, coalition, immediate, spawnPoints); + } else if (category === "NavyUnit") { + if (getMissionHandler().getRemainingSetupTime() < 0) { + getInfoPopup().setText("Navy units can be spawned during the SETUP phase only"); + return false; + } + spawnPoints = units.reduce((unit: any, points: number) => {return points + navyUnitDatabase.getSpawnPointsByName(unit.unitType)}, 0); + spawnNavyUnits(units, coalition, immediate, spawnPoints); + } + if (spawnPoints <= getMissionHandler().getAvailableSpawnPoints()) { + getMissionHandler().setSpentSpawnPoints(spawnPoints); + return true; + } else { + getInfoPopup().setText("Not enough spawn points available!"); + return false; } } diff --git a/client/views/index.ejs b/client/views/index.ejs index 558d6b67..2aabcabb 100644 --- a/client/views/index.ejs +++ b/client/views/index.ejs @@ -25,7 +25,11 @@ <%- include('panels/mouseinfo.ejs') %> <%- include('panels/connectionstatus.ejs') %> <%- include('panels/hotgroup.ejs') %> - <%- include('panels/navbar.ejs') %> + +
+ <%- include('toolbars/primary.ejs') %> + <%- include('toolbars/rts.ejs') %> +
<%- include('other/dialogs.ejs') %> <%- include('other/popups.ejs') %> diff --git a/client/views/other/contextmenus.ejs b/client/views/other/contextmenus.ejs index 9bb8e91b..226fd0d0 100644 --- a/client/views/other/contextmenus.ejs +++ b/client/views/other/contextmenus.ejs @@ -34,7 +34,7 @@
-
+
Aircraft name
Select role first
@@ -88,7 +88,7 @@
-
+
Helicopter name
Select role first
@@ -142,7 +142,7 @@
-
+
Ground unit name
Select role first
@@ -171,7 +171,7 @@
-