From 3657c836555028cfc2927d291a7903734d37a9c2 Mon Sep 17 00:00:00 2001 From: Joël Simoneau Date: Mon, 24 Mar 2025 16:16:16 -0400 Subject: Fix attack --- rules.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rules.js b/rules.js index f119c22..798b884 100644 --- a/rules.js +++ b/rules.js @@ -2916,7 +2916,7 @@ function has_unmoved_piece(space, faction) { function has_valid_attackers(s, faction) { let valid_attacker = false for_each_movable(faction, p => { - if (piece_space(p) === s && (!game.cmd || !set_has(game.cmd.pieces, p))) + if (piece_space(p) === s && (!game.cmd || !game.cmd.pieces || !set_has(game.cmd.pieces, p))) valid_attacker = true if (piece_space(p) === s || (has_piece(piece_space(p), faction, DISC) && SPACES[s].adjacent.includes(piece_space(p)))) if (!game.cmd.pieces || game.cmd.pieces.length === 0) @@ -5144,9 +5144,9 @@ function vm_free_attack() { where: game.vm.s, } - if (!can_attack_in_space(game.vm.s) && !(game.cmd && game.cmd.pieces)) + if (!can_attack_in_space(game.vm.s) && !(game.cmd && game.cmd.pieces)) { vm_next() - else { + } else { log_space(game.vm.s, "Attack") if (is_timurid()) game.cmd.attacker = MI @@ -5551,6 +5551,7 @@ states.shaded_6_2 = { gen_action_resources(VE) }, resources(f) { + push_undo() let n = Math.min(game.resources[f], 3) add_resources(f, -n) add_resources(DS, n) @@ -5626,6 +5627,7 @@ states.shaded_29 = { view.actions.next = 1 }, token(c) { + push_undo() game.cmd.count -= 1 add_resources(game.current, -1) log_summary_cavalry(c) -- cgit v1.2.3