From cb34247e38d109c75e07c26332d3e81c04007023 Mon Sep 17 00:00:00 2001
From: kopareigns <kopareigns@gmail.com>
Date: Wed, 20 Mar 2019 01:12:33 -0400
Subject: [PATCH] Minor updates

---
 src/SecExp/SecExpBackwardCompatibility.tw | 18 +++++++-------
 src/SecExp/attackReport.tw                |  4 +--
 src/SecExp/rebellionGenerator.tw          |  2 +-
 src/SecExp/unitsBattleReport.tw           |  2 +-
 src/SecExp/unitsRebellionReport.tw        |  2 +-
 src/SecExp/widgets/battleWidgets.tw       |  6 ++---
 src/SecExp/widgets/miscSecExpWidgets.tw   | 30 +++++++++++------------
 src/js/utilJS.js                          | 29 +---------------------
 src/uncategorized/arcmgmt.tw              |  2 +-
 src/uncategorized/persBusiness.tw         |  4 +--
 10 files changed, 36 insertions(+), 63 deletions(-)

diff --git a/src/SecExp/SecExpBackwardCompatibility.tw b/src/SecExp/SecExpBackwardCompatibility.tw
index 1708368a8f1..8efeeb27226 100644
--- a/src/SecExp/SecExpBackwardCompatibility.tw
+++ b/src/SecExp/SecExpBackwardCompatibility.tw
@@ -433,20 +433,20 @@
 	defense: 0,
 	hp:0}>>
 <<else>>
-	<<if isInt($droneUpgrades)>>
+	<<if Number.isInteger($droneUpgrades)>>
 		<<unset $droneUpgrades>>
 		<<set $droneUpgrades = {
 		attack: 0,
 		defense: 0,
 		hp:0}>>
 	<</if>>
-	<<if ndef $droneUpgrades.attack || !isInt($droneUpgrades.attack)>>
+	<<if ndef $droneUpgrades.attack || !Number.isInteger($droneUpgrades.attack)>>
 		<<set $droneUpgrades.attack = 0>>
 	<</if>>
-	<<if ndef $droneUpgrades.defense || !isInt($droneUpgrades.defense)>>
+	<<if ndef $droneUpgrades.defense || !Number.isInteger($droneUpgrades.defense)>>
 		<<set $droneUpgrades.defense = 0>>
 	<</if>>
-	<<if ndef $droneUpgrades.hp || !isInt($droneUpgrades.hp)>>
+	<<if ndef $droneUpgrades.hp || !Number.isInteger($droneUpgrades.hp)>>
 		<<set $droneUpgrades.hp = 0>>
 	<</if>>
 <</if>>
@@ -463,7 +463,7 @@
 	hp:0,
 	morale: 0}>>
 <<else>>
-	<<if isInt($humanUpgrade)>>
+	<<if Number.isInteger($humanUpgrade)>>
 		<<unset $humanUpgrade>>
 		<<set $humanUpgrade = {
 		attack: 0,
@@ -471,16 +471,16 @@
 		hp:0,
 		morale: 0}>>
 	<</if>>
-	<<if ndef $humanUpgrade.attack || !isInt($humanUpgrade.attack)>>
+	<<if ndef $humanUpgrade.attack || !Number.isInteger($humanUpgrade.attack)>>
 		<<set $humanUpgrade.attack = 0>>
 	<</if>>
-	<<if ndef $humanUpgrade.defense || !isInt($humanUpgrade.defense)>>
+	<<if ndef $humanUpgrade.defense || !Number.isInteger($humanUpgrade.defense)>>
 		<<set $humanUpgrade.defense = 0>>
 	<</if>>
-	<<if ndef $humanUpgrade.hp || !isInt($humanUpgrade.hp)>>
+	<<if ndef $humanUpgrade.hp || !Number.isInteger($humanUpgrade.hp)>>
 		<<set $humanUpgrade.hp = 0>>
 	<</if>>
-	<<if ndef $humanUpgrade.morale || !isInt($humanUpgrade.morale)>>
+	<<if ndef $humanUpgrade.morale || !Number.isInteger($humanUpgrade.morale)>>
 		<<set $humanUpgrade.morale = 0>>
 	<</if>>
 <</if>>
diff --git a/src/SecExp/attackReport.tw b/src/SecExp/attackReport.tw
index c258dbdf444..d36aff21bcf 100644
--- a/src/SecExp/attackReport.tw
+++ b/src/SecExp/attackReport.tw
@@ -750,7 +750,7 @@
 	<</if>>
 	<<run cashX(forceNeg($bribeCost), "war")>>
 <</if>>
