diff options
-rw-r--r-- | play.js | 15 | ||||
-rw-r--r-- | rules.js | 30 |
2 files changed, 36 insertions, 9 deletions
@@ -790,11 +790,11 @@ function layout_score() { } } -function update_rebels(faction, type, rebel) { - let p0 = first_piece[faction][type] - let p1 = last_piece[faction][type] +function update_rebels(faction) { + let p0 = first_piece[faction][ELITE] + let p1 = last_piece[faction][ELITE] for (let i = 0, p = p0; p <= p1; ++i, ++p) { - if (underground & (1 << i)) + if (view.rebel[faction] & (1 << i)) ui.pieces[p].classList.add("rebel") else ui.pieces[p].classList.remove("rebel") @@ -942,6 +942,10 @@ function on_update() { layout_sop() + // Rebel status + update_rebels(BK) + update_rebels(VE) + // Action for pieces if (view.actions && view.actions.piece) for (let i = 0; i < ui.pieces.length; ++i) @@ -1027,9 +1031,6 @@ return tix = layout_terror(tix, s, map_get(view.terror, s, 0) * 1) - update_rebels(BK, AMIR, view.rebel[BK]) - update_rebels(VE, RAJA, view.rebel[VE]) - drugs.length = 0 for (let i = 0; i < 4; ++i) { let shx = view.shipments[i] @@ -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) { |