diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-12-14 12:37:25 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-01-08 16:36:48 +0100 |
commit | a3447a670f869ea2d4d8bca26fad526fa3e531c9 (patch) | |
tree | 0f5954fb0790486f73266b49814c2d665b726dad | |
parent | 000d7493517e569b9ebe5cb493c3541eef9589f4 (diff) | |
download | table-battles-a3447a670f869ea2d4d8bca26fad526fa3e531c9.tar.gz |
Chiari - cassines.
-rw-r--r-- | rules.js | 79 |
1 files changed, 74 insertions, 5 deletions
@@ -285,10 +285,20 @@ const S35_MONTROSE = find_card(35, "Montrose") const S35_GORDON = find_card(35, "Gordon") const S39_MARSAGLIA = find_scenario(39) -const S39_EUGENE = find_card(39, "Eugene") const S39_CANNONS = find_card(39, "Cannons") +const S39_EUGENE = find_card(39, "Eugene") +const S39_DUKE_OF_SAVOY = find_card(39, "Duke of Savoy") const S39_BAYONETS = find_card(39, "Bayonets!") const S39_CATINAT = find_card(39, "Catinat") +const S39_HOGUETTE = find_card(39, "Hoguette") + +const S40_CHIARI = find_scenario(40) +const S40_CASSINES_I = find_card(40, "Cassines I") +const S40_NIGRELLI = find_card(40, "Nigrelli") +const S40_KRIECHBAUM = find_card(40, "Kriechbaum") +const S40_CASSINES_II = find_card(40, "Cassines II") +const S40_MANNSFELDT = find_card(40, "Mannsfeldt") +const S40_GUTTENSTEIN = find_card(40, "Guttenstein") // === SETUP === @@ -371,14 +381,18 @@ exports.setup = function (seed, scenario, options) { log(".h1 " + info.name) log(".h2 " + info.date) log("") - if (info.rule_text) + if (info.rule_text) { log(info.rule_text) + log("") + } + if (info.players[0].tactical > 0 || info.players[1].tactical > 0) { log("Tactical Victory:") if (info.players[0].tactical > 0) log(">" + player_name(0) + ": " + info.players[0].tactical) if (info.players[1].tactical > 0) log(">" + player_name(1) + ": " + info.players[1].tactical) + log("") } if (game.scenario === S37_INKERMAN) { @@ -477,9 +491,6 @@ function take_all_dice(from, to) { for (let i = 0; i < 12; ++i) { if (get_dice_location(i) === from) { set_dice_location(i, to) - if (to === POOL) - set_dice_value(i, 0) - to = POOL } } } @@ -652,6 +663,14 @@ function check_impossible_to_attack_victory() { function check_victory() { let info = data.scenarios[game.scenario] + // Scenario specific victory conditions. + if (game.scenario === S39_MARSAGLIA) { + if (is_removed_from_play(S39_HOGUETTE) && is_removed_from_play(S39_CATINAT)) + goto_game_over(P1, P2 + " lost both linked formations.") + if (is_removed_from_play(S39_DUKE_OF_SAVOY) && is_removed_from_play(S39_EUGENE)) + goto_game_over(P2, P1 + " lost both linked formations.") + } + if (game.morale[0] === 0) return goto_game_over(P2, P1 + " has run out of morale!") if (game.morale[1] === 0) @@ -1602,6 +1621,10 @@ function can_take_action(c, a, ix) { return false } +function s40_can_take_cassines_action(c, a, b) { + return (player_index() === 1) && (get_sticks(c) < 3) && (is_card_in_play(a) || is_card_in_play(b)) +} + function can_take_any_action() { let p = player_index() for (let c of game.front[p]) { @@ -1612,6 +1635,14 @@ function can_take_any_action() { return true } } + + if (game.scenario === S40_CHIARI) { + if (s40_can_take_cassines_action(S40_CASSINES_I, S40_NIGRELLI, S40_KRIECHBAUM)) + return true + if (s40_can_take_cassines_action(S40_CASSINES_II, S40_MANNSFELDT, S40_GUTTENSTEIN)) + return true + } + return false } @@ -1719,6 +1750,13 @@ states.action = { gen_action_retire(c) } } + + if (game.scenario === S40_CHIARI) { + if (s40_can_take_cassines_action(S40_CASSINES_I, S40_NIGRELLI, S40_KRIECHBAUM)) + gen_action_card(S40_CASSINES_I) + if (s40_can_take_cassines_action(S40_CASSINES_II, S40_MANNSFELDT, S40_GUTTENSTEIN)) + gen_action_card(S40_CASSINES_II) + } }, retire(c) { push_undo() @@ -1746,6 +1784,37 @@ states.action = { goto_roll_phase() roll_dice_in_pool() }, + card(c) { + push_undo() + if (game.scenario === S40_CHIARI) { + game.selected = c + game.state = "s40_cassines" + } + } +} + +states.s40_cassines = { + prompt() { + view.prompt = "Cassines: Move one unit stick to this card." + if (game.selected === S40_CASSINES_I) { + if (is_card_in_play(S40_NIGRELLI)) + gen_action_card(S40_NIGRELLI) + if (is_card_in_play(S40_KRIECHBAUM)) + gen_action_card(S40_KRIECHBAUM) + } + if (game.selected === S40_CASSINES_II) { + if (is_card_in_play(S40_MANNSFELDT)) + gen_action_card(S40_MANNSFELDT) + if (is_card_in_play(S40_GUTTENSTEIN)) + gen_action_card(S40_GUTTENSTEIN) + } + }, + card(c) { + log(game.selected + " moved one stick from " + c) + set_sticks(c, get_sticks(c) - 1) + set_sticks(game.selected, get_sticks(game.selected) + 1) + end_action_phase() + }, } function goto_null(c) { |