-<<if !isInt($lowerClass)>>
+<<if !Number.isInteger($lowerClass)>>
 	<<if isNaN($lowerClass)>>
 		<br>@@.red;Error: lowerClass is NaN, please report this issue@@
 	<<elseif $lowerClass > 0>>
@@ -759,7 +759,7 @@
 		<<set $lowerClass = 0>>
 	<</if>>
 <</if>>
-<<if !isInt($NPCSlaves)>>
+<<if !Number.isInteger($NPCSlaves)>>
 	<<if isNaN($NPCSlaves)>>
 		<br>@@.red;Error: NPCSlaves is NaN, please report this issue@@
 	<<elseif $NPCSlaves > 0>>
diff --git a/src/SecExp/rebellionGenerator.tw b/src/SecExp/rebellionGenerator.tw
index a8b7d300031..7f629bc71fb 100644
--- a/src/SecExp/rebellionGenerator.tw
+++ b/src/SecExp/rebellionGenerator.tw
@@ -196,7 +196,7 @@
 	<<elseif $citizenRebellionEventFires == 1>>
 		@@.red;citizen malcontent increased@@.
 	<</if>>
-<<elseif !isInt($tension)>>
+<<elseif !Number.isInteger($tension)>>
 	<br>Error: tension is outside accepted range.
 <</if>>
 
diff --git a/src/SecExp/unitsBattleReport.tw b/src/SecExp/unitsBattleReport.tw
index fce1092cc1b..503111bf754 100644
--- a/src/SecExp/unitsBattleReport.tw
+++ b/src/SecExp/unitsBattleReport.tw
@@ -81,7 +81,7 @@
 	/* sanity check for losses */
 	<<set _count = 0>>
 	<<for _i = 0; _i < _lossesList.length; _i++>>
-		<<if !isInt(_lossesList[_i])>>
+		<<if !Number.isInteger(_lossesList[_i])>>
 			<<set _lossesList[_i] = 0>>
 		<</if>>
 		<<set _count += _lossesList[_i]>>
diff --git a/src/SecExp/unitsRebellionReport.tw b/src/SecExp/unitsRebellionReport.tw
index 235bbacc991..7b6a1c20c85 100644
--- a/src/SecExp/unitsRebellionReport.tw
+++ b/src/SecExp/unitsRebellionReport.tw
@@ -279,7 +279,7 @@
 	/* sanity check for losses */
 	<<set _count = 0>>
 	<<for _i = 0; _i < _lossesList.length; _i++>>
-		<<if !isInt(_lossesList[_i])>>
+		<<if !Number.isInteger(_lossesList[_i])>>
 			<<set _lossesList[_i] = 0>>
 		<</if>>
 		<<set _count += _lossesList[_i]>>
diff --git a/src/SecExp/widgets/battleWidgets.tw b/src/SecExp/widgets/battleWidgets.tw
index fbf36b41b7c..183ca80de9a 100644
--- a/src/SecExp/widgets/battleWidgets.tw
+++ b/src/SecExp/widgets/battleWidgets.tw
@@ -4,14 +4,14 @@
 	<<if $slaveRebellion != 1 || $citizenRebellion != 1>>
 		/* atk, def */
 		<<set _upgradesSum = $SF.Squad.Armoury + $SF.Squad.Drugs + ($SF.Squad.AA+$SF.Squad.TA < 1) + ($SF.Squad.AV+$SF.Squad.TV)>>
-		<<if !isInt(_upgradesSum)>>
+		<<if !Number.isInteger(_upgradesSum)>>
 			<<set _upgradesSum = random(10,15)>>
 		<</if>>
 		<<set $SFatk = Math.trunc(0.65 * _upgradesSum)>>
 		<<set $SFdef = Math.trunc(0.40 * _upgradesSum)>>
 		/* hp */
 		<<set $carriableSoldiers = 125 * ($SF.Squad.GunS + (($SF.Squad.AV + $SF.Squad.TV)/2))>>
-		<<if !isInt($carriableSoldiers)>>
+		<<if !Number.isInteger($carriableSoldiers)>>
 			<<set $carriableSoldiers = $SF.Squad.Troops / 10>>
 		<</if>>
 		<<if $SF.Squad.Troops > $carriableSoldiers>>
