summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js140
1 files changed, 96 insertions, 44 deletions
diff --git a/rules.js b/rules.js
index 1766531..607e5a0 100644
--- a/rules.js
+++ b/rules.js
@@ -576,6 +576,7 @@ const DRESDEN = find_city("Dresden")
const WOLDENBURG = find_city("Woldenburg")
const OMANS = find_city("Omans")
const STEINAMANGER = find_city("Steinamanger")
+const GRONINGEN = find_city("Groningen")
const ENGLAND = find_city("England")
const EAST_PRUSSIA = find_city("East Prussia")
@@ -4812,6 +4813,7 @@ states.political_card_done = {
view.actions.end_political_card = 1
},
end_political_card() {
+ push_undo()
end_execute_political_card()
},
}
@@ -4976,7 +4978,7 @@ function goto_pragmatic_general_to_england() {
log("Pragmatic Army -1 TC until game end.")
set_active_to_power(P_PRAGMATIC)
game.selected = ENGLAND
- game.state = "send_expeditionary_corps_off_map"
+ game.state = "send_expeditionary_corps"
}
/* POLITICAL TRACKS */
@@ -5088,29 +5090,27 @@ function goto_adjust_political_tracks() {
goto_expeditionary_corps()
}
-function check_expeditionary_corps(power, space, active) {
- let p = find_general_of_power(space, power)
+function check_expeditionary_corps(power, active) {
+ let p = find_off_map_piece(power)
if (active && p < 0) {
set_active_to_power(power)
- game.selected = space
- game.state = "send_expeditionary_corps_off_map"
+ game.state = "send_expeditionary_corps"
return 1
}
if (!active && p >= 0) {
set_active_to_power(power)
- game.selected = p
- game.state = "bring_expeditionary_corps_on_map"
+ goto_return_expeditionary_corps()
return 1
}
return 0
}
function goto_expeditionary_corps() {
- if (check_expeditionary_corps(P_PRUSSIA, EAST_PRUSSIA, game.russia >= 5))
+ if (check_expeditionary_corps(P_PRUSSIA, game.russia >= 5))
return
- if (check_expeditionary_corps(P_FRANCE, FRENCH_ITALY_BOX, game.italy >= 8))
+ if (check_expeditionary_corps(P_FRANCE, game.italy >= 8))
return
- if (check_expeditionary_corps(P_AUSTRIA, AUSTRIAN_ITALY_BOX, game.italy <= 2))
+ if (check_expeditionary_corps(P_AUSTRIA, game.italy <= 2))
return
goto_saxony_defection()
}
@@ -5130,48 +5130,100 @@ function goto_saxony_defection() {
/* EXPEDITIONARY CORPS */
-states.bring_expeditionary_corps_on_map = {
- inactive: "bring expeditionary corps onto map",
+function off_map_box(pow) {
+ if (pow === P_PRUSSIA)
+ return EAST_PRUSSIA
+ if (pow === P_FRANCE)
+ return FRENCH_ITALY_BOX
+ if (pow === P_AUSTRIA)
+ return AUSTRIAN_ITALY_BOX
+ if (pow === P_PRAGMATIC)
+ return ENGLAND
+ return -1
+}
+
+function off_map_entry_space(pow) {
+ if (pow === P_PRUSSIA)
+ return WOLDENBURG
+ if (pow === P_FRANCE)
+ return OMANS
+ if (pow === P_AUSTRIA)
+ return STEINAMANGER
+ if (pow === P_PRAGMATIC)
+ return GRONINGEN
+ return -1
+}
+
+function find_off_map_piece(pow) {
+ return find_general_of_power(off_map_box(pow), pow)
+}
+
+function goto_return_expeditionary_corps() {
+ game.state = "return_expeditionary_corps"
+ if (can_move_piece_to(find_off_map_piece(game.power), ELIMINATED, off_map_entry_space(game.power)))
+ game.state = "return_expeditionary_corps"
+ else
+ game.state = "return_expeditionary_corps_push"
+}
+
+states.return_expeditionary_corps_push = {
+ inactive: "return expeditionary corps",
prompt() {
- prompt("Bring expeditionary corps onto map.")
- view.selected = game.selected
- let entry = -1
- if (game.power === P_PRUSSIA)
- entry = WOLDENBURG
- if (game.power === P_FRANCE)
- entry = OMANS
- if (game.power === P_AUSTRIA)
- entry = STEINAMANGER
- if (can_move_piece_to(game.selected, ELIMINATED, entry))
- gen_action_space(entry)
- else
- for (let s of search_nearest_city(game.selected, entry))
- gen_action_space(s)
+ prompt("Move blocking pieces out of the way.")
+ let s = off_map_entry_space(game.power)
+ for (let p of all_pieces)
+ if (game.pos[p] === s)
+ gen_action_piece(p)
},
- space(s) {
+ piece(p) {
push_undo()
- log(`Expeditionary corps P${game.selected} from S${game.pos[game.selected]} to S${s}.`)
- enter_piece_at(game.selected, s)
+ set_active_to_power(piece_power[p])
+ game.selected = p
+ game.state = "return_expeditionary_corps_push_to"
+ },
+}
+
+states.return_expeditionary_corps_push_to = {
+ inactive: "return expeditionary corps",
+ prompt() {
+ prompt("Move blocking pieces out of the way.")
+ view.selected = game.selected
+ for (let s of search_nearest_city(game.selected, game.pos[game.selected]))
+ gen_action_space(s)
+ },
+ space(to) {
+ let who = game.selected
+ let from = game.pos[who]
+ log("P" + who + " from S" + from + " to S" + to + ".")
+ enter_piece_at(who, to)
game.selected = -1
- game.state = "bring_expeditionary_corps_on_map_done"
+ if (has_any_piece(from))
+ game.state = "return_expeditionary_corps_push"
+ else
+ goto_expeditionary_corps()
},
}
-states.bring_expeditionary_corps_on_map_done = {
- inactive: "bring expeditionary corps onto map",
+states.return_expeditionary_corps = {
+ inactive: "return expeditionary corps",
prompt() {
- prompt("Bring expeditionary corps onto map done.")
- view.actions.next = 1
+ prompt("Return expeditionary corps.")
+ view.selected = find_off_map_piece(game.power)
+ gen_action_space(off_map_entry_space(game.power))
},
- next() {
+ space(to) {
+ let who = find_off_map_piece(game.power)
+ let from = game.pos[who]
+ log("P" + who + " from S" + from + " to S" + to + ".")
+ enter_piece_at(who, to)
goto_expeditionary_corps()
},
}
-states.send_expeditionary_corps_off_map = {
+states.send_expeditionary_corps = {
inactive: "send expeditionary corps off map",
prompt() {
- prompt("Send expeditionary corps off map.")
+ prompt("Send expeditionary corps to off map box.")
for (let p of all_power_generals[game.power])
if (is_piece_on_map_or_eliminated(p))
gen_action_piece(p)
@@ -5179,9 +5231,9 @@ states.send_expeditionary_corps_off_map = {
piece(p) {
push_undo()
- log(`Expeditionary corps P${p} from S${game.pos[p]} to S${game.selected}.`)
- game.pos[p] = game.selected
- game.selected = -1
+ let s = off_map_box(game.power)
+ log(`Expeditionary corps P${p} from S${game.pos[p]} to S${s}.`)
+ game.pos[p] = s
if (game.troops[p] === 0) {
game.recruit = {
@@ -5191,15 +5243,15 @@ states.send_expeditionary_corps_off_map = {
game.selected = p
game.state = "recruit_for_expeditionary_corps"
} else {
- game.state = "send_expeditionary_corps_off_map_done"
+ game.state = "send_expeditionary_corps_done"
}
},
}
-states.send_expeditionary_corps_off_map_done = {
+states.send_expeditionary_corps_done = {
inactive: "send expeditionary corps off map",
prompt() {
- prompt("Send expeditionary corps off map done.")
+ prompt("Send expeditionary corps to off map box done.")
view.actions.next = 1
},
next() {
@@ -5469,7 +5521,7 @@ states.saxony_move_general = {
},
space(s) {
log(">P" + game.selected + " to S" + s)
- enter_general_at(game.selected, s)
+ enter_piece_at(game.selected, s)
end_saxony_neutral()
},
}