From 7f18725fedd24399652c0890a1b98a6354682b34 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 12 Dec 2023 20:50:14 +0100 Subject: Don't allow removing the currently selected piece. --- rules.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/rules.js b/rules.js index ee140f8..f6ced70 100644 --- a/rules.js +++ b/rules.js @@ -1798,19 +1798,24 @@ states.remove_pieces = { disable_negotiation: true, prompt() { view.prompt = "Remove pieces to Available Forces." + let who = -1 + if (game.op) + who = game.op.who + else if (game.prop) + who = game.prop.who for (let p = first_piece[game.current][BASE]; p <= last_piece[game.current][BASE]; ++p) - if (piece_space(p) >= 0) + if (piece_space(p) >= 0 && p !== who) gen_action_piece(p) if (game.current === GOVT) { for (let p = first_piece[game.current][TROOPS]; p <= last_piece[game.current][TROOPS]; ++p) - if (piece_space(p) >= 0) + if (piece_space(p) >= 0 && p !== who) gen_action_piece(p) for (let p = first_piece[game.current][POLICE]; p <= last_piece[game.current][POLICE]; ++p) - if (piece_space(p) >= 0) + if (piece_space(p) >= 0 && p !== who) gen_action_piece(p) } else { for (let p = first_piece[game.current][GUERRILLA]; p <= last_piece[game.current][GUERRILLA]; ++p) - if (piece_space(p) >= 0) + if (piece_space(p) >= 0 && p !== who) gen_action_piece(p) } view.actions.done = 1 -- cgit v1.2.3