From fd2f3f6d70d1641c435a37a6f06d67fb04d22bb1 Mon Sep 17 00:00:00 2001
From: Tor Andersson <tor@ccxvii.net>
Date: Sat, 9 Nov 2024 11:57:03 +0100
Subject: Flanders mixed stacking permission. No modifying Bavarian subsidy.

---
 rules.js | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/rules.js b/rules.js
index e3127f4..c36946d 100644
--- a/rules.js
+++ b/rules.js
@@ -2402,8 +2402,8 @@ function resume_movement_after_flanders_stacking() {
 	flush_alternate_move()
 	set_active_to_power(coop_major_power(game.power))
 	game.selected = -1
+	// keep moving with new power
 	game.state = "movement"
-	// TODO: proper alternation? resume_movement() ?
 }
 
 function is_forbidden_neutral_space(pow, to) {
@@ -3026,15 +3026,17 @@ states.move_give = {
 }
 
 function is_flanders_stack_move() {
-	let here = game.pos[game.selected]
-	if (is_flanders_space(here)) {
-		if (game.power === P_PRAGMATIC) {
-			if (find_general_of_power(here, P_AUSTRIA) >= 0)
-				return true
-		}
-		if (game.power === P_AUSTRIA) {
-			if (find_general_of_power(here, P_PRAGMATIC) >= 0)
-				return true
+	if (!is_two_player()) {
+		let here = game.pos[game.selected]
+		if (is_flanders_space(here)) {
+			if (game.power === P_PRAGMATIC) {
+				if (find_general_of_power(here, P_AUSTRIA) >= 0)
+					return true
+			}
+			if (game.power === P_AUSTRIA) {
+				if (find_general_of_power(here, P_PRAGMATIC) >= 0)
+					return true
+			}
 		}
 	}
 	return false
@@ -3078,6 +3080,7 @@ function end_move_piece() {
 	}
 
 	delete game.move_path
+	delete game.forbidden
 
 	// uniting stacks: flag all as moved
 	let supreme = false
@@ -3091,9 +3094,6 @@ function end_move_piece() {
 		}
 	}
 
-	if (game.flags & F_MOVE_FLANDERS)
-		delete game.forbidden
-
 	if (supreme)
 		game.state = "move_supreme"
 	else if (is_flanders_stack_move())
@@ -3178,11 +3178,8 @@ states.confirm_flanders_stack_2 = {
 		view.actions.refuse = 1
 	},
 	accept() {
+		push_undo()
 		delete game.proposal
-		if (game.power === P_AUSTRIA)
-			set_active_to_power(P_PRAGMATIC)
-		else
-			set_active_to_power(P_AUSTRIA)
 		resume_movement_after_flanders_stacking()
 	},
 	refuse() {
@@ -5422,7 +5419,7 @@ function goto_saxony_becomes_neutral(reason) {
 	map_delete(game.contracts[P_PRUSSIA], P_SAXONY)
 
 	// Return all victory markers
-	log(">Removed victory markers")
+	log("Removed victory markers.")
 	for (let s of all_home_country_fortresses[P_SAXONY]) {
 		let pow = map_get(game.victory, s, -1)
 		if (pow >= 0) {
@@ -6031,6 +6028,8 @@ states.propose_subsidy_to = {
 		prompt(`Subsidy contract from ${power_name[from]} to who?`)
 		for (let to of (is_two_player() ? all_minor_powers : all_powers)) {
 			if (from !== to && is_allied_power(from, to)) {
+				if (from === P_FRANCE && to === P_BAVARIA && game.turn <= 3)
+					continue // may not modify first 3-turn contract
 				if (to === P_SAXONY && is_saxony_neutral())
 					continue
 				gen_action_power(to)
-- 
cgit v1.2.3