diff options
author | Joël Simoneau <simoneaujoel@gmail.com> | 2024-10-27 19:29:49 -0400 |
---|---|---|
committer | Joël Simoneau <simoneaujoel@gmail.com> | 2024-10-27 19:29:49 -0400 |
commit | 48b128fa766363fc35a74bfdeefed133c1f6b78c (patch) | |
tree | 643935509bed8c98383ce7f6e235aea1d0ebac72 /rules.js | |
parent | 47833d20bdd7dbfdd3f13e820f595fbd5b5c387b (diff) | |
download | vijayanagara-48b128fa766363fc35a74bfdeefed133c1f6b78c.tar.gz |
Rebel status
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 30 |
1 files changed, 28 insertions, 2 deletions
@@ -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) { |