選戰卡牌:對手規則、隨機行事曆、流派核心牌、精英站、局中小勝利

每局不一樣(docs/25 第 3、4 節)
- 對手規則 7 條(名嘴加持、地方大老、大打空戰、鐵票區、網路謠言、地毯式掃街、形象牌),開局抽 1 條,逆風 5 起 2 條
- 辯論、民調、黑函的週次每局隨機;上方週次標出大場面
- 精英站「地方派系談判」:接下挑戰,下週在指定的區淨增票數,達成拿稀有幕僚
- 下一站畫面看得到下下週的門

流派與小勝利(第 2、5 節)
- 9 張流派核心牌、5 位改規則的幕僚
- 翻區抽牌(每週最多 2 張)、民調領先多一張稀有牌、落後下週體力 +1、結果頁標出最關鍵的一區

選人與手感(第 1、7 節)
- 選人畫面顯示候選人類型、技能、弱點與這個類型的逆風紀錄(伺服器啟動時先算好,人物查詢改用姓名索引)
- 出牌不等伺服器:牌先飛出去、手牌體力先扣,伺服器回來校正
- 設定加「快速模式」:開票夜、週末結算、選情快報快一倍

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha5kfuiGbEBhsk7ijDg
This commit is contained in:
王性驊 2026-10-28 17:45:05 +08:00
parent fdd8a5cbb8
commit 0e24ee6a16
35 changed files with 1003 additions and 96 deletions

View File

@ -7,12 +7,12 @@ import { CONTENT, candidateStats, personName, withCustomCandidate } from "@elect
import { loadScenarioRegistry, type ScenarioRegistry } from "@election2026/scenarios"; import { loadScenarioRegistry, type ScenarioRegistry } from "@election2026/scenarios";
import { DEFAULT_PARAMS, buildPackData, type PackData, type PackFiles, type Scenario } from "@election2026/engine"; import { DEFAULT_PARAMS, buildPackData, type PackData, type PackFiles, type Scenario } from "@election2026/engine";
import { DEFAULT_PACKS_ROOT, loadGenders, loadPackFiles, loadSlogans } from "@election2026/pack-loader"; import { DEFAULT_PACKS_ROOT, loadGenders, loadPackFiles, loadSlogans } from "@election2026/pack-loader";
import { cleanAvatar, type ApiError, type ScenarioSummary } from "@election2026/protocol"; import { cleanAvatar, type ApiError, type RogueArchetype, type ScenarioSummary } from "@election2026/protocol";
import Fastify, { type FastifyInstance, type FastifyReply } from "fastify"; import Fastify, { type FastifyInstance, type FastifyReply } from "fastify";
import type { z } from "zod"; import type { z } from "zod";
import type { CouncilDistrict } from "@election2026/rogue/local"; import type { CouncilDistrict } from "@election2026/rogue/local";
import type { TopologyLike } from "@election2026/rogue/setup"; import type { TopologyLike } from "@election2026/rogue/setup";
import { registerRogue } from "./rogue-routes.ts"; import { realArchetype, registerRogue } from "./rogue-routes.ts";
import { registerPeople } from "./people-routes.ts"; import { registerPeople } from "./people-routes.ts";
export interface AppOptions { export interface AppOptions {
@ -28,6 +28,8 @@ export interface AppOptions {
rogueSaveDir?: string | null; rogueSaveDir?: string | null;
/** 議員選區檔;沒給就用 data/build/council/2022.json */ /** 議員選區檔;沒給就用 data/build/council/2022.json */
councilFile?: string; councilFile?: string;
/** 啟動後在背景先算好每位候選人的類型(正式啟動用;測試不需要) */
warmArchetypes?: boolean;
} }
const DEFAULT_COUNCIL_FILE = fileURLToPath(new URL("../../../data/build/council/2022.json", import.meta.url)); const DEFAULT_COUNCIL_FILE = fileURLToPath(new URL("../../../data/build/council/2022.json", import.meta.url));
@ -54,7 +56,7 @@ function withSlogans(s: Scenario, slogans: Slogans): Scenario {
}; };
} }
function summary(raw: Scenario, genders: Readonly<Record<string, "m" | "f">>, slogans: Slogans): ScenarioSummary { function summary(raw: Scenario, genders: Readonly<Record<string, "m" | "f">>, slogans: Slogans, archetypes: ReadonlyMap<string, RogueArchetype>): ScenarioSummary {
const s = withSlogans(raw, slogans); const s = withSlogans(raw, slogans);
return { return {
id: s.id, id: s.id,
@ -89,6 +91,7 @@ function summary(raw: Scenario, genders: Readonly<Record<string, "m" | "f">>, sl
slogan: c.slogan ?? null, slogan: c.slogan ?? null,
sloganSource: c.sloganSource ?? null, sloganSource: c.sloganSource ?? null,
stats: candidateStats(s, c), stats: candidateStats(s, c),
archetype: archetypes.get(`${s.id}|${c.id}`) ?? null,
})), })),
notes: [...s.notes], notes: [...s.notes],
sources: s.sources.map((x) => ({ ...x })), sources: s.sources.map((x) => ({ ...x })),
@ -141,7 +144,24 @@ export async function buildApp(options: AppOptions = {}): Promise<FastifyInstanc
app.get("/api/health", async () => ({ ok: true })); app.get("/api/health", async () => ({ ok: true }));
app.get("/api/scenarios", async () => registry.all.map((s) => summary(s, genders, slogans))); // 每位候選人的類型(docs/25,依中選會選舉紀錄):第一次要劇本清單時算一次(正式啟動時在背景先算),之後用快取
let archetypes: Promise<Map<string, RogueArchetype>> | null = null;
const archetypesOf = (): Promise<Map<string, RogueArchetype>> =>
(archetypes ??= (async () => {
const out = new Map<string, RogueArchetype>();
for (const s of registry.all)
for (const c of s.candidates) {
const record = await people.abilitiesFor(personName(c.name), s.region.countyCode, s.electionDate);
out.set(`${s.id}|${c.id}`, realArchetype(record, candidateStats(s, c).wealth).archetype);
}
return out;
})());
app.get("/api/scenarios", async () => {
const types = await archetypesOf();
return registry.all.map((s) => summary(s, genders, slogans, types));
});
// 啟動後馬上在背景算好,首頁第一次要劇本清單就不用等(people 在下面才註冊,所以排到下一輪)
if (options.warmArchetypes) setImmediate(() => void archetypesOf().catch(() => (archetypes = null)));
const topologies = new Map<string, Promise<TopologyLike | null>>(); const topologies = new Map<string, Promise<TopologyLike | null>>();
let council: Promise<readonly CouncilDistrict[]> | null = null; let council: Promise<readonly CouncilDistrict[]> | null = null;

View File

@ -6,5 +6,5 @@ const host = process.env.HOST ?? "127.0.0.1";
/** 選戰卡牌的存檔(每一局一個 JSON 檔),伺服器重開也能繼續玩 */ /** 選戰卡牌的存檔(每一局一個 JSON 檔),伺服器重開也能繼續玩 */
const rogueSaveDir = process.env.ROGUE_SAVE_DIR ?? fileURLToPath(new URL("../../../data/runs/", import.meta.url)); const rogueSaveDir = process.env.ROGUE_SAVE_DIR ?? fileURLToPath(new URL("../../../data/runs/", import.meta.url));
const app = await buildApp({ logger: true, rogueSaveDir }); const app = await buildApp({ logger: true, rogueSaveDir, warmArchetypes: true });
await app.listen({ port, host }); await app.listen({ port, host });

View File

@ -94,10 +94,27 @@ const NATIONWIDE = "00000";
* 同名的還有好幾位時,有「這場選舉本身」紀錄的那一位優先(同一天投票、同一個縣市;總統選舉看總統副總統紀錄)。 * 同名的還有好幾位時,有「這場選舉本身」紀錄的那一位優先(同一天投票、同一個縣市;總統選舉看總統副總統紀錄)。
* 這場選舉本身的紀錄只拿來認人,不算進能力。 * 這場選舉本身的紀錄只拿來認人,不算進能力。
*/ */
/** 依姓名索引(同一份名單只建一次):劇本清單一次要查兩千多位候選人 */
const byName = new WeakMap<readonly PersonRecord[], Map<string, PersonRecord[]>>();
function peopleNamed(people: readonly PersonRecord[], key: string): readonly PersonRecord[] {
let index = byName.get(people);
if (!index) {
index = new Map();
for (const p of people) {
const k = searchKey(p.name);
const list = index.get(k);
if (list) list.push(p);
else index.set(k, [p]);
}
byName.set(people, index);
}
return index.get(key) ?? [];
}
function findPerson(people: readonly PersonRecord[], name: string, countyCode: string, date: string): PersonRecord | null { function findPerson(people: readonly PersonRecord[], name: string, countyCode: string, date: string): PersonRecord | null {
const key = searchKey(name); const key = searchKey(name);
const nationwide = countyCode === NATIONWIDE; const nationwide = countyCode === NATIONWIDE;
const named = people.filter((p) => searchKey(p.name) === key && p.confidence !== "low" && (nationwide || p.runs.some((r) => r.countyCode === countyCode))); const named = peopleNamed(people, key).filter((p) => p.confidence !== "low" && (nationwide || p.runs.some((r) => r.countyCode === countyCode)));
if (named.length === 1) return named[0]!; if (named.length === 1) return named[0]!;
const same = named.filter((p) => p.runs.some((r) => r.date === date && (nationwide ? r.office === "president" : r.countyCode === countyCode))); const same = named.filter((p) => p.runs.some((r) => r.date === date && (nationwide ? r.office === "president" : r.countyCode === countyCode)));
return same.length === 1 ? same[0]! : null; return same.length === 1 ? same[0]! : null;

View File

@ -9,14 +9,28 @@
| 節 | 狀態 | 實際做法 | | 節 | 狀態 | 實際做法 |
|---|---|---| |---|---|---|
| 1a 本命區 | 完成 | `rogue/src/archetypes.ts` 的 `homeTowns`;雙方都有。你的牌 ×1.2、失守聲勢 −2;攻下對手的本命區聲勢 +2、對手下週少一個行動(`rivalStun`);對手在自己本命區 ×1.2。新牌「回鄉造勢」(`homecoming`,只能打在本命區) | | 1a 本命區 | 完成 | `rogue/src/archetypes.ts` 的 `homeTowns`;雙方都有。你的牌 ×1.2、失守聲勢 −2;攻下對手的本命區聲勢 +2、對手下週少一個行動(`rivalStun`);對手在自己本命區 ×1.2。新牌「回鄉造勢」(`homecoming`,只能打在本命區) |
| 1b 類型與技能 | 完成(數字已依模擬調過) | 六種類型照規格,調整:黑馬型每點聲勢 +12%(規格 +16% 太強)、財務型每週 +150 萬、地面牌 −5%。真實候選人:資歷三項取最高,同級比實際數字超過門檻多少;資歷都是 0 才看經費(多 → 財務型,少 → 黑馬型)。2022 縣市長 42 位主要候選人:組織 20、媒體 9、資深 7、財務 5、黑馬 1。每日一戰也套用。對手的類型還沒做 | | 1b 類型與技能 | 完成(數字已依模擬調過) | 六種類型照規格,調整:黑馬型每點聲勢 +12%(規格 +16% 太強)、財務型每週 +150 萬、地面牌 −5%。真實候選人:資歷三項取最高,同級比實際數字超過門檻多少;資歷都是 0 才看經費(多 → 財務型,少 → 黑馬型)。2022 縣市長 42 位主要候選人:組織 20、媒體 9、資深 7、財務 5、黑馬 1。每日一戰也套用;選人畫面就看得到類型(`/api/scenarios` 的 `archetype`,伺服器啟動時先算好)。對手的類型還沒做 |
| 1c 接上流派 | 完成 | 下一站、物資行裡和類型搭配的牌、幕僚權重 ×1.5,牌面標「適合你的類型」 | | 1c 接上流派 | 完成 | 下一站、物資行裡和類型搭配的牌、幕僚權重 ×1.5,牌面標「適合你的類型」 |
| 7 再來一局 | 部分 | 結果頁:贏了就有「挑戰逆風 N+1 級」(已解鎖就出現,不只剛解鎖那次)、Enter 直接再來、「攻下一塊地盤」(隨機挑還沒打下的縣市開新局)。出牌不等伺服器、快速模式還沒做 | | 2 流派與爆分 | 完成 | 9 張核心牌(走透透、挨家挨戶、樁腳網、聲量滾雪球、懶人包、反將一軍、沙盤推演、地毯式廣告、小額募款)+5 位幕僚(鐵腿、派系協調人、懶人包小編、危機變轉機、精算師)。「全面動員令+」沒改。插圖先共用主題相近的 |
| 8 跨局進度 | 部分 | 完成度:全台制霸(22 縣市+總統大選)、六種類型、類型逆風挑戰(每種類型 0–10 級)、成就;大廳一條、圖鑑完整面板(`web/src/game/rogue/Completion.tsx`、`progress.ts`)。聲望解鎖新牌還沒做 | | 3 對手規則與精英站 | 完成 | 7 條規則(名嘴加持、地方大老、大打空戰、鐵票區、網路謠言、地毯式掃街、形象牌;後發制人維持原本的風格),逆風 5 起抽 2 條。精英站「地方派系談判」:第 2、4 週結束後可能出現,選了就接下挑戰(不進門),下週結算。下一站畫面灰色顯示下下週的門(到時候不能用的會重抽) |
| 2、3、4、5、6 | 還沒做 | 流派核心牌、對手規則與精英站、隨機行事曆、局中小勝利、難度重調 | | 4 隨機行事曆 | 部分 | 8 週的局辯論 3–5、民調 4–5、黑函 5–6 週,5 種排法;上方週次標「辯、民、函、勢、夜」。地方事件週(遶境、義民祭…)還沒做 |
| 5 局中小勝利 | 完成 | 翻區抽牌(每週最多 2 張,黑馬型另外再抽);民調領先多一張稀有牌(偏向你的類型)、落後下週體力 +1;結果頁標「最關鍵的一區」 |
| 6 張力與難度 | 不改基準數字 | 見下面的模擬。預估數字照舊完整顯示(docs/21 的決定:畫面上的數字和打出去一致) |
| 7 再來一局 | 完成 | 結果頁:贏了就有「挑戰逆風 N+1 級」(已解鎖就出現)、Enter 直接再來、「攻下一塊地盤」;出牌不等伺服器(牌先飛出去、手牌體力先扣,伺服器回來校正);設定的「快速模式」讓開票夜、週末結算、選情快報快一倍 |
| 8 跨局進度 | 部分 | 完成度:全台制霸(22 縣市+總統大選)、六種類型、類型逆風挑戰(每種類型 0–10 級)、成就;大廳一條、圖鑑完整面板(`web/src/game/rogue/Completion.tsx`、`progress.ts`);選人畫面顯示這個類型的逆風紀錄。聲望解鎖新牌沒做(新牌直接進獎勵池) |
模擬(`node apps/sim/src/rogue-balance.ts --archetypes all`,桃園 2022 勢均力敵,每種 80 局):「打得好」六種類型都 100% 勝,平均差距 +7.8~+12 個百分點; 模擬(`node apps/sim/src/rogue-balance.ts`,桃園 2022 勢均力敵,每種 100 局,兩位候選人):
標準難度對會打的人太簡單的問題(第 6 節)還在,目前靠「贏了直接挑戰下一級逆風」與類型逆風挑戰讓會打的人往上爬。
| 難度 | 打得好(greedy) | 隨手玩(casual) | 只拿地面/空戰/攻防牌 |
|---|---|---|---|
| 標準 | 99–100%(差距 +7.6~+8.0) | 45–46%(加對手規則前是 52–65%) | 差距 +8.0~+8.3/+6.4~+6.6/+6.1 |
| 逆風 6 | 67–74% | 6–10% | — |
六種類型分開跑(`--archetypes all`):「打得好」都 98–100%,差距 +6.7~+10.7;「隨手玩」30–68%(財務型、資深型最難,黑馬型、組織型最容易)。
第 6 節的兩個目標(打得好 75–85%、隨手玩 35–45%)在目前的技術差距下互相衝突:兩種玩家差 8 個百分點,
把會打的人壓到 85% 以下,隨手玩會掉到一成左右。所以標準難度不再加難(隨手玩已經落在目標裡),
會打的人靠「贏了直接挑戰下一級逆風」往上爬(逆風 6 約七成)。流派核心牌讓單一流派接近混打,但還沒有超過混打(規格目標 +5~10),之後可以再加強核心牌的倍率。
## 0. 現況診斷 ## 0. 現況診斷

View File

@ -57,8 +57,8 @@ backend/packages ──► backend/apps/server(Fastify,REST /api)──►
| `rules.ts` | `createRun`、`endWeek`、`choose`、`ultimate`,以及從 `cards.ts` 轉出的 `playCard`:每個動作回傳新的狀態 | | `rules.ts` | `createRun`、`endWeek`、`choose`、`ultimate`,以及從 `cards.ts` 轉出的 `playCard`:每個動作回傳新的狀態 |
| `state.ts` | `RunState`、`TOTAL_WEEKS = 8`、存檔版本 `SAVE_VERSION` 與 `migrateRun` | | `state.ts` | `RunState`、`TOTAL_WEEKS = 8`、存檔版本 `SAVE_VERSION` 與 `migrateRun` |
| `data.ts`、`cards.ts` | 牌的資料與效果 | | `data.ts`、`cards.ts` | 牌的資料與效果 |
| `rival.ts` | 對手每週的意圖與行動 | | `rival.ts` | 對手每週的意圖與行動;每局抽的對手規則(docs/25) |
| `route.ts`、`scenes.ts`、`content.ts` | 每週結束的「下一站」、辯論/民調/黑函週、堵麥與地方抉擇 | | `route.ts`、`scenes.ts`、`content.ts` | 每週結束的「下一站」(含地方派系談判、下下週的門)、辯論/民調/黑函週(週次每局隨機)、堵麥與地方抉擇 |
| `advisors.ts`、`feats.ts`、`meta.ts`、`ultimate.ts`、`mechanics.ts` | 幕僚、成就、生涯能力與政策、大絕招、逆風等級 | | `advisors.ts`、`feats.ts`、`meta.ts`、`ultimate.ts`、`mechanics.ts` | 幕僚、成就、生涯能力與政策、大絕招、逆風等級 |
| `view.ts` | 給前端的玩家視角(含每張手牌打在每一區的預估) | | `view.ts` | 給前端的玩家視角(含每張手牌打在每一區的預估) |
| `tutorial.ts`、`bots.ts` | 新手教學;模擬玩家(平衡報告用) | | `tutorial.ts`、`bots.ts` | 新手教學;模擬玩家(平衡報告用) |

View File

@ -32,3 +32,7 @@ export const SourceList = z.object({
sources: z.array(SourceRef), sources: z.array(SourceRef),
}); });
export type SourceList = z.infer<typeof SourceList>; export type SourceList = z.infer<typeof SourceList>;
/** 候選人類型(docs/25):真實候選人依中選會選舉紀錄、自創角色依出身;決定選戰卡牌的技能與弱點 */
export const RogueArchetype = z.enum(["media", "organization", "eloquence", "finance", "integrity", "newcomer"]);
export type RogueArchetype = z.infer<typeof RogueArchetype>;

View File

