From 7517f0e485f63c6c97ee2871ca64373375c504b8 Mon Sep 17 00:00:00 2001 From: Frans Bongers Date: Wed, 11 Dec 2024 22:38:27 +0100 Subject: resolve fascist test and end of year --- rules.js | 73 +++++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 24 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 5b8efd5..697ec13 100644 --- a/rules.js +++ b/rules.js @@ -1,6 +1,6 @@ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); -exports.roles = exports.scenarios = exports.MODERATE = exports.COMMUNIST = exports.ANARCHIST = void 0; +exports.roles = exports.scenarios = void 0; exports.action = action; exports.view = game_view; exports.setup = setup; @@ -8,19 +8,16 @@ const data_1 = require("./data"); const states = {}; let game = {}; var view = {}; -exports.ANARCHIST = 'Anarchist'; -exports.COMMUNIST = 'Communist'; -exports.MODERATE = 'Moderate'; const role_ids = [data_1.ANARCHISTS_ID, data_1.COMMUNISTS_ID, data_1.MODERATES_ID]; const faction_player_map = { - [data_1.ANARCHISTS_ID]: exports.ANARCHIST, - [data_1.COMMUNISTS_ID]: exports.COMMUNIST, - [data_1.MODERATES_ID]: exports.MODERATE, + [data_1.ANARCHISTS_ID]: data_1.ANARCHIST, + [data_1.COMMUNISTS_ID]: data_1.COMMUNIST, + [data_1.MODERATES_ID]: data_1.MODERATE, }; const player_faction_map = { - [exports.ANARCHIST]: data_1.ANARCHISTS_ID, - [exports.COMMUNIST]: data_1.COMMUNISTS_ID, - [exports.MODERATE]: data_1.MODERATES_ID, + [data_1.ANARCHIST]: data_1.ANARCHISTS_ID, + [data_1.COMMUNIST]: data_1.COMMUNISTS_ID, + [data_1.MODERATE]: data_1.MODERATES_ID, }; const front_names = { a: 'Aragon Front', @@ -41,10 +38,12 @@ const faction_cards = { const medaillons = make_list(0, 8); console.log('medaillons', medaillons); const fascist_decks = { - 1: make_list(55, 62), + 1: make_list(55, 72), + 2: make_list(73, 90), + 3: make_list(91, 108), }; exports.scenarios = ['Standard']; -exports.roles = [exports.ANARCHIST, exports.COMMUNIST, exports.MODERATE]; +exports.roles = [data_1.ANARCHIST, data_1.COMMUNIST, data_1.MODERATE]; function gen_action(action, argument) { if (argument === undefined) { view.actions[action] = 1; @@ -118,7 +117,7 @@ function setup_choose_card() { const player_order = get_player_order(); game.engine = player_order.map((faction_id) => create_leaf_node('choose_card', faction_id)); game.engine.push(create_function_node('setup_player_turn')); - next(); + resolve_active_and_proceed(); } function setup_player_turn() { console.log('setup_player_turn'); @@ -126,7 +125,7 @@ function setup_player_turn() { game.engine = player_order.map((faction_id) => create_seq_node([create_leaf_node('player_turn', faction_id)])); game.engine.push(create_function_node('resolve_fascist_test')); game.engine.push(create_function_node('setup_bag_of_glory')); - next(); + resolve_active_and_proceed(); } const engine_functions = { check_activate_icon, @@ -184,7 +183,6 @@ function next() { const node = get_active_node(game.engine); console.log('node', node); if (node.t === function_node && engine_functions[node.f]) { - resolve_active_node(); const args = node.a; if (args) { engine_functions[node.f](args); @@ -218,10 +216,13 @@ function game_view(state, player) { prompt: null, location: game.location, selected: game.selected, + bag_of_glory: game.bag_of_glory, bonuses: game.bonuses, current_events: game.current_events, fronts: game.fronts, + glory: game.glory, hand: game.hands[faction_id], + hero_points: game.hero_points, medaillons: game.medaillons, selected_card: game.chosen_cards[faction_id], tableaus: game.tableaus, @@ -246,12 +247,8 @@ function setup(seed, _scenario, _options) { game = { seed: seed, state: null, - active: exports.ANARCHIST, - bag_of_glory: { - [data_1.ANARCHISTS_ID]: 1, - [data_1.COMMUNISTS_ID]: 1, - [data_1.MODERATES_ID]: 1, - }, + active: data_1.ANARCHIST, + bag_of_glory: [data_1.ANARCHISTS_ID, data_1.COMMUNISTS_ID, data_1.MODERATES_ID], blank_markers: [[], [], [], [], []], bonuses: [data_1.ON, data_1.ON], current_events: [], @@ -268,6 +265,7 @@ function setup(seed, _scenario, _options) { n: -2, s: -2, }, + glory: [], hands: { [data_1.ANARCHISTS_ID]: [], [data_1.COMMUNISTS_ID]: [], @@ -323,7 +321,9 @@ function draw_hand_cards() { }); } function start_year() { + console.log('start year'); log_h1('Year ' + game.year); + game.current_events = []; draw_hand_cards(); start_turn(); } @@ -414,7 +414,7 @@ states.add_glory = { if (game.turn === 4) { number++; } - game.bag_of_glory[get_active_faction()] += number; + game.bag_of_glory.push(get_active_faction()); if (number === 1) { log_h3(`${game.active} adds 1 token to the Bag of Glory`); } @@ -722,11 +722,33 @@ function end_of_turn() { start_turn(); } } -function end_of_year() { } +function end_of_year() { + const gloryToDraw = [0, 1, 2, 5]; + for (let i = 0; i < gloryToDraw[game.year]; ++i) { + const index = random(game.bag_of_glory.length); + game.glory.push(game.bag_of_glory[index]); + array_remove(game.bag_of_glory, index); + } + game.year++; + start_year(); +} function resolve_fascist_test() { console.log('resolve fascist test'); log_h2('Fascist test is resolved'); - next(); + const test = get_current_event().test; + const test_passed = game.fronts[test.front] >= test.value; + if (test_passed) { + log('The Test is passed'); + } + else { + log('The Test is failed'); + } + const effect = test_passed ? test.pass : test.fail; + const node = resolve_effect(effect); + if (node !== null) { + insert_after_active_node(node); + } + resolve_active_and_proceed(); } function get_fronts_to_add_to(target) { console.log('get_fronts_to_add_to', target); @@ -872,6 +894,9 @@ function get_active_faction_id() { function get_faction_id(player) { return player_faction_map[player]; } +function get_current_event() { + return cards[game.current_events[game.current_events.length - 1]]; +} function get_icon_count_in_tableau(icon, faction = get_active_faction_id()) { let count = 0; for (const c of game.tableaus[faction]) { -- cgit v1.2.3