diff options
author | Mischa Untaga <99098079+MischaU8@users.noreply.github.com> | 2023-09-29 16:44:40 +0200 |
---|---|---|
committer | Mischa Untaga <99098079+MischaU8@users.noreply.github.com> | 2023-09-29 16:44:40 +0200 |
commit | 3bf03569b869780d6e1e11cfb8bef30f3009a9da (patch) | |
tree | 9fcb226e69506424ef817cfa3d62582ae6399182 | |
parent | 7ac15ba7b269ec3a091b7a9d0426d471f68d45a1 (diff) | |
download | algeria-3bf03569b869780d6e1e11cfb8bef30f3009a9da.tar.gz |
only 1 front per area
-rw-r--r-- | rules.js | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -459,6 +459,13 @@ function has_friendly_unit_in_locs(xs) { return false } +function has_unit_type_in_loc(t, x) { + for (let u = 0; u <= unit_count; ++u) + if (unit_loc(u) === x && unit_type(u) === t) + return true + return false +} + // #endregion // #region PUBLIC FUNCTIONS @@ -743,12 +750,18 @@ function can_deploy_to(u, to) { let type = unit_type(u) let zone = area_zone(to) let deployment = current_player_deployment() - if (zone in deployment && deployment[zone].includes(type)) { - return deployment[zone].includes(type) + if (!(zone in deployment)) + return false - // TODO check current deployment counts - } - return false + if (!deployment[zone].includes(type)) + return false + + // - only 1 Front per area + if (type === FRONT && has_unit_type_in_loc(FRONT, to)) + return false + + // TODO check current deployment counts + return true } states.scenario_setup = { |