diff options
-rw-r--r-- | play.js | 15 | ||||
-rw-r--r-- | rules.js | 146 |
2 files changed, 103 insertions, 58 deletions
@@ -502,17 +502,24 @@ function on_update() { for (let i = 0; i < space_names.length; ++i) layout[i] = [] + for (let i = 0; i < 36; ++i) { if (view.pieces[i] >= 0) { layout[view.pieces[i]].push(ui.cubes[i]) ui.cubes[i].classList.remove("hide") - ui.cubes[i].classList.toggle("action", is_piece_action(i)) - ui.cubes[i].classList.toggle("selected", i === view.selected_cube) - } - else { + } else if (i >= 18) { ui.cubes[i].classList.add("hide") } + ui.cubes[i].classList.toggle("action", is_piece_action(i)) + ui.cubes[i].classList.toggle("selected", i === view.selected_cube) } + + let red_out_of_play = [] + for (let i = 0; i <= 17; ++i) + if (view.pieces[i] < 0) + red_out_of_play.push(ui.cubes[i]) + layout_cubes(red_out_of_play, 1225, 225) + for (let i = 0; i < space_count; ++i) { layout_cubes(layout[i], space_layout_cube[i].x, space_layout_cube[i].y) ui.spaces[i].classList.toggle("action", is_space_action(i)) @@ -1161,8 +1161,7 @@ states.advance_revolutionary_momentum = { view.actions.red_momentum = 1 }, red_momentum() { - advance_revolutionary_momentum1(1) - advance_revolutionary_momentum2(1) + increase_revolutionary_momentum() }, } @@ -1172,8 +1171,7 @@ states.advance_prussian_collaboration = { view.actions.blue_momentum = 1 }, blue_momentum() { - advance_prussian_collaboration1(1) - advance_prussian_collaboration2(1) + increase_prussian_collaboration() }, } @@ -1238,59 +1236,108 @@ function discard_final() { // === PLAYER MOMENTUM TRACKS === -function advance_revolutionary_momentum(x) { - advance_revolutionary_momentum1(x) - advance_revolutionary_momentum2(x) +function increase_revolutionary_momentum() { + game.red_momentum += 1 + log("Increased RM to " + game.red_momentum + ".") + goto_increase_revolutionary_momentum_trigger() } -function advance_revolutionary_momentum1(x) { - game.red_momentum += x - if (x > 0) - log("Increased RM to " + game.red_momentum + ".") - else - log("Decreased RM to " + game.red_momentum + ".") - for (let i = game.red_momentum; i < 3; ++i) - for_each_commune_cube(RED_CUBE_POOL[i], remove_piece_from_play) -} - -function advance_revolutionary_momentum2(x) { +function goto_increase_revolutionary_momentum_trigger() { game.momentum_active = game.active game.active = VERSAILLES - if (x > 0 && game.red_momentum >= 2 && can_place_cube_in_any(INSTITUTIONAL)) { + if (game.red_momentum >= 2 && can_place_cube_in_any(INSTITUTIONAL)) { clear_undo() - game.state = "revolutionary_momentum_trigger" + game.state = "increase_revolutionary_momentum_trigger" } else { - end_momentum_trigger() + end_increase_momentum() } } -function advance_prussian_collaboration(x) { - advance_prussian_collaboration1(x) - advance_prussian_collaboration2(x) +function increase_prussian_collaboration() { + game.blue_momentum += 1 + log("Increased BM to " + game.blue_momentum + ".") + goto_increase_prussian_collaboration_add() } -function advance_prussian_collaboration1(x) { - game.blue_momentum += x - if (x > 0) - log("Increased BM to " + game.blue_momentum + ".") - else - log("Decreased BM to " + game.blue_momentum + ".") +function goto_increase_prussian_collaboration_add() { + game.state = "increase_prussian_collaboration_add" for (let i = 0; i < game.blue_momentum; ++i) - for_each_versailles_cube(PRUSSIAN_COLLABORATION[i], remove_piece) + if (has_versailles_cube(PRUSSIAN_COLLABORATION[i])) + return + goto_increase_prussian_collaboration_trigger() } -function advance_prussian_collaboration2(x) { +function goto_increase_prussian_collaboration_trigger() { game.momentum_active = game.active game.active = COMMUNE - if (x > 0 && game.blue_momentum >= 2 && can_place_cube_in_any(PUBLIC_OPINION)) { + if (game.blue_momentum >= 2 && can_place_cube_in_any(PUBLIC_OPINION)) { clear_undo() - game.state = "prussian_collaboration_trigger" + game.state = "increase_prussian_collaboration_trigger" } else { - end_momentum_trigger() + end_increase_momentum() } } -states.revolutionary_momentum_trigger = { +function end_increase_momentum() { + game.active = game.momentum_active + delete game.momentum_active + if (game.vm) + vm_next() + else + end_card_play() +} + +function decrease_revolutionary_momentum() { + game.red_momentum -= 1 + log("Decreased RM to " + game.red_momentum + ".") + goto_decrease_revolutionary_momentum_remove() +} + +function goto_decrease_revolutionary_momentum_remove() { + game.state = "decrease_revolutionary_momentum_remove" + for (let i = game.red_momentum; i < 3; ++i) + if (has_commune_cube(RED_CUBE_POOL[i])) + return + end_decrease_momentum() +} + +function decrease_prussian_collaboration() { + game.blue_momentum -= 1 + log("Decreased BM to " + game.blue_momentum + ".") + end_decrease_momentum() +} + +function end_decrease_momentum() { + vm_next() +} + +states.decrease_revolutionary_momentum_remove = { + prompt() { + view.prompt = "Revolutionary Momentum: Remove cubes from Pool." + for (let i = game.red_momentum; i < 3; ++i) + for_each_commune_cube(RED_CUBE_POOL[i], gen_action_piece) + }, + piece(p) { + log("Removed RC from play.") + remove_piece_from_play(p) + goto_decrease_revolutionary_momentum_remove() + }, +} + +states.increase_prussian_collaboration_add = { + prompt() { + view.prompt = "Prussian Collaboration: Add cubes to Pool." + for (let i = 0; i < game.blue_momentum; ++i) + for_each_versailles_cube(PRUSSIAN_COLLABORATION[i], gen_action_piece) + }, + piece(p) { + log("Added BC to Pool.") + remove_piece(p) + goto_increase_prussian_collaboration_add() + }, +} + +states.increase_revolutionary_momentum_trigger = { prompt() { view.prompt = "Revolutionary Momentum: Place a cube in an Institutional space." for (let s of INSTITUTIONAL) @@ -1301,14 +1348,14 @@ states.revolutionary_momentum_trigger = { space(s) { log("Placed RC in S" + s + ".") place_cube(s) - end_momentum_trigger() + end_increase_momentum() }, pass() { - end_momentum_trigger() + end_increase_momentum() }, } -states.prussian_collaboration_trigger = { +states.increase_prussian_collaboration_trigger = { prompt() { view.prompt = "Prussian Collaboration: Place a cube in a Public Opinion space." for (let s of PUBLIC_OPINION) @@ -1319,22 +1366,13 @@ states.prussian_collaboration_trigger = { space(s) { log("Placed BC in S" + s + ".") place_cube(s) - end_momentum_trigger() + end_increase_momentum() }, pass() { - end_momentum_trigger() + end_increase_momentum() }, } -function end_momentum_trigger() { - game.active = game.momentum_active - delete game.momentum_active - if (game.vm) - vm_next() - else - end_card_play() -} - // === CRISIS TRACK & CUBE POOLS === function end_card_play() { @@ -2479,7 +2517,7 @@ states.vm_increase_revolutionary_momentum = { }, red_momentum() { push_undo() - advance_revolutionary_momentum(1) + increase_revolutionary_momentum() }, } @@ -2490,7 +2528,7 @@ states.vm_increase_prussian_collaboration = { }, blue_momentum() { push_undo() - advance_prussian_collaboration(1) + increase_prussian_collaboration() }, } @@ -2501,7 +2539,7 @@ states.vm_decrease_revolutionary_momentum = { }, red_momentum() { push_undo() - advance_revolutionary_momentum(-1) + decrease_revolutionary_momentum() }, } @@ -2512,7 +2550,7 @@ states.vm_decrease_prussian_collaboration = { }, blue_momentum() { push_undo() - advance_prussian_collaboration(-1) + decrease_prussian_collaboration() }, } |