diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-10-10 14:41:42 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-12-10 18:16:55 +0100 |
commit | 91ff0889ade96fc7a07c39f7879497bf6c525385 (patch) | |
tree | 511ad14cc9b8b71f24726ccae0a3f8f19905e9a7 /rules.js | |
parent | 87313231c6654b8e21fddbadc2cc42c571f73900 (diff) | |
download | plantagenet-91ff0889ade96fc7a07c39f7879497bf6c525385.tar.gz |
Hide asset/forces/routed implementation details.
Use accessors everywhere.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -93,6 +93,7 @@ const CART = 2 const SHIP = 3 const ASSET_TYPE_NAME = [ "Provender", "Coin", "Cart", "Ship" ] +const ASSET_TYPE_COUNT = 4 // battle array const A1 = 0 // attackers @@ -916,8 +917,9 @@ function get_lord_routed_forces(lord, n) { } function lord_has_unrouted_units(lord) { - if (game.pieces.forces[lord] !== 0) - return true + for (let x = 0; x < FORCE_TYPE_COUNT; ++x) + if (get_lord_forces(lord, x) > 0) + return true let result = false for_each_vassal_with_lord(lord, v => { if (!set_has(game.battle.routed_vassals, v)) @@ -927,8 +929,9 @@ function lord_has_unrouted_units(lord) { } function lord_has_routed_units(lord) { - if (game.pieces.routed[lord] !== 0) - return true + for (let x = 0; x < FORCE_TYPE_COUNT; ++x) + if (get_lord_routed(lord, x) > 0) + return true let result = false for_each_vassal_with_lord(lord, v => { if (set_has(game.battle.routed_vassals, v)) @@ -7017,9 +7020,14 @@ function disband_lord(lord, permanently = false) { discard_lord_capability_n(lord, 0) discard_lord_capability_n(lord, 1) - game.pieces.assets[lord] = 0 - game.pieces.forces[lord] = 0 - game.pieces.routed[lord] = 0 + + for (let x = 0; x < ASSET_TYPE_COUNT; ++x) + set_lord_assets(lord, x, 0) + + for (let x = 0; x < FORCE_TYPE_COUNT; ++x) { + set_lord_forces(lord, x, 0) + set_lord_routed(lord, x, 0) + } set_lord_moved(lord, 0) |