summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-12-03 13:27:47 +0100
committerMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-12-03 13:27:47 +0100
commit1a9928a0f1190dc3ec6e7c57192b4cea4f190d67 (patch)
tree07831958b89fb5236c0641ba631f666890106786
parent5c15104e4a283c373ed36f075bfd299d334f3a21 (diff)
downloadalgeria-1a9928a0f1190dc3ec6e7c57192b4cea4f190d67.tar.gz
don't generates and initializes the array each time
-rw-r--r--rules.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/rules.js b/rules.js
index 3dddb10..968f655 100644
--- a/rules.js
+++ b/rules.js
@@ -594,12 +594,16 @@ function remove_oas() {
// #region UNIT DATA
+function is_fln_unit_type(type) {
+ return type === FRONT || type === CADRE || type === BAND || type === FAILEK
+}
+
function find_free_unit_by_type(type) {
for (let u = 0; u < unit_count; ++u)
if (!game.units[u] && units[u].type === type)
return u
// FLN units can be rebuild, so on second pass get one from the ELIMINATED pile.
- if ([FRONT, CADRE, BAND, FAILEK].includes(type))
+ if (is_fln_unit_type(type))
for (let u = 0; u < unit_count; ++u)
if (unit_loc(u) === ELIMINATED && units[u].type === type)
return u
@@ -608,7 +612,7 @@ function find_free_unit_by_type(type) {
function has_free_unit_by_type(type) {
for (let u = 0; u < unit_count; ++u)
- if (units[u].type === type && (!game.units[u] || ([FRONT, CADRE, BAND, FAILEK].includes(type) && unit_loc(u) === ELIMINATED)))
+ if (units[u].type === type && (!game.units[u] || (is_fln_unit_type(type) && unit_loc(u) === ELIMINATED)))
return true
return false
}
@@ -638,8 +642,12 @@ function has_any_airmobile_target(u) {
return has_target
}
+function is_airmobilizable_unit_type(type) {
+ return type === FR_X || type === EL_X || type === AL_X
+}
+
function can_airmobilize_unit(u) {
- return !is_unit_airmobile(u) && ([FR_X, EL_X, AL_X].includes(unit_type(u))) && [OPS, PTL].includes(unit_box(u))
+ return !is_unit_airmobile(u) && (is_airmobilizable_unit_type(unit_type(u))) && (unit_box(u) === OPS || unit_box(u) === PTL)
}
function is_division_unit(u) {