From fcf9259fa975c89eb3f7058963f28363d41fed27 Mon Sep 17 00:00:00 2001
From: Tor Andersson <tor@ccxvii.net>
Date: Fri, 28 Mar 2025 14:21:54 +0100
Subject: Tweak Final Bid prompts and logging.

---
 rules.js | 40 ++++++++++++++++++++++------------------
 rules.ts | 42 ++++++++++++++++++++++--------------------
 2 files changed, 44 insertions(+), 38 deletions(-)

diff --git a/rules.js b/rules.js
index ae6c72b..d872110 100644
--- a/rules.js
+++ b/rules.js
@@ -1072,31 +1072,34 @@ states.choose_card = {
     },
 };
 states.choose_final_bid = {
-    inactive: 'add a card to the Final Bid',
+    inactive: 'add cards to the Final Bid',
     prompt() {
-        view.prompt = 'Add a card to the Final Bid.';
         const faction = get_active_faction();
-        for (let c of game.hands[faction]) {
-            if (!game.selected_cards[faction].includes(c)) {
-                gen_action_card(c);
+        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)) {
+            for (let c of game.hands[faction]) {
+                if (!game.selected_cards[faction].includes(c)) {
+                    gen_action_card(c);
+                }
             }
         }
-        gen_action('done');
+        let n = 0;
+        for (let c of game.selected_cards[faction]) {
+            n += cards[c].strength;
+        }
+        if (n > 0)
+            view.prompt = `Final Bid for Glory: Discard up to 3 cards for ${n} strength.`;
+        else
+            view.prompt = `Final Bid for Glory: Discard up to 3 cards for strength.`;
+        gen_action('confirm');
     },
     card(c) {
         const faction = get_active_faction();
         game.selected_cards[faction].push(c);
-        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)) {
-            resolve_active_and_proceed();
-        }
-        else {
-            next();
-        }
+        next();
     },
-    done() {
+    confirm() {
         resolve_active_and_proceed(true);
     },
 };
@@ -2431,12 +2434,13 @@ function resolve_fascist_test() {
 function resolve_final_bid() {
     let highest_bid = 0;
     let winners = [];
+    log("Final Bid for Glory:");
     for (const f of get_player_order()) {
         let player_bid = 0;
         for (const c of game.selected_cards[f]) {
             player_bid += cards[c].strength;
         }
-        log(`${faction_player_map[f]} bid ${player_bid} cards`);
+        log(`>${faction_player_map[f]} ${player_bid} strength`);
         if (player_bid === highest_bid) {
             winners.push(f);
         }
@@ -2800,7 +2804,7 @@ 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.`);
     game.glory.push(faction_id);
 }
 function win_game(player, glory) {
diff --git a/rules.ts b/rules.ts
index f7bd01e..21b862b 100644
--- a/rules.ts
+++ b/rules.ts
@@ -1353,33 +1353,34 @@ states.choose_card = {
 };
 
 states.choose_final_bid = {
-  inactive: 'add a card to the Final Bid',
+  inactive: 'add cards to the Final Bid',
   prompt() {
-    view.prompt = 'Add a card to the Final Bid.';
     const faction = get_active_faction();
-    for (let c of game.hands[faction]) {
-      if (!game.selected_cards[faction].includes(c)) {
-        gen_action_card(c);
+    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)) {
+      for (let c of game.hands[faction]) {
+        if (!game.selected_cards[faction].includes(c)) {
+          gen_action_card(c);
+        }
       }
     }
-    gen_action('done');
+    let n = 0
+    for (let c of game.selected_cards[faction]) {
+      n += cards[c].strength
+    }
+    if (n > 0)
+      view.prompt = `Final Bid for Glory: Discard up to 3 cards for ${n} strength.`
+    else
+      view.prompt = `Final Bid for Glory: Discard up to 3 cards for strength.`
+    gen_action('confirm');
   },
   card(c: CardId) {
     const faction = get_active_faction();
     game.selected_cards[faction].push(c);
-    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)
-    ) {
-      resolve_active_and_proceed();
-    } else {
-      next();
-    }
+    next();
   },
-  done() {
+  confirm() {
     resolve_active_and_proceed(true);
   },
 };
@@ -2987,12 +2988,13 @@ function resolve_fascist_test() {
 function resolve_final_bid() {
   let highest_bid = 0;
   let winners: FactionId[] = [];
+  log("Final Bid for Glory:")
   for (const f of get_player_order()) {
     let player_bid = 0;
     for (const c of game.selected_cards[f]) {
       player_bid += (cards[c] as PlayerCard).strength;
     }
-    log(`${faction_player_map[f]} bid ${player_bid} cards`);
+    log(`>${faction_player_map[f]} ${player_bid} strength`);
     if (player_bid === highest_bid) {
       winners.push(f);
     } else if (player_bid > highest_bid) {
@@ -3467,7 +3469,7 @@ 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.`);
   game.glory.push(faction_id);
 }
 
-- 
cgit v1.2.3