@ -1,5 +1,5 @@
import { z } from "zod"; import { z } from "zod";
import { TownCode, VillageCode } from "./common.ts"; import { RogueArchetype, TownCode, VillageCode } from "./common.ts";
import { PARTY_NAMES } from "./parties.ts"; import { PARTY_NAMES } from "./parties.ts";
const PARTY_SET = new Set(PARTY_NAMES); const PARTY_SET = new Set(PARTY_NAMES);
@ -448,6 +448,8 @@ export const ScenarioSummary = z.object({
stats: CandidateStats.optional(), stats: CandidateStats.optional(),
/** 歷史劇本:真實的政治獻金收支(元) */ /** 歷史劇本:真實的政治獻金收支(元) */
realFinance: z.object({ income: z.number().int(), spending: z.number().int() }).nullable(), realFinance: z.object({ income: z.number().int(), spending: z.number().int() }).nullable(),
/** 選戰卡牌的候選人類型(docs/25,依中選會選舉紀錄);伺服器還沒算好是 null */
archetype: RogueArchetype.nullable().default(null),
}), }),
), ),
/** 數字的出處,以及哪些是遊戲設定 */ /** 數字的出處,以及哪些是遊戲設定 */

View File

@ -1,4 +1,5 @@
import { z } from "zod"; import { z } from "zod";
import { RogueArchetype } from "./common.ts";
import { CandidatePublic, CustomCandidate } from "./game.ts"; import { CandidatePublic, CustomCandidate } from "./game.ts";
/** /**
@ -11,9 +12,6 @@ export type RogueTrait = z.infer<typeof RogueTrait>;
export const RogueOwner = z.enum(["you", "rival"]).nullable(); export const RogueOwner = z.enum(["you", "rival"]).nullable();
/** 候選人類型(docs/25):真實候選人依中選會選舉紀錄、自創角色依出身;決定技能與弱點 */
export const RogueArchetype = z.enum(["media", "organization", "eloquence", "finance", "integrity", "newcomer"]);
export type RogueArchetype = z.infer<typeof RogueArchetype>;
export const RogueTown = z.object({ export const RogueTown = z.object({
code: z.string(), code: z.string(),
@ -228,7 +226,7 @@ export const IslandBuilding = z.object({
}); });
export type IslandBuilding = z.infer<typeof IslandBuilding>; export type IslandBuilding = z.infer<typeof IslandBuilding>;
export const RogueStopKind = z.enum(["card", "advisor", "upgrade", "remove", "shop", "encounter", "event", "minigame"]); export const RogueStopKind = z.enum(["card", "advisor", "upgrade", "remove", "shop", "encounter", "event", "minigame", "elite"]);
export type RogueStopKind = z.infer<typeof RogueStopKind>; export type RogueStopKind = z.infer<typeof RogueStopKind>;
/** 獎勵、商店上的一個選項(牌或幕僚) */ /** 獎勵、商店上的一個選項(牌或幕僚) */
@ -366,6 +364,14 @@ export const RogueView = z.object({
others: z.array(CandidatePublic), others: z.array(CandidatePublic),
/** 雙方的代表色(政黨色;同一個顏色或教學關卡用別的顏色區分) */ /** 雙方的代表色(政黨色;同一個顏色或教學關卡用別的顏色區分) */
colors: z.object({ you: z.string(), rival: z.string() }), colors: z.object({ you: z.string(), rival: z.string() }),
/** 這局的行事曆(docs/25):辯論、民調、黑函、對手大型造勢在第幾週;新手教學是 null */
schedule: z.object({ debate: z.number().int(), poll: z.number().int(), crisis: z.number().int(), bigRally: z.number().int().nullable() }).nullable().default(null),
/** 下下週的門(docs/25:看得到前方):選下一站的時候灰色顯示 */
nextRoute: z.array(z.object({ kind: RogueStopKind, title: z.string() })).nullable().default(null),
/** 地方派系談判(精英站,docs/25):這週在哪一區淨增多少票;progress 是目前淨增 */
contract: z.object({ town: z.string(), name: z.string(), goal: z.number().int(), progress: z.number().int() }).nullable().default(null),
/** 這局對手的規則(docs/25):整局有效 */
rivalRules: z.array(z.object({ id: z.string(), name: z.string(), text: z.string() })).default([]),
/** 你的候選人特色(docs/25):類型、技能、弱點與依據;新手教學、舊存檔是 null */ /** 你的候選人特色(docs/25):類型、技能、弱點與依據;新手教學、舊存檔是 null */
identity: z identity: z
.object({ .object({

View File

@ -18,6 +18,12 @@ export const ADVISORS: readonly AdvisorDef[] = [
{ id: "hakka_director", name: "客家事務主任", art: "visit_associations", text: "打在客家庄的牌 +50%", school: "ground" }, { id: "hakka_director", name: "客家事務主任", art: "visit_associations", text: "打在客家庄的牌 +50%", school: "ground" },
{ id: "farm_ally", name: "農會總幹事", art: "homecoming", text: "打在地廣人稀的區的牌 +50%", school: "ground" }, { id: "farm_ally", name: "農會總幹事", art: "homecoming", text: "打在地廣人稀的區的牌 +50%", school: "ground" },
{ id: "student_leader", name: "學生會長", art: "forum", text: "打在年輕人多的區的牌 +40%", school: "ground" }, { id: "student_leader", name: "學生會長", art: "forum", text: "打在年輕人多的區的牌 +40%", school: "ground" },
// 流派的改規則幕僚(docs/25 第 2 節)
{ id: "iron_legs", name: "鐵腿", art: "grassroots_walk", text: "一週在 3 個以上不同的區出牌,週末聲勢 +2", school: "ground" },
{ id: "faction_broker", name: "派系協調人", art: "banquet", text: "你的樁腳擋下對手的票,一半變成你的", school: "org" },
{ id: "meme_editor", name: "懶人包小編", art: "influencer_live", text: "爆紅之後,那張牌回到手上(每週一次)", school: "air" },
{ id: "crisis_flip", name: "危機變轉機", art: "crisis_pr", text: "每擋下對手一次批評,週末聲勢 +1", school: "defend" },
{ id: "actuary", name: "精算師", art: "self_fund", text: "週末存款每 100 萬多 5 萬利息(最多 +50 萬)", school: "money" },
{ id: "truck_captain", name: "宣傳車隊長", art: "sound_truck", text: "打在某區的地面牌,隔壁每一區也有兩成效果", school: "ground" }, { id: "truck_captain", name: "宣傳車隊長", art: "sound_truck", text: "打在某區的地面牌,隔壁每一區也有兩成效果", school: "ground" },
{ id: "social_editor", name: "網路小編", art: "online_ad", text: "每週第一張網路牌不花體力", school: "air" }, { id: "social_editor", name: "網路小編", art: "online_ad", text: "每週第一張網路牌不花體力", school: "air" },

View File

@ -121,11 +121,13 @@ const CARD_TASTE: Record<string, number> = {
rally: 5, pilgrimage: 5, celebrity: 4.5, door: 4, tv: 4, counter: 4, office: 4, online: 3.5, oath: 3.5, kneel: 4, night: 3, calls: 3, clarify: 3, expose: 2.5, probe: 2.5, live: 3, talk: 2.5, rally: 5, pilgrimage: 5, celebrity: 4.5, door: 4, tv: 4, counter: 4, office: 4, online: 3.5, oath: 3.5, kneel: 4, night: 3, calls: 3, clarify: 3, expose: 2.5, probe: 2.5, live: 3, talk: 2.5,
walk: 2.5, small: 2, breakfast: 3.5, park: 3, campus: 3, hakka: 2.5, weddings: 3, truck: 4, banquet: 3.5, endorse: 3.5, billboard: 3, volunteers: 3.5, phonebank: 3.5, mobilize: 3, allnighter: 3, walk: 2.5, small: 2, breakfast: 3.5, park: 3, campus: 3, hakka: 2.5, weddings: 3, truck: 4, banquet: 3.5, endorse: 3.5, billboard: 3, volunteers: 3.5, phonebank: 3.5, mobilize: 3, allnighter: 3,
shorts: 3, line: 3.5, radio: 3, flyers: 3, policy: 3.5, whitepaper: 3, mediatraining: 3.5, fieldwork: 3.5, factcheck: 3, contrast: 3, selffund: 2.5, tycoon: 2, elder: 4, shorts: 3, line: 3.5, radio: 3, flyers: 3, policy: 3.5, whitepaper: 3, mediatraining: 3.5, fieldwork: 3.5, factcheck: 3, contrast: 3, selffund: 2.5, tycoon: 2, elder: 4,
legwork: 3.5, doorstep: 4, network: 3.5, buzz: 3.5, explainer: 3.5, turntable: 3, wargame: 3, carpetads: 3, microdonate: 2.5,
}; };
const ADVISOR_TASTE: Record<string, number> = { const ADVISOR_TASTE: Record<string, number> = {
chief: 5, youth_corps: 4.5, scheduler: 4, combo_coach: 4, rally_king: 3.5, temple_master: 3, market_auntie: 3.5, ad_planner: 3, tycoon: 3, old_stake: 2.5, spin_doctor: 3, social_editor: 2.5, chief: 5, youth_corps: 4.5, scheduler: 4, combo_coach: 4, rally_king: 3.5, temple_master: 3, market_auntie: 3.5, ad_planner: 3, tycoon: 3, old_stake: 2.5, spin_doctor: 3, social_editor: 2.5,
muckraker: 2.5, opener: 4, night_owl: 3.5, truck_captain: 3.5, councilors: 3, iron_base: 3, party_org: 3.5, volunteer_lead: 3.5, mascot: 3, pollster: 3, fundraiser: 2.5, cfo: 2.5, lawyer: 2.5, muckraker: 2.5, opener: 4, night_owl: 3.5, truck_captain: 3.5, councilors: 3, iron_base: 3, party_org: 3.5, volunteer_lead: 3.5, mascot: 3, pollster: 3, fundraiser: 2.5, cfo: 2.5, lawyer: 2.5,
crisis_team: 2.5, debate_coach: 3, influencer: 2.5, speechwriter: 3, hakka_director: 2, farm_ally: 2, student_leader: 2.5, crisis_team: 2.5, debate_coach: 3, influencer: 2.5, speechwriter: 3, hakka_director: 2, farm_ally: 2, student_leader: 2.5,
iron_legs: 3.5, faction_broker: 3, meme_editor: 2.5, crisis_flip: 3, actuary: 2.5,
}; };
const ARCHETYPE_TAGS: Partial<Record<BotName, string[]>> = { ground: ["ground", "rally", "org"], air: ["media", "online", "tv", "press"], attack: ["attack", "intel", "press", "defend"] }; const ARCHETYPE_TAGS: Partial<Record<BotName, string[]>> = { ground: ["ground", "rally", "org"], air: ["media", "online", "tv", "press"], attack: ["attack", "intel", "press", "defend"] };
const ARCHETYPE_SCHOOL: Partial<Record<BotName, string[]>> = { ground: ["ground", "org", "any"], air: ["air", "any", "money"], attack: ["defend", "any", "air"] }; const ARCHETYPE_SCHOOL: Partial<Record<BotName, string[]>> = { ground: ["ground", "org", "any"], air: ["air", "any", "money"], attack: ["defend", "any", "air"] };
@ -212,6 +214,7 @@ function routeScore(s: RunState, bot: BotName, kind: StopKind): number {
encounter: 2.4, encounter: 2.4,
event: 2.2, event: 2.2,
minigame: 2.3, minigame: 2.3,
elite: 2.5,
}; };
if (bot === "attack" && kind === "encounter") return 1; if (bot === "attack" && kind === "encounter") return 1;
return scores[kind]; return scores[kind];
@ -251,6 +254,8 @@ function pickStopFor(s: RunState, bot: BotName, d: Dice): { pick: number | "skip
const stop = s.stop!; const stop = s.stop!;
const randomish = !smart(bot); const randomish = !smart(bot);
switch (stop.kind) { switch (stop.kind) {
case "elite":
return { pick: "skip", target: null };
case "card": { case "card": {
if (randomish) return { pick: Math.floor(d.next() * stop.options.length), target: null }; if (randomish) return { pick: Math.floor(d.next() * stop.options.length), target: null };
const ranked = stop.options.map((id, i) => ({ i, v: cardScore(bot, id) })).sort((a, b) => b.v - a.v); const ranked = stop.options.map((id, i) => ({ i, v: cardScore(bot, id) })).sort((a, b) => b.v - a.v);

View File

@ -2,7 +2,7 @@ import { ADVISOR_BY_ID } from "./advisors.ts";
import { HOME_MULT } from "./archetypes.ts"; import { HOME_MULT } from "./archetypes.ts";
import { POWERS, TRAIT_LABELS, cardDef, hasKeyword, type CardDef } from "./data.ts"; import { POWERS, TRAIT_LABELS, cardDef, hasKeyword, type CardDef } from "./data.ts";
import { BUILDING_BY_ID, POLICY_HOME, POLICY_HOME_STEP, policyTargetOf } from "./meta.ts"; import { BUILDING_BY_ID, POLICY_HOME, POLICY_HOME_STEP, policyTargetOf } from "./meta.ts";
import { addMomentum, addStatus, asc, cityVotes, drawCards, eventMult, eventOf, has, isArch, loseVotes, moveVotes, spread, updateFlags } from "./mechanics.ts"; import { addMomentum, addRivalMomentum, addStatus, asc, cityVotes, drawCards, eventMult, eventOf, has, isArch, loseVotes, moveVotes, spread, updateFlags } from "./mechanics.ts";
import { addTally, cloneState, newCard, rand, type CardInst, type Intent, type RunState, type TownState } from "./state.ts"; import { addTally, cloneState, newCard, rand, type CardInst, type Intent, type RunState, type TownState } from "./state.ts";
/** 組合拳:同一週同一區打出第 n 種不同的牌,這張牌的加成 */ /** 組合拳:同一週同一區打出第 n 種不同的牌,這張牌的加成 */
@ -21,6 +21,9 @@ export function cardCost(s: RunState, card: CardDef): { energy: number; money: n
// 資深型:回應記者追問不花體力;組織型:每週第一張佈樁牌不花體力 // 資深型:回應記者追問不花體力;組織型:每週第一張佈樁牌不花體力
if ((card.id === "reporter" || card.id === "storm") && isArch(s, "eloquence")) return { energy: 0, money: 0 }; if ((card.id === "reporter" || card.id === "storm") && isArch(s, "eloquence")) return { energy: 0, money: 0 };
if (card.effect.kind === "shield" && isArch(s, "organization") && !(s.weekCards ?? []).some((id) => cardDef(id)?.effect.kind === "shield")) return { energy: 0, money: card.money }; if (card.effect.kind === "shield" && isArch(s, "organization") && !(s.weekCards ?? []).some((id) => cardDef(id)?.effect.kind === "shield")) return { energy: 0, money: card.money };
// 沙盤推演(能力):每週第一張擋對手的牌不花體力
const blocker = (id: string) => ["counter", "clarify", "nullify", "turnaround"].includes(cardDef(id)?.effect.kind ?? "");
if (s.powers.includes("wargame") && blocker(card.id) && !(s.weekCards ?? []).some(blocker)) return { energy: 0, money: card.money };
const freeOnline = has(s, "social_editor") && card.tags.includes("online") && s.onlinePlayed === 0; const freeOnline = has(s, "social_editor") && card.tags.includes("online") && s.onlinePlayed === 0;
const ads = has(s, "ad_planner") && (card.id === "tv" || card.id === "online"); const ads = has(s, "ad_planner") && (card.id === "tv" || card.id === "online");
return { energy: freeOnline ? 0 : card.cost, money: Math.round(card.money * (ads ? 0.7 : 1)) }; return { energy: freeOnline ? 0 : card.cost, money: Math.round(card.money * (ads ? 0.7 : 1)) };
@ -82,8 +85,14 @@ export function boost(s: RunState, card: CardDef, town: TownState | null): Boost
for (const a of CARD_ADVISORS) if (has(s, a.id) && a.ok(card)) apply(a.m, `${ADVISOR_BY_ID.get(a.id)!.name} ×${a.m}`); for (const a of CARD_ADVISORS) if (has(s, a.id) && a.ok(card)) apply(a.m, `${ADVISOR_BY_ID.get(a.id)!.name} ×${a.m}`);
for (const p of s.powers) { for (const p of s.powers) {
const power = POWERS[p]; const power = POWERS[p];
if (power && card.tags.includes(power.tag)) apply(power.mult, `${power.label} ×${power.mult}`); if (power?.tag && power.mult && card.tags.includes(power.tag)) apply(power.mult, `${power.label} ×${power.mult}`);
} }
// 流派核心牌(docs/25 第 2 節)
const ground = s.groundPlayed ?? 0;
if (s.powers.includes("legwork") && card.tags.includes("ground") && ground > 0) apply(1 + 0.08 * ground, `走透透 ×${(1 + 0.08 * ground).toFixed(2)}`);
const buzz = s.buzz ?? 0;
if (s.powers.includes("buzz") && card.tags.includes("media") && buzz > 0) apply(1 + 0.03 * buzz, `聲量 ${buzz} ×${(1 + 0.03 * buzz).toFixed(2)}`);
if (card.id === "explainer" && buzz > 0) apply(1 + 0.05 * buzz, `懶人包・聲量 ${buzz} ×${(1 + 0.05 * buzz).toFixed(2)}`);
for (const b of s.buffs) if (card.tags.includes(b.tag)) apply(b.mult, `這週加成 ×${b.mult}`); for (const b of s.buffs) if (card.tags.includes(b.tag)) apply(b.mult, `這週加成 ×${b.mult}`);
// 政策島的建築 // 政策島的建築
const perk = (id: string) => s.options.perks?.[id] ?? 0; const perk = (id: string) => s.options.perks?.[id] ?? 0;
@ -133,6 +142,8 @@ function comboOf(s: RunState, card: CardDef, town: TownState): number {
interface Played { interface Played {
log: RunState["log"]; log: RunState["log"];
notes: string[]; notes: string[];
/** 懶人包小編:這張牌打完回到手上 */
back?: boolean;
} }
/** 你在某一區加票:先被對手樁腳擋掉一部分。spill 是擴散到隔壁區(不算組合拳) */ /** 你在某一區加票:先被對手樁腳擋掉一部分。spill 是擴散到隔壁區(不算組合拳) */
@ -166,8 +177,22 @@ function gainCity(s: RunState, card: CardDef, total: number, weightTrait: string
out.log.push({ side: "you", text: `${label}・全市`, town: null, votes: Math.round(net) }); out.log.push({ side: "you", text: `${label}・全市`, town: null, votes: Math.round(net) });
} }
/** 對手全市掉票(依對手支持者分布) */ /** 對手規則(rival.ts 的 RIVAL_RULES);cards 不依賴 rival.ts */
const rule = (s: RunState, id: string): boolean => (s.rivalRules ?? []).includes(id);
/** 名嘴加持:你澄清、事實查核的時候,對手聲勢 −1 */
function punditBacklash(s: RunState, out: Played): void {
if (!rule(s, "pundit") || s.rivalMomentum <= 0) return;
addRivalMomentum(s, -1);
out.notes.push("名嘴被打臉:對手聲勢 −1");
}
/** 對手全市掉票(依對手支持者分布);對手規則「形象牌」只剩一半 */
function hurtRival(s: RunState, amount: number, out: Played, text: string): void { function hurtRival(s: RunState, amount: number, out: Played, text: string): void {
if (rule(s, "image")) {
amount *= 0.5;
out.notes.push("形象牌:效果只剩一半");
}
const parts = spread(s.towns, amount, (t) => t.rival); const parts = spread(s.towns, amount, (t) => t.rival);
const hurt = s.towns.reduce((a, t, i) => a + loseVotes(t, parts[i]!, "rival"), 0); const hurt = s.towns.reduce((a, t, i) => a + loseVotes(t, parts[i]!, "rival"), 0);
out.log.push({ side: "you", text, town: null, votes: Math.round(hurt) }); out.log.push({ side: "you", text, town: null, votes: Math.round(hurt) });
@ -225,6 +250,11 @@ function resolve(s: RunState, card: CardDef, town: TownState | null, intent: Int
s.viral = { used: true, boost: true }; s.viral = { used: true, boost: true };
out.notes.push("媒體型:下一張空戰牌效果加倍"); out.notes.push("媒體型:下一張空戰牌效果加倍");
} }
if (hit && e.hit > 1 && has(s, "meme_editor") && !s.memeUsed) {
s.memeUsed = true;
out.back = true;
out.notes.push("懶人包小編:這張牌回到手上");
}
break; break;
} }
case "counter": { case "counter": {
@ -238,6 +268,7 @@ function resolve(s: RunState, card: CardDef, town: TownState | null, intent: Int
case "clarify": { case "clarify": {
for (const i of s.intents) if (i.kind === "attack") i.cut = Math.min(i.cut, e.cut); for (const i of s.intents) if (i.kind === "attack") i.cut = Math.min(i.cut, e.cut);
if (e.momentum) addMomentum(s, e.momentum); if (e.momentum) addMomentum(s, e.momentum);
punditBacklash(s, out);
out.notes.push(e.cut === 0 ? "對手這週的批評全部無效" : `對手這週的批評剩 ${Math.round(e.cut * 100)}%`); out.notes.push(e.cut === 0 ? "對手這週的批評全部無效" : `對手這週的批評剩 ${Math.round(e.cut * 100)}%`);
if (e.base > 0) gainCity(s, card, e.base * boost(s, card, null).mult, undefined, out); if (e.base > 0) gainCity(s, card, e.base * boost(s, card, null).mult, undefined, out);
else out.log.push({ side: "you", text: card.name, town: null, votes: 0 }); else out.log.push({ side: "you", text: card.name, town: null, votes: 0 });
@ -246,6 +277,7 @@ function resolve(s: RunState, card: CardDef, town: TownState | null, intent: Int
case "nullify": { case "nullify": {
intent!.cut = 0; intent!.cut = 0;
out.notes.push("這個批評失效"); out.notes.push("這個批評失效");
punditBacklash(s, out);
gainCity(s, card, e.base * boost(s, card, null).mult, undefined, out); gainCity(s, card, e.base * boost(s, card, null).mult, undefined, out);
break; break;
} }
@ -320,6 +352,40 @@ function resolve(s: RunState, card: CardDef, town: TownState | null, intent: Int
out.notes.push(`${POWERS[e.power]?.label ?? card.name}:整局有效`); out.notes.push(`${POWERS[e.power]?.label ?? card.name}:整局有效`);
out.log.push({ side: "you", text: `${card.name}:整局有效`, town: null, votes: 0 }); out.log.push({ side: "you", text: `${card.name}:整局有效`, town: null, votes: 0 });
break; break;
case "breadth": {
// 這週出過牌的區(含這一區)
const towns = Math.min(5, s.towns.filter((t) => t.played.length > 0 && t !== town).length + 1);
out.notes.push(`這週出過牌的區 ${towns} 區 ×${towns}`);
gainAt(s, card, town!, e.base * towns, out);
break;
}
case "turnaround":
for (const i of s.intents) if (i.kind === "attack") i.cut = Math.min(i.cut, e.cut);
s.turnaround = true;
out.notes.push(`對手這週的批評剩 ${Math.round(e.cut * 100)}%,擋下的一半變成你的票`);
out.log.push({ side: "you", text: card.name, town: null, votes: 0 });
punditBacklash(s, out);
break;
case "spend": {
const hundreds = Math.floor(s.money / 100);
if (hundreds <= 0) {
out.log.push({ side: "you", text: `${card.name}:手上沒有錢`, town: null, votes: 0 });
break;
}
s.money -= hundreds * 100;
const b = boost(s, card, null);
out.notes.push(...b.notes, `花掉 ${hundreds * 100} 萬`);
gainCity(s, card, e.perHundred * hundreds * b.mult, undefined, out);
break;
}
case "flagMoney": {
const flags = s.towns.filter((t) => t.flag === "you").length;
const amount = Math.round((e.base + e.perFlag * flags) * (has(s, "fundraiser") ? 1.5 : 1));
s.money += amount;
out.notes.push(`資金 +${amount} 萬(${flags} 面旗)`);
out.log.push({ side: "you", text: `${card.name}:資金 +${amount} 萬`, town: null, votes: 0 });
break;
}
case "kneel": { case "kneel": {
const b = boost(s, card, null); const b = boost(s, card, null);
out.notes.push(...b.notes); out.notes.push(...b.notes);
@ -377,6 +443,9 @@ export function playCard(state: RunState, uid: string, target: string | null, ex
const boosted = s.viral?.boost === true; const boosted = s.viral?.boost === true;
resolve(s, card, town, intent, expect, out); resolve(s, card, town, intent, expect, out);
if (boosted && card.tags.includes("media") && s.viral) s.viral.boost = false; if (boosted && card.tags.includes("media") && s.viral) s.viral.boost = false;
// 流派核心牌:這週打過幾張地面牌、聲量(整局累積,最多 15)
if (card.tags.includes("ground")) s.groundPlayed = (s.groundPlayed ?? 0) + 1;
if (card.tags.includes("media")) s.buzz = Math.min(15, (s.buzz ?? 0) + 1);
const mark = town ?? (intent?.town ? s.towns.find((t) => t.code === intent!.town)! : null); const mark = town ?? (intent?.town ? s.towns.find((t) => t.code === intent!.town)! : null);
if (mark && !mark.played.includes(card.id)) { if (mark && !mark.played.includes(card.id)) {
mark.played.push(card.id); mark.played.push(card.id);
@ -393,7 +462,8 @@ export function playCard(state: RunState, uid: string, target: string | null, ex
const lost = cityVotes(s, -card.side.backlash * s.scale); const lost = cityVotes(s, -card.side.backlash * s.scale);
out.log.push({ side: "you", text: `${card.name}:被刪預算的人不高興`, town: null, votes: Math.round(lost) }); out.log.push({ side: "you", text: `${card.name}:被刪預算的人不高興`, town: null, votes: Math.round(lost) });
} }
if (hasKeyword(card, "exhaust")) s.exhausted.push(inst); if (out.back) s.hand.push(inst);
else if (hasKeyword(card, "exhaust")) s.exhausted.push(inst);
else s.discard.push(inst); else s.discard.push(inst);
s.paying = 0; s.paying = 0;
s.weekCards = [...(s.weekCards ?? []), card.id]; s.weekCards = [...(s.weekCards ?? []), card.id];

View File

@ -47,6 +47,14 @@ export type CardEffect =
| { kind: "buff"; tag: string; mult: number; base: number } | { kind: "buff"; tag: string; mult: number; base: number }
/** 能力牌:整局有效 */ /** 能力牌:整局有效 */
| { kind: "power"; power: string } | { kind: "power"; power: string }
/** 挨家挨戶:該區 base × 這週出過牌的區數(含這區,最多 5 區) */
| { kind: "breadth"; base: number }
/** 反將一軍:這週對手的批評剩 cut,擋下的一半變成你的全市票 */
| { kind: "turnaround"; cut: number }
/** 地毯式廣告:花光資金,每 100 萬全市 +perHundred */
| { kind: "spend"; perHundred: number }
/** 小額募款:資金 +base,你每插一面旗再 +perFlag(萬元) */
| { kind: "flagMoney"; base: number; perFlag: number }
/** 選前之夜下跪:只能在最後一週打,聲勢大增、全市加票 */ /** 選前之夜下跪:只能在最後一週打,聲勢大增、全市加票 */
| { kind: "kneel"; base: number; momentum: number } | { kind: "kneel"; base: number; momentum: number }
/** 狀態牌:回應記者追問(全市一點點) */ /** 狀態牌:回應記者追問(全市一點點) */
@ -107,6 +115,16 @@ export const CARDS: readonly CardDef[] = [
{ id: "temple", name: "宮廟參拜", art: "temple_visit", cost: 1, money: 0, rarity: "basic", tags: ["ground", "temple"], target: "town", effect: { kind: "gain", base: 1260 }, bonus: [{ trait: "temples", mult: 2 }], text: "該區 +{n};宮廟多 ×2" }, { id: "temple", name: "宮廟參拜", art: "temple_visit", cost: 1, money: 0, rarity: "basic", tags: ["ground", "temple"], target: "town", effect: { kind: "gain", base: 1260 }, bonus: [{ trait: "temples", mult: 2 }], text: "該區 +{n};宮廟多 ×2" },
{ id: "stake", name: "拜託里長佈樁", art: "recruit_machine", cost: 1, money: 0, rarity: "basic", tags: ["org", "defend"], target: "town", effect: { kind: "shield", base: 2880, gain: 580 }, text: "該區樁腳 {n},擋對手這週在這區的行動" }, { id: "stake", name: "拜託里長佈樁", art: "recruit_machine", cost: 1, money: 0, rarity: "basic", tags: ["org", "defend"], target: "town", effect: { kind: "shield", base: 2880, gain: 580 }, text: "該區樁腳 {n},擋對手這週在這區的行動" },
{ id: "dinner", name: "募款餐會", art: "fundraiser_dinner", cost: 1, money: 0, rarity: "basic", tags: ["money"], target: "none", effect: { kind: "money", base: 300, perMomentum: 30 }, text: "資金 +{m} 萬;聲勢越高募越多" }, { id: "dinner", name: "募款餐會", art: "fundraiser_dinner", cost: 1, money: 0, rarity: "basic", tags: ["money"], target: "none", effect: { kind: "money", base: 300, perMomentum: 30 }, text: "資金 +{m} 萬;聲勢越高募越多" },
// ── 流派核心牌(docs/25 第 2 節):會疊加、組成形會爆分 ──
{ id: "legwork", name: "走透透", art: "workout", cost: 1, money: 0, rarity: "rare", tags: ["ground"], target: "none", effect: { kind: "power", power: "legwork" }, text: "能力:這週每打過一張地面牌,之後的地面牌 +8%(週末歸零)" },
{ id: "doorstep", name: "挨家挨戶", art: "door_to_door", cost: 1, money: 0, rarity: "rare", tags: ["ground"], target: "town", effect: { kind: "breadth", base: 900 }, text: "該區 +{n} × 這週出過牌的區數(最多 5 區)" },
{ id: "network", name: "樁腳網", art: "party_elder", cost: 1, money: 0, rarity: "rare", tags: ["org"], target: "none", effect: { kind: "power", power: "network" }, text: "能力:週末每座還沒被用掉的樁腳,兩成變成你在那區的票" },
{ id: "buzz", name: "聲量滾雪球", art: "short_video", cost: 1, money: 0, rarity: "rare", tags: ["media"], target: "none", effect: { kind: "power", power: "buzz" }, text: "能力:每打一張空戰牌聲量 +1(整局累積,最多 15);空戰牌每點聲量 +3%" },
{ id: "explainer", name: "懶人包", art: "line_groups", cost: 1, money: 0, rarity: "rare", tags: ["media", "online"], target: "city", effect: { kind: "city", base: 2300, weight: "young" }, text: "全市 +{n},年輕人多的區分到較多;每點聲量再 +5%" },
{ id: "turntable", name: "反將一軍", art: "press_conference", cost: 1, money: 0, rarity: "rare", tags: ["defend"], target: "none", effect: { kind: "turnaround", cut: 0.5 }, text: "對手這週的批評剩一半;擋下來的一半變成你的全市票" },
{ id: "wargame", name: "沙盤推演", art: "internal_poll", cost: 1, money: 0, rarity: "rare", tags: ["defend", "intel"], target: "none", effect: { kind: "power", power: "wargame" }, text: "能力:每週第一張打對台、澄清、事實查核、反將一軍不花體力" },
{ id: "carpetads", name: "地毯式廣告", art: "eve_online_ad", cost: 1, money: 0, rarity: "rare", tags: ["money"], target: "city", effect: { kind: "spend", perHundred: 900 }, text: "花光手上的資金:每 100 萬全市 +{n}" },
{ id: "microdonate", name: "小額募款", art: "live_pledge", cost: 1, money: 0, rarity: "rare", tags: ["money"], target: "none", effect: { kind: "flagMoney", base: 120, perFlag: 60 }, text: "資金 +{m} 萬;你每插一面旗再 +{p} 萬" },
{ id: "homecoming", name: "回鄉造勢", art: "homecoming", cost: 1, money: 0, rarity: "basic", tags: ["ground", "rally"], target: "town", homeOnly: true, effect: { kind: "rally", base: 2600, momentum: 1 }, text: "只能打在你的本命區;該區 +{n},聲勢 +1" }, { id: "homecoming", name: "回鄉造勢", art: "homecoming", cost: 1, money: 0, rarity: "basic", tags: ["ground", "rally"], target: "town", homeOnly: true, effect: { kind: "rally", base: 2600, momentum: 1 }, text: "只能打在你的本命區;該區 +{n},聲勢 +1" },
{ id: "rally", name: "造勢晚會", art: "rally", cost: 2, money: 200, rarity: "basic", tags: ["ground", "rally"], target: "town", effect: { kind: "rally", base: 3450, momentum: 2, spill: 0.25 }, plus: { effect: { kind: "rally", base: 4140, momentum: 3, spill: 0.3 } }, text: "該區 +{n}、隔壁區兩成半,聲勢 +2" }, { id: "rally", name: "造勢晚會", art: "rally", cost: 2, money: 200, rarity: "basic", tags: ["ground", "rally"], target: "town", effect: { kind: "rally", base: 3450, momentum: 2, spill: 0.25 }, plus: { effect: { kind: "rally", base: 4140, momentum: 3, spill: 0.3 } }, text: "該區 +{n}、隔壁區兩成半,聲勢 +2" },
@ -239,6 +257,14 @@ function scaleEffect(e: CardEffect): CardEffect {
return { ...e, energy: e.energy + 1 }; return { ...e, energy: e.energy + 1 };
case "buff": case "buff":
return { ...e, base: m(e.base), mult: e.mult + 0.2 }; return { ...e, base: m(e.base), mult: e.mult + 0.2 };
case "breadth":
return { ...e, base: m(e.base) };
case "turnaround":
return { ...e, cut: e.cut * 0.6 };
case "spend":
return { ...e, perHundred: m(e.perHundred) };
case "flagMoney":
return { ...e, base: m(e.base), perFlag: m(e.perFlag) };
case "probe": case "probe":
case "power": case "power":
case "none": case "none":
@ -270,9 +296,14 @@ export const upgradable = (id: string, up?: boolean): boolean => !up && (findCar
export const hasKeyword = (card: CardDef, k: Keyword): boolean => (card.keywords ?? []).includes(k); export const hasKeyword = (card: CardDef, k: Keyword): boolean => (card.keywords ?? []).includes(k);
/** 能力牌的效果 */ /** 能力牌的效果 */
export const POWERS: Record<string, { tag: string; mult: number; label: string }> = { /** 能力牌:tag、mult 是「某類牌固定加成」;沒寫的是規則裡另外處理的能力(流派核心牌,docs/25) */
export const POWERS: Record<string, { tag?: string; mult?: number; label: string }> = {
media: { tag: "media", mult: 1.25, label: "媒體訓練" }, media: { tag: "media", mult: 1.25, label: "媒體訓練" },
ground: { tag: "ground", mult: 1.15, label: "蹲點研究" }, ground: { tag: "ground", mult: 1.15, label: "蹲點研究" },
legwork: { label: "走透透" },
network: { label: "樁腳網" },
buzz: { label: "聲量滾雪球" },
wargame: { label: "沙盤推演" },
}; };
export interface EventDef { export interface EventDef {

View File

@ -1,7 +1,7 @@
import type { RogueArchetype } from "@election2026/protocol"; import type { RogueArchetype } from "@election2026/protocol";
import { HOME_LOST_MOMENTUM, HOME_TAKEN_MOMENTUM } from "./archetypes.ts"; import { HOME_LOST_MOMENTUM, HOME_TAKEN_MOMENTUM } from "./archetypes.ts";
import { EVENT_BY_ID, EVENTS, type EventDef } from "./data.ts"; import { EVENT_BY_ID, EVENTS, type EventDef } from "./data.ts";
import { FLAG_LEAD, HAND_MAX, MOMENTUM_MAX, newCard, shuffle, townLead, type Owner, type RunState, type TownState } from "./state.ts"; import { ELDER_LEAD, FLAG_LEAD, FLIP_DRAW_MAX, HAND_MAX, MOMENTUM_MAX, newCard, shuffle, townLead, type Owner, type RunState, type TownState } from "./state.ts";
/** 規則與對手 AI 共用的小工具:幕僚、每週事件、逆風難度、搬票、抽牌、插旗 */ /** 規則與對手 AI 共用的小工具:幕僚、每週事件、逆風難度、搬票、抽牌、插旗 */
export const has = (s: RunState, advisor: string): boolean => s.advisors.includes(advisor); export const has = (s: RunState, advisor: string): boolean => s.advisors.includes(advisor);
@ -109,8 +109,11 @@ export const flagOwner = (t: TownState): Owner => {
export function updateFlags(s: RunState): { gained: TownState[]; lost: TownState[] } { export function updateFlags(s: RunState): { gained: TownState[]; lost: TownState[] } {
const gained: TownState[] = []; const gained: TownState[] = [];
const lost: TownState[] = []; const lost: TownState[] = [];
// 地方大老(對手規則,rival.ts):對手插旗的區,要領先 ELDER_LEAD 才翻得過來
const elder = (s.rivalRules ?? []).includes("elder");
for (const t of s.towns) { for (const t of s.towns) {
const next = flagOwner(t); let next = flagOwner(t);
if (elder && t.flag === "rival" && next !== "rival" && townLead(t) < ELDER_LEAD) next = "rival";
t.flag = next; t.flag = next;
if (!next || next === t.was) continue; if (!next || next === t.was) continue;
if (t.was === "rival") gained.push(t); if (t.was === "rival") gained.push(t);
@ -129,10 +132,15 @@ export function updateFlags(s: RunState): { gained: TownState[]; lost: TownState
s.log.push({ side: "you", text: `攻下${s.setup.rival.name}的本命區${t.name}!聲勢 +${HOME_TAKEN_MOMENTUM},對手下週少一個行動`, town: t.code, votes: 0 }); s.log.push({ side: "you", text: `攻下${s.setup.rival.name}的本命區${t.name}!聲勢 +${HOME_TAKEN_MOMENTUM},對手下週少一個行動`, town: t.code, votes: 0 });
} else s.log.push({ side: "you", text: `翻轉!你在${t.name}插旗,聲勢 +1`, town: t.code, votes: 0 }); } else s.log.push({ side: "you", text: `翻轉!你在${t.name}插旗,聲勢 +1`, town: t.code, votes: 0 });
} }
// 黑馬型:每翻轉一區多抽 1 張(出牌時才抽,週末結算翻的不抽) // 翻區獎勵:每翻轉一區抽 1 張,每週最多 FLIP_DRAW_MAX 張;黑馬型每區再多抽 1 張(出牌時才抽,週末結算翻的不抽)
if (isArch(s, "newcomer") && s.phase === "plan") { if (s.phase === "plan") {
drawCards(s, gained.length); const reward = Math.min(gained.length, FLIP_DRAW_MAX - (s.flipDraws ?? 0));
s.log.push({ side: "you", text: `黑馬氣勢:抽 ${gained.length} 張牌`, town: null, votes: 0 }); const extra = isArch(s, "newcomer") ? gained.length : 0;
if (reward > 0) s.flipDraws = (s.flipDraws ?? 0) + reward;
if (reward + extra > 0) {
drawCards(s, reward + extra);
s.log.push({ side: "you", text: `翻區獎勵:抽 ${reward + extra} 張牌${extra ? "(含黑馬氣勢)" : ""}`, town: null, votes: 0 });
}
} }
} }
if (lost.length) { if (lost.length) {

View File

@ -31,6 +31,57 @@ const STYLE_WEIGHTS: Record<RivalStyle, Record<RogueIntentKind, number>> = {
air: { canvass: 2, rally: 1, tv: 2.5, online: 2, attack: 1.2, smear: 0.6, stake: 0.6 }, air: { canvass: 2, rally: 1, tv: 2.5, online: 2, attack: 1.2, smear: 0.6, stake: 0.6 },
}; };
/**
* 對手規則(docs/25 第 3 節,參考《小丑牌》的 Boss 盲注):開局抽 1 條(逆風 5 起 2 條),整局有效、畫面上一直看得到。
* 對手的風格決定比較常抽到哪幾條。規則對所有候選人一樣,只是機制,不描述真人。
*/
export const RIVAL_RULES: Record<string, { name: string; text: string; weight: Record<RivalStyle, number> }> = {
pundit: { name: "名嘴加持", text: "對手的批評 ×1.5;你澄清、事實查核的時候,對手聲勢 −1", weight: { balanced: 1, ground: 0.6, air: 1.5 } },
elder: { name: "地方大老", text: "對手插旗的區,你要領先 12 個百分點(一般 8)才翻得過來", weight: { balanced: 1, ground: 1.5, air: 0.6 } },
airwar: { name: "大打空戰", text: "對手每週多一個電視或網路廣告", weight: { balanced: 1, ground: 0.5, air: 1.5 } },
stronghold: { name: "鐵票區", text: "對手的本命區每週自動有一座樁腳", weight: { balanced: 1, ground: 1.5, air: 0.8 } },
rumor: { name: "網路謠言", text: "每週末隨機一區你的支持者被拉走一點;那週打探過對手就沒事", weight: { balanced: 1, ground: 0.8, air: 1.3 } },
carpet: { name: "地毯式掃街", text: "對手的掃街會擴散到隔壁區兩成", weight: { balanced: 1, ground: 1.5, air: 0.5 } },
image: { name: "形象牌", text: "你的爆料、比較文宣效果只剩一半;電視辯論贏的回合多 50%", weight: { balanced: 1, ground: 1, air: 1 } },
};
/** 網路謠言:每週被拉走的票(以全市 100 萬人為基準) */
const RUMOR_BASE = 900;
export const hasRule = (s: RunState, id: string): boolean => (s.rivalRules ?? []).includes(id);
/** 開局抽對手規則(新手教學沒有) */
export function drawRivalRules(s: RunState): string[] {
if (s.options.tutorial) return [];
const n = asc(s, 5) ? 2 : 1;
const out: string[] = [];
for (let k = 0; k < n; k++) {
const id = pickWeighted(s, Object.keys(RIVAL_RULES).filter((x) => !out.includes(x)), (x) => RIVAL_RULES[x]!.weight[s.setup.rivalStyle]);
if (id) out.push(id);
}
return out;
}
/** 每週開始:鐵票區(對手本命區自動有樁腳) */
export function applyRivalRules(s: RunState): void {
if (!hasRule(s, "stronghold")) return;
for (const t of s.towns.filter((x) => x.home === "rival")) {
t.rivalShield += intentAmount(s, "stake", t);
s.log.push({ side: "rival", text: `鐵票區:${s.setup.rival.name}的本命區${t.name}樁腳到位`, town: t.code, votes: 0 });
}
}
/** 週末:網路謠言(那週打探過對手就沒事) */
export function rumorAtWeekend(s: RunState, probed: boolean): void {
if (!hasRule(s, "rumor")) return;
if (probed) {
s.log.push({ side: "you", text: "網路謠言:你這週打探過對手,謠言沒有擴散", town: null, votes: 0 });
return;
}
const t = pickWeighted(s, s.towns, (x) => x.you) ?? s.towns[0]!;
const lost = loseVotes(t, RUMOR_BASE * s.scale * t.reach, "you");
s.log.push({ side: "rival", text: `網路謠言在${t.name}流傳`, town: t.code, votes: -Math.round(lost) });
}
/** 每週最多幾個同一類的行動 */ /** 每週最多幾個同一類的行動 */
const LIMITS: Partial<Record<RogueIntentKind, number>> = { rally: 1, tv: 1, online: 1, attack: 1, smear: 1, stake: 1 }; const LIMITS: Partial<Record<RogueIntentKind, number>> = { rally: 1, tv: 1, online: 1, attack: 1, smear: 1, stake: 1 };
@ -73,7 +124,8 @@ function intentAmount(s: RunState, kind: RogueIntentKind, town: TownState | null
// 對手在自己的本命區比較強;媒體型被批評損失比較大(docs/25) // 對手在自己的本命區比較強;媒體型被批評損失比較大(docs/25)
const home = town?.home === "rival" ? RIVAL_HOME_MULT : 1; const home = town?.home === "rival" ? RIVAL_HOME_MULT : 1;
const weak = kind === "attack" && isArch(s, "media") ? 1.2 : 1; const weak = kind === "attack" && isArch(s, "media") ? 1.2 : 1;
return round10(INTENT_BASE[kind] * rivalPower(s) * reach * eventMult(s, INTENT_TAGS[kind]) * styleMult(s, kind) * home * weak); const pundit = kind === "attack" && hasRule(s, "pundit") ? 1.5 : 1;
return round10(INTENT_BASE[kind] * rivalPower(s) * reach * eventMult(s, INTENT_TAGS[kind]) * styleMult(s, kind) * home * weak * pundit);
} }
export function planIntents(s: RunState): Intent[] { export function planIntents(s: RunState): Intent[] {
@ -106,6 +158,11 @@ export function planIntents(s: RunState): Intent[] {
if (town) used.add(town.code); if (town) used.add(town.code);
out.push({ id: `i${s.week}-${k}`, kind, town: town?.code ?? null, amount: intentAmount(s, kind, town), cut: 1 }); out.push({ id: `i${s.week}-${k}`, kind, town: town?.code ?? null, amount: intentAmount(s, kind, town), cut: 1 });
} }
// 大打空戰:每週多一個電視或網路廣告(這週還沒排的那一種)
if (hasRule(s, "airwar")) {
const kind = !count.get("tv") ? "tv" : !count.get("online") ? "online" : null;
if (kind) out.push({ id: `i${s.week}-air`, kind, town: null, amount: intentAmount(s, kind, null), cut: 1 });
}
return out; return out;
} }
@ -149,6 +206,11 @@ export function executeIntent(s: RunState, i: Intent): void {
if (prevented >= 1) { if (prevented >= 1) {
const how = i.kind === "attack" ? (i.cut === 0 ? "批評被你完全擋下" : "批評被你擋掉一部分") : "被你打對台"; const how = i.kind === "attack" ? (i.cut === 0 ? "批評被你完全擋下" : "批評被你擋掉一部分") : "被你打對台";
s.log.push({ side: "you", text: `${name}${label}${how}`, town: i.town, votes: 0, blocked: Math.round(prevented) }); s.log.push({ side: "you", text: `${name}${label}${how}`, town: i.town, votes: 0, blocked: Math.round(prevented) });
// 反將一軍:擋下的批評,一半變成你的全市票
if (i.kind === "attack" && s.turnaround) {
const got = cityVotes(s, prevented * 0.5, "you");
s.log.push({ side: "you", text: "反將一軍:擋下的批評變成你的票", town: null, votes: Math.round(got) });
}
} }
if (i.kind === "tv" || i.kind === "online") { if (i.kind === "tv" || i.kind === "online") {
const parts = spread(s.towns, amount, (x) => x.voters * (x.traits.includes(i.kind === "tv" ? "old" : "young") ? 1.5 : 1)); const parts = spread(s.towns, amount, (x) => x.voters * (x.traits.includes(i.kind === "tv" ? "old" : "young") ? 1.5 : 1));
@ -172,6 +234,11 @@ export function executeIntent(s: RunState, i: Intent): void {
t.shield -= blocked; t.shield -= blocked;
const rest = amount - blocked; const rest = amount - blocked;
if (blocked > 0) s.log.push({ side: "you", text: `樁腳擋下${name}在${t.name}的${INTENT_LABELS[i.kind]}`, town: t.code, votes: 0, blocked: Math.round(blocked) }); if (blocked > 0) s.log.push({ side: "you", text: `樁腳擋下${name}在${t.name}的${INTENT_LABELS[i.kind]}`, town: t.code, votes: 0, blocked: Math.round(blocked) });
// 派系協調人:樁腳擋下的票,一半變成你的
if (blocked > 0 && has(s, "faction_broker")) {
const got = moveVotes(t, blocked * 0.5, "you");
if (got >= 1) s.log.push({ side: "you", text: `派系協調人・${t.name}`, town: t.code, votes: Math.round(got) });
}
if (i.kind === "smear") { if (i.kind === "smear") {
// 到你的票倉拉票:你的支持者被拉走一部分(變回還沒表態),對手拿到一半 // 到你的票倉拉票:你的支持者被拉走一部分(變回還沒表態),對手拿到一半
const lost = loseVotes(t, rest, "you"); const lost = loseVotes(t, rest, "you");
@ -182,4 +249,16 @@ export function executeIntent(s: RunState, i: Intent): void {
const net = moveVotes(t, rest, "rival"); const net = moveVotes(t, rest, "rival");
s.log.push({ side: "rival", text: `${name}${label}`, town: t.code, votes: -Math.round(net) }); s.log.push({ side: "rival", text: `${name}${label}`, town: t.code, votes: -Math.round(net) });
if (i.kind === "rally") addRivalMomentum(s, i.big ? 3 : 2); if (i.kind === "rally") addRivalMomentum(s, i.big ? 3 : 2);
// 地毯式掃街:擴散到隔壁區兩成(隔壁區的樁腳照樣先擋)
if (i.kind === "canvass" && hasRule(s, "carpet")) {
for (const code of t.neighbors) {
const n = s.towns.find((x) => x.code === code);
if (!n) continue;
const spill = amount * 0.2;
const stop = Math.min(n.shield, spill);
n.shield -= stop;
const got = moveVotes(n, spill - stop, "rival");
if (got >= 1) s.log.push({ side: "rival", text: `${name}地毯式掃街擴散到${n.name}`, town: n.code, votes: -Math.round(got) });
}
}
} }

View File

@ -7,7 +7,7 @@ import { REWARD_CARDS, cardDef, upgradable } from "./data.ts";
import { addMomentum, asc, cityVotes, has, isArch, moveVotes } from "./mechanics.ts"; import { addMomentum, asc, cityVotes, has, isArch, moveVotes } from "./mechanics.ts";
import { applyOutcome, choiceBlocked, rollChoice } from "./scenes.ts"; import { applyOutcome, choiceBlocked, rollChoice } from "./scenes.ts";
import type { MiniGameKind } from "@election2026/protocol"; import type { MiniGameKind } from "@election2026/protocol";
import { MAX_ADVISORS, gainCard, newCard, pickWeighted, rand, shuffle, type RunState, type ShopItem, type Stop, type StopKind } from "./state.ts"; import { MAX_ADVISORS, TOTAL_WEEKS, gainCard, newCard, pickWeighted, rand, round10, shuffle, type RunState, type ShopItem, type Stop, type StopKind } from "./state.ts";
/** /**
* 每週結束後的「下一站」(docs/22,像《殺戮尖塔》的地圖):三選一,再進那一站做選擇。 * 每週結束後的「下一站」(docs/22,像《殺戮尖塔》的地圖):三選一,再進那一站做選擇。
@ -40,8 +40,12 @@ export const STOP_LABELS: Record<StopKind, { title: string; text: string }> = {
encounter: { title: "深入基層", text: "親自拜票,連遇三個人" }, encounter: { title: "深入基層", text: "親自拜票,連遇三個人" },
event: { title: "地方抉擇", text: "有代價、有風險的選擇" }, event: { title: "地方抉擇", text: "有代價、有風險的選擇" },
minigame: { title: "選戰小遊戲", text: "掃街、造勢或看板卡位,玩得好就加成" }, minigame: { title: "選戰小遊戲", text: "掃街、造勢或看板卡位,玩得好就加成" },
elite: { title: "地方派系談判", text: "接下挑戰:下週在指定的區淨增票數,達成拿一位稀有幕僚;沒達成聲勢 −1" },
}; };
/** 地方派系談判的目標(以全市 100 萬人為基準,乘上區的大小) */
export const ELITE_GOAL = 3000;
const deckOf = (s: RunState) => [...s.draw, ...s.discard, ...s.hand]; const deckOf = (s: RunState) => [...s.draw, ...s.discard, ...s.hand];
const optionCount = (s: RunState) => (asc(s, 4) ? 2 : 3); const optionCount = (s: RunState) => (asc(s, 4) ? 2 : 3);
const advisorOpen = (s: RunState) => s.advisors.length < MAX_ADVISORS; const advisorOpen = (s: RunState) => s.advisors.length < MAX_ADVISORS;
@ -60,6 +64,8 @@ export function makeRoute(s: RunState): StopKind[] {
encounter: 1.2, encounter: 1.2,
event: STOP_EVENTS.some((e) => !s.seen.includes(e.id)) ? 1.3 : 0, event: STOP_EVENTS.some((e) => !s.seen.includes(e.id)) ? 1.3 : 0,
minigame: s.options.tutorial ? 0 : 1.1, minigame: s.options.tutorial ? 0 : 1.1,
// 精英站:第 2、4 週結束後可能出現(docs/25 第 3 節)
elite: !s.options.tutorial && s.totalWeeks === TOTAL_WEEKS && (s.week === 2 || s.week === 4) ? 1.4 : 0,
}; };
while (out.length < optionCount(s)) { while (out.length < optionCount(s)) {
const kinds = (Object.keys(weights) as StopKind[]).filter((k) => !out.includes(k)); const kinds = (Object.keys(weights) as StopKind[]).filter((k) => !out.includes(k));
@ -121,6 +127,10 @@ const encounterPool = (): readonly EncounterDef[] => ENCOUNTERS.filter((e) => e.
function makeStop(s: RunState, kind: StopKind): Stop { function makeStop(s: RunState, kind: StopKind): Stop {
switch (kind) { switch (kind) {
case "elite": {
const t = contestedTown(s);
return { kind, town: t.code, goal: round10(ELITE_GOAL * s.scale * t.reach) };
}
case "card": case "card":
return { kind, options: cardOptions(s, optionCount(s)) }; return { kind, options: cardOptions(s, optionCount(s)) };
case "advisor": case "advisor":
@ -155,9 +165,27 @@ function makeStop(s: RunState, kind: StopKind): Stop {
} }
/** 這週結束:排好三扇門,門裡的內容也先備好(畫面直接攤開,一次點選就拿到) */ /** 這週結束:排好三扇門,門裡的內容也先備好(畫面直接攤開,一次點選就拿到) */
/** 先抽好的門到時候還能不能用(幕僚滿了、牌組太小、地方抉擇都看過了、精英站只在第 2、4 週) */
function stillValid(s: RunState, kinds: readonly StopKind[]): boolean {
return kinds.every((k) => {
if (k === "advisor") return advisorOpen(s);
if (k === "remove") return deckOf(s).length > 8;
if (k === "event") return STOP_EVENTS.some((e) => !s.seen.includes(e.id));
if (k === "elite") return s.week === 2 || s.week === 4;
return true;
});
}
export function prepareRoute(s: RunState): void { export function prepareRoute(s: RunState): void {
s.route = makeRoute(s); // 上週已經預告的門照用(還能用的話)
s.route = s.nextRoute && stillValid(s, s.nextRoute) ? s.nextRoute : makeRoute(s);
s.routeStops = s.route.map((k) => makeStop(s, k)); s.routeStops = s.route.map((k) => makeStop(s, k));
// 下下週的門:照下週的狀況先抽好種類,畫面灰色顯示
if (s.week + 1 < s.totalWeeks) {
s.week += 1;
s.nextRoute = makeRoute(s);
s.week -= 1;
} else s.nextRoute = null;
} }
/** 拜會地方、招募幕僚、地方抉擇:在門上直接選,不用再進門 */ /** 拜會地方、招募幕僚、地方抉擇:在門上直接選,不用再進門 */
@ -181,6 +209,13 @@ export function pickRoute(s: RunState, pick: number | "skip", option?: number):
const stop = s.routeStops?.[pick] ?? makeStop(s, kind); const stop = s.routeStops?.[pick] ?? makeStop(s, kind);
s.route = null; s.route = null;
s.routeStops = null; s.routeStops = null;
// 地方派系談判:選了就接下挑戰,下週結算
if (stop.kind === "elite") {
s.contract = { town: stop.town, goal: stop.goal, week: s.week + 1 };
const name = s.towns.find((t) => t.code === stop.town)?.name ?? stop.town;
s.log.push({ side: "system", text: `接下地方派系談判:下週在${name}淨增 ${stop.goal.toLocaleString("en-US")} 票`, town: stop.town, votes: 0 });
return { done: true };
}
if (stop.kind === "event") s.seen.push(stop.id); if (stop.kind === "event") s.seen.push(stop.id);
s.stop = stop; s.stop = stop;
s.phase = "stop"; s.phase = "stop";

View File

@ -1,19 +1,20 @@
import type { MiniGameKind, RogueResult } from "@election2026/protocol"; import type { MiniGameKind, RogueResult } from "@election2026/protocol";
import { ADVISOR_BY_ID } from "./advisors.ts"; import { ADVISOR_BY_ID, ADVISORS } from "./advisors.ts";
import { ARCHETYPES, homeBasis, homeTowns } from "./archetypes.ts"; import { ARCHETYPES, homeBasis, homeTowns } from "./archetypes.ts";
import type { IslandPerk, PolicySpec } from "@election2026/protocol"; import type { IslandPerk, PolicySpec } from "@election2026/protocol";
import { MINOR_REPORTER_MULT, ORIGINS, PARTY_LEAN_SHIFT, type Background } from "@election2026/protocol"; import { MINOR_REPORTER_MULT, ORIGINS, PARTY_LEAN_SHIFT, type Background } from "@election2026/protocol";
import { CARD_BY_ID, cardDef, EVENTS, findCard, hasKeyword, REPORTER_PENALTY, STARTER_DECK, upgradable } from "./data.ts"; import { CARD_BY_ID, cardDef, EVENTS, findCard, hasKeyword, REPORTER_PENALTY, STARTER_DECK, upgradable } from "./data.ts";
import { perkLevels, policyCardId, policySlots } from "./meta.ts"; import { perkLevels, policyCardId, policySlots } from "./meta.ts";
import { asc, cityVotes, drawCards, eventOf, flagOwner, has, isArch, moveVotes, updateFlags } from "./mechanics.ts"; import { addMomentum, asc, cityVotes, drawCards, eventOf, flagOwner, has, isArch, moveVotes, updateFlags } from "./mechanics.ts";
import { featsOf } from "./feats.ts"; import { featsOf } from "./feats.ts";
import { announceBigRally, applyRivalShields, executeIntent, planIntents } from "./rival.ts"; import { announceBigRally, applyRivalRules, applyRivalShields, drawRivalRules, executeIntent, planIntents, rumorAtWeekend } from "./rival.ts";
import { pickRoute, pickStop, prepareRoute } from "./route.ts"; import { pickRoute, pickStop, prepareRoute } from "./route.ts";
import { applyUltimate, chargeUltimate, secondChance } from "./ultimate.ts"; import { applyUltimate, chargeUltimate, secondChance } from "./ultimate.ts";
import { committedShares, resolveScene, sceneFor } from "./scenes.ts"; import { committedShares, makeSchedule, resolveScene, sceneFor } from "./scenes.ts";
import { import {
BASE_ENERGY, BASE_ENERGY,
FLAG_INCOME, FLAG_INCOME,
MAX_ADVISORS,
HAND_SIZE, HAND_SIZE,
SAVE_VERSION, SAVE_VERSION,
TOTAL_WEEKS, TOTAL_WEEKS,
@ -79,6 +80,10 @@ function startWeek(s: RunState): void {
s.energy = Math.max(0, s.energyMax + s.energyNext); s.energy = Math.max(0, s.energyMax + s.energyNext);
s.energyNext = 0; s.energyNext = 0;
s.buffs = []; s.buffs = [];
s.flipDraws = 0;
s.groundPlayed = 0;
s.turnaround = false;
s.memeUsed = false;
if (s.viral) s.viral.used = false; if (s.viral) s.viral.used = false;
s.playedThisWeek = 0; s.playedThisWeek = 0;
s.onlinePlayed = 0; s.onlinePlayed = 0;
@ -96,6 +101,13 @@ function startWeek(s: RunState): void {
announceBigRally(s); announceBigRally(s);
s.intents = planIntents(s); s.intents = planIntents(s);
applyRivalShields(s); applyRivalShields(s);
applyRivalRules(s);
// 地方派系談判:記下這週開始時那區的差距
const deal = s.contract;
if (deal && deal.week === s.week) {
const t = s.towns.find((x) => x.code === deal.town);
if (t) deal.start = t.you - t.rival;
}
// 組織型:本命區每週自動有一座樁腳(和「拜託里長佈樁」一樣大) // 組織型:本命區每週自動有一座樁腳(和「拜託里長佈樁」一樣大)
if (isArch(s, "organization")) { if (isArch(s, "organization")) {
for (const t of s.towns.filter((x) => x.home === "you")) { for (const t of s.towns.filter((x) => x.home === "you")) {
@ -261,6 +273,10 @@ export function createRun(setup: RogueSetup, runId: string, seed: number, opts:
s.policyNames = { ...s.policyNames, [id]: p.name }; s.policyNames = { ...s.policyNames, [id]: p.name };
gainCard(s, newCard(s, id)); gainCard(s, newCard(s, id));
}); });
// 每局不一樣(docs/25):對手規則、辯論/民調/黑函的週次
s.rivalRules = drawRivalRules(s);
const schedule = makeSchedule(s);
if (schedule) s.schedule = schedule;
const start = committedShares(s); const start = committedShares(s);
s.startGap = (start.you - start.rival) * 100; s.startGap = (start.you - start.rival) * 100;
s.history.push({ week: 0, ...start }); s.history.push({ week: 0, ...start });
@ -338,6 +354,58 @@ function cleanupHand(s: RunState): void {
s.hand = keep; s.hand = keep;
} }
/** 地方派系談判結算(對手週末行動之後):達成拿一位稀有幕僚(滿了就升級兩張牌),沒達成聲勢 −1 */
function settleContract(s: RunState): void {
const deal = s.contract;
if (!deal || deal.week !== s.week) return;
s.contract = undefined;
const t = s.towns.find((x) => x.code === deal.town);
if (!t) return;
const net = t.you - t.rival - (deal.start ?? 0);
if (net < deal.goal) {
addMomentum(s, -1);
s.log.push({ side: "rival", text: `地方派系談判沒談成:${t.name}只淨增 ${Math.round(Math.max(0, net)).toLocaleString("en-US")} 票,聲勢 −1`, town: t.code, votes: 0 });
return;
}
if (s.advisors.length < MAX_ADVISORS) {
const pool = ADVISORS.filter((a) => !s.advisors.includes(a.id));
const arch = s.options.archetype ? ARCHETYPES[s.options.archetype] : null;
const pick = pickWeighted(s, pool, (a) => (arch && arch.school === a.school ? 1.5 : 1));
if (pick) {
s.advisors.push(pick.id);
s.log.push({ side: "you", text: `地方派系談判成功:${pick.name}加入團隊`, town: t.code, votes: 0 });
return;
}
}
const ups = shuffle(s, [...s.draw, ...s.discard, ...s.hand].filter((c) => upgradable(c.id, c.up))).slice(0, 2);
for (const c of ups) c.up = true;
s.log.push({ side: "you", text: `地方派系談判成功:升級 ${ups.length} 張牌`, town: t.code, votes: 0 });
}
/** 週末的流派效果(docs/25 第 2 節):樁腳網、鐵腿、危機變轉機(在樁腳、出牌紀錄清掉之前) */
function weekendSchools(s: RunState): void {
if (s.powers.includes("network")) {
for (const t of s.towns.filter((x) => x.shield > 0)) {
const net = moveVotes(t, t.shield * 0.2, "you");
if (net >= 1) s.log.push({ side: "you", text: `樁腳網・${t.name}`, town: t.code, votes: Math.round(net) });
}
}
if (has(s, "iron_legs")) {
const towns = s.towns.filter((t) => t.played.length > 0).length;
if (towns >= 3) {
addMomentum(s, 2);
s.log.push({ side: "you", text: `鐵腿:這週跑了 ${towns} 區,聲勢 +2`, town: null, votes: 0 });
}
}
if (has(s, "crisis_flip")) {
const blocked = s.intents.filter((i) => i.kind === "attack" && i.cut < 1).length;
if (blocked > 0) {
addMomentum(s, blocked);
s.log.push({ side: "you", text: `危機變轉機:擋下 ${blocked} 次批評,聲勢 +${blocked}`, town: null, votes: 0 });
}
}
}
/** 結束這週:服務處加票、對手照意圖行動、記者追問、聲勢消退、收入,然後選下一站(最後一週直接開票) */ /** 結束這週:服務處加票、對手照意圖行動、記者追問、聲勢消退、收入,然後選下一站(最後一週直接開票) */
export function endWeek(state: RunState): RunState | { error: string } { export function endWeek(state: RunState): RunState | { error: string } {
if (state.phase !== "plan") return { error: "現在不能結束這週" }; if (state.phase !== "plan") return { error: "現在不能結束這週" };
@ -355,6 +423,9 @@ export function endWeek(state: RunState): RunState | { error: string } {
} }
} }
for (const intent of s.intents) executeIntent(s, intent); for (const intent of s.intents) executeIntent(s, intent);
rumorAtWeekend(s, (s.weekCards ?? []).some((id) => cardDef(id)?.effect.kind === "probe"));
weekendSchools(s);
settleContract(s);
const reporters = s.hand.filter((c) => c.id === "reporter" || c.id === "storm").length; const reporters = s.hand.filter((c) => c.id === "reporter" || c.id === "storm").length;
if (reporters > 0 && !has(s, "crisis_team")) { if (reporters > 0 && !has(s, "crisis_team")) {
const integrity = 1 - 0.15 * (s.options.abilities?.integrity ?? 0); const integrity = 1 - 0.15 * (s.options.abilities?.integrity ?? 0);
@ -376,6 +447,14 @@ export function endWeek(state: RunState): RunState | { error: string } {
) * (isArch(s, "integrity") ? 0.8 : 1); ) * (isArch(s, "integrity") ? 0.8 : 1);
s.money += income; s.money += income;
s.log.push({ side: "system", text: `本週收入 ${income} 萬${flags ? `(含 ${flags} 面旗的小額捐款)` : ""}`, town: null, votes: 0 }); s.log.push({ side: "system", text: `本週收入 ${income} 萬${flags ? `(含 ${flags} 面旗的小額捐款)` : ""}`, town: null, votes: 0 });
// 精算師:存款利息
if (has(s, "actuary")) {
const interest = Math.min(50, Math.floor(s.money / 100) * 5);
if (interest > 0) {
s.money += interest;
s.log.push({ side: "system", text: `精算師:利息 ${interest} 萬`, town: null, votes: 0 });
}
}
s.lastFocus = s.towns s.lastFocus = s.towns
.filter((t) => t.played.length > 0) .filter((t) => t.played.length > 0)
.sort((a, b) => b.played.length - a.played.length) .sort((a, b) => b.played.length - a.played.length)

View File

@ -1,4 +1,5 @@
import { ADVISORS } from "./advisors.ts"; import { ADVISORS } from "./advisors.ts";
import { AFFINITY_WEIGHT, ARCHETYPES } from "./archetypes.ts";
import { import {
CRISIS_CHOICES, CRISIS_CHOICES,
DEBATE_ARGS, DEBATE_ARGS,
@ -14,9 +15,9 @@ import {
type Outcome, type Outcome,
type PressTrigger, type PressTrigger,
} from "./content.ts"; } from "./content.ts";
import { findCard, upgradable } from "./data.ts"; import { REWARD_CARDS, findCard, upgradable } from "./data.ts";
import { addMomentum, addRivalMomentum, addStatus, asc, cityVotes, has, isArch, loseVotes, spread } from "./mechanics.ts"; import { addMomentum, addRivalMomentum, addStatus, asc, cityVotes, has, isArch, loseVotes, spread } from "./mechanics.ts";
import { MAX_ADVISORS, addTally, gainCard, newCard, pickWeighted, rand, shuffle, totals, type DebateArg, type DebateMove, type RunState, type Scene } from "./state.ts"; import { MAX_ADVISORS, TOTAL_WEEKS, addTally, gainCard, newCard, pickWeighted, rand, shuffle, totals, type DebateArg, type DebateMove, type RunState, type Scene } from "./state.ts";
/** /**
* 每週開場的劇情(docs/22):記者堵麥、電視辯論(第 3 週)、民調公布(第 4 週)、匿名黑函危機(第 6 週)。 * 每週開場的劇情(docs/22):記者堵麥、電視辯論(第 3 週)、民調公布(第 4 週)、匿名黑函危機(第 6 週)。
@ -26,6 +27,24 @@ import { MAX_ADVISORS, addTally, gainCard, newCard, pickWeighted, rand, shuffle,
export const DEBATE_WEEK = 3; export const DEBATE_WEEK = 3;
export const POLL_WEEK = 4; export const POLL_WEEK = 4;
export const CRISIS_WEEK = 6; export const CRISIS_WEEK = 6;
/** 8 週的局,辯論、民調、黑函的週次每局隨機(docs/25 第 4 節):辯論 3–5、民調 4–5、黑函 5–6 週,不重疊 */
const SCHEDULES = [
[3, 4, 5],
[3, 4, 6],
[3, 5, 6],
[4, 5, 6],
[5, 4, 6],
] as const;
export function makeSchedule(s: RunState): RunState["schedule"] {
if (s.options.tutorial || s.totalWeeks !== TOTAL_WEEKS) return undefined;
const [debate, poll, crisis] = SCHEDULES[Math.floor(rand(s) * SCHEDULES.length)]!;
return { debate, poll, crisis };
}
/** 這局的行事曆;短局(里長、議員)、舊存檔用固定週次 */
export const scheduleOf = (s: RunState): { debate: number; poll: number; crisis: number } => s.schedule ?? { debate: DEBATE_WEEK, poll: POLL_WEEK, crisis: CRISIS_WEEK };
/** 辯論贏一回合:全市加票(基準),連續答對 ×1.5、×2;輸一回合:你掉票 */ /** 辯論贏一回合:全市加票(基準),連續答對 ×1.5、×2;輸一回合:你掉票 */
export const DEBATE_WIN = 1730; export const DEBATE_WIN = 1730;
export const DEBATE_LOSS = 860; export const DEBATE_LOSS = 860;
@ -201,11 +220,21 @@ function publishPoll(s: RunState): void {
const lead = you >= rival; const lead = you >= rival;
s.stats.pollGap = (rival - you) * 100; s.stats.pollGap = (rival - you) * 100;
if (lead) { if (lead) {
// 領先:西瓜效應,還多一張稀有牌(和你的類型搭配的比較常出現)
addMomentum(s, 1); addMomentum(s, 1);
s.log.push({ side: "you", text: "民調領先,西瓜效應:聲勢 +1", town: null, votes: 0 }); const arch = s.options.archetype ? ARCHETYPES[s.options.archetype] : null;
const rare = pickWeighted(
s,
REWARD_CARDS.filter((c) => c.rarity === "rare" && c.effect.kind !== "kneel"),
(c) => (arch && arch.tags.some((t) => c.tags.includes(t)) ? AFFINITY_WEIGHT : 1),
);
if (rare) s.hand.push(newCard(s, rare.id));
s.log.push({ side: "you", text: `民調領先,西瓜效應:聲勢 +1${rare ? `,支持者送來一張「${rare.name}」` : ""}`, town: null, votes: 0 });
} else { } else {
// 落後:悲情催票,下週體力 +1
s.hand.push(newCard(s, "sympathy")); s.hand.push(newCard(s, "sympathy"));
s.log.push({ side: "you", text: "民調落後,支持者危機意識上升:手上多一張「悲情催票」", town: null, votes: 0 }); s.energyNext += 1;
s.log.push({ side: "you", text: "民調落後,支持者危機意識上升:手上多一張「悲情催票」,下週體力 +1", town: null, votes: 0 });
} }
s.poll = { week: s.week, you, rival, lead }; s.poll = { week: s.week, you, rival, lead };
} }
@ -219,12 +248,13 @@ function crisisScene(s: RunState): Scene {
/** 這週開場的劇情;新手教學沒有 */ /** 這週開場的劇情;新手教學沒有 */
export function sceneFor(s: RunState, prev: RunState["lastWeek"]): Scene | null { export function sceneFor(s: RunState, prev: RunState["lastWeek"]): Scene | null {
if (s.options.tutorial || s.week < 2) return null; if (s.options.tutorial || s.week < 2) return null;
if (s.week === DEBATE_WEEK) return debateScene(s); const when = scheduleOf(s);
if (s.week === POLL_WEEK) { if (s.week === when.debate) return debateScene(s);
if (s.week === when.poll) {
publishPoll(s); publishPoll(s);
return null; return null;
} }
if (s.week === CRISIS_WEEK) return crisisScene(s); if (s.week === when.crisis) return crisisScene(s);
return pressScene(s, prev); return pressScene(s, prev);
} }
@ -272,7 +302,9 @@ function resolveSceneInner(s: RunState, pick: number): string | null {
scene.combo += 1; scene.combo += 1;
addMomentum(s, 1); addMomentum(s, 1);
const mult = DEBATE_COMBO[Math.min(scene.combo, DEBATE_COMBO.length) - 1]! * (arg.policy ? DEBATE_POLICY_BONUS : 1); const mult = DEBATE_COMBO[Math.min(scene.combo, DEBATE_COMBO.length) - 1]! * (arg.policy ? DEBATE_POLICY_BONUS : 1);
votes = Math.round(cityVotes(s, DEBATE_WIN * mult * s.scale)); // 對手規則「形象牌」:辯論贏的回合多 50%
const image = (s.rivalRules ?? []).includes("image") ? 1.5 : 1;
votes = Math.round(cityVotes(s, DEBATE_WIN * mult * image * s.scale));
s.log.push({ side: "you", text: `${head},說服了觀眾!${scene.combo > 1 ? `${scene.combo} 連擊 ×${DEBATE_COMBO[Math.min(scene.combo, DEBATE_COMBO.length) - 1]},` : ""}聲勢 +1`, town: null, votes }); s.log.push({ side: "you", text: `${head},說服了觀眾!${scene.combo > 1 ? `${scene.combo} 連擊 ×${DEBATE_COMBO[Math.min(scene.combo, DEBATE_COMBO.length) - 1]},` : ""}聲勢 +1`, town: null, votes });
} else if (result === "lose") { } else if (result === "lose") {
scene.losses += 1; scene.losses += 1;

View File

@ -157,7 +157,7 @@ export type Scene =
| { kind: "crisis"; amount: number } | { kind: "crisis"; amount: number }
| { kind: "poll"; you: number; rival: number; lead: boolean }; | { kind: "poll"; you: number; rival: number; lead: boolean };
export type StopKind = "card" | "advisor" | "upgrade" | "remove" | "shop" | "encounter" | "event" | "minigame"; export type StopKind = "card" | "advisor" | "upgrade" | "remove" | "shop" | "encounter" | "event" | "minigame" | "elite";
export interface ShopItem { export interface ShopItem {
kind: "card" | "advisor" | "remove"; kind: "card" | "advisor" | "remove";
@ -174,7 +174,9 @@ export type Stop =
| { kind: "shop"; items: ShopItem[] } | { kind: "shop"; items: ShopItem[] }
| { kind: "encounter"; town: string; encounters: string[]; step: number; score: number; notes: string[] } | { kind: "encounter"; town: string; encounters: string[]; step: number; score: number; notes: string[] }
| { kind: "event"; id: string } | { kind: "event"; id: string }
| { kind: "minigame"; game: MiniGameKind; town: string | null; level: number; seed: number }; | { kind: "minigame"; game: MiniGameKind; town: string | null; level: number; seed: number }
/** 地方派系談判(精英站,docs/25 第 3 節):選了就接下挑戰,不用進門 */
| { kind: "elite"; town: string; goal: number };
export interface RunStats { export interface RunStats {
played: number; played: number;
@ -247,6 +249,8 @@ export interface RunState {
route: StopKind[] | null; route: StopKind[] | null;
/** 下一站每扇門裡面的內容(開門前就備好,畫面直接攤開;舊存檔沒有) */ /** 下一站每扇門裡面的內容(開門前就備好,畫面直接攤開;舊存檔沒有) */
routeStops?: Stop[] | null; routeStops?: Stop[] | null;
/** 下下週的門(docs/25:看得到前方,好規劃);只先決定種類,到時候不能用的門會重抽 */
nextRoute?: StopKind[] | null;
/** 最近一次民調(第 4 週自動公布;舊存檔沒有) */ /** 最近一次民調(第 4 週自動公布;舊存檔沒有) */
poll?: { week: number; you: number; rival: number; lead: boolean } | null; poll?: { week: number; you: number; rival: number; lead: boolean } | null;
stop: Stop | null; stop: Stop | null;
@ -272,6 +276,19 @@ export interface RunState {
viral?: { used: boolean; boost: boolean }; viral?: { used: boolean; boost: boolean };
/** 你翻走對手的本命區:對手下週少幾個行動 */ /** 你翻走對手的本命區:對手下週少幾個行動 */
rivalStun?: number; rivalStun?: number;
/** 這局的行事曆(docs/25 第 4 節):辯論、民調、黑函在第幾週;舊存檔、短局沒有,用固定週次 */
schedule?: { debate: number; poll: number; crisis: number };
/** 這局對手的規則(docs/25 第 3 節,rival.ts 的 RIVAL_RULES);舊存檔沒有 */
rivalRules?: string[];
/** 這週翻區已經抽了幾張(每週最多 FLIP_DRAW_MAX) */
flipDraws?: number;
/** 地方派系談判:第 week 週在 town 淨增 goal 票(start 是那週開始時的差距) */
contract?: { town: string; goal: number; week: number; start?: number };
/** 流派核心牌(docs/25 第 2 節):聲量(整局累積)、這週打過幾張地面牌、反將一軍、懶人包小編用過了 */
buzz?: number;
groundPlayed?: number;
turnaround?: boolean;
memeUsed?: boolean;
stats: RunStats; stats: RunStats;
result: RogueResult | null; result: RogueResult | null;
} }
@ -292,6 +309,10 @@ export const WEEKLY_INCOME = 100;
export const FLAG_LEAD = 0.08; export const FLAG_LEAD = 0.08;
/** 每面旗每週的小額捐款(萬元) */ /** 每面旗每週的小額捐款(萬元) */
export const FLAG_INCOME = 20; export const FLAG_INCOME = 20;
/** 對手規則「地方大老」:翻對手的旗要領先這麼多 */
export const ELDER_LEAD = 0.12;
/** 翻區獎勵:每翻轉一區抽 1 張,每週最多幾張(docs/25 第 5 節) */
export const FLIP_DRAW_MAX = 2;
/** 可重現的亂數(mulberry32):回傳 [0, 1) 與新的狀態 */ /** 可重現的亂數(mulberry32):回傳 [0, 1) 與新的狀態 */
export function nextRandom(rng: number): [number, number] { export function nextRandom(rng: number): [number, number] {

View File

@ -9,9 +9,9 @@ import { CARD_BY_ID, EVENTS, KEYWORD_LABELS, ORIGIN_CARDS, POWERS, REPORTER_PENA
import { FEATS } from "./feats.ts"; import { FEATS } from "./feats.ts";
import { ABILITY_EFFECTS, ABILITY_LABELS, BUILDINGS, POLICY_HOME } from "./meta.ts"; import { ABILITY_EFFECTS, ABILITY_LABELS, BUILDINGS, POLICY_HOME } from "./meta.ts";
import { ASCENSION, eventOf, has, momentumMax } from "./mechanics.ts"; import { ASCENSION, eventOf, has, momentumMax } from "./mechanics.ts";
import { BIG_RALLY_WEEK, RIVAL_TRAITS, intentDamp, intentLabel } from "./rival.ts"; import { BIG_RALLY_WEEK, RIVAL_RULES, RIVAL_TRAITS, intentDamp, intentLabel } from "./rival.ts";
import { encounterById, fillVars, MINIGAME_INFO, pickInDoor, PRICES, SKIP_MONEY, STOP_LABELS } from "./route.ts"; import { encounterById, fillVars, MINIGAME_INFO, pickInDoor, PRICES, SKIP_MONEY, STOP_LABELS } from "./route.ts";
import { bestArg, choiceBlocked, debateSure } from "./scenes.ts"; import { bestArg, choiceBlocked, debateSure, scheduleOf } from "./scenes.ts";
import { electionForecast } from "./rules.ts"; import { electionForecast } from "./rules.ts";
import { MAX_ADVISORS, round10, totals, type CardInst, type RunState, type ShopItem, type Stop } from "./state.ts"; import { MAX_ADVISORS, round10, totals, type CardInst, type RunState, type ShopItem, type Stop } from "./state.ts";
@ -63,6 +63,14 @@ function face(s: RunState | null, card: CardDef): { value: string | null; text:
return { value: `×${e.mult}`, text: fill(card.text, { n: fmt(n(e.base)) }).replace("×1.5", `×${e.mult}`) }; return { value: `×${e.mult}`, text: fill(card.text, { n: fmt(n(e.base)) }).replace("×1.5", `×${e.mult}`) };
case "power": case "power":
return { value: "能力", text: card.text }; return { value: "能力", text: card.text };
case "breadth":
return { value: `+${fmt(n(e.base))}×區`, text: fill(card.text, { n: fmt(n(e.base)) }) };
case "turnaround":
return { value: "反將", text: card.text };
case "spend":
return { value: "錢換票", text: fill(card.text, { n: fmt(n(e.perHundred)) }) };
case "flagMoney":
return { value: `+${e.base}萬`, text: fill(card.text, { m: String(e.base), p: String(e.perFlag) }) };
case "answer": case "answer":
return { value: "回應", text: fill(card.text, { n: fmt(n(e.base)), n2: fmt(n(REPORTER_PENALTY)) }) }; return { value: "回應", text: fill(card.text, { n: fmt(n(e.base)), n2: fmt(n(REPORTER_PENALTY)) }) };
case "none": case "none":
@ -189,6 +197,9 @@ function stopView(s: RunState): RogueStop | null {
function stopViewOf(s: RunState, stop: Stop): RogueStop { function stopViewOf(s: RunState, stop: Stop): RogueStop {
switch (stop.kind) { switch (stop.kind) {
case "elite":
// 地方派系談判選了就接下挑戰(route.ts pickRoute),不會停在站裡
throw new Error("地方派系談判沒有站內畫面");
case "card": case "card":
return { kind: "card", options: stop.options.map((id) => cardOffer(s, id)) }; return { kind: "card", options: stop.options.map((id) => cardOffer(s, id)) };
case "advisor": case "advisor":
@ -270,6 +281,22 @@ function colorsOf(s: RunState): RogueView["colors"] {
} }
/** 地方派系談判的門:寫出哪一區、要淨增多少 */
function eliteText(s: RunState, stop: Stop | undefined): { text?: string } {
if (stop?.kind !== "elite") return {};
const name = s.towns.find((t) => t.code === stop.town)?.name ?? stop.town;
return { text: `下週在${name}淨增 ${fmt(stop.goal)} 票:達成拿一位稀有幕僚(幕僚滿了就升級兩張牌);沒達成聲勢 −1` };
}
/** 這週的地方派系談判進度 */
function contractOf(s: RunState): RogueView["contract"] {
const deal = s.contract;
if (!deal || deal.week !== s.week) return null;
const t = s.towns.find((x) => x.code === deal.town);
if (!t) return null;
return { town: t.code, name: t.name, goal: deal.goal, progress: Math.round(t.you - t.rival - (deal.start ?? 0)) };
}
/** 你的候選人特色:類型、技能、弱點、本命區(docs/25);新手教學、舊存檔是 null */ /** 你的候選人特色:類型、技能、弱點、本命區(docs/25);新手教學、舊存檔是 null */
function identityOf(s: RunState): RogueView["identity"] { function identityOf(s: RunState): RogueView["identity"] {
const arch = s.options.archetype; const arch = s.options.archetype;
@ -308,6 +335,8 @@ export function toView(s: RunState): RogueView {
others: s.setup.others, others: s.setup.others,
colors: colorsOf(s), colors: colorsOf(s),
identity: identityOf(s), identity: identityOf(s),
schedule: s.options.tutorial ? null : { ...scheduleOf(s), bigRally: s.totalWeeks >= BIG_RALLY_WEEK ? BIG_RALLY_WEEK : null },
rivalRules: (s.rivalRules ?? []).flatMap((id) => (RIVAL_RULES[id] ? [{ id, name: RIVAL_RULES[id]!.name, text: RIVAL_RULES[id]!.text }] : [])),
rivalTrait: RIVAL_TRAITS[s.setup.rivalStyle], rivalTrait: RIVAL_TRAITS[s.setup.rivalStyle],
towns: s.towns.map((t) => ({ towns: s.towns.map((t) => ({
code: t.code, code: t.code,
@ -343,7 +372,9 @@ export function toView(s: RunState): RogueView {
previews: s.phase === "plan" ? previewsFor(s) : {}, previews: s.phase === "plan" ? previewsFor(s) : {},
scene: sceneView(s), scene: sceneView(s),
// 門上直接攤開內容(拜會地方的三張牌、幕僚、地方抉擇的選項),一次點選就拿到 // 門上直接攤開內容(拜會地方的三張牌、幕僚、地方抉擇的選項),一次點選就拿到
route: s.route ? s.route.map((kind, i) => ({ kind, ...STOP_LABELS[kind], preview: pickInDoor(kind) && s.routeStops?.[i] ? stopViewOf(s, s.routeStops[i]!) : null })) : null, route: s.route ? s.route.map((kind, i) => ({ kind, ...STOP_LABELS[kind], ...eliteText(s, s.routeStops?.[i]), preview: pickInDoor(kind) && s.routeStops?.[i] ? stopViewOf(s, s.routeStops[i]!) : null })) : null,
contract: contractOf(s),
nextRoute: s.route && s.nextRoute ? s.nextRoute.map((kind) => ({ kind, title: STOP_LABELS[kind].title })) : null,
poll: s.poll ?? null, poll: s.poll ?? null,
ultimate: s.options.tutorial ultimate: s.options.tutorial
? null ? null

View File

@ -0,0 +1,153 @@
import { describe, expect, it } from "vitest";
import { REWARD_CARDS } from "../src/data.ts";
import { executeIntent } from "../src/rival.ts";
import { createRun, endWeek, playCard } from "../src/rules.ts";
import { FLAG_LEAD, type Intent, type RunState, type TownState } from "../src/state.ts";
import { catalog } from "../src/view.ts";
import { SETUP, must } from "./fixtures.ts";
/** 流派核心牌與改規則的幕僚(docs/25 第 2 節) */
const town = (s: RunState, code: string): TownState => s.towns.find((t) => t.code === code)!;
/** 乾淨的局面:指定手牌、幕僚、能力,清掉意圖、樁腳、本命區、對手規則 */
function bare(hand: string[], opts: { advisors?: string[]; powers?: string[]; intents?: Intent[] } = {}): RunState {
const s = structuredClone(createRun(SETUP, "r", 1));
return {
...s,
phase: "plan",
scene: null,
rivalRules: [],
towns: s.towns.map((t) => ({ ...t, shield: 0, rivalShield: 0, home: null })),
hand: hand.map((id, i) => ({ uid: `t${i}`, id })),
intents: opts.intents ?? [],
advisors: opts.advisors ?? [],
powers: opts.powers ?? [],
energy: 9,
money: 1000,
momentum: 0,
};
}
const ok = (r: ReturnType<typeof playCard>): RunState => {
if ("error" in r) throw new Error(r.error);
return r.state;
};
const gained = (a: RunState, b: RunState) => b.towns.reduce((x, t, i) => x + t.you - a.towns[i]!.you, 0);
describe("流派核心牌", () => {
it("十張新牌都在獎勵池、圖鑑裡", () => {
const ids = ["legwork", "doorstep", "network", "buzz", "explainer", "turntable", "wargame", "carpetads", "microdonate"];
for (const id of ids) expect(REWARD_CARDS.some((c) => c.id === id)).toBe(true);
const listed = new Set(catalog().cards.map((c) => c.id));
for (const id of ids) expect(listed.has(id)).toBe(true);
for (const a of ["iron_legs", "faction_broker", "meme_editor", "crisis_flip", "actuary"]) expect(catalog().advisors.some((x) => x.id === a)).toBe(true);
});
it("走透透:這週每打過一張地面牌,之後的地面牌 +8%", () => {
const s = bare(["canvass", "canvass", "canvass"], { powers: ["legwork"] });
const plain = bare(["canvass"]);
const one = ok(playCard(s, "t0", "D"));
const two = ok(playCard(one, "t1", "C"));
const three = ok(playCard(two, "t2", "D"));
const base = gained(plain, ok(playCard(plain, "t0", "D")));
// 第三張打在丁區:前面打過 2 張地面牌 ×1.16,同一區第二種牌不算組合拳(都是掃街)
expect(gained(two, three)).toBeCloseTo(base * 1.16, 0);
});
it("挨家挨戶:這週出過牌的區越多越強(最多 5 區)", () => {
const s = bare(["canvass", "canvass", "doorstep"]);
const after2 = ok(playCard(ok(playCard(s, "t0", "A")), "t1", "B"));
const first = bare(["doorstep"]);
const alone = gained(first, ok(playCard(first, "t0", "D")));
expect(gained(after2, ok(playCard(after2, "t2", "D")))).toBeCloseTo(alone * 3, 0);
});
it("樁腳網:週末還沒被用掉的樁腳,兩成變成你在那區的票", () => {
const s = bare([], { powers: ["network"] });
town(s, "A").shield = 1000;
const after = must(endWeek(s));
expect(after.log.some((l) => l.text === "樁腳網・甲區" && l.votes === 200)).toBe(true);
});
it("聲量滾雪球:空戰牌累積聲量,每點 +3%;懶人包每點再 +5%", () => {
const s = bare(["tv", "tv"], { powers: ["buzz"] });
const one = ok(playCard(s, "t0", null));
expect(one.buzz).toBe(1);
const plain = bare(["tv"]);
const base = gained(plain, ok(playCard(plain, "t0", null)));
expect(gained(one, ok(playCard(one, "t1", null)))).toBeCloseTo(base * 1.03, -1);
const ex = { ...bare(["explainer"]), buzz: 4 };
const exPlain = bare(["explainer"]);
expect(gained(ex, ok(playCard(ex, "t0", null)))).toBeCloseTo(gained(exPlain, ok(playCard(exPlain, "t0", null))) * 1.2, -1);
});
it("反將一軍:批評剩一半,擋下的一半變成你的全市票", () => {
const attack: Intent = { id: "a", kind: "attack", town: null, amount: 1000, cut: 1 };
const s = ok(playCard(bare(["turntable"], { intents: [attack] }), "t0", null));
expect(s.intents[0]!.cut).toBe(0.5);
const before = s.towns.reduce((a, t) => a + t.you, 0);
executeIntent(s, s.intents[0]!);
const back = s.log.find((l) => l.text === "反將一軍:擋下的批評變成你的票")!;
expect(back.votes).toBe(250);
expect(before).toBeGreaterThan(0);
});
it("沙盤推演:每週第一張擋對手的牌不花體力", () => {
const attack: Intent = { id: "a", kind: "attack", town: null, amount: 1000, cut: 1 };
const s = bare(["clarify", "clarify"], { powers: ["wargame"], intents: [attack] });
const one = ok(playCard(s, "t0", null));
expect(one.energy).toBe(9);
expect(ok(playCard(one, "t1", null)).energy).toBe(8);
});
it("地毯式廣告:花光資金,每 100 萬全市 +票;小額募款:每面旗多 60 萬", () => {
const s = bare(["carpetads"]);
const after = ok(playCard(s, "t0", null));
expect(after.money).toBe(0);
expect(gained(s, after)).toBeGreaterThan(0);
const m = bare(["microdonate"]);
for (const code of ["A", "B"]) {
const t = town(m, code);
t.you = t.rival + (t.you + t.rival + t.others) * (FLAG_LEAD + 0.05) * 2;
t.flag = "you";
}
expect(ok(playCard(m, "t0", null)).money - m.money).toBe(120 + 60 * 2);
});
});
describe("流派幕僚", () => {
it("鐵腿:一週跑 3 區以上,週末聲勢 +2", () => {
let s = bare(["canvass", "canvass", "canvass"], { advisors: ["iron_legs"] });
for (const [uid, code] of [["t0", "A"], ["t1", "B"], ["t2", "C"]] as const) s = ok(playCard(s, uid, code));
const before = s.momentum;
expect(must(endWeek(s)).log.some((l) => l.text.startsWith("鐵腿"))).toBe(true);
expect(before).toBeGreaterThanOrEqual(0);
});
it("派系協調人:樁腳擋下的票,一半變成你的", () => {
const s = bare([], { advisors: ["faction_broker"] });
town(s, "A").shield = 1000;
executeIntent(s, { id: "c", kind: "canvass", town: "A", amount: 800, cut: 1 });
expect(s.log.find((l) => l.text === "派系協調人・甲區")!.votes).toBe(400);
});
it("懶人包小編:爆紅之後那張牌回到手上(每週一次)", () => {
// 找一個會爆紅的亂數狀態
for (let rng = 1; rng < 200; rng++) {
const s = { ...bare(["live"], { advisors: ["meme_editor"] }), rng };
const after = ok(playCard(s, "t0", null));
if (!after.memeUsed) continue;
expect(after.hand.map((c) => c.id)).toEqual(["live"]);
return;
}
throw new Error("找不到爆紅的亂數");
});
it("危機變轉機:擋下幾次批評,週末聲勢就 +幾;精算師:存款利息最多 50 萬", () => {
const s = bare(["clarify"], { advisors: ["crisis_flip", "actuary"], intents: [{ id: "a", kind: "attack", town: null, amount: 1000, cut: 1 }] });
const after = must(endWeek(ok(playCard(s, "t0", null))));
expect(after.log.some((l) => l.text.startsWith("危機變轉機"))).toBe(true);
expect(after.log.find((l) => l.text.startsWith("精算師"))!.text).toContain("50 萬");
});
});

View File

@ -0,0 +1,206 @@
import { describe, expect, it } from "vitest";
import { cardDef } from "../src/data.ts";
import { updateFlags } from "../src/mechanics.ts";
import { applyRivalRules, executeIntent, planIntents, RIVAL_RULES } from "../src/rival.ts";
import { choose, createRun, endWeek, playCard } from "../src/rules.ts";
import { sceneFor } from "../src/scenes.ts";
import { ELDER_LEAD, FLAG_LEAD, FLIP_DRAW_MAX, type RogueSetup, type RunState, type TownState } from "../src/state.ts";
import { toView } from "../src/view.ts";
import { SETUP, must, toPlan } from "./fixtures.ts";
/** 每局不一樣(docs/25 第 3、4 節)與局中的小勝利(第 5 節) */
const LEANED: RogueSetup = {
...SETUP,
towns: [
{ ...SETUP.towns[0]!, lean: { you: 0.55, rival: 0.35, others: 0.1 } },
{ ...SETUP.towns[1]!, lean: { you: 0.35, rival: 0.55, others: 0.1 } },
{ ...SETUP.towns[2]!, lean: { you: 0.6, rival: 0.3, others: 0.1 } },
{ ...SETUP.towns[3]!, lean: { you: 0.45, rival: 0.45, others: 0.1 } },
],
};
const town = (s: RunState, code: string): TownState => s.towns.find((t) => t.code === code)!;
/** 指定手牌與對手規則,清掉意圖與樁腳 */
function bare(s: RunState, rules: string[], hand: string[] = []): RunState {
const copy = structuredClone(s);
return { ...copy, phase: "plan", scene: null, rivalRules: rules, towns: copy.towns.map((t) => ({ ...t, shield: 0, rivalShield: 0 })), hand: hand.map((id, i) => ({ uid: `t${i}`, id })), intents: [], energy: 9, money: 5000, momentum: 0 };
}
const ok = (r: ReturnType<typeof playCard>): RunState => {
if ("error" in r) throw new Error(r.error);
return r.state;
};
function takeLead(t: TownState, side: "you" | "rival", lead: number): void {
const other = side === "you" ? "rival" : "you";
t.was = other;
t.flag = other;
t[side] = (t[other] + lead * (t[other] + t.others)) / (1 - lead);
}
describe("行事曆每局不同", () => {
it("8 週的局:辯論 3–5、民調 4–5、黑函 5–6 週,不重疊;同一個種子一樣;換種子會變", () => {
const seen = new Set<string>();
for (let seed = 1; seed <= 40; seed++) {
const s = createRun(LEANED, "r", seed);
const { debate, poll, crisis } = s.schedule!;
expect([3, 4, 5]).toContain(debate);
expect([4, 5]).toContain(poll);
expect([5, 6]).toContain(crisis);
expect(new Set([debate, poll, crisis]).size).toBe(3);
seen.add(`${debate}${poll}${crisis}`);
}
expect(seen.size).toBeGreaterThan(2);
expect(createRun(LEANED, "r", 9).schedule).toEqual(createRun(LEANED, "r", 9).schedule);
expect(createRun(LEANED, "r", 9, { tutorial: true }).schedule).toBeUndefined();
expect(createRun(LEANED, "r", 9, { weeks: 5 }).schedule).toBeUndefined();
});
it("辯論照行事曆的週次開場;畫面拿得到行事曆", () => {
const s = createRun(LEANED, "r", 3);
const when = s.schedule!;
expect(sceneFor({ ...structuredClone(s), week: when.debate }, s.lastWeek)?.kind).toBe("debate");
expect(sceneFor({ ...structuredClone(s), week: when.crisis }, s.lastWeek)?.kind).toBe("crisis");
expect(toView(s).schedule).toMatchObject({ ...when, bigRally: 7 });
});
});
describe("對手規則", () => {
it("開局抽 1 條(逆風 5 起 2 條),同一個種子一樣,新手教學沒有;畫面列出名稱與說明", () => {
const s = createRun(LEANED, "r", 5);
expect(s.rivalRules).toHaveLength(1);
expect(createRun(LEANED, "r", 5, { ascension: 5 }).rivalRules).toHaveLength(2);
expect(createRun(LEANED, "r", 5).rivalRules).toEqual(s.rivalRules);
expect(createRun(LEANED, "r", 5, { tutorial: true }).rivalRules).toEqual([]);
const id = s.rivalRules![0]!;
expect(toView(s).rivalRules).toEqual([{ id, name: RIVAL_RULES[id]!.name, text: RIVAL_RULES[id]!.text }]);
});
it("名嘴加持:批評 ×1.5;你澄清時對手聲勢 −1", () => {
const base = { ...createRun(LEANED, "r", 1), week: 3, rng: 77 };
const attack = (rules: string[]) => planIntents({ ...structuredClone(base), rivalRules: rules }).find((i) => i.kind === "attack");
const a = attack(["pundit"]);
const b = attack([]);
if (a && b) expect(a.amount / b.amount).toBeCloseTo(1.5, 1);
const s = { ...bare(createRun(LEANED, "r", 1), ["pundit"], ["clarify"]), rivalMomentum: 2 };
expect(ok(playCard(s, "t0", null)).rivalMomentum).toBe(1);
});
it("地方大老:對手插旗的區要領先 12 個百分點才翻得過來", () => {
const s = bare(createRun(LEANED, "r", 1), ["elder"]);
takeLead(town(s, "B"), "you", FLAG_LEAD + 0.01);
updateFlags(s);
expect(town(s, "B").flag).toBe("rival");
takeLead(town(s, "B"), "you", ELDER_LEAD + 0.01);
updateFlags(s);
expect(town(s, "B").flag).toBe("you");
});
it("大打空戰:每週多一個電視或網路廣告", () => {
const base = { ...createRun(LEANED, "r", 1), week: 3, rng: 5 };
const air = planIntents({ ...structuredClone(base), rivalRules: ["airwar"] });
const plain = planIntents({ ...structuredClone(base), rivalRules: [] });
expect(air.length).toBe(plain.length + (plain.some((i) => i.kind === "tv") && plain.some((i) => i.kind === "online") ? 0 : 1));
});
it("鐵票區:對手本命區每週自動有樁腳", () => {
const s = bare(createRun(LEANED, "r", 1), ["stronghold"]);
applyRivalRules(s);
expect(town(s, "B").rivalShield).toBeGreaterThan(0);
expect(town(s, "A").rivalShield).toBe(0);
});
it("網路謠言:週末有一區被拉走票;那週打探過就沒事", () => {
const run = (played: string[]) => {
const s = { ...bare(createRun(LEANED, "r", 1), ["rumor"]), weekCards: played };
const after = must(endWeek(s));
return after.log.find((l) => l.text.includes("網路謠言"))!;
};
expect(run([]).votes).toBeLessThan(0);
expect(run(["probe"]).votes).toBe(0);
});
it("地毯式掃街:對手掃街擴散到隔壁區兩成", () => {
const s = bare(createRun(LEANED, "r", 1), ["carpet"]);
const before = town(s, "B").rival;
executeIntent(s, { id: "x", kind: "canvass", town: "A", amount: 1000, cut: 1 });
expect(town(s, "B").rival - before).toBeCloseTo(200, 0);
});
it("形象牌:你的比較文宣只剩一半", () => {
const hurt = (rules: string[]) => {
const s = bare(createRun(LEANED, "r", 1), rules, ["contrast"]);
const after = ok(playCard(s, "t0", null));
return s.towns.reduce((a, t, i) => a + t.rival - after.towns[i]!.rival, 0);
};
expect(hurt(["image"])).toBeCloseTo(hurt([]) / 2, 0);
});
});
describe("局中的小勝利", () => {
it("翻區:每翻轉一區抽 1 張,每週最多 2 張", () => {
const s = bare(createRun(LEANED, "r", 1), []);
s.draw = Array.from({ length: 6 }, (_, i) => ({ uid: `d${i}`, id: "canvass" }));
for (const code of ["B", "D", "C"]) takeLead(town(s, code), "you", FLAG_LEAD + 0.03);
updateFlags(s);
expect(s.hand).toHaveLength(FLIP_DRAW_MAX);
expect(s.flipDraws).toBe(FLIP_DRAW_MAX);
});
it("民調週:領先聲勢 +1、多一張稀有牌;落後多一張悲情催票、下週體力 +1", () => {
const s = createRun(LEANED, "r", 2);
const poll = s.schedule!.poll;
const lead: RunState = { ...structuredClone(s), week: poll, momentum: 0, hand: [] };
lead.towns = lead.towns.map((t) => ({ ...t, you: t.you * 2 }));
sceneFor(lead, s.lastWeek);
expect(lead.momentum).toBe(1);
expect(lead.hand.map((c) => cardDef(c.id)!.rarity)).toEqual(["rare"]);
const behind: RunState = { ...structuredClone(s), week: poll, momentum: 0, hand: [], energyNext: 0 };
behind.towns = behind.towns.map((t) => ({ ...t, rival: t.rival * 2 }));
sceneFor(behind, s.lastWeek);
expect(behind.hand.map((c) => c.id)).toEqual(["sympathy"]);
expect(behind.energyNext).toBe(1);
});
});
describe("精英站:地方派系談判", () => {
/** 停在下一站、只有一扇派系談判的門 */
const atDoor = (): RunState => {
const s = must(endWeek(toPlan(createRun(LEANED, "r", 4))));
return { ...s, rivalRules: [], route: ["elite"], routeStops: [{ kind: "elite", town: "D", goal: 1000 }] };
};
it("選了就接下挑戰、直接進下一週;畫面看得到進度", () => {
const s = must(choose(atDoor(), 0));
expect(s.phase === "plan" || s.phase === "scene").toBe(true);
expect(s.contract).toMatchObject({ town: "D", goal: 1000, week: s.week });
expect(toView(toPlan(s)).contract).toMatchObject({ town: "D", name: "丁區", goal: 1000 });
});
it("達成:拿一位幕僚;沒達成:聲勢 −1", () => {
const won = toPlan(must(choose(atDoor(), 0)));
const d = town(won, "D");
d.you += 5000;
d.undecided = Math.max(0, d.undecided - 5000);
const after = must(endWeek({ ...won, intents: [], advisors: [] }));
expect(after.advisors).toHaveLength(1);
expect(after.contract).toBeUndefined();
const lost = toPlan(must(choose(atDoor(), 0)));
const before = { ...lost, intents: [], momentum: 3 };
expect(must(endWeek(before)).log.some((l) => l.text.startsWith("地方派系談判沒談成"))).toBe(true);
});
});
describe("看得到前方:下下週的門", () => {
it("選下一站時看得到下下週的門;到時候還能用就照預告的出現", () => {
let s = must(endWeek(toPlan(createRun(LEANED, "r", 6))));
expect(s.nextRoute?.length).toBeGreaterThan(0);
expect(toView(s).nextRoute?.map((d) => d.kind)).toEqual(s.nextRoute);
const promised = s.nextRoute!;
s = must(endWeek(toPlan(must(choose(s, "skip")))));
// 第 2 週結束時可能被換掉的只有「不能用」的門;三扇都還能用就一模一樣
if (!promised.includes("elite") && !promised.includes("advisor")) expect(s.route).toEqual(promised);
});
});

View File

@ -10,10 +10,12 @@ export interface Settings {
shake: boolean; shake: boolean;
/** 全遊戲的頭像畫風(comic 漫畫、chibi Q 版大頭、pixel 復刻像素、sticker 平面貼紙;docs/24);自創角色可以各自選 */ /** 全遊戲的頭像畫風(comic 漫畫、chibi Q 版大頭、pixel 復刻像素、sticker 平面貼紙;docs/24);自創角色可以各自選 */
avatarStyle: string; avatarStyle: string;
/** 快速模式(docs/25):開票夜、週末結算、選情快報的節奏加快一倍 */
fast: boolean;
} }
const KEY = "tongsuan.settings"; const KEY = "tongsuan.settings";
const DEFAULTS: Settings = { sound: true, music: true, voice: true, shake: true, avatarStyle: "comic" }; const DEFAULTS: Settings = { sound: true, music: true, voice: true, shake: true, avatarStyle: "comic", fast: false };
const AVATAR_STYLES = ["comic", "chibi", "pixel", "sticker"]; const AVATAR_STYLES = ["comic", "chibi", "pixel", "sticker"];
const listeners = new Set<() => void>(); const listeners = new Set<() => void>();
@ -59,3 +61,6 @@ export function subscribeSettings(fn: () => void): () => void {
listeners.add(fn); listeners.add(fn);
return () => listeners.delete(fn); return () => listeners.delete(fn);
} }
/** 動畫、播報的時間:快速模式減半 */
export const pace = (ms: number): number => (current.fast ? Math.round(ms / 2) : ms);

View File

@ -43,6 +43,10 @@ export function SettingsMenu() {
畫面震動 畫面震動
<input type="checkbox" checked={settings.shake} onChange={(e) => updateSettings({ shake: e.target.checked })} /> <input type="checkbox" checked={settings.shake} onChange={(e) => updateSettings({ shake: e.target.checked })} />
</label> </label>
<label>
快速模式
<input type="checkbox" checked={settings.fast} onChange={(e) => updateSettings({ fast: e.target.checked })} />
</label>
<label> <label>
頭像畫風 頭像畫風
<select value={settings.avatarStyle} onChange={(e) => updateSettings({ avatarStyle: e.target.value })}> <select value={settings.avatarStyle} onChange={(e) => updateSettings({ avatarStyle: e.target.value })}>

View File

@ -51,7 +51,7 @@ const SCENE_TITLE: Record<string, string> = { press: "記者堵麥", crisis: "
* 選戰卡牌(新玩法,docs/21–23):地圖+各區支持度+對手意圖+手牌。 * 選戰卡牌(新玩法,docs/21–23):地圖+各區支持度+對手意圖+手牌。
* 一週只剩三步(docs/23 流程整合):看對手 → 出牌 → 拿獎勵。 * 一週只剩三步(docs/23 流程整合):看對手 → 出牌 → 拿獎勵。
* - 快報在地圖上方跑馬燈(第一週開場才自動播電視);記者堵麥是手牌裡的事件牌;民調自動公布。 * - 快報在地圖上方跑馬燈(第一週開場才自動播電視);記者堵麥是手牌裡的事件牌;民調自動公布。
* - 辯論(第 3 週)、黑函(第 6 週)是大場面,全畫面;選完的結果用提示和地圖跳字顯示,不另外跳視窗。 * - 辯論、黑函(週次每局不同,docs/25)是大場面,全畫面;選完的結果用提示和地圖跳字顯示,不另外跳視窗。
* - 結束這週:結算在地圖上播,旁邊同一個面板選下一站(門上直接攤開內容)。 * - 結束這週:結算在地圖上播,旁邊同一個面板選下一站(門上直接攤開內容)。
* 規則都在伺服器;每個動作拿回新的狀態,畫面只負責演出。 * 規則都在伺服器;每個動作拿回新的狀態,畫面只負責演出。
*/ */
@ -206,13 +206,16 @@ export function RogueScreen({ runId }: { runId: string }) {
setError(null); setError(null);
const preview = previews.get(target ?? "city"); const preview = previews.get(target ?? "city");
const el = document.querySelector(`.rg-hand-card[data-uid="${card.uid}"]`); const el = document.querySelector(`.rg-hand-card[data-uid="${card.uid}"]`);
try { // 出牌不等伺服器(docs/25 第 7 節):牌先飛出去、手牌和體力先扣,伺服器回來再用它的結算校正(出錯時 recover 重新讀)
const next = await rogueApi.play(runId, card.uid, target);
flyCard(el, mapRef.current); flyCard(el, mapRef.current);
if (card.tags.includes("rally")) sfx.cheer(); if (card.tags.includes("rally")) sfx.cheer();
else if (card.tags.includes("money")) sfx.coin(); else if (card.tags.includes("money")) sfx.coin();
else if (card.tags.includes("attack")) sfx.alert(); else if (card.tags.includes("attack")) sfx.alert();
else sfx.place(); else sfx.place();
setView((v) => (v ? { ...v, hand: v.hand.filter((c) => c.uid !== card.uid), energy: Math.max(0, v.energy - card.cost), money: Math.max(0, v.money - card.money) } : v));
setSelected(null);
try {
const next = await rogueApi.play(runId, card.uid, target);
const votes = next.log.reduce((a, e) => a + e.votes, 0); const votes = next.log.reduce((a, e) => a + e.votes, 0);
const flipped = next.log.some((e) => e.text.startsWith("翻轉")); const flipped = next.log.some((e) => e.text.startsWith("翻轉"));
// 加成說明用伺服器實際結算的(機率牌會寫爆紅或失言),舊版伺服器沒有就用預估的 // 加成說明用伺服器實際結算的(機率牌會寫爆紅或失言),舊版伺服器沒有就用預估的
@ -233,7 +236,6 @@ export function RogueScreen({ runId }: { runId: string }) {
setLastTown(town); setLastTown(town);
} }
setView(next); setView(next);
setSelected(null);
} catch (e) { } catch (e) {
recover(e); recover(e);
} finally { } finally {

View File

@ -395,6 +395,21 @@ interface FreeProps {
} }
/** 自由選戰:選舉類型 → 年份 → 地區 → 候選人 → 勢均力敵、逆風難度 → 開始 */ /** 自由選戰:選舉類型 → 年份 → 地區 → 候選人 → 勢均力敵、逆風難度 → 開始 */
const archetypeName = (catalog: RogueCatalog | null, id: string): string => catalog?.archetypes.find((a) => a.id === id)?.name ?? "";
/** 選好的候選人的類型:技能、弱點,這個類型的逆風紀錄 */
function ArchetypeNote({ catalog, progress, archetype }: { catalog: RogueCatalog | null; progress: Progress; archetype: string }) {
const a = catalog?.archetypes.find((x) => x.id === archetype);
if (!a) return null;
const best = progress.typeBest?.[a.id];
return (
<p className="rgs-arch-note">
<b>{a.name}</b>:{a.skill};弱點:{a.weakness}
<small>{best === undefined ? "這個類型還沒贏過" : `這個類型最高贏到逆風 ${best} 級`}</small>
</p>
);
}
function FreeSetup({ function FreeSetup({
scenarios, scenarios,
byId, byId,
@ -620,12 +635,17 @@ function FreeSetup({
<b> <b>
{c.number} 號 {c.name} {c.number} 號 {c.name}
</b> </b>
<small>{c.party ?? "無黨籍"}</small> <small>
{c.party ?? "無黨籍"}
{c.archetype && <em className="rgs-arch">{archetypeName(catalog, c.archetype)}</em>}
</small>
{c.slogan && <q>{c.slogan}</q>} {c.slogan && <q>{c.slogan}</q>}
</span> </span>
</button> </button>
))} ))}
</div> </div>
{/* 選好的人的類型(docs/25):技能、弱點,這個類型最高贏到第幾級逆風 */}
{candidate?.archetype && <ArchetypeNote catalog={catalog} progress={progress} archetype={candidate.archetype} />}
</div> </div>
)} )}

View File

@ -1,6 +1,7 @@
import type { RogueLog, RogueView } from "@election2026/protocol"; import type { RogueLog, RogueView } from "@election2026/protocol";
import { Tv, X } from "lucide-react"; import { Tv, X } from "lucide-react";
import { useEffect } from "react"; import { useEffect } from "react";
import { pace } from "../audio/settings.ts";
import { sfx } from "../audio/sfx.ts"; import { sfx } from "../audio/sfx.ts";
import { CHANNELS } from "../news/channels.ts"; import { CHANNELS } from "../news/channels.ts";
import { overall, pct, raceLabel, signed, weekLabel } from "./labels.ts"; import { overall, pct, raceLabel, signed, weekLabel } from "./labels.ts";
@ -46,6 +47,9 @@ export function briefNews(view: RogueView, last: readonly RogueLog[] | null) {
...(view.seats > 1 ...(view.seats > 1
? [`這區選 ${view.seats} 席:贏過最後一席的${view.rival.name}就當選${view.threshold ? `(2022 年最後一席得票率 ${(view.threshold * 100).toFixed(1)}%)` : ""}`] ? [`這區選 ${view.seats} 席:贏過最後一席的${view.rival.name}就當選${view.threshold ? `(2022 年最後一席得票率 ${(view.threshold * 100).toFixed(1)}%)` : ""}`]
: []), : []),
// 這局對手的規則、大場面在第幾週(docs/25):第一週說
...(view.week === 1 ? view.rivalRules.map((r) => `這局對手規則「${r.name}」:${r.text}`) : []),
...(view.week === 1 && view.schedule ? [`這局的大場面:第 ${view.schedule.debate} 週電視辯論、第 ${view.schedule.poll} 週民調、第 ${view.schedule.crisis} 週黑函危機`] : []),
// 候選人特色(docs/25):第一週介紹類型、技能、本命區 // 候選人特色(docs/25):第一週介紹類型、技能、本命區
...(view.week === 1 && view.identity ...(view.week === 1 && view.identity
? [`你是${view.identity.name}:${view.identity.skill};弱點:${view.identity.weakness}${view.identity.home ? `。本命區:${view.identity.home}` : ""}`] ? [`你是${view.identity.name}:${view.identity.skill};弱點:${view.identity.weakness}${view.identity.home ? `。本命區:${view.identity.home}` : ""}`]
@ -81,7 +85,7 @@ export function NewsTicker({ view, last, onOpen }: { view: RogueView; last: read
export function WeekBrief({ view, last, onDone }: { view: RogueView; last: readonly RogueLog[] | null; onDone: () => void }) { export function WeekBrief({ view, last, onDone }: { view: RogueView; last: readonly RogueLog[] | null; onDone: () => void }) {
useEffect(() => { useEffect(() => {
sfx.channel(); sfx.channel();
const t = setTimeout(onDone, BRIEF_MS); const t = setTimeout(onDone, pace(BRIEF_MS));
return () => clearTimeout(t); return () => clearTimeout(t);
}, [onDone]); }, [onDone]);
const { now, headline, top, big, ticker } = briefNews(view, last); const { now, headline, top, big, ticker } = briefNews(view, last);
@ -126,7 +130,7 @@ export function WeekBrief({ view, last, onDone }: { view: RogueView; last: reado
<div className="rg-brief-ticker" aria-hidden> <div className="rg-brief-ticker" aria-hidden>
<span>{ticker.join(" | ")}</span> <span>{ticker.join(" | ")}</span>
</div> </div>
<i className="rg-brief-timer" style={{ animationDuration: `${BRIEF_MS}ms` }} aria-hidden /> <i className="rg-brief-timer" style={{ animationDuration: `${pace(BRIEF_MS)}ms` }} aria-hidden />
</section> </section>
</div> </div>
); );

View File

@ -5,6 +5,7 @@ import { api, rogueApi } from "../api.ts";
import { CandidateBadge } from "../art/Badge.tsx"; import { CandidateBadge } from "../art/Badge.tsx";
import { BallotStamp } from "../art/BallotStamp.tsx"; import { BallotStamp } from "../art/BallotStamp.tsx";
import { setMusic } from "../audio/music.ts"; import { setMusic } from "../audio/music.ts";
import { pace } from "../audio/settings.ts";
import { sfx } from "../audio/sfx.ts"; import { sfx } from "../audio/sfx.ts";
import { num, pct, raceLabel, signed } from "./labels.ts"; import { num, pct, raceLabel, signed } from "./labels.ts";
import { pointsForRun } from "../island/data.ts"; import { pointsForRun } from "../island/data.ts";
@ -196,7 +197,7 @@ function VoteNight({ view, onDone, map }: { view: RogueView; onDone: () => void;
useEffect(() => { useEffect(() => {
if (tick >= TICKS) return; if (tick >= TICKS) return;
const t = setTimeout(() => setTick((x) => x + 1), tickDelay(tick)); const t = setTimeout(() => setTick((x) => x + 1), pace(tickDelay(tick)));
return () => clearTimeout(t); return () => clearTimeout(t);
}, [tick]); }, [tick]);
@ -370,6 +371,8 @@ function ResultPanel({
// 贏了就能直接挑戰下一級(已經解鎖的話):一場接一場 // 贏了就能直接挑戰下一級(已經解鎖的話):一場接一場
const nextLevel = r.won && free && !view.options.daily && level < 10 && level + 1 <= record.progress.ascension ? level + 1 : null; const nextLevel = r.won && free && !view.options.daily && level < 10 && level + 1 <= record.progress.ascension ? level + 1 : null;
const owned = Object.keys(record.progress.conquered ?? {}).length; const owned = Object.keys(record.progress.conquered ?? {}).length;
// 最關鍵的一區(docs/25):雙方差距最小的區(多區才有意義)
const closest = r.byTown.length > 1 ? [...r.byTown].sort((a, b) => Math.abs(a.you - a.rival) - Math.abs(b.you - b.rival))[0] : null;
const [moving, setMoving] = useState(false); const [moving, setMoving] = useState(false);
/** 攻下一塊地盤(全台制霸):挑一個還沒打下的縣市,縣市長劇本(勢均力敵版優先、最近一屆),兩大黨候選人隨機一位 */ /** 攻下一塊地盤(全台制霸):挑一個還沒打下的縣市,縣市長劇本(勢均力敵版優先、最近一屆),兩大黨候選人隨機一位 */
@ -481,6 +484,11 @@ function ResultPanel({
{view.options.daily && <span className="rgn-tag is-daily">每日一戰 {view.options.daily} 完成</span>} {view.options.daily && <span className="rgn-tag is-daily">每日一戰 {view.options.daily} 完成</span>}
{record.record && !tutorial && <span className="rgn-tag is-record">{r.won ? "新紀錄" : "個人最佳"}</span>} {record.record && !tutorial && <span className="rgn-tag is-record">{r.won ? "新紀錄" : "個人最佳"}</span>}
</p> </p>
{!tutorial && closest && (
<p className="rgn-close">
最關鍵的一區:<b>{names.get(closest.code) ?? closest.code}</b>,{closest.you >= closest.rival ? "只贏" : "只輸"} {num(Math.abs(closest.you - closest.rival))} 票
</p>
)}
{record.unlocked !== null && ( {record.unlocked !== null && (
<p className="rgn-unlock"> <p className="rgn-unlock">
<Flame size={20} aria-hidden /> 解鎖逆風 {record.unlocked} 級! <Flame size={20} aria-hidden /> 解鎖逆風 {record.unlocked} 級!

View File

@ -1,29 +1,6 @@
import "./rogue-flow.css"; import "./rogue-flow.css";
import type { RogueChoice, RogueDeckCard, RogueOffer, RogueScene, RogueStop, RogueView } from "@election2026/protocol"; import type { RogueChoice, RogueDeckCard, RogueOffer, RogueScene, RogueStop, RogueStopKind, RogueView } from "@election2026/protocol";
import { import { ArrowRight, Check, ChevronsUp, Coins, Dices, FileText, Footprints, Gamepad2, Handshake, Heart, MessageCircle, Mic, Scissors, ShieldAlert, Signpost, Star, Store, Swords, Trophy, Tv, UserPlus, X, type LucideIcon } from "lucide-react";
ArrowRight,
Check,
ChevronsUp,
Coins,
Dices,
FileText,
Footprints,
Gamepad2,
Handshake,
Heart,
MessageCircle,
Mic,
Scissors,
ShieldAlert,
Signpost,
Star,
Store,
Trophy,
Tv,
UserPlus,
X,
type LucideIcon,
} from "lucide-react";
import { lazy, Suspense, useEffect, useMemo, useState } from "react"; import { lazy, Suspense, useEffect, useMemo, useState } from "react";
import { CandidateBadge } from "../art/Badge.tsx"; import { CandidateBadge } from "../art/Badge.tsx";
import { sfx } from "../audio/sfx.ts"; import { sfx } from "../audio/sfx.ts";
@ -312,7 +289,7 @@ function PollScene({ view, scene, busy, onChoose }: { view: RogueView; scene: Sc
// ───────────────────────── 下一站 ───────────────────────── // ───────────────────────── 下一站 ─────────────────────────
export const STOP_STYLE: Record<RogueStop["kind"], { Icon: LucideIcon; color: string }> = { export const STOP_STYLE: Record<RogueStopKind, { Icon: LucideIcon; color: string }> = {
card: { Icon: Handshake, color: "#e8833a" }, card: { Icon: Handshake, color: "#e8833a" },
advisor: { Icon: UserPlus, color: "#7a5cc4" }, advisor: { Icon: UserPlus, color: "#7a5cc4" },
upgrade: { Icon: ChevronsUp, color: "#c99400" }, upgrade: { Icon: ChevronsUp, color: "#c99400" },
@ -321,6 +298,7 @@ export const STOP_STYLE: Record<RogueStop["kind"], { Icon: LucideIcon; color: st
encounter: { Icon: Footprints, color: "#a3670f" }, encounter: { Icon: Footprints, color: "#a3670f" },
event: { Icon: Signpost, color: "var(--stamp)" }, event: { Icon: Signpost, color: "var(--stamp)" },
minigame: { Icon: Gamepad2, color: "#1f8a4c" }, minigame: { Icon: Gamepad2, color: "#1f8a4c" },
elite: { Icon: Swords, color: "#111419" },
}; };
type ChooseWithTarget = (pick: number | "skip", target?: string | null) => void; type ChooseWithTarget = (pick: number | "skip", target?: string | null) => void;
@ -354,6 +332,24 @@ export function RouteOverlay({ view, busy, onChoose }: { view: RogueView; busy:
} }
} }
/** 下下週的門(docs/25:看得到前方,好規劃) */
export function NextDoors({ view }: { view: RogueView }) {
if (!view.nextRoute?.length) return null;
return (
<p className="rgf-next">
下下週的門:
{view.nextRoute.map((d) => {
const { Icon } = STOP_STYLE[d.kind];
return (
<span key={d.kind}>
<Icon size={14} aria-hidden /> {d.title}
</span>
);
})}
</p>
);
}
function RouteChooser({ view, busy, onChoose }: { view: RogueView; busy: boolean; onChoose: ChooseWithTarget }) { function RouteChooser({ view, busy, onChoose }: { view: RogueView; busy: boolean; onChoose: ChooseWithTarget }) {
useEffect(() => sfx.shuffle(), []); useEffect(() => sfx.shuffle(), []);
return ( return (
@ -385,6 +381,7 @@ function RouteChooser({ view, busy, onChoose }: { view: RogueView; busy: boolean
); );
})} })}
</div> </div>
<NextDoors view={view} />
<button <button
type="button" type="button"
className="btn btn-ghost rgf-skip" className="btn btn-ghost rgf-skip"

View File

@ -16,7 +16,7 @@ export function HelpModal({ onClose }: { onClose: () => void }) {
<li><b>結束這週。</b>對手照計畫行動,你的樁腳會先擋下一部分;結果直接在地圖上跳出來。</li> <li><b>結束這週。</b>對手照計畫行動,你的樁腳會先擋下一部分;結果直接在地圖上跳出來。</li>
<li><b>拿獎勵。</b>同一個畫面選下一站:拿新牌、找幕僚、地方抉擇直接點;升級、拿掉弱牌、物資行、深入基層、小遊戲點了再進去。</li> <li><b>拿獎勵。</b>同一個畫面選下一站:拿新牌、找幕僚、地方抉擇直接點;升級、拿掉弱牌、物資行、深入基層、小遊戲點了再進去。</li>
<li><b>記者堵麥。</b>手牌最左邊的紅色事件牌,這週內回答就好(結束這週前要回答)。</li> <li><b>記者堵麥。</b>手牌最左邊的紅色事件牌,這週內回答就好(結束這週前要回答)。</li>
<li><b>特別的週。</b>第 3 週電視辯論、第 4 週民調自動公布、第 6 週匿名黑函危機、最後一週選前之夜,然後開票。地圖上方的跑馬燈是每週快報,點一下看電視。</li> <li><b>特別的週。</b>電視辯論、民調公布、匿名黑函危機的週次每局不同(上方週次的小字:辯、民、函、勢),最後一週選前之夜,然後開票。每局對手還會抽一條規則,寫在對手行動旁邊。地圖上方的跑馬燈是每週快報,點一下看電視。</li>
</ol> </ol>
<h3>讓票數翻倍的方法</h3> <h3>讓票數翻倍的方法</h3>
<ul> <ul>

View File

@ -5,6 +5,18 @@ import { CardArt } from "../art/CardArt.tsx";
import { AdvisorFace, CardFace } from "./cards.tsx"; import { AdvisorFace, CardFace } from "./cards.tsx";
import { INTENT_ICONS, TRAIT_LABELS, attackable, counterable, num, overall, pct, signed, townShare, raceLabel, weekLabel } from "./labels.ts"; import { INTENT_ICONS, TRAIT_LABELS, attackable, counterable, num, overall, pct, signed, townShare, raceLabel, weekLabel } from "./labels.ts";
/** 行事曆(docs/25):這一週有什麼大場面(辯論、民調、黑函、對手大型造勢、選前之夜) */
function weekMark(view: RogueView, week: number): { short: string; label: string } | null {
const s = view.schedule;
if (!s) return null;
if (week === s.debate) return { short: "辯", label: "電視辯論" };
if (week === s.poll) return { short: "民", label: "民調公布" };
if (week === s.crisis) return { short: "函", label: "匿名黑函危機" };
if (week === s.bigRally) return { short: "勢", label: `${view.rival.name}大型造勢` };
if (week === view.totalWeeks) return { short: "夜", label: "選前之夜" };
return null;
}
/** 頂部狀態列:週次與事件、體力、資金、聲勢、把柄、全市支持度、對手性格 */ /** 頂部狀態列:週次與事件、體力、資金、聲勢、把柄、全市支持度、對手性格 */
export function RogueHud({ view, onDeck, onHelp }: { view: RogueView; onDeck: () => void; onHelp: () => void }) { export function RogueHud({ view, onDeck, onHelp }: { view: RogueView; onDeck: () => void; onHelp: () => void }) {
const o = overall(view.towns); const o = overall(view.towns);
@ -16,11 +28,15 @@ export function RogueHud({ view, onDeck, onHelp }: { view: RogueView; onDeck: ()
<p className="rg-race">{raceLabel(view)}</p> <p className="rg-race">{raceLabel(view)}</p>
{view.identity && <Identity view={view} />} {view.identity && <Identity view={view} />}
<ol className="rg-weeks" aria-label="週次"> <ol className="rg-weeks" aria-label="週次">
{Array.from({ length: view.totalWeeks }, (_, i) => ( {Array.from({ length: view.totalWeeks }, (_, i) => {
<li key={i} className={i + 1 < view.week ? "is-done" : i + 1 === view.week ? "is-now" : ""}> const mark = weekMark(view, i + 1);
return (
<li key={i} className={i + 1 < view.week ? "is-done" : i + 1 === view.week ? "is-now" : ""} title={mark ? `第 ${i + 1} 週:${mark.label}` : undefined}>
{i + 1} {i + 1}
{mark && <small>{mark.short}</small>}
</li> </li>
))} );
})}
<li className={`is-vote${view.phase === "finished" ? " is-now" : ""}`}>開票</li> <li className={`is-vote${view.phase === "finished" ? " is-now" : ""}`}>開票</li>
</ol> </ol>
<p className="rg-event" title={view.event.text}> <p className="rg-event" title={view.event.text}>
@ -135,6 +151,11 @@ export function IntentList({ view, previews, onPick, targeting }: { view: RogueV
<span className="rg-trait-chip" title={view.rivalTrait.text}> <span className="rg-trait-chip" title={view.rivalTrait.text}>
{view.rivalTrait.name} {view.rivalTrait.name}
</span> </span>
{view.rivalRules.map((r) => (
<span key={r.id} className="rg-trait-chip is-rule" title={r.text}>
{r.name}
</span>
))}
</h3> </h3>
<ul> <ul>
{view.intents.map((i) => { {view.intents.map((i) => {
@ -161,6 +182,17 @@ export function IntentList({ view, previews, onPick, targeting }: { view: RogueV
)} )}
{view.intents.some((i) => i.kind === "attack") && <p className="rg-hint">全市的批評樁腳擋不了:用「澄清記者會」「事實查核」,沒擋下會多一張「記者追問」。</p>} {view.intents.some((i) => i.kind === "attack") && <p className="rg-hint">全市的批評樁腳擋不了:用「澄清記者會」「事實查核」,沒擋下會多一張「記者追問」。</p>}
<p className="rg-hint">{view.rivalTrait.name}:{view.rivalTrait.text}</p> <p className="rg-hint">{view.rivalTrait.name}:{view.rivalTrait.text}</p>
{view.rivalRules.map((r) => (
<p key={r.id} className="rg-hint is-rule">
對手規則・{r.name}:{r.text}
</p>
))}
{view.contract && (
<p className={`rg-hint is-contract${view.contract.progress >= view.contract.goal ? " is-done" : ""}`}>
地方派系談判:這週在{view.contract.name}淨增 {num(Math.max(0, view.contract.progress))}/{num(view.contract.goal)} 票
{view.contract.progress >= view.contract.goal ? "(目前達成,週末對手行動後結算)" : "(週末結算,對手的行動也會算進去)"}
</p>
)}
</section> </section>
); );
} }

View File

@ -157,3 +157,5 @@
/* 小鎮幣(服裝店,docs/24) */ /* 小鎮幣(服裝店,docs/24) */
.rgn-unlock.is-coins { flex-wrap: wrap; justify-content: center; border-radius: 16px; background: var(--signal); color: var(--signal-ink); font-size: 15px; animation-delay: 320ms; } .rgn-unlock.is-coins { flex-wrap: wrap; justify-content: center; border-radius: 16px; background: var(--signal); color: var(--signal-ink); font-size: 15px; animation-delay: 320ms; }
.rgn-unlock.is-coins a { font-weight: 900; color: inherit; text-decoration: underline; text-underline-offset: 3px; } .rgn-unlock.is-coins a { font-weight: 900; color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.rgn-close { margin: 0; font-size: 14px; color: var(--muted); }
.rgn-close b { color: var(--ink); }

View File

@ -244,3 +244,6 @@
.rgf-polltrack i { animation: none; } .rgf-polltrack i { animation: none; }
.rgf-choice, .rgf-move, .rgf-door, .rgf-option, .rgf-deckcard, .rgf-item { transition: none; } .rgf-choice, .rgf-move, .rgf-door, .rgf-option, .rgf-deckcard, .rgf-item { transition: none; }
} }
/* 下下週的門(docs/25:看得到前方) */
.rgf-next { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 12px; margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.rgf-next span { display: inline-flex; align-items: center; gap: 3px; opacity: 0.8; }

View File

@ -74,3 +74,7 @@
.rgs-free { animation: rg-fade 200ms ease both; } .rgs-free { animation: rg-fade 200ms ease both; }
.rgs-knob::after, .rgs-cand, .rgs-chips button { transition: none; } .rgs-knob::after, .rgs-cand, .rgs-chips button { transition: none; }
} }
/* 候選人類型(docs/25) */
.rgs-arch { margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--signal); color: var(--signal-ink); font-style: normal; font-weight: 800; font-size: 11px; }
.rgs-arch-note { display: grid; gap: 2px; margin: 8px 0 0; padding: 8px 12px; border-radius: 12px; background: color-mix(in srgb, var(--signal) 22%, var(--surface)); font-size: 13px; line-height: 1.5; }
.rgs-arch-note small { color: var(--muted); }

View File

@ -44,6 +44,11 @@
.rg-weeks { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; } .rg-weeks { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.rg-weeks li { min-width: 26px; padding: 1px 6px; border-radius: 6px; text-align: center; font-family: var(--font-num); font-weight: 700; font-size: 14px; background: var(--surface-2); color: var(--muted); } .rg-weeks li { min-width: 26px; padding: 1px 6px; border-radius: 6px; text-align: center; font-family: var(--font-num); font-weight: 700; font-size: 14px; background: var(--surface-2); color: var(--muted); }
.rg-weeks li.is-done { background: color-mix(in srgb, var(--ink) 18%, var(--surface)); color: var(--ink); } .rg-weeks li.is-done { background: color-mix(in srgb, var(--ink) 18%, var(--surface)); color: var(--ink); }
.rg-weeks li small { margin-left: 1px; font-family: var(--font-serif); font-size: 10px; color: var(--stamp); }
.rg-trait-chip.is-rule { margin-left: 4px; background: var(--stamp); color: #fff; }
.rg-hint.is-rule { color: var(--stamp); }
.rg-hint.is-contract { padding: 4px 8px; border-radius: 8px; background: color-mix(in srgb, var(--signal) 25%, var(--surface)); color: var(--ink); font-weight: 700; }
.rg-hint.is-contract.is-done { background: color-mix(in srgb, #1f8a4c 22%, var(--surface)); }
.rg-weeks li.is-now { background: var(--signal); color: #111419; box-shadow: 0 0 0 2px var(--ink); } .rg-weeks li.is-now { background: var(--signal); color: #111419; box-shadow: 0 0 0 2px var(--ink); }
.rg-weeks li.is-vote { background: color-mix(in srgb, var(--stamp) 15%, var(--surface)); color: var(--stamp); } .rg-weeks li.is-vote { background: color-mix(in srgb, var(--stamp) 15%, var(--surface)); color: var(--stamp); }
.rg-weeks li.is-vote.is-now { background: var(--stamp); color: #fff; } .rg-weeks li.is-vote.is-now { background: var(--stamp); color: #fff; }

View File

@ -2,9 +2,10 @@ import type { RogueLog, RogueRoute, RogueStop, RogueView } from "@election2026/p
import { ArrowRight, ChevronDown, Coins, Flag, Shield } from "lucide-react"; import { ArrowRight, ChevronDown, Coins, Flag, Shield } from "lucide-react";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { CandidateBadge } from "../art/Badge.tsx"; import { CandidateBadge } from "../art/Badge.tsx";
import { pace } from "../audio/settings.ts";
import { sfx } from "../audio/sfx.ts"; import { sfx } from "../audio/sfx.ts";
import { OfferFace } from "./cards.tsx"; import { OfferFace } from "./cards.tsx";
import { ChoiceList, STOP_STYLE } from "./flow.tsx"; import { ChoiceList, NextDoors, STOP_STYLE } from "./flow.tsx";
import { num, overall, signed } from "./labels.ts"; import { num, overall, signed } from "./labels.ts";
/** /**
@ -49,7 +50,7 @@ export function WeekEnd({
if (e.text.includes("翻轉")) sfx.flag(); if (e.text.includes("翻轉")) sfx.flag();
else if (e.side === "rival" && Math.abs(e.votes) > 0) sfx.bad(); else if (e.side === "rival" && Math.abs(e.votes) > 0) sfx.bad();
setShown(shown + 1); setShown(shown + 1);
}, shown === 0 ? 200 : STEP_MS); }, pace(shown === 0 ? 200 : STEP_MS));
return () => clearTimeout(t); return () => clearTimeout(t);
}, [shown, playing, entries, onStep]); }, [shown, playing, entries, onStep]);
useEffect(() => sfx.shuffle(), []); useEffect(() => sfx.shuffle(), []);
@ -125,6 +126,7 @@ export function WeekEnd({
<Door key={`${r.kind}-${i}`} route={r} index={i} view={view} busy={busy} onChoose={onChoose} /> <Door key={`${r.kind}-${i}`} route={r} index={i} view={view} busy={busy} onChoose={onChoose} />
))} ))}
</div> </div>
<NextDoors view={view} />
<button <button
type="button" type="button"
className="btn btn-ghost rg-weekend-skip" className="btn btn-ghost rg-weekend-skip"