summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js84
1 files changed, 78 insertions, 6 deletions
diff --git a/rules.js b/rules.js
index 65562e7..61e360a 100644
--- a/rules.js
+++ b/rules.js
@@ -116,6 +116,7 @@ const V_POLITICS = 1
const V_HUSSARS = 2
const V_MOVEMENT = 4
const V_RETREAT = 8
+const V_COMBAT = 16
const SPADES = 0
const CLUBS = 1
@@ -3873,6 +3874,8 @@ function goto_resolve_combat() {
set_active_defender()
game.state = "combat_defend"
}
+
+ save_checkpoint()
}
function end_resolve_combat() {
@@ -3952,6 +3955,18 @@ function resume_combat_defend() {
game.state = "combat_defend"
}
+function resume_combat_attack_v() {
+ set_active_attacker()
+ game.state = "combat_attack"
+ save_checkpoint()
+}
+
+function resume_combat_defend_v() {
+ set_active_defender()
+ game.state = "combat_defend"
+ save_checkpoint()
+}
+
function gen_play_card(suit) {
let score = Math.abs(game.count)
let has_suit = false
@@ -4022,7 +4037,7 @@ states.combat_attack = {
play_combat_card(c, +1, resume_combat_attack, "combat_attack_reserve")
},
pass() {
- end_resolve_combat()
+ goto_validate_combat(end_resolve_combat)
},
}
@@ -4036,7 +4051,7 @@ states.combat_defend = {
play_combat_card(c, -1, resume_combat_defend, "combat_defend_reserve")
},
pass() {
- end_resolve_combat()
+ goto_validate_combat(end_resolve_combat)
},
}
@@ -4073,8 +4088,7 @@ states.combat_attack_swap = {
view.actions.next = 1
},
next() {
- set_active_defender()
- game.state = "combat_defend"
+ goto_validate_combat(resume_combat_defend_v)
},
}
@@ -4085,8 +4099,7 @@ states.combat_defend_swap = {
view.actions.next = 1
},
next() {
- set_active_attacker()
- game.state = "combat_attack"
+ goto_validate_combat(resume_combat_attack_v)
},
}
@@ -6986,6 +6999,65 @@ states.validate_movement_fail = {
},
}
+/* VALIDATE: COMBAT */
+
+const validate_combat_next = {
+ end_resolve_combat,
+ resume_combat_defend_v,
+ resume_combat_attack_v,
+}
+
+function goto_validate_combat(next) {
+ game.validate_next = next.name
+ goto_validate_promise(V_COMBAT, resume_validate_combat)
+}
+
+function resume_validate_combat() {
+ resume_validate_promise("validate_combat", end_validate_combat)
+}
+
+function end_validate_combat() {
+ let next = validate_combat_next[game.validate_next]
+ delete game.validate_next
+ clear_checkpoint()
+ next()
+}
+
+states.validate_combat = {
+ dont_snap: true,
+ inactive: "confirm that promises were kept",
+ prompt() {
+ let other = game.restart.power
+ prompt("Did " + power_name[other] + " keep their combat promise?")
+ view.actions.keep = 1
+ view.actions.break = 1
+ view.actions.undo = 0
+ },
+ keep() {
+ resume_validate_combat()
+ },
+ break() {
+ let other = game.power
+ restore_checkpoint()
+ game.proposal = { other, state: game.state }
+ game.state = "validate_combat_fail"
+ },
+}
+
+states.validate_combat_fail = {
+ dont_snap: true,
+ inactive: "combat",
+ prompt() {
+ prompt("Combat promise to " + power_name[game.proposal.other] + " was not kept.")
+ view.actions.resume = 1
+ view.actions.undo = 0
+ },
+ resume() {
+ game.state = game.proposal.state
+ delete game.proposal
+ },
+}
+
/* VALIDATE: RETREAT */
function goto_validate_retreat() {