From a142db65d810ff668ba5b1a48a59c4b2db31499c Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 2 May 2021 14:49:24 +0200 Subject: 300: Miltiades as offense. --- rules.js | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/rules.js b/rules.js index a13dbde..ce4c514 100644 --- a/rules.js +++ b/rules.js @@ -25,6 +25,7 @@ const PELLA = "Pella"; // Greek event numbers const MINES_OF_LAURION = 1; +const MILTIADES = 4; const LEONIDAS = 8; const EVANGELION = 10; const MOLON_LABE = 12; @@ -1077,10 +1078,18 @@ states.greek_land_movement_confirm = { if (is_inactive_player(current)) return view.prompt = "Greek Land Movement."; view.prompt = "Greek Land Movement: Confirm destination."; + if (game.greek.hand.includes(MILTIADES) && can_play_miltiades_attack()) { + view.prompt += " You may also play Miltiades."; + gen_action(view, 'card_event', MILTIADES); + } gen_action(view, 'city', game.where); gen_action(view, 'next'); gen_action(view, 'undo'); }, + card_event: function (card) { + push_undo(); + play_miltiades_attack(); + }, city: function () { clear_undo(); goto_greek_land_battle(); @@ -2200,7 +2209,6 @@ states.leonidas_pay = { }, city: function (space) { push_undo(); - log("Greece removes 1 army in " + space + "."); game.trigger.leonidas = 1; remove_greek_army(space); game.state = 'leonidas'; @@ -2318,6 +2326,44 @@ states.desertion_of_greek_soldiers = { } } +// GREEK REACTION EVENTS + +function can_play_miltiades_attack() { + return !game.trigger.miltiades && count_persian_armies(game.where) > 0; +} + +function play_miltiades_attack() { + play_greek_event_card(MILTIADES); + game.event = MILTIADES; + if (count_greek_armies(RESERVE) > 0) { + remove_greek_army(RESERVE); + game.trigger.miltiades = 1; + } else { + game.state = 'miltiades_attack_pay'; + } +} + +states.miltiades_attack_pay = { + prompt: function (view, current) { + if (is_inactive_player(current)) + return view.prompt = "Leonidas."; + view.prompt = "Miltiades: Remove one Greek army to pay for the event."; + for (let city of CITIES) { + let need = (city == game.where) ? 2 : 1; + if (count_greek_armies(city) >= need) + gen_action(view, 'city', city); + } + gen_action_undo(view); + }, + city: function (space) { + push_undo(); + remove_greek_army(space); + game.trigger.miltiades = 1; + game.state = 'greek_land_movement_confirm'; + }, + undo: pop_undo, +} + // SUPPLY PHASE function goto_supply_phase() { -- cgit v1.2.3