diff --git a/backend/apps/server/src/app.ts b/backend/apps/server/src/app.ts
index bef4050..96d9add 100644
--- a/backend/apps/server/src/app.ts
+++ b/backend/apps/server/src/app.ts
@@ -7,12 +7,12 @@ import { CONTENT, candidateStats, personName, withCustomCandidate } from "@elect
import { loadScenarioRegistry, type ScenarioRegistry } from "@election2026/scenarios";
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 { 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 type { z } from "zod";
import type { CouncilDistrict } from "@election2026/rogue/local";
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";
export interface AppOptions {
@@ -28,6 +28,8 @@ export interface AppOptions {
rogueSaveDir?: string | null;
/** 議員選區檔;沒給就用 data/build/council/2022.json */
councilFile?: string;
+ /** 啟動後在背景先算好每位候選人的類型(正式啟動用;測試不需要) */
+ warmArchetypes?: boolean;
}
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>, slogans: Slogans): ScenarioSummary {
+function summary(raw: Scenario, genders: Readonly>, slogans: Slogans, archetypes: ReadonlyMap): ScenarioSummary {
const s = withSlogans(raw, slogans);
return {
id: s.id,
@@ -89,6 +91,7 @@ function summary(raw: Scenario, genders: Readonly>, sl
slogan: c.slogan ?? null,
sloganSource: c.sloganSource ?? null,
stats: candidateStats(s, c),
+ archetype: archetypes.get(`${s.id}|${c.id}`) ?? null,
})),
notes: [...s.notes],
sources: s.sources.map((x) => ({ ...x })),
@@ -141,7 +144,24 @@ export async function buildApp(options: AppOptions = {}): Promise ({ ok: true }));
- app.get("/api/scenarios", async () => registry.all.map((s) => summary(s, genders, slogans)));
+ // 每位候選人的類型(docs/25,依中選會選舉紀錄):第一次要劇本清單時算一次(正式啟動時在背景先算),之後用快取
+ let archetypes: Promise
+ {!tutorial && closest && (
+
+ 最關鍵的一區:{names.get(closest.code) ?? closest.code},{closest.you >= closest.rival ? "只贏" : "只輸"} {num(Math.abs(closest.you - closest.rival))} 票
+
+ )}
{record.unlocked !== null && (
解鎖逆風 {record.unlocked} 級!
diff --git a/web/src/game/rogue/flow.tsx b/web/src/game/rogue/flow.tsx
index 05b70e4..54c92ab 100644
--- a/web/src/game/rogue/flow.tsx
+++ b/web/src/game/rogue/flow.tsx
@@ -1,29 +1,6 @@
import "./rogue-flow.css";
-import type { RogueChoice, RogueDeckCard, RogueOffer, RogueScene, RogueStop, RogueView } from "@election2026/protocol";
-import {
- 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 type { RogueChoice, RogueDeckCard, RogueOffer, RogueScene, RogueStop, RogueStopKind, RogueView } from "@election2026/protocol";
+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";
import { lazy, Suspense, useEffect, useMemo, useState } from "react";
import { CandidateBadge } from "../art/Badge.tsx";
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 = {
+export const STOP_STYLE: Record = {
card: { Icon: Handshake, color: "#e8833a" },
advisor: { Icon: UserPlus, color: "#7a5cc4" },
upgrade: { Icon: ChevronsUp, color: "#c99400" },
@@ -321,6 +298,7 @@ export const STOP_STYLE: Record 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 (
+
+ 下下週的門:
+ {view.nextRoute.map((d) => {
+ const { Icon } = STOP_STYLE[d.kind];
+ return (
+
+ {d.title}
+
+ );
+ })}
+
+ );
+}
+
function RouteChooser({ view, busy, onChoose }: { view: RogueView; busy: boolean; onChoose: ChooseWithTarget }) {
useEffect(() => sfx.shuffle(), []);
return (
@@ -385,6 +381,7 @@ function RouteChooser({ view, busy, onChoose }: { view: RogueView; busy: boolean
);
})}
+