summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js30
1 files changed, 28 insertions, 2 deletions
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) {