summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2025-03-28 19:46:03 +0100
committerTor Andersson <tor@ccxvii.net>2025-03-28 19:46:03 +0100
commit58e68e72dbdea27adfdebdd69d11d05dce2454eb (patch)
treed53bc3d95f6116476c26d86ae39888bb80c0bf03
parentc1e92a93746613965bf534572d84d95a7c2f6826 (diff)
downloadland-and-freedom-58e68e72dbdea27adfdebdd69d11d05dce2454eb.tar.gz
Make final bid multi-active.
-rw-r--r--rules.js36
-rw-r--r--rules.ts42
2 files changed, 44 insertions, 34 deletions
diff --git a/rules.js b/rules.js
index a7c9248..19a9b45 100644
--- a/rules.js
+++ b/rules.js
@@ -76,7 +76,7 @@ function gen_spend_hero_points() {
gen_action('spend_hp');
}
}
-const multiactive_states = ['choose_card', 'end_of_year_discard'];
+const multiactive_states = ['choose_card', 'end_of_year_discard', 'choose_final_bid'];
function action(state, player, action, arg) {
game = state;
if (action !== 'undo' && !multiactive_states.includes(game.state)) {
@@ -140,8 +140,7 @@ function setup_choose_card() {
function setup_final_bid() {
game.fascist = 0;
log_header('Final Bid', 't');
- const player_order = get_player_order();
- game.engine = player_order.map((faction_id) => create_state_node('choose_final_bid', faction_id));
+ game.engine = [create_state_node('choose_final_bid', 'all')];
game.engine.push(create_function_node('checkpoint'));
game.engine.push(create_function_node('resolve_final_bid'));
game.engine.push(create_function_node('setup_choose_card'));
@@ -998,7 +997,6 @@ states.play_card = {
states.choose_card = {
inactive: 'play a card for this turn',
prompt(player) {
- gen_spend_hero_points();
view.prompt = 'Play a card for this turn.';
const faction = player_faction_map[player];
if (game.selected_cards[faction].length === 0) {
@@ -1018,9 +1016,6 @@ states.choose_card = {
gen_action('skip');
}
},
- spend_hp() {
- resolve_spend_hp();
- },
card(c, player) {
const faction = player_faction_map[player];
game.selected_cards[faction] = [c];
@@ -1044,8 +1039,8 @@ states.choose_card = {
};
states.choose_final_bid = {
inactive: 'add cards to the Final Bid',
- prompt() {
- const faction = get_active_faction();
+ prompt(player) {
+ const faction = player_faction_map[player];
const number_selected = game.selected_cards[faction].length;
const number_hand = game.hands[faction].length;
if (number_selected < 3 && !(number_hand < 4 && number_selected === number_hand - 1)) {
@@ -1060,18 +1055,26 @@ states.choose_final_bid = {
n += cards[c].strength;
}
if (n > 0)
- view.prompt = `Final Bid for Glory: Discard up to 3 cards for ${n} strength.`;
+ view.prompt = `Final Bid for Glory: Discard up to 3 cards. Your bid is ${n} strength.`;
else
view.prompt = `Final Bid for Glory: Discard up to 3 cards for strength.`;
gen_action('confirm');
+ if (game.selected_cards[faction].length > 0)
+ gen_action('undo');
},
- card(c) {
- const faction = get_active_faction();
+ card(c, player) {
+ const faction = player_faction_map[player];
game.selected_cards[faction].push(c);
- next();
},
- confirm() {
- resolve_active_and_proceed(true);
+ undo(_, player) {
+ const faction = player_faction_map[player];
+ game.selected_cards[faction].length--;
+ },
+ confirm(_, player) {
+ set_delete(game.active, player);
+ if (game.active.length === 0) {
+ resolve_active_and_proceed();
+ }
},
};
function setup_momentum() {
@@ -2825,7 +2828,8 @@ function resolve_effect(effect, source) {
}
function win_final_bid(faction_id) {
log_br();
- log(`${faction_player_map[faction_id]} won the Final Bid.`);
+ log(`${faction_player_map[faction_id]} won the Final Bid:`);
+ logi("Placed T" + faction_id);
game.glory.push(faction_id);
}
function win_game(player, glory) {
diff --git a/rules.ts b/rules.ts
index 2be983c..995296c 100644
--- a/rules.ts
+++ b/rules.ts
@@ -168,7 +168,7 @@ function gen_spend_hero_points() {
}
}
-const multiactive_states = ['choose_card', 'end_of_year_discard'];
+const multiactive_states = ['choose_card', 'end_of_year_discard', 'choose_final_bid'];
export function action(
state: Game,
@@ -257,10 +257,8 @@ function setup_final_bid() {
game.fascist = 0;
log_header('Final Bid', 't');
- const player_order = get_player_order();
- game.engine = player_order.map((faction_id) =>
- create_state_node('choose_final_bid', faction_id)
- );
+
+ game.engine = [create_state_node('choose_final_bid', 'all')];
game.engine.push(create_function_node('checkpoint'));
game.engine.push(create_function_node('resolve_final_bid'));
game.engine.push(create_function_node('setup_choose_card'));
@@ -1281,7 +1279,6 @@ states.play_card = {
states.choose_card = {
inactive: 'play a card for this turn',
prompt(player: Player) {
- gen_spend_hero_points();
view.prompt = 'Play a card for this turn.';
const faction = player_faction_map[player];
@@ -1303,9 +1300,6 @@ states.choose_card = {
gen_action('skip');
}
},
- spend_hp() {
- resolve_spend_hp();
- },
card(c: CardId, player: Player) {
const faction = player_faction_map[player];
game.selected_cards[faction] = [c];
@@ -1330,8 +1324,9 @@ states.choose_card = {
states.choose_final_bid = {
inactive: 'add cards to the Final Bid',
- prompt() {
- const faction = get_active_faction();
+ prompt(player: Player) {
+ const faction = player_faction_map[player];
+
const number_selected = game.selected_cards[faction].length;
const number_hand = game.hands[faction].length;
if (number_selected < 3 && !(number_hand < 4 && number_selected === number_hand - 1)) {
@@ -1341,23 +1336,33 @@ states.choose_final_bid = {
}
}
}
+
let n = 0
for (let c of game.selected_cards[faction]) {
n += (cards[c] as PlayerCard).strength
}
if (n > 0)
- view.prompt = `Final Bid for Glory: Discard up to 3 cards for ${n} strength.`
+ view.prompt = `Final Bid for Glory: Discard up to 3 cards. Your bid is ${n} strength.`
else
view.prompt = `Final Bid for Glory: Discard up to 3 cards for strength.`
+
gen_action('confirm');
+ if (game.selected_cards[faction].length > 0)
+ gen_action('undo');
},
- card(c: CardId) {
- const faction = get_active_faction();
+ card(c: CardId, player: Player) {
+ const faction = player_faction_map[player];
game.selected_cards[faction].push(c);
- next();
},
- confirm() {
- resolve_active_and_proceed(true);
+ undo(_, player: Player) {
+ const faction = player_faction_map[player];
+ game.selected_cards[faction].length--;
+ },
+ confirm(_, player: Player) {
+ set_delete(game.active as Player[], player);
+ if (game.active.length === 0) {
+ resolve_active_and_proceed();
+ }
},
};
@@ -3489,7 +3494,8 @@ function resolve_effect(effect: Effect, source?: EffectSource): EngineNode {
function win_final_bid(faction_id: FactionId) {
log_br();
- log(`${faction_player_map[faction_id]} won the Final Bid.`);
+ log(`${faction_player_map[faction_id]} won the Final Bid:`);
+ logi("Placed T" + faction_id)
game.glory.push(faction_id);
}