summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-05-25 20:17:26 +0200
committerTor Andersson <tor@ccxvii.net>2024-05-30 21:59:25 +0200
commit0e4abab197699be791514f7c0837e67052a4e79a (patch)
treef7f2167106e6dcdc64312fabcf8584dad6504582
parent8892166f17febbf7a91e6daef4b684b1345495ca (diff)
downloadfriedrich-0e4abab197699be791514f7c0837e67052a4e79a.tar.gz
dilatory daun!
-rw-r--r--play.js11
-rw-r--r--rules.js67
2 files changed, 78 insertions, 0 deletions
diff --git a/play.js b/play.js
index 6da09b2..a2b93f6 100644
--- a/play.js
+++ b/play.js
@@ -169,46 +169,57 @@ const fate_effect_text = [
"Any one Russian on-map general receives a new troop for free (if possible).",
"Austria and Russia may exchange one TC with each other.",
"Tottleben receives a new troop for free (if possible and if on-map).",
+
"No effect.",
"If Fermor starts his move in Küstrin (H6) or in an adjacent city, he may not move next turn.",
"Apraxin immediately loses one troop (but not if he has to be taken off-map).",
"Next turn, Saltikov may move only 2 cities (3 on main roads).",
+
"No effect.",
"Next turn, if Prussia and France fight each other, they may not use TCs with values of 10 or more.",
"Next turn, Soubise and Hildburghausen may not attack with the same TC-symbol.",
"Next turn, no general may be attacked in the city of Halle (E4) and no supply train may be eliminated in the city of Halle.",
+
"Next turn, the first TC played by France is worth an additional point.",
"No effect.",
"France may discard any one TC for a new one from the draw deck.",
"Next turn, Cumberland may not move into attack position; he may not eliminate a supply train.",
+
"Next turn, Soubise may not move into attack position; he may not eliminate a supply train.",
"No effect.",
"Next turn, Richelieu may move 2 cities only (3 on main roads).",
"If stacked, Chevert may not unstack next turn.",
+
"Austria may move Laudon by one city immediately; Laudon may even unstack.",
"Daun receives one new troop (if possible and if on-map).",
"No effect.",
"Austria may flip any one Prussian general/stack in Austria or Saxony, and in doing so, set him out of supply.",
+
"Next turn, Friedrich may not move into attack position and may not eliminate a supply train.",
"No effect.",
"Next turn, Friedrich may not receive any new troops.",
"If Friedrich is involved in combat next turn, Prussia must reach a positive score with the first TC(s) she plays (if possible).",
+
"Any one Prussian on-map general receives a new troop for free (if possible).",
"Next turn, any Prussians who are attacked by Daun may move to any empty adjacent city (before the combat is resolved); by doing so they avoid all combat.",
"No effect.",
"If Friedrich attacks next turn, his first TC is worth 5 additional points.",
+
"All Russian generals 5 or 6 cities distant from their nearest supply train are immediately out of supply; flip them.",
"Next turn, Friedrich may move 4 cities, even as a stack (5 on main roads).",
"No effect.",
"Prussia may draw randomly one TC from Austria, after first giving one TC of her choice to Austria.",
+
"Next turn, every Prussian general who receives new troops may not move into attack position.",
"Any one Prussian general with 2 or more troops loses one troop immediately.",
"If Friedrich is attacked next turn, the first TC played by Prussia is worth nothing (0 points).",
"No effect.",
+
"Next turn, Prussia may play the 11 of spades (Seydlitz) once at double value.",
"Any one Hanoverian on-map general receives a new troop (if possible).",
"Next turn, Prinz Heinrich protects objectives up to 4 cities distant.",
"No effect.",
+
"Next turn, Daun may move only 2 cities (3 on main roads).",
"If Ehrensvärd is 5 or 6 cities distant from his supply train, he is immediately out of supply; flip him.",
"If Hildburghausen has lost a battle this turn, Prussia may move him 2 cities westwards (if possible).",
diff --git a/rules.js b/rules.js
index caad38b..8d6a48f 100644
--- a/rules.js
+++ b/rules.js
@@ -399,6 +399,61 @@ function must_reach_positive_score() {
return false
}
+function has_empty_adjacent_city(here) {
+ for (let next of data.cities.adjacent[here])
+ if (!has_any_piece(next))
+ return true
+ return false
+}
+
+function are_prussians_attacked_by_daun() {
+ let from = game.pos[GEN_DAUN]
+ if (game.power === P_AUSTRIA && from < ELIMINATED) {
+ for (let p of all_power_generals[P_PRUSSIA])
+ if (set_has(data.cities.adjacent[from], game.pos[p]) && has_empty_adjacent_city(game.pos[p]))
+ return true
+ }
+ return false
+}
+
+states.prussians_who_are_attacked_by_daun_may_move = {
+ prompt() {
+ prompt("Any Prussians who are attacked by Daun may move to any empty adjacent city.")
+ let daun = game.pos[GEN_DAUN]
+ for (let p of all_power_generals[P_PRUSSIA])
+ if (set_has(data.cities.adjacent[daun], game.pos[p]))
+ gen_action_supreme_commander(game.pos[p])
+ view.actions.next = 1
+ },
+ piece(p) {
+ push_undo()
+ game.selected = select_stack(game.pos[p])
+ game.state = "move_to_any_empty_adjacent_city"
+ },
+ next() {
+ clear_undo()
+ set_active_to_power(P_AUSTRIA)
+ goto_combat_2()
+ },
+}
+
+states.move_to_any_empty_adjacent_city = {
+ prompt() {
+ prompt(format_selected() + " may move to any empty adjacent city.")
+ let here = game.pos[game.selected[0]]
+ for (let next of data.cities.adjacent[here])
+ if (!has_any_piece(next))
+ gen_action_space(next)
+ },
+ space(s) {
+ for (let p of game.selected) {
+ log("P" + p + " to S" + s)
+ game.pos[p] = s
+ }
+ game.state = "prussians_who_are_attacked_by_daun_may_move"
+ },
+}
+
/* OBJECTIVES */
const all_objectives = []
@@ -2246,6 +2301,18 @@ function inactive_defend() {
function goto_combat() {
set_clear(game.moved)
+ if (game.fx === NEXT_TURN_ANY_PRUSSIANS_WHO_ARE_ATTACKED_BY_DAUN_MAY_MOVE_TO_ANY_EMPTY_ADJACENT_CITY) {
+ if (are_prussians_attacked_by_daun()) {
+ set_active_to_power(P_PRUSSIA)
+ game.state = "prussians_who_are_attacked_by_daun_may_move"
+ return
+ }
+ }
+
+ goto_combat_2()
+}
+
+function goto_combat_2() {
let from = []
let to = []