diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-12-09 17:28:44 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-01-08 16:36:47 +0100 |
commit | 005a221f87a6b1a24ee9ea38c2e57798401146fe (patch) | |
tree | 51dcbd17cee726f5a22d277653fc4a74c29e8153 | |
parent | 3787128803368f761acdd49303a9bc961e29d979 (diff) | |
download | table-battles-005a221f87a6b1a24ee9ea38c2e57798401146fe.tar.gz |
Inkerman & The Fog.
-rw-r--r-- | play.html | 4 | ||||
-rw-r--r-- | play.js | 5 | ||||
-rw-r--r-- | rules.js | 102 |
3 files changed, 88 insertions, 23 deletions
@@ -86,6 +86,10 @@ main { margin: 12px; } +/* S37 Inkerman - The Fog */ +[data-card="225B"] .slot_sticks { display: none } + + .slot_sticks { height: 87px; display: flex; @@ -111,6 +111,7 @@ function create_formation_slot(id, top) { let card = data.cards[id] let e = create_div("slot " + wing_name[card.wing]) + e.dataset.card = card.number register_animation(e, 250) @@ -119,9 +120,9 @@ function create_formation_slot(id, top) { e.appendChild(ui.cards[id]) } - if (card.special) + if (card.special || card.name === "The Fog") ui.slot_cubes[id] = append_div(e, "slot_cubes") - else + if (!card.special) ui.slot_sticks[id] = append_div(e, "slot_sticks") if (!top) { @@ -29,7 +29,7 @@ TODO: extra input steps */ -// TODO: allow placing dice on full special formations? +// TODO: morale cube limit (cannot place on special if maxed) // TODO: fizzle when action says to take cards from other dice? const data = require("./data.js") @@ -196,6 +196,14 @@ const S8_CLINTON = find_card(8, "Clinton") const S8_GRANT = find_card(8, "Grant") const S8_HESSIANS = find_card(8, "Hessians") +const S37_INKERMAN = find_scenario(37) +const S37_PAULOFFS_LEFT = find_card(37, "Pauloff's Left") +const S37_PAULOFFS_RIGHT = find_card(37, "Pauloff's Right") +const S37_BRITISH_TROOPS = find_card(37, "British Troops") +const S37_FRENCH_TROOPS = find_card(37, "French Troops") +const S37_SOIMONOFF = find_card(37, "Soimonoff") +const S37_THE_FOG = find_card(37, "The Fog") + // === SETUP === exports.setup = function (seed, scenario, options) { @@ -271,6 +279,10 @@ exports.setup = function (seed, scenario, options) { log(".h2 " + info.date) log("") + if (game.scenario === S37_INKERMAN) { + map_set(game.cubes, S37_THE_FOG, 3) + } + goto_action_phase() return game @@ -319,7 +331,7 @@ function add_cubes(c, n) { function remove_cubes(c, n) { let old = map_get(game.cubes, c, 0) - map_set(game.cubes, c, Math.min(0, old - n)) + map_set(game.cubes, c, Math.max(0, old - n)) } function add_sticks(c, n) { @@ -423,9 +435,6 @@ function check_impossible_to_attack_victory() { for (let c of game.front[p]) if (is_card_attack_with_target_in_play(c)) return false - for (let c of game.reserve[p]) - if (is_card_attack_with_target_in_play(c)) - return false return true } @@ -1119,10 +1128,15 @@ function is_mandatory_reaction(c, a) { } function can_take_action(c, a) { - if (a.type === "Attack" && find_target_of_attack(a) < 0) - return false - if (a.type === "Command" && find_first_target_of_command(a) < 0) - return false + if (a.type === "Attack") { + if (find_target_of_attack(a) < 0) + return false + } + + if (a.type === "Command") { + if (find_first_target_of_command(c, a) < 0) + return false + } if (game.scenario === S8_BROOKLYN_HEIGHTS) { if (c === S8_CLINTON) { @@ -1259,7 +1273,7 @@ function goto_take_action(c, ix) { game.state = "bombard" break case "Command": - game.state = "command" + goto_command() break } } @@ -1278,12 +1292,18 @@ function find_target_of_attack(a) { return -1 } -function find_first_target_of_command(a) { - for (let c of a.target_list) { - if (set_has(game.reserve[0], c)) - return c - if (set_has(game.reserve[1], c)) - return c +function find_first_target_of_command(c, a) { + + if (game.scenario === S37_INKERMAN) { + if (c === S37_THE_FOG) + return S37_THE_FOG + } + + for (let t of a.target_list) { + if (set_has(game.reserve[0], t)) + return t + if (set_has(game.reserve[1], t)) + return t } return -1 } @@ -1332,6 +1352,13 @@ function goto_attack() { } } + if (game.scenario === S37_INKERMAN) { + // Until the first Fog Cube is lifted. + if (map_get(game.cubes, S37_THE_FOG, 0) === 3) { + game.hits -= 1 + } + } + if (card_has_rule(game.target, "suffer_1_less_1_max")) game.hits = Math.max(0, Math.min(1, game.hits - 1)) if (card_has_rule(game.target, "suffer_1_less")) @@ -1366,6 +1393,22 @@ function resume_attack() { end_action_phase() } +// === COMMAND === + +function goto_command() { + + if (game.scenario === S37_INKERMAN && game.selected === S37_THE_FOG) { + log("The Fog Lifts...") + remove_cubes(S37_THE_FOG, 1) + remove_dice(game.selected) + end_action_phase() + return + } + + game.state = "command" +} + + states.command = { prompt() { let list = find_all_targets_of_command(current_action()) @@ -1388,7 +1431,14 @@ states.command = { } } - if (find_first_target_of_command(current_action())) { + if (game.scenario === S37_INKERMAN) { + if (c === S37_PAULOFFS_LEFT) { + log("Morale Cube added to Russian side.") + game.morale[0] += 1 + } + } + + if (find_first_target_of_command(game.selected, current_action()) < 0) { pay_for_action(game.selected) end_action_phase() } @@ -1672,6 +1722,7 @@ function get_attack_hits(c, a) { return 1 case "1 hit per die.": case "1 hit per die. 1 self per action.": + case "1 hit per die. Ignore first target until it comes out of Reserve.": return count_dice_on_card(c) case "1 hit per pair.": case "1 hit per pair. 1 self per action.": @@ -1687,6 +1738,7 @@ function get_attack_self(c, a) { throw new Error("invalid attack effect: " + a.effect) case "1 hit.": case "1 hit per die.": + case "1 hit per die. Ignore first target until it comes out of Reserve.": case "1 hit per pair.": return 0 case "1 hit. 1 self per action.": @@ -1877,10 +1929,18 @@ states.pursuit = { // === RESERVE === -function should_enter_reserve(rc) { - let reserve = data.cards[rc].reserve - for (let c of reserve) - if (!set_has(game.front[0], c) && !set_has(game.front[1], c)) +function should_enter_reserve(c) { + let reserve = data.cards[c].reserve + + if (game.scenario === S37_INKERMAN) { + if (c === S37_BRITISH_TROOPS) + return map_get(game.cubes, S37_THE_FOG, 0) === 1 + if (c === S37_FRENCH_TROOPS) + return map_get(game.cubes, S37_THE_FOG, 0) === 0 + } + + for (let t of reserve) + if (!set_has(game.front[0], t) && !set_has(game.front[1], t)) return true return false } |