Started to implement RTS advanced options

This commit is contained in:
Pax1601 2023-07-13 17:52:05 +02:00
parent 785647ad24
commit e9a3ecb9eb
34 changed files with 919 additions and 562 deletions

View File

@ -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;
}
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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;
}

View File

@ -19,6 +19,7 @@ interface CustomEventMap {
"mapStateChanged": CustomEvent<string>,
"mapContextMenu": CustomEvent<>,
"visibilityModeChanged": CustomEvent<string>,
"RTSOptionsChanged": CustomEvent<>,
}
declare global {

View File

@ -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;
}

View File

@ -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 => {

View File

@ -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 );

View File

@ -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 );

View File

@ -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();

View File

@ -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 {
(<HTMLElement>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);
}

View File

@ -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()
}

View File

@ -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)

View File

@ -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");

View File

@ -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() {
(<HTMLButtonElement>this.getContainer()?.querySelector("#aircraft-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = true;
(<HTMLButtonElement>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() {
(<HTMLButtonElement>this.getContainer()?.querySelector("#aircraft-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = true;
(<HTMLButtonElement>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() {
(<HTMLButtonElement>this.getContainer()?.querySelector("#helicopter-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = true;
(<HTMLButtonElement>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() {
(<HTMLButtonElement>this.getContainer()?.querySelector("#helicopter-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = true;
(<HTMLButtonElement>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() {
(<HTMLButtonElement>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;
(<HTMLButtonElement>this.getContainer()?.querySelector("#groundunit-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = false;
}
this.clip();
this.#computeSpawnPoints();
}
#resetGroundUnitName() {
#resetGroundUnitLabel() {
(<HTMLButtonElement>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() {
(<HTMLButtonElement>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;
(<HTMLButtonElement>this.getContainer()?.querySelector("#navyunit-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = false;
}
this.clip();
this.#computeSpawnPoints();
}
#resetNavyUnitName() {
#resetNavyUnitLabel() {
(<HTMLButtonElement>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());
(<HTMLButtonElement>this.getContainer()?.querySelector("#aircraft-spawn-menu")?.querySelector(".deploy-unit-button")).dataset.points = `${aircraftSpawnPoints}`;
(<HTMLButtonElement>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());
(<HTMLButtonElement>this.getContainer()?.querySelector("#helicopter-spawn-menu")?.querySelector(".deploy-unit-button")).dataset.points = `${helicopterSpawnPoints}`;
(<HTMLButtonElement>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());
(<HTMLButtonElement>this.getContainer()?.querySelector("#groundunit-spawn-menu")?.querySelector(".deploy-unit-button")).dataset.points = `${groundUnitSpawnPoints}`;
(<HTMLButtonElement>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());
(<HTMLButtonElement>this.getContainer()?.querySelector("#navyunit-spawn-menu")?.querySelector(".deploy-unit-button")).dataset.points = `${navyUnitSpawnPoints}`;
(<HTMLButtonElement>this.getContainer()?.querySelector("#navyunit-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = navyUnitSpawnPoints > getMissionHandler().getAvailableSpawnPoints();
}
}
}

View File

@ -211,10 +211,6 @@ export function getMap() {
return map;
}
export function getMissionData() {
return missionHandler;
}
export function getUnitDataTable() {
return unitDataTable;
}

View File

@ -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) {

View File

@ -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) {

View File

@ -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);
}

View File

@ -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);

View File

@ -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

View File

@ -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();

File diff suppressed because it is too large Load Diff

View File

@ -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";
}

View File

@ -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";
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -25,7 +25,11 @@
<%- include('panels/mouseinfo.ejs') %>
<%- include('panels/connectionstatus.ejs') %>
<%- include('panels/hotgroup.ejs') %>
<%- include('panels/navbar.ejs') %>
<div id="toolbar-container">
<%- include('toolbars/primary.ejs') %>
<%- include('toolbars/rts.ejs') %>
</div>
<%- include('other/dialogs.ejs') %>
<%- include('other/popups.ejs') %>

View File

@ -34,7 +34,7 @@
</div>
</div>
<div class="ol-select-container">
<div id="aircraft-type-options" class="ol-select">
<div id="aircraft-label-options" class="ol-select">
<div class="ol-select-value">Aircraft name</div>
<div class="ol-select-options">
<div>Select role first</div>
@ -88,7 +88,7 @@
</div>
</div>
<div class="ol-select-container">
<div id="helicopter-type-options" class="ol-select">
<div id="helicopter-label-options" class="ol-select">
<div class="ol-select-value">Helicopter name</div>
<div class="ol-select-options">
<div>Select role first</div>
@ -142,7 +142,7 @@
</div>
</div>
<div class="ol-select-container">
<div id="groundunit-name-options" class="ol-select">
<div id="groundunit-label-options" class="ol-select">
<div class="ol-select-value">Ground unit name</div>
<div class="ol-select-options">
<div>Select role first</div>
@ -171,7 +171,7 @@
</div>
</div>
<div class="ol-select-container">
<div id="navyunit-name-options" class="ol-select">
<div id="navyunit-label-options" class="ol-select">
<div class="ol-select-value">Navy unit name</div>
<div class="ol-select-options">
<div>Select role first</div>

View File

@ -26,8 +26,6 @@
</div>
</div>
<span id="visibiliy-mode"></span>
<div id="map-type" class="ol-select">
<div class="ol-select-value map-source-dropdown">
<span>ArcGIS Satellite</span>

View File

@ -0,0 +1,5 @@
<nav id="rts-toolbar" class="ol-panel" oncontextmenu="return false;">
<span id="command-mode"></span>
<div id="spawn-points-container">Spawn points: <span id="spawn-points"></span></div>
<span id="rts-phase"></span>
</nav>

View File

@ -794,10 +794,12 @@ function Olympus.setMissionData(arg, time)
local mission = {}
mission.theatre = env.mission.theatre
mission.elapsedTime = DCS.getRealTime()
mission.time = mist.time.getDHMS(timer.getAbsTime())
mission.startTime = env.mission.start_time
mission.date = env.mission.date
mission.dateAndTime = {
["elapsedTime"] = DCS.getRealTime()
["time"] = mist.time.getDHMS(timer.getAbsTime())
["startTime"] = env.mission.start_time
["date"] = env.mission.date
}
-- Assemble missionData table
missionData["bullseyes"] = bullseyes

View File

@ -116,12 +116,13 @@ void Server::handle_get(http_request request)
else if (URI.compare(BULLSEYE_URI) == 0)
answer[L"bullseyes"] = bullseyes;
else if (URI.compare(MISSION_URI) == 0) {
mission[L"RTSOptions"] = json::value::object();
if (password.compare(gameMasterPassword) == 0)
mission[L"visibilityMode"] = json::value(L"Game master");
mission[L"RTSOptions"][L"commandMode"] = json::value(L"Game master");
else if (password.compare(blueCommanderPassword) == 0)
mission[L"visibilityMode"] = json::value(L"Blue commander");
mission[L"RTSOptions"][L"commandMode"] = json::value(L"Blue commander");
else if (password.compare(redCommanderPassword) == 0)
mission[L"visibilityMode"] = json::value(L"Red commander");
mission[L"RTSOptions"][L"commandMode"] = json::value(L"Red commander");
answer[L"mission"] = mission;
}