From 48b128fa766363fc35a74bfdeefed133c1f6b78c Mon Sep 17 00:00:00 2001 From: Joël Simoneau Date: Sun, 27 Oct 2024 19:29:49 -0400 Subject: Rebel status --- rules.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index f91e303..6cef5b5 100644 --- a/rules.js +++ b/rules.js @@ -101,6 +101,7 @@ exports.view = function (state, role) { pieces: game.pieces, tributary: game.tributary, control: game.control, + rebel: game.rebel, } if (game.result) { @@ -189,7 +190,7 @@ exports.setup = function (seed, scenario, _options) { ve_inf: 0, tributary: 8191, // all 13 provinces control: [0, 0, 0], - rebel: 0, // amir/raja rebel status + rebel: [null, 0, 0], // amir/raja rebel status pieces: Array(104).fill(AVAILABLE), // piece locations cavalry: [0, 0, 0], deck: [], @@ -628,6 +629,7 @@ states.rebel = { push_undo() select_cmd_space(s, 1) remove_tributary(s) + to_rebel_space(s, game.current) log_space(s, "Rebel") }, end_rebel: end_command, @@ -762,7 +764,7 @@ function can_build_in_space(s) { return has_piece(s, game.current, ELITE) } -/* TOKENS */ +/* TRIBUTARY AND REBELS */ function add_tributary(s) { game.tributary |= (1 << s) @@ -778,6 +780,30 @@ function remove_tributary(s) { update_control() } +function to_obedient(p) { + let faction = piece_faction(p) + let piece_index = p - first_piece[faction][ELITE] + game.rebel[faction] |= ~(1 << piece_index) +} + +function to_rebel(p) { + let faction = piece_faction(p) + let piece_index = p - first_piece[faction][ELITE] + console.log("with p ", p) + console.log("with piece_index ", piece_index) + console.log(game.rebel) + game.rebel[faction] |= (1 << piece_index) + console.log(game.rebel) +} + +function to_rebel_space(s, faction) { + let first = first_piece[faction][ELITE] + let last = last_piece[faction][ELITE] + for (let p = first; p <= last; ++p) + if (piece_space(p) === s) + to_rebel(p) +} + /* MISC SPACE + PIECE QUERIES */ function count_pieces(s, faction, type) { -- cgit v1.2.3