diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-05-12 00:20:28 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-05-24 21:06:18 +0200 |
commit | fa51443a305cfb8eba1e2021e4bd3f77fe336ea6 (patch) | |
tree | 9ad09e96c8e3a2b06fdc30a17ba570b0e3f30d44 /rules.js | |
parent | 5e98e7faa05aacf69e8a628d142dd243dd35a9b0 (diff) | |
download | red-flag-over-paris-fa51443a305cfb8eba1e2021e4bd3f77fe336ea6.tar.gz |
Clean up objective handling.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 67 |
1 files changed, 44 insertions, 23 deletions
@@ -321,11 +321,11 @@ function objective_card_space(c) { } function commune_objective_card() { - return game.red_objective[0] + return game.red_objective } function versailles_objective_card() { - return game.blue_objective[0] + return game.blue_objective } function commune_objective_space() { @@ -908,7 +908,7 @@ function start_round() { log_h1("Round " + game.round) let n = 4 - if (game.scenario === "Censorship") + if (game.censorship) n = 5 for (let i = 0; i < n; ++i) { @@ -916,10 +916,8 @@ function start_round() { game.blue_hand.push(draw_strategy_card()) } - for (let i = 0; i < 2; ++i) { - game.red_objective.push(game.objective_deck.pop()) - game.blue_objective.push(game.objective_deck.pop()) - } + game.red_objective = [ game.objective_deck.pop(), game.objective_deck.pop() ] + game.blue_objective = [ game.objective_deck.pop(), game.objective_deck.pop() ] game.active = "Both" game.state = "choose_objective_card" @@ -941,14 +939,14 @@ states.choose_objective_card = { }, card(c, player) { if (player === COMMUNE) - game.red_objective = [ c ] + game.red_objective = c else - game.blue_objective = [ c ] - if (game.red_objective.length === 1 && game.blue_objective.length === 1) + game.blue_objective = c + if (typeof game.red_objective === "number" && typeof game.blue_objective === "number") end_choose_objective_card() - else if (game.red_objective.length === 1) + else if (typeof game.red_objective === "number") game.active = VERSAILLES - else if (game.blue_objective.length === 1) + else if (typeof game.blue_objective === "number") game.active = COMMUNE else game.active = "Both" @@ -994,7 +992,7 @@ function end_initiative_phase() { game.active = game.initiative if (game.round === 4) goto_final_crisis_events() - else if (game.scenario === "Censorship") + else if (game.censorship) goto_censorship_phase() else goto_strategy_phase() @@ -1123,7 +1121,7 @@ states.play_card = { }, momentum() { push_undo() - if (game.scenario === "Censorship") + if (game.censorship) recycle_card(game.what) else discard_card(game.what) @@ -1517,6 +1515,7 @@ states.operations_place = { game.count -= 2 else game.count -= 1 + log("Placed in S" + s + ".") place_cube(s) resume_operations_place() }, @@ -1835,11 +1834,11 @@ states.objective_card_scoring = { function goto_objective_card_events() { if (!is_commune_control(commune_objective_space())) { log("Removed C" + commune_objective_card()) - game.red_objective = [] + game.red_objective = 0 } if (!is_versailles_control(versailles_objective_space())) { log("Removed C" + versailles_objective_card()) - game.blue_objective = [] + game.blue_objective = 0 } resume_objective_card_events() } @@ -1871,7 +1870,7 @@ states.objective_card_events = { }, card(c) { if (c === commune_objective_card()) { - game.red_objective = [] + game.red_objective = 0 game.red_fulfilled += 1 game.active = COMMUNE log_h2(COMMUNE) @@ -1879,7 +1878,7 @@ states.objective_card_events = { goto_play_event(c) } if (c === versailles_objective_card()) { - game.blue_objective = [] + game.blue_objective = 0 game.blue_fulfilled += 1 game.active = VERSAILLES log_h2(VERSAILLES) @@ -2698,7 +2697,7 @@ states.vm_move = { states.reveal_commune_objective = { prompt() { - view.prompt = "Revealing Commune player's Objective Card." + event_prompt("Revealing Commune player's Objective Card.") view.red_objective = game.red_objective view.actions.done = 1 }, @@ -2709,7 +2708,7 @@ states.reveal_commune_objective = { states.reveal_commune_hand = { prompt() { - view.prompt = "Revealing Commune player's hand." + event_prompt("Revealing Commune player's hand.") view.hand = game.red_hand view.actions.done = 1 }, @@ -2720,7 +2719,7 @@ states.reveal_commune_hand = { states.general_louis_valentin = { prompt() { - event_prompt("Remove a red cube from up to 2 different Paris spaces where you are present.") + event_prompt("Remove 1 from up to 2 different Paris spaces where present.") view.actions.skip = 1 for (let s of game.vm.spaces) if (can_remove_cube(s)) @@ -2741,7 +2740,8 @@ states.general_louis_valentin = { } function init_karl_marx() { - // clear_undo() + clear_undo() + // Draw cards into hand in case a reshuffle is triggered. game.red_hand.push(draw_strategy_card()) game.red_hand.push(draw_strategy_card()) game.red_hand.push(draw_strategy_card()) @@ -2819,7 +2819,6 @@ states.freemason_parade = { exports.setup = function (seed, scenario, options) { game = { seed: seed, - scenario: scenario, log: [], undo: [], active: null, @@ -2905,6 +2904,11 @@ exports.setup = function (seed, scenario, options) { log_h1("Red Flag Over Paris") + if (scenario === "Censorship") { + log_h2("Censorship") + game.censorship = 1 + } + for (let c = 1; c <= 41; ++c) if (c !== 17 && c !== 34) game.strategy_deck.push(c) @@ -2974,6 +2978,19 @@ exports.view = function(state, player) { set_aside: 0, } + if (game.censorship) + view.censorship = 1 + + if (typeof game.red_objective === "object") + view.red_objective = 2 + else if (game.red_objective > 0) + view.red_objective = 1 + + if (typeof game.blue_objective === "object") + view.blue_objective = 2 + else if (game.blue_objective > 0) + view.blue_objective = 1 + if (player === COMMUNE) { view.hand = game.red_hand view.set_aside = game.red_set_aside @@ -3211,8 +3228,12 @@ const CODE = [] CODE[1] = [ // Jules Ducatel [ vm_asm, ()=>clear_undo() ], [ vm_if, ()=>(game.round < 4) ], + [ vm_asm, ()=>log("Commune Objective:") ], + [ vm_asm, ()=>logi("C" + game.red_objective) ], [ vm_goto, "reveal_commune_objective" ], [ vm_else ], + [ vm_asm, ()=>log("Commune hand:") ], + [ vm_asm, ()=>{ for (let c of game.red_hand) logi("C" + c) } ], [ vm_goto, "reveal_commune_hand" ], [ vm_endif ], [ vm_ops, 1, MILITARY ], |