diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-08-28 13:11:32 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 11:54:52 +0100 |
commit | fdab7a730cc2d9c7f403a6cc40a604a64646509a (patch) | |
tree | 47590dd95a356625d67a5b48a0c914600bf7f258 /rules.js | |
parent | 120e91eac89b0af42a28dc5e54238e62524fd34d (diff) | |
download | wilderness-war-fdab7a730cc2d9c7f403a6cc40a604a64646509a.tar.gz |
Add WBC tournament rules variant with 1-step MD units.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 50 |
1 files changed, 38 insertions, 12 deletions
@@ -4,6 +4,8 @@ // TODO: select leader for defense instead of automatically picking the best // TODO: remove old 7 command leader(s) immediately as they're drawn, before placing reinforcements +// TODO: use set functions from rommel instead of array.includes array.push + const { spaces, pieces, cards } = require("./data") const BRITAIN = 'Britain' @@ -80,6 +82,7 @@ function is_light_infantry(p) { return (p >= 26 && p <= 31) } function is_provincial(p) { return (p >= 32 && p <= 55) } function is_southern_provincial(p) { return (p >= 50 && p <= 55) } function is_northern_provincial(p) { return (p >= 32 && p <= 49) } +function is_marine_detachment(p) { return (p >= 127 && p <= 133) } function is_coureurs(p) { return (p >= 119 && p <= 126) } function is_ranger(p) { return (p >= 23 && p <= 25) } function is_indian(p) { return (p >= 14 && p <= 22) || (p >= 97 && p <= 118) } @@ -1071,6 +1074,16 @@ function set_unit_reduced(p, v) { } } +function is_one_step_marine_detachment(p) { + return is_marine_detachment(p) && game.options.one_step_md +} + +function can_reduce_unit(p) { + if (is_one_step_marine_detachment(p)) + return false + return !is_unit_reduced(p) +} + function is_piece_inside(p) { return game.location[p] < 0 } @@ -1757,7 +1770,7 @@ function restore_unit(p) { } function reduce_unit(p, verbose=true) { - if (is_unit_reduced(p)) { + if (is_unit_reduced(p) || is_one_step_marine_detachment(p)) { eliminate_piece(p, verbose) return true } @@ -4933,7 +4946,7 @@ states.step_losses = { if (game.battle.dt_loss > 0) { for (let i = 0; i < game.battle.units.length; ++i) { let p = game.battle.units[i] - if (is_drilled_troops(p) && !is_unit_reduced(p)) { + if (is_drilled_troops(p) && can_reduce_unit(p)) { done = false gen_action_piece(p) } @@ -4951,7 +4964,7 @@ states.step_losses = { if (done) { for (let i = 0; i < game.battle.units.length; ++i) { let p = game.battle.units[i] - if (!is_unit_reduced(p)) { + if (can_reduce_unit(p)) { done = false gen_action_piece(p) } @@ -5016,7 +5029,7 @@ states.raid_step_losses = { if (game.raid.step_loss > 0) { for (let i = 0; i < game.raid.units.length; ++i) { let p = game.raid.units[i] - if (!is_unit_reduced(p)) { + if (can_reduce_unit(p)) { can_reduce = true gen_action_piece(p) } @@ -6503,6 +6516,11 @@ function goto_remove_raided_markers() { // LATE SEASON - WINTER ATTRITION +function is_unit_reduced_for_winter(p) { + // WBC rules: one-step MD are considered reduced for winter attrition + return is_unit_reduced(p) || is_one_step_marine_detachment(p) +} + function goto_winter_attrition() { set_active(FRANCE) game.state = 'winter_attrition' @@ -6530,7 +6548,7 @@ function resume_winter_attrition() { if (is_drilled_troops(p)) { if (is_piece_inside(p) || !safe) { stack.dt.push(p) - if (is_unit_reduced(p)) + if (is_unit_reduced_for_winter(p)) stack.n++ } } @@ -6569,7 +6587,7 @@ states.winter_attrition = { for (let s in game.winter_attrition) { let stack = game.winter_attrition[s] for (let p of stack.dt) { - if (is_unit_reduced(p)) { + if (is_unit_reduced_for_winter(p)) { if (stack.n > 0) { done = false gen_action_piece(p) @@ -6592,7 +6610,7 @@ states.winter_attrition = { piece(p) { let stack = game.winter_attrition[piece_space(p)] push_undo() - if (is_unit_reduced(p)) + if (is_unit_reduced_for_winter(p)) stack.n-- reduce_unit(p, true) remove_from_array(stack.dt, p) @@ -7670,17 +7688,15 @@ states.small_pox_eliminate_steps = { let done = true if (game.count > 0) { for_each_friendly_unit_in_space(game.small_pox, p => { - if (!is_unit_reduced(p)) { + if (can_reduce_unit(p)) { done = false gen_action_piece(p) } }) if (done) { for_each_friendly_unit_in_space(game.small_pox, p => { - if (is_unit_reduced(p)) { - done = false - gen_action_piece(p) - } + done = false + gen_action_piece(p) }) } } @@ -9008,6 +9024,7 @@ states.intrigues_against_shirley = { exports.scenarios = [ "Annus Mirabilis", + "Annus Mirabilis (WBC)", "Early War Campaign", "Late War Campaign", "The Full Campaign", @@ -9414,6 +9431,11 @@ exports.setup = function (seed, scenario, options) { // See https://boardgamegeek.com/thread/1366550/article/19163465#19163465 setup_1757(1759, 2) break + case "Annus Mirabilis (WBC)": + setup_1757(1759, 3) + game.options.one_step_md = 1 + game.options.regulars_from_discard = 1 + break case "Early War Campaign": setup_1755(1759) break @@ -9466,6 +9488,10 @@ exports.setup = function (seed, scenario, options) { log(`After 1756 Britain may exchange a random card for a discarded Regulars or Highlanders.`) } + if (game.options.one_step_md) { + log(`Marine Detachments only have one step.`) + } + start_year() return game |