@@ -23,7 +23,7 @@
 	<<else>>
 		/* atk, def */
 		<<set _upgradesSum = $SF.Squad.Armoury + $SF.Squad.Drugs + ($SF.Squad.AA+$SF.Squad.TA < 1) + ($SF.Squad.AV+$SF.Squad.TV)>>
-		<<if !isInt(_upgradesSum)>>
+		<<if !Number.isInteger(_upgradesSum)>>
 			<<set _upgradesSum = random(10,15)>>
 		<</if>>
 		<<set $SFatk = Math.trunc(0.75 * _upgradesSum)>>
diff --git a/src/SecExp/widgets/miscSecExpWidgets.tw b/src/SecExp/widgets/miscSecExpWidgets.tw
index e704c8f183a..5fd970e2375 100644
--- a/src/SecExp/widgets/miscSecExpWidgets.tw
+++ b/src/SecExp/widgets/miscSecExpWidgets.tw
@@ -233,7 +233,7 @@
 		<br>Fixed security bots wrong max troop count.
 		<<set $secBots.maxTroops = 30>>
 	<</if>>
-	<<if !isInt($secBots.troops)>>
+	<<if !Number.isInteger($secBots.troops)>>
 		<br>Fixed security bots wrong max troop count.
 		<<set $secBots.troops = $secBots.maxTroops>>
 	<</if>>
@@ -263,7 +263,7 @@
 			<br>Fixed militia unit wrong max troop count.
 			<<set $militiaUnits[_i].maxTroops = 30>>
 		<</if>>
-		<<if !isInt($militiaUnits[_i].troops)>>
+		<<if !Number.isInteger($militiaUnits[_i].troops)>>
 			<<set $militiaUnits[_i].troops = $militiaUnits[_i].maxTroops>>
 			<br>Fixed militia unit wrong troop count.
 		<</if>>
@@ -294,7 +294,7 @@
 			<br>Fixed slave unit wrong max troop count.
 			<<set $slaveUnits[_i].maxTroops = 30>>
 		<</if>>
-		<<if !isInt($slaveUnits[_i].troops)>>
+		<<if !Number.isInteger($slaveUnits[_i].troops)>>
 			<<set $slaveUnits[_i].troops = $slaveUnits[_i].maxTroops>>
 			<br>Fixed slave unit wrong troop count.
 		<</if>>
@@ -325,7 +325,7 @@
 			<br>Fixed merc unit wrong max troop count.
 			<<set $mercUnits[_i].maxTroops = 30>>
 		<</if>>
-		<<if !isInt($mercUnits[_i].troops)>>
+		<<if !Number.isInteger($mercUnits[_i].troops)>>
 			<<set $mercUnits[_i].troops = $mercUnits[_i].maxTroops>>
 			<br>Fixed merc unit wrong troop count.
 		<</if>>
@@ -337,37 +337,37 @@
 <</widget>>
 
 <<widget "fixBrokenStats">>
-	<<if !isInt($totalKills)>>
+	<<if !Number.isInteger($totalKills)>>
 		<<set $totalKills = 0>>
 	<</if>>
-	<<if !isInt($mercTotalCasualties)>>
+	<<if !Number.isInteger($mercTotalCasualties)>>
 		<<set $mercTotalCasualties = 0>>
 	<</if>>
-	<<if !isInt($mercEmployedManpower)>>
+	<<if !Number.isInteger($mercEmployedManpower)>>
 		<<set $mercEmployedManpower = 0>>
 	<</if>>
-	<<if !isInt($mercTotalManpower)>>
+	<<if !Number.isInteger($mercTotalManpower)>>
 		<<set $mercTotalManpower = 0>>
 	<</if>>
-	<<if !isInt($slavesTotalCasualties)>>
+	<<if !Number.isInteger($slavesTotalCasualties)>>
 		<<set $slavesTotalCasualties = 0>>
 	<</if>>
-	<<if !isInt($slavesEmployedManpower)>>
+	<<if !Number.isInteger($slavesEmployedManpower)>>
 		<<set $slavesEmployedManpower = 0>>
 	<</if>>
-	<<if !isInt($militiaTotalCasualties)>>
+	<<if !Number.isInteger($militiaTotalCasualties)>>
 		<<set $militiaTotalCasualties = 0>>
 	<</if>>
-	<<if !isInt($militiaEmployedManpower)>>
+	<<if !Number.isInteger($militiaEmployedManpower)>>
 		<<set $militiaEmployedManpower = 0>>
 	<</if>>
-	<<if !isInt($militiaFreeManpower)>>
+	<<if !Number.isInteger($militiaFreeManpower)>>
 		<<set $militiaFreeManpower = 0>>
 	<</if>>
-	<<if !isInt($militiaTotalManpower)>>
+	<<if !Number.isInteger($militiaTotalManpower)>>
 		<<set $militiaTotalManpower = 0>>
 	<</if>>
-	<<if !isInt($battlesCount)>>
+	<<if !Number.isInteger($battlesCount)>>
 		<<set $battlesCount = 0>>
 	<</if>>
 <</widget>>
diff --git a/src/js/utilJS.js b/src/js/utilJS.js
index e3cb2928bb3..7506847e8c5 100644
--- a/src/js/utilJS.js
+++ b/src/js/utilJS.js
@@ -413,29 +413,6 @@ window.gaussianPair = function() {
 	return [r * Math.cos(sigma), r * Math.sin(sigma)];
 };
 
-if (!Array.prototype.findIndex) {
-	Array.prototype.findIndex = function(predicate) {
-		if (this == null) {
-			throw new TypeError('Array.prototype.find called on null or undefined');
-		}
-		if (typeof predicate !== 'function') {
-			throw new TypeError('predicate must be a function');
-		}
-		let list = Object(this);
-		let length = list.length >>> 0;
-		let thisArg = arguments[1];
-		let value;
-
-		for (let i = 0; i < length; i++) {
-			value = list[i];
-			if (predicate.call(thisArg, value, i, list)) {
-				return i;
-			}
-		}
-		return -1;
-	};
-}
-
 /*
 A categorizer is used to "slice" a value range into distinct categories in an efficient manner.
 
@@ -736,11 +713,7 @@ window.budgetLine = function(category, title) {
 };
 
 window.isFloat = function(n) {
-	return n === +n && n !== (n|0);
-};
-
-window.isInt = function(n) {
-	return n === +n && n === (n|0);
+	return Number.isFinite(n) && Math.floor(n) !== n;
 };
 
 window.jsRandom = function(min, max) {
diff --git a/src/uncategorized/arcmgmt.tw b/src/uncategorized/arcmgmt.tw
index 0013f17583c..f6bce3e5446 100644
--- a/src/uncategorized/arcmgmt.tw
+++ b/src/uncategorized/arcmgmt.tw
@@ -1079,7 +1079,7 @@ _percTopClass = Math.trunc(($topClass / ($ACitizens + $ASlaves)) * 1000) / 10>>
 	Those of your citizens who have not yet subscribed to the society you are building are permitted to live and do business here, but must pay a moderate jizya tax for the privilege as part of their rent.
 <</if>>
 <<set _rents = Math.trunc(($lowerClass * $LCRent + $middleClass * $MCRent + $upperClass * $UCRent + $topClass * $TCRent) * _rentMultiplier / 25)>>
-<<if !isInt(_rents)>>
+<<if !Number.isInteger(_rents)>>
 	<br>@@.red;Error: rents is outside accepted range, please report this issue@@
 <<else>>
 	<<run cashX(_rents, "rents")>>
diff --git a/src/uncategorized/persBusiness.tw b/src/uncategorized/persBusiness.tw
index 31e7c744dc0..1b5f7747402 100644
--- a/src/uncategorized/persBusiness.tw
+++ b/src/uncategorized/persBusiness.tw
@@ -737,7 +737,7 @@
 			<<set _upgradeCount += 1>>
 		<</if>>
 		<<set _dataGain = _upgradeCount * 200>>
-		<<if !isInt(_dataGain)>>
+		<<if !Number.isInteger(_dataGain)>>
 			<br>@@.red;Error, dataGain is NaN@@
 		<<else>>
 			You are selling the data collected by your security department, which earns a discreet sum of @@.yellowgreen;<<print cashFormat(_dataGain)>>@@.
@@ -855,7 +855,7 @@ Routine upkeep of your demesne costs @@.yellow;<<print cashFormat($costs)>>.@@
 		<</if>>
 		<<set _income = Math.trunc(_income * 0.5)>>
 		This week we made @@.yellowgreen;<<print cashFormat(_income)>>.@@
-		<<if !isInt(_income)>>
+		<<if !Number.isInteger(_income)>>
 			<br>@@.red;Error failed to calculate income@@
 		<<else>>
 			<<run cashX(_income, "personalBusiness")>>
-- 
GitLab