From 3bf03569b869780d6e1e11cfb8bef30f3009a9da Mon Sep 17 00:00:00 2001 From: Mischa Untaga <99098079+MischaU8@users.noreply.github.com> Date: Fri, 29 Sep 2023 16:44:40 +0200 Subject: only 1 front per area --- rules.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/rules.js b/rules.js index f0c7a8e..5bd6756 100644 --- a/rules.js +++ b/rules.js @@ -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 = { -- cgit v1.2.3