diff --git a/src/Mods/SecExp/js/Unit.js b/src/Mods/SecExp/js/Unit.js index 78caa6b7860260f1294b3ff4922314ac60356b01..8ca5c36a4768f225802d8ee701528cd79d6ffaee 100644 --- a/src/Mods/SecExp/js/Unit.js +++ b/src/Mods/SecExp/js/Unit.js @@ -5,7 +5,7 @@ App.Mods.SecExp.unit = (function() { return { list, checkID, - gen:generate, + gen: generate, barracksList, replenishAll, isDeployed, @@ -120,15 +120,21 @@ App.Mods.SecExp.unit = (function() { V.SecExp.units[type].created = V.SecExp.units[type].created || count || 0; } else if (addNew) { V.SecExp.units[type].created++; - let newUnit = { - equip: 0, active: 1, - maxTroops: 30, troops: 30, - platoonName: `${ordinalSuffix(V.SecExp.units[type].created)} ${V.SecExp.units[type].defaultName}` + const newUnit = { + equip: 0, + active: 1, + maxTroops: 30, + troops: 30, + platoonName: `${ordinalSuffix(V.SecExp.units[type].created)} ${V.SecExp.units[type].defaultName}`, }; if (type !== "bots") { Object.assign(newUnit, { - training: 0, cyber: 0, medics: 0, - SF: 0, commissars: 0, battlesFought: 0, + training: 0, + cyber: 0, + medics: 0, + SF: 0, + commissars: 0, + battlesFought: 0, loyalty: jsRandom(40, 60), }); newUnit.troops = Math.min(newUnit.maxTroops, unitFree(type).print()); @@ -144,8 +150,8 @@ App.Mods.SecExp.unit = (function() { * @returns {DocumentFragment} */ function barracksList(type) { - let list = new DocumentFragment(); - let unitDetail = new DocumentFragment(); + const list = new DocumentFragment(); + const unitDetail = new DocumentFragment(); let linkArray = []; linkArray.push("Default unit name:", App.UI.DOM.makeTextBox(V.SecExp.units[type].defaultName, str => { V.SecExp.units[type].defaultName = str; App.UI.reload(); })); @@ -173,8 +179,8 @@ App.Mods.SecExp.unit = (function() { linkArray.push(App.UI.DOM.makeTextBox(unit.platoonName, str => { unit.platoonName = str; App.UI.reload(); })); linkArray.push(App.UI.DOM.link(`Disband the unit`, () => { unitFree(type).add(unit.troops); - V.SecExp.units[type].squads.deleteAt(unit); - V.SecExp.battles.lastSelection.deleteAt(unit); + V.SecExp.units[type].squads.delete(unit); + V.SecExp.battles.lastSelection.delete(unit); App.UI.reload(); } )); @@ -224,8 +230,8 @@ App.Mods.SecExp.unit = (function() { V.peacekeepers.attitude += Math.ceil(unitAdjust / 5); cashX(cost, "securityExpansion"); unitFree(type).add(unit.troops); - V.SecExp.units[type].squads.deleteAt(unit); - V.SecExp.battles.lastSelection.deleteAt(unit); + V.SecExp.units[type].squads.delete(unit); + V.SecExp.battles.lastSelection.delete(unit); App.UI.reload(); } )); @@ -404,8 +410,10 @@ App.Mods.SecExp.unit = (function() { x.equip = 3; if (checkID(x.ID) !== "bots") { Object.assign(x, { - maxTroops: 50, commissars: 2, - cyber: 1, medics: 1 + maxTroops: 50, + commissars: 2, + cyber: 1, + medics: 1, }); x.SF = (V.SF.Active >= 1 ? 1 : 0); } else { @@ -487,8 +495,8 @@ App.Mods.SecExp.unit = (function() { * @returns {HTMLDivElement} */ function replenishAll() { - let el = document.createElement("div"); - let woundedUnit = new Map([]); + const el = document.createElement("div"); + const woundedUnit = new Map([]); for (const squad of App.Mods.SecExp.unit.squads()) { const unit = checkID(squad.ID); if (squad.troops < squad.maxTroops && unitFree(unit).canUpgrade()) { @@ -524,7 +532,7 @@ App.Mods.SecExp.unit = (function() { function describe(input, inBattle) { const brief = V.SecExp.settings.unitDescriptions; const unitType = App.Mods.SecExp.unit.checkID(input.ID); - let el = new DocumentFragment(); + const el = new DocumentFragment(); if (inBattle) { const canDeploy = !isDeployed(input) && App.Mods.SecExp.battle.deployableUnits() > 0; @@ -704,7 +712,7 @@ App.Mods.SecExp.unit = (function() { * @returns {Array} */ function squads(type = '') { - let array = Object.values(V.SecExp.units).map(s => s.squads).flatten(); + const array = Object.values(V.SecExp.units).map(s => s.squads).flatten(); switch (type) { case "human": return array.filter(s => checkID(s.ID) !== "bots"); } @@ -813,8 +821,11 @@ App.Mods.SecExp.unit = (function() { } return { - print, canUpgrade, - add, remove, set + print, + canUpgrade, + add, + remove, + set, }; } @@ -1273,7 +1284,7 @@ App.Mods.SecExp.DroneUnit = class SecExpDroneUnit extends App.Mods.SecExp.Unit { } printStats() { - let r = new DocumentFragment(); + const r = new DocumentFragment(); App.UI.DOM.appendNewElement("div", r, `Security drones base attack: ${this._baseUnit.attack} (After modifiers: ${Math.trunc(this.attack)})`); App.UI.DOM.appendNewElement("div", r, `Security drones base defense: ${this._baseUnit.defense} (After modifiers: ${Math.trunc(this.defense)})`); App.UI.DOM.appendNewElement("div", r, `Equipment bonus: +${this._data.equip * 15}%`); @@ -1315,7 +1326,7 @@ App.Mods.SecExp.HumanUnit = class SecExpHumanUnit extends App.Mods.SecExp.Unit { } printStats() { - let r = new DocumentFragment(); + const r = new DocumentFragment(); this._descType = App.Mods.SecExp.unit.checkID(this._data.ID); App.UI.DOM.appendNewElement("div", r, `${this._descType} base attack: ${this._baseUnit.attack} (After modifiers: ${Math.trunc(this.attack)})`); App.UI.DOM.appendNewElement("div", r, `${this._descType} base defense: ${this._baseUnit.defense} (After modifiers: ${Math.trunc(this.defense)})`);