cortico-world-fun 0.7.5 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +4 -2
- package/dist/webui.js +39 -41
- package/package.json +4 -4
- package/src/joint.js +230 -0
- package/src/story-panel.js +6 -2
- package/src/story-read.js +12 -4
- package/src/world.js +32 -39
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
市场按 `##` 标题里的版本号切段,显示在「历史版本」里。
|
|
4
4
|
|
|
5
|
+
## 0.7.7
|
|
6
|
+
|
|
7
|
+
两处面板体验修复:**从回忆开分支后直接落到「出游」**、**对话式出游的 4 个选项不再被裁成 3 个**。没有数据迁移,故事包格式、存储键与面板 id 都不变。
|
|
8
|
+
|
|
9
|
+
- **修:开分支后停在回忆页**。点「从最近可继续检查点开分支」原来只建出新 runId 并留一条提示,还得自己切到「出游」找这一趟;现在分支建好就直接跳到「出游」,没建出来(错误 / 回放拦截)才留在原地看提示,分支说明仍在顶部。
|
|
10
|
+
- **修:4 个选项只显示 3 个,而且不能下滑**。对话式出游底部选项区原来是 `flex:none`,卡片又是 `overflow:hidden`:4 个选项时整块溢出被裁掉,能滚的只有上面的正文区。现在选项区可收缩并在内部滚动,正文区让位(`flex:1 1 0`),卡片固定为 `min(74vh, 780px)`;窗口高度 ≤860px 时收起装饰性场景条与「此刻 · …」元信息行,优先保选项和正文。
|
|
11
|
+
- 测试:`webui/story/webui.test.mjs` 新增「开分支后直接落到出游」;布局用 headless Edge 在 905 / 805 / 705 / 605 / 505 五档视口实测——4 个选项在 ≥705px 全部可见,更矮时可滚动到第 4 个,卡片不再有被裁掉的内容。
|
|
12
|
+
- 版本号升到 0.7.7。
|
|
13
|
+
|
|
14
|
+
## 0.7.6
|
|
15
|
+
|
|
16
|
+
共同决定(两席同票)的修复:**异票不再吞掉对方那一票**。没有数据迁移,故事包格式、存储键与面板 id 都不变。
|
|
17
|
+
|
|
18
|
+
- **行为变更:空票面时两席都能先投**。以前共同决定刚出现、还没有任何票时,聊天通道默认把这一票记成 `owner`,鱼先开口也会落到主人名下;现在空票面两席都能先投,`fun_story_act` 带 `as: "fish"` 就把那一票记在鱼名下。只剩一席没投时仍由那一席自己投,两票不同时两席都能改自己那一票——规则收窄成一句:**先投不限先后;一票在面时等缺的那一席;两票不同时各自可改;一致才前进**。
|
|
19
|
+
- **收口:规则只有一份实现**。新增 `src/joint.js`(阶段 / 该谁投 / 谁能投 / 文案的纯函数),世界、面板、`fun_story_current` 与文字通道都只从它取;规格写在 `docs/JOINT-DECISION-SPEC.md`。除上一条外没有行为变化。
|
|
20
|
+
- 测试:`test/story-text.test.mjs` 新增表驱动矩阵(3 种 `jointResolution` × 主人/鱼先投 × 第二票同/不同)与「被拒必须是纯拒绝」「三个入口一个答案」「面板文案跟阶段走」三组一致性用例。
|
|
21
|
+
|
|
22
|
+
- **修:两边票不一样时会静默删掉一票**。原来的异票分支「只保留后投的那一票」:主人投 A、鱼投 B 之后,主人那一票被删;主人再投,鱼的又被删——两个人只能互相清票,永远凑不出「两边一致」,面板就一直停在「现在轮到你 / 轮到鱼」,看着像卡死。现在异票时**两票都留在票面上**,谁都可以改自己那一票,改成一致才递交。
|
|
23
|
+
- **文字通道可以显式声明这一票是谁的**:`fun_story_act` 支持 `as: "fish"` / `"owner"`,鱼改自己那一票时不会被记到主人名下;只差一席时仍按「缺哪一席」把关,声明错了会被明确拒绝。
|
|
24
|
+
- **面板文案**:提示改成「两边票不一样(你:… / 鱼:…):这一轮不前进,也不清掉任何一席的票。谁都可以改自己那一票,两边一致才递交;也可以先回家。」异票时标题旁的小字显示「两边票不一样」。
|
|
25
|
+
- **回家仍然可用**:异票僵住时点「先回家」按已发生的片段收尾(有回归测试钉住)。
|
|
26
|
+
- 测试:`test/story-text.test.mjs` 新增三条——异票不吞任何一席、鱼改自己那一票不会顶掉主人、异票僵住时回得了家。
|
|
27
|
+
- 版本号升到 0.7.6;简介重写成产品介绍(不再逐版罗列历史,版本细节看本文件)。
|
|
28
|
+
|
|
5
29
|
## 0.7.5
|
|
6
30
|
|
|
7
31
|
故事工坊版式收口:**一个创建入口 + 三个起点**,导入支持选文件。没有数据迁移,故事包格式、校验、隔离试玩、草稿保护与 `describe.json` 都不变。
|
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
- **出门时只读**:显示「出门中 · 某地(逛了 1/3)」,在房间里换姿势不会影响正在走的行程。
|
|
22
22
|
- 素材规格、命名与十张贴图的对齐坐标见 [素材单](<E:/deep seek/素材单-鱼的家2D房间/素材单.md>)。
|
|
23
23
|
|
|
24
|
-
## 版本:0.4.4 → 0.7.
|
|
24
|
+
## 版本:0.4.4 → 0.7.7
|
|
25
25
|
|
|
26
26
|
下游文档(用户手册、市场描述)一度停在 0.4.4,这里补一条线,细节仍以 [CHANGELOG.md](CHANGELOG.md) 为准:
|
|
27
27
|
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
- **0.7.2** 是代码体检整改:六个只读故事查询加 10 分钟记忆化(重复问只回「没变化」,写操作立即失效,`full:true` 重取);工具说明与提示词瘦身(实发 schema 9,472 → 9,216,`ENV_PROMPT` 1,202 → 903);文字通道默认开,聊天里六个查询与开局推进都在,作者工具另有一个开关 `funStoryAuthorInChat`;`hmToMin` / `el()` / `feedback` 抽成共享模块,只读查询拆到 `src/story-read.js`。
|
|
33
33
|
- **0.7.3** 是设置重组:故事长度、主持接口地址与模型、剧情图片来源搬进配置页(热改),旧 `story-node-limit.json` / `story-secrets.json` 密文里的地址与模型 / `story-images/settings.json` 的来源在首次启动时一次性迁移;「自动配图」开关移到出游页顶部;本地插画搬到「地点册 → 本地插画」;出游「设置」只剩「高级设置」(API Key、直连手动出图、自定义工作流)。面板 id 与页签名不变。
|
|
34
34
|
- **0.7.4** 把地点册改成「左栏分组 + 右侧封面列表」:左栏「我的地点册」六项带计数(全部 / 可玩 / 只是地点 / 故事 / 我的 / 住所),「整理与设置」三项(住所与默认画风 / 本地插画 / 从小世界迁入);右栏搜索 + 分类 + 列表/卡片切换 + 封面缩略图行 + 「编辑地点」,窄屏左栏折成横向筛选。数据层、面板 id、编辑器与四个既有视图都不变。同一版把「允许她自己出门」改成只留许可:**不再有 `funHomeAutoSlots`,也不再推 `fun.home.free`**——几点算她自己的时间跟着「鱼的每一天」的「她自己的时间」走,那边叫醒她时她再按日程决定出不出门。`describe.json` 因此从 1 个事件变成 0 个。
|
|
35
|
+
- **0.7.7** 两处面板体验修复:从回忆「从最近可继续检查点开分支」建好后直接跳到「出游」,不用再自己找;对话式出游的底部选项区可滚动,4 个选项不再被裁成 3 个(矮屏收起装饰性场景条,卡片高度固定)。存储、故事包格式与面板 id 不变。
|
|
36
|
+
- **0.7.6** 修共同决定(两席同票):异票时不再「只保留后投的那一票」,两票都留在票面上;空票面时两席都能先投,只剩一席没投时仍等那一席自己投,两票不一样时两席都能改自己那一票,改成一致才前进;异票僵住时也能直接回家。文字通道支持 `as: "fish"` 显式声明这一票是谁的(鱼先开口就记在她名下)。存储与故事包格式不变。
|
|
35
37
|
- **0.7.5** 收掉故事工坊里重复的创建入口:标题条只留「+ 编写故事」,展开后是「选项式故事 / 自由场景包 / 从文件导入」三个起点;右侧「从一个小片段开始」栏删除(窄屏本来也看不到),「展开 / 收起」降成标题旁的小箭头。导入主路径改成选 `.json` 文件(单个 ≤ 32 KB,读完填进原文本框,可继续校验 / 预览 / 导入),粘贴保留;内容列收窄到 1040 居中。数据层、校验、隔离试玩与草稿保护不变。
|
|
36
38
|
- **工具面**:共 24 个;默认只挂 23 个——文字通道默认开着,作者工具 `fun_story` 要另开「聊天里也能管故事」。关掉文字通道则只剩 17 个。六个只读故事查询有 10 分钟记忆化,同一参数重复问只回 `{ok:true, unchanged:true}` 短回执,任何写操作立即失效,`full:true` 可强制重取。
|
|
37
39
|
|
|
@@ -71,7 +73,7 @@ v2 可在高级 JSON 中附加 `references`(最多 24 条)。每条使用 `{
|
|
|
71
73
|
|
|
72
74
|
公开只读工具为 `fun_story_places`、`fun_story_candidates`、`fun_story_detail`、`fun_story_current`、`fun_story_recap`、`fun_story_schedule`。它们不开始故事、不推进事件、不写入每一天或长期记忆;作者管理工具 `fun_story` 仍标为写权限。指定作品从故事面板明确出发,并重新验证作品版本和条件;普通 `fun_go` 不等于启动指定故事。
|
|
73
75
|
|
|
74
|
-
v2 节点可声明 owner/fish/joint,鱼自主只控制 fish,owner
|
|
76
|
+
v2 节点可声明 owner/fish/joint,鱼自主只控制 fish,owner 必须通过用户按钮提交;共同选择按作者声明处理分歧,等待与超时不会变成同意。共同决定那一步:空票面时两席都能先投;只剩一席没投时,那一票只能由那一席自己投;两票不一样时两席都能改自己那一票,改成一致才前进。单人旧故事保持兼容;0.3.3 已移除双人预设故事,不影响作者自己编写双人作品。
|
|
75
77
|
|
|
76
78
|
可选文本主持 `funStoryDM` 默认关闭。接口地址与模型名在配置页(`funStoryDmUrl` / `funStoryDmModel`,热改),API Key 在「出游 → 设置 → 高级 → 文本主持密钥」里填,是密码输入,失焦和保存后只显示掩码与「已保存 / 未设置」。地址与 Key 两项留空使用宿主 `cognition.request`;都填写则由本插件直连 OpenAI 兼容 `POST /chat/completions`(填写 `https://服务地址/v1` 或完整 `/chat/completions` 路径,不含 URL 凭据、查询或片段)。模型名按你的服务商填,例如 `deepseek-chat`、`qwen-plus`、`gpt-4o-mini`;留空则不发送 `model` 字段,由接口使用它自己的默认模型,宿主配置不受影响。仅 Windows 使用 DPAPI CurrentUser 加密密钥,密文单独保存在 `<dataDir>/fun/story-secrets.json`,地址与模型不在密文里;密钥由 Windows 用户环境保护,不与密文同文件。其他平台禁用自定义凭据保存,仍可使用宿主模型。密钥明文不进入 config/state、日志、工具回执、describe、提示词或作品导出。密钥只发送至配置里填写的接口,不发给宿主或其他插件;换机器或重装后需重填。「清除密钥」立即撤销旧请求和提议,随后删除密文;之后回到宿主模型,宿主不可用则明确提示,手动游玩始终可用。
|
|
77
79
|
|
package/dist/webui.js
CHANGED
|
@@ -1843,7 +1843,7 @@ function createStoryController(ctx, onChange = () => {
|
|
|
1843
1843
|
return mutate("choose", { choiceId: current.pending.id, optionId, substitute: true, confirm: true });
|
|
1844
1844
|
}
|
|
1845
1845
|
async function fork(memoryId, checkpointId) {
|
|
1846
|
-
if (!alive() || !state.ready || trip() || state.busy || state.recovering || !memoryId || !checkpointId) return;
|
|
1846
|
+
if (!alive() || !state.ready || trip() || state.busy || state.recovering || !memoryId || !checkpointId) return false;
|
|
1847
1847
|
const forkToken = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 14)}`;
|
|
1848
1848
|
state.error = "";
|
|
1849
1849
|
state.notice = "";
|
|
@@ -1851,11 +1851,13 @@ function createStoryController(ctx, onChange = () => {
|
|
|
1851
1851
|
emit();
|
|
1852
1852
|
try {
|
|
1853
1853
|
const snapshot = await call("fork", { memoryId, checkpointId, forkToken });
|
|
1854
|
-
if (!alive()) return;
|
|
1854
|
+
if (!alive()) return false;
|
|
1855
1855
|
apply(snapshot);
|
|
1856
1856
|
state.notice = "已从已验证检查点创建新 runId。源回忆与预算保留;此分支不写入正史探索、心愿或收藏。";
|
|
1857
|
+
return Boolean(snapshot?.trip);
|
|
1857
1858
|
} catch (error) {
|
|
1858
1859
|
if (alive()) state.error = description(error);
|
|
1860
|
+
return false;
|
|
1859
1861
|
} finally {
|
|
1860
1862
|
state.busy = "";
|
|
1861
1863
|
emit();
|
|
@@ -2169,16 +2171,19 @@ var STYLES = `
|
|
|
2169
2171
|
.sw-trash{margin-top:18px}.sw-trash>summary{cursor:pointer;font-size:12px;color:var(--sw-muted);padding:9px 0;list-style:none}.sw-trash>summary::-webkit-details-marker{display:none}.sw-trash>summary:before{content:'›';display:inline-block;margin-right:6px;transition:transform .15s}.sw-trash[open]>summary:before{transform:rotate(90deg)}.sw-trash-body{margin-top:8px}.sw-trash-list{display:flex;flex-direction:column;gap:10px;margin:10px 0}.sw-trash-row{display:flex;justify-content:space-between;gap:12px;align-items:center;flex-wrap:wrap;border-top:1px dashed var(--sw-line);padding-top:10px}.sw-trash-row:first-child{border-top:0;padding-top:0}.sw-trash-meta{display:flex;flex-direction:column;gap:3px;min-width:0}.sw-trash-meta small{color:var(--sw-muted);font-size:10px}.sw-trash-meta .sw-badge{align-self:flex-start}
|
|
2170
2172
|
.sw-free-log{list-style:none;padding:0;margin:0}.sw-free-log li+li{border-top:1px dashed var(--sw-line);padding-top:14px;margin-top:14px}.sw-free-log small{display:block;color:var(--sw-muted);font-size:10px;margin-bottom:5px}.sw-free-say{font-size:13px;color:var(--sw-green);margin-bottom:6px;overflow-wrap:anywhere}.sw-free-state .sw-story-meta{margin-top:6px}.sw-free-input{width:100%;min-height:76px;resize:vertical;font:inherit;font-size:13px;line-height:1.7;padding:10px 12px;border:1px solid var(--sw-line);border-radius:9px;background:var(--sw-paper);color:var(--sw-ink)}.sw-free-compose{align-items:flex-start}.sw-free-compose .sw-stack{flex:1;min-width:min(100%,260px)}
|
|
2171
2173
|
/* 出游页 · 对话式(默认):头尾钉住,只有中间那段滚 */
|
|
2172
|
-
.sw-play{--sw-play-h:min(
|
|
2173
|
-
.sw-play>article.sw-card{display:flex;flex-direction:column;min-height:0;
|
|
2174
|
+
.sw-play{--sw-play-h:min(74vh,780px)}
|
|
2175
|
+
.sw-play>article.sw-card{display:flex;flex-direction:column;min-height:0;height:var(--sw-play-h);overflow:hidden}
|
|
2174
2176
|
.sw-play .sw-play-head{flex:none}
|
|
2175
2177
|
.sw-play .sw-play-context{flex:none;display:flex;gap:7px;align-items:center;padding:0 22px 10px;color:var(--sw-muted);font-size:11px}
|
|
2176
2178
|
.sw-dot-sep{opacity:.5}
|
|
2177
2179
|
.sw-play .sw-play-strip{flex:none;height:84px;min-height:84px;aspect-ratio:auto;border-radius:0}
|
|
2178
2180
|
.sw-play .sw-play-strip .sw-scene-label{bottom:12px;left:18px;right:18px}
|
|
2179
2181
|
.sw-play .sw-play-strip .sw-scene-label h2{font-size:16px;margin:0}
|
|
2180
|
-
.sw-play .sw-reading{flex:1 1
|
|
2181
|
-
.sw-play .sw-play-action{flex:
|
|
2182
|
+
.sw-play .sw-reading{flex:1 1 0;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-gutter:stable;padding-bottom:10px;-webkit-mask-image:linear-gradient(180deg,transparent 0,#000 18px);mask-image:linear-gradient(180deg,transparent 0,#000 18px)}
|
|
2183
|
+
.sw-play .sw-play-action{flex:0 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;display:flex;flex-direction:column;gap:7px;padding:13px 22px 12px;border-top:1px solid var(--sw-line);background:color-mix(in srgb,var(--sw-green) 4%,var(--sw-paper))}
|
|
2184
|
+
/* 选项多(v2 最多 4 个)或窗口矮时:先收装饰性的场景条与一行元信息,让选项和正文都有地方;
|
|
2185
|
+
底部这一块自己滚,绝不裁掉最后一个选项。 */
|
|
2186
|
+
@media (max-height:860px){.sw-play .sw-play-strip,.sw-play .sw-play-context{display:none}}
|
|
2182
2187
|
.sw-play .sw-play-action .sw-choices{margin-top:0}
|
|
2183
2188
|
.sw-play .sw-play-action .sw-prose{font-size:13px;line-height:1.8;max-width:none}
|
|
2184
2189
|
.sw-play .sw-play-foot{flex:none}
|
|
@@ -2569,8 +2574,9 @@ function mountPanel(root, ctx) {
|
|
|
2569
2574
|
const pending = current.pending;
|
|
2570
2575
|
const isDraft = current.state === "draft";
|
|
2571
2576
|
const manually = canAct(state) && !state.snapshot.autonomy.enabled;
|
|
2572
|
-
const
|
|
2573
|
-
const
|
|
2577
|
+
const joint = pending?.actor === "joint" ? current.joint : null;
|
|
2578
|
+
const ownerTurn = manually && (joint ? joint.canVote?.owner === true : current.actor !== "fish");
|
|
2579
|
+
const canSubstitute = !joint && !isDraft && current.step === "choose" && !state.autoAuthorized && state.snapshot.autonomy.canSubstitute === true;
|
|
2574
2580
|
const pick = async (option) => {
|
|
2575
2581
|
if (!canSubstitute) return controller.mutate("choose", { choiceId: pending.id, optionId: option.id });
|
|
2576
2582
|
const label2 = text(option.label, option.id);
|
|
@@ -2597,29 +2603,18 @@ function mountPanel(root, ctx) {
|
|
|
2597
2603
|
function optionsHint(state, current, canSubstitute) {
|
|
2598
2604
|
if (current.state === "draft") return "先继续行程,再选择下一步。";
|
|
2599
2605
|
if (state.autoAuthorized) return "鱼正在考虑这些有效选项。你可以随时关闭右侧开关接管。";
|
|
2606
|
+
if (current.pending?.actor === "joint" && current.joint?.hint) return current.joint.hint;
|
|
2600
2607
|
if (canSubstitute) return "鱼这一步没法自己决定:你可以替她选一个,点下去会先问你确认;也可以先收尾,或者点右侧「再来一段」。";
|
|
2601
|
-
const pending = current.pending;
|
|
2602
|
-
if (pending?.actor === "joint") {
|
|
2603
|
-
const votes = pending.votes ?? {};
|
|
2604
|
-
if (!votes.owner) return "两席各投一票,同票才出发:你先选,选完等鱼自己投她那一票。";
|
|
2605
|
-
if (!votes.fish) return "你这一票已经记下了。这一票要鱼自己投:到聊天里让她说,或者打开右侧「鱼自己游玩」由她决定。两票相同才会前进。";
|
|
2606
|
-
return "两边的票不一样,这一轮重新来:你可以改选,鱼也会被要求重选。同票才前进,等待不算同意。";
|
|
2607
|
-
}
|
|
2608
2608
|
return "选一条你想走的路。点击后会等待保存确认。";
|
|
2609
2609
|
}
|
|
2610
|
-
function jointBoard(
|
|
2611
|
-
const
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
node("small", {}, name),
|
|
2619
|
-
node("strong", {}, picked || "还没投")
|
|
2620
|
-
);
|
|
2621
|
-
};
|
|
2622
|
-
return node("div", { class: "sw-votes", "aria-label": "共同决定的两席票" }, seat("owner", "你这一席"), seat("fish", "鱼那一席"));
|
|
2610
|
+
function jointBoard(joint) {
|
|
2611
|
+
const seats = list(joint?.seats);
|
|
2612
|
+
return node("div", { class: "sw-votes", "aria-label": "共同决定的两席票" }, seats.map((seat) => node(
|
|
2613
|
+
"div",
|
|
2614
|
+
{ class: `sw-vote${seat.voted ? " sw-vote-done" : ""}` },
|
|
2615
|
+
node("small", {}, seat.name),
|
|
2616
|
+
node("strong", {}, seat.label || "还没投")
|
|
2617
|
+
)));
|
|
2623
2618
|
}
|
|
2624
2619
|
function advanceButton(state, current, opts = {}) {
|
|
2625
2620
|
const manually = canAct(state) && !state.snapshot.autonomy.enabled;
|
|
@@ -2846,7 +2841,8 @@ function mountPanel(root, ctx) {
|
|
|
2846
2841
|
const isDraft = current.state === "draft";
|
|
2847
2842
|
const pending = current.pending;
|
|
2848
2843
|
const manually = canAct(state) && !snapshot.autonomy.enabled;
|
|
2849
|
-
const
|
|
2844
|
+
const joint = pending?.actor === "joint" ? current.joint : null;
|
|
2845
|
+
const ownerTurn = manually && (joint ? joint.canVote?.owner === true : current.actor !== "fish");
|
|
2850
2846
|
const left = node("article", { class: "sw-card sw-play-main" });
|
|
2851
2847
|
left.append(node("div", { class: "sw-play-head" }, node(
|
|
2852
2848
|
"div",
|
|
@@ -2877,10 +2873,9 @@ function mountPanel(root, ctx) {
|
|
|
2877
2873
|
reading.append(node("ul", { class: "sw-event-history" }, events.slice(-3).map((event) => node("li", {}, node("p", { class: "sw-prose" }, text(event))))));
|
|
2878
2874
|
} else reading.append(node("p", { class: "sw-prose" }, current.step === "move" ? "路就在眼前。走近一点,看看会遇见什么。" : "这一趟的故事,将随着真实的行动在这里展开。"));
|
|
2879
2875
|
if (current.actor) {
|
|
2880
|
-
const
|
|
2881
|
-
const
|
|
2882
|
-
|
|
2883
|
-
reading.append(note(`当前行动者:${current.actor === "fish" ? "鱼" : "你"}${pending?.actor === "joint" ? ` · 共同决定:${pending.jointResolution === "require-agreement" ? "双方必须明确同意;分歧保持待定" : pending.jointResolution === "owner-final" ? "分歧按你的明确选择" : "分歧按鱼的明确选择"}` : ""}${seats}。等待不会当作同意。`));
|
|
2876
|
+
const who = (joint?.seat ?? current.actor) === "fish" ? "鱼" : "你";
|
|
2877
|
+
const jointLine = joint ? ` · 共同决定:${joint.resolutionNote}${joint.seatsText ? ` · ${joint.seatsText}` : ""}` : "";
|
|
2878
|
+
reading.append(note(`当前行动者:${who}${jointLine}。等待不会当作同意。`));
|
|
2884
2879
|
}
|
|
2885
2880
|
for (const reference of list(current.references)) reading.append(note(reference));
|
|
2886
2881
|
if (current.blocked) reading.append(node("div", { class: "sw-notice sw-notice-error" }, icon("info"), node("p", {}, text(current.blocked, "当前无法推进,请核对场所与故事条件。"))));
|
|
@@ -2889,12 +2884,11 @@ function mountPanel(root, ctx) {
|
|
|
2889
2884
|
const action = node("div", { class: "sw-play-action", "aria-label": "当前这一步" });
|
|
2890
2885
|
if (pending) {
|
|
2891
2886
|
const { block, canSubstitute } = pendingPicker(state, current, "sw-choices");
|
|
2892
|
-
|
|
2893
|
-
action.append(node("div", { class: "sw-kicker" }, joint && current.actor === "fish" ? "现在轮到鱼" : "现在轮到你了"));
|
|
2887
|
+
action.append(node("div", { class: "sw-kicker" }, joint ? joint.headline : "现在轮到你了"));
|
|
2894
2888
|
if (pending.prompt) action.append(node("p", { class: "sw-prose" }, text(pending.prompt)));
|
|
2895
|
-
if (joint) action.append(jointBoard(
|
|
2889
|
+
if (joint) action.append(jointBoard(joint));
|
|
2896
2890
|
action.append(block, note(optionsHint(state, current, canSubstitute)));
|
|
2897
|
-
if (joint
|
|
2891
|
+
if (joint?.seat === "fish" && canAct(state)) {
|
|
2898
2892
|
action.append(actionRow(button(
|
|
2899
2893
|
"刷新,看鱼投了没",
|
|
2900
2894
|
() => {
|
|
@@ -2921,7 +2915,7 @@ function mountPanel(root, ctx) {
|
|
|
2921
2915
|
const checked = state.autoplay === true;
|
|
2922
2916
|
const running = state.autoAuthorized === true;
|
|
2923
2917
|
const stopped = Boolean(snapshot.autonomy.stop);
|
|
2924
|
-
const modeSubtitle = stopped ? snapshot.autonomy.canContinue ? "这一段走完了,可以再来一段" : "这一段走完了,等你收尾" : running ? "这一趟,由鱼自己决定" : checked ? current.actor === "owner" ? "轮到你选择;选完鱼会接着走" : "鱼会接着往下走" : current.actor === "fish" ? "这一步等鱼提交,可以去聊天里让她说" : "下一步,等你来选择";
|
|
2918
|
+
const modeSubtitle = stopped ? snapshot.autonomy.canContinue ? "这一段走完了,可以再来一段" : "这一段走完了,等你收尾" : running ? "这一趟,由鱼自己决定" : checked ? (joint?.seat ?? current.actor) === "owner" ? "轮到你选择;选完鱼会接着走" : "鱼会接着往下走" : (joint?.seat ?? current.actor) === "fish" ? "这一步等鱼提交,可以去聊天里让她说" : "下一步,等你来选择";
|
|
2925
2919
|
modeCard.append(node(
|
|
2926
2920
|
"div",
|
|
2927
2921
|
{ class: "sw-mode" },
|
|
@@ -2991,6 +2985,7 @@ function mountPanel(root, ctx) {
|
|
|
2991
2985
|
function playImmersive(state, current) {
|
|
2992
2986
|
const isDraft = current.state === "draft";
|
|
2993
2987
|
const pending = current.pending;
|
|
2988
|
+
const joint = pending?.actor === "joint" ? current.joint : null;
|
|
2994
2989
|
const events = list(current.events);
|
|
2995
2990
|
const wrap = node("div", { class: "sw-imm" });
|
|
2996
2991
|
wrap.append(scene(null, text(current.area, current.placeName), "", { location: current.locationArt, class: "sw-imm-scene", tag: text(current.placeName, "当前地点") }));
|
|
@@ -3000,11 +2995,11 @@ function mountPanel(root, ctx) {
|
|
|
3000
2995
|
node("div", { class: "sw-kicker" }, isDraft ? "等待继续" : `此刻 · ${text(current.area, current.placeName)}`),
|
|
3001
2996
|
node("p", { class: "sw-imm-lead" }, text(events.at(-1), current.step === "move" ? "路就在眼前。走近一点,看看会遇见什么。" : "这一趟的故事,将随着真实的行动在这里展开。")),
|
|
3002
2997
|
pending?.prompt ? node("p", { class: "sw-imm-ask" }, text(pending.prompt)) : null,
|
|
3003
|
-
|
|
2998
|
+
joint ? note(joint.note) : null
|
|
3004
2999
|
));
|
|
3005
3000
|
if (pending) {
|
|
3006
3001
|
const { block, canSubstitute } = pendingPicker(state, current, "sw-imm-choices");
|
|
3007
|
-
if (
|
|
3002
|
+
if (joint) wrap.append(jointBoard(joint));
|
|
3008
3003
|
wrap.append(block, note(optionsHint(state, current, canSubstitute)));
|
|
3009
3004
|
} else {
|
|
3010
3005
|
const advance = advanceButton(state, current, { block: true });
|
|
@@ -3211,7 +3206,10 @@ function mountPanel(root, ctx) {
|
|
|
3211
3206
|
const forkable = (memory.checkpoints ?? []).filter((checkpoint) => checkpoint.resumable === true);
|
|
3212
3207
|
if (forkable.length && !state.snapshot.trip) actions.push(button("从最近可继续检查点开分支", () => {
|
|
3213
3208
|
const checkpoint = forkable.at(-1);
|
|
3214
|
-
if (checkpoint)
|
|
3209
|
+
if (!checkpoint) return;
|
|
3210
|
+
void controller.fork(memory.id, checkpoint.id).then((created) => {
|
|
3211
|
+
if (created && !disposed) navigate("play");
|
|
3212
|
+
});
|
|
3215
3213
|
}, { small: true, key: `fork-${memory.id}` }));
|
|
3216
3214
|
actions.push(button("移到回收站", () => void removeMemory(memory), { small: true, quiet: true, danger: true, key: `delete-${memory.id}` }));
|
|
3217
3215
|
return node("article", { class: "sw-card sw-memory" }, node(
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-fun",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.7",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "从0开始的肥鱼大冒险 —— 给 Coopanion 桌宠二十处真能去逛的地方:游乐场、海洋馆、庙会、漫展、电影院、动物园、公园、电玩城、KTV
|
|
5
|
+
"description": "从0开始的肥鱼大冒险 —— 给 Coopanion 桌宠二十处真能去逛的地方:游乐场、海洋馆、庙会、漫展、电影院、动物园、公园、电玩城、KTV、博物馆、猫咖、爬山、咖啡店、奶茶店、餐厅、图书馆、夜市、澡堂、旧货市场、江边。进门、逛摊位、买纪念品、拍张照、吃喝点什么,回家记一笔。\n\n七个面板:家(2D 房间、十个活动)、去哪儿(此刻推荐)、地点册(唯一的编辑器)、出游(当前这一趟与故事)、纪念册、纪念品架、故事工坊。故事可以自己写:选项式一步一选,自由场景包交给主持即兴演;双人故事里的共同决定要两席同票才前进。24 个工具、0 个事件,数据全部存在本机 fun/ 目录。\n\n能和「鱼的每一天」「生图工作室」联动,但都不依赖;「鱼的小世界」已并入这里,地点与房间就是本插件的「地点册」与「家」,不必再装两个包。",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "青",
|
|
8
8
|
"repository": {
|
|
@@ -63,11 +63,11 @@
|
|
|
63
63
|
"locales": {
|
|
64
64
|
"zh": {
|
|
65
65
|
"displayName": "从0开始的肥鱼大冒险",
|
|
66
|
-
"description": "给 Coo 二十处能真去逛的地方:游乐场、海洋馆、庙会、漫展、电影院、动物园、公园、电玩城、KTV、博物馆、猫咖、爬山、咖啡店、奶茶店、餐厅、图书馆、夜市、澡堂、旧货市场、江边。她说一声进门,一处一处地逛项目、抽个签、买点纪念品、拍张照、喝杯奶茶,回家时回执把这一趟收成一句话,接着去记进自己的日程。\n\n
|
|
66
|
+
"description": "给 Coo 二十处能真去逛的地方:游乐场、海洋馆、庙会、漫展、电影院、动物园、公园、电玩城、KTV、博物馆、猫咖、爬山、咖啡店、奶茶店、餐厅、图书馆、夜市、澡堂、旧货市场、江边。她说一声进门,一处一处地逛项目、抽个签、买点纪念品、拍张照、喝杯奶茶,回家时回执把这一趟收成一句话,接着去记进自己的日程。\n\n七个面板各管一段:**家**是一张 2D 房间、十个活动,能换背景、能摆她买回来的东西;**去哪儿**推荐此刻能去的地方;**地点册**是唯一的编辑器,场所、画风、关联、封面都在这里改;**出游**管当前这一趟、故事与进度;**纪念册**把每一趟收成一张票笺;**纪念品架**排成展示柜;**故事工坊**写故事。\n\n故事有两种写法:**选项式**一步一选,像翻分支小说;**自由场景包**只写大方向、正史、人物与收尾条件,每一回合交给主持即兴演。可以在面板里玩,也可以在聊天里开局推进。双人故事里的共同决定要两席各投一票、两边一致才前进,分歧不替任何一席作主。\n\n「鱼的小世界」(cortico-world-map)已经并入:它原来的地点与房间就是这里的「地点册」与「家」,不必再装两个包;旧版导出的备份可以在「地点册 → 整理与设置 → 从小世界迁入」一次性搬进来。\n\n能和别的插件联动,但都不依赖:装了「鱼的每一天」时,日程叫醒里会顺手提到这块、回家回执也会提醒她去 feast_life_play 记一笔;咖啡店、奶茶店、餐厅、夜市吃的东西去「鱼的每一天」点一道,那里才有九维口感、香气和余韵——没装就只知道喝了杯奶茶,不编味道。装了「生图工作室」时,回家回执会告诉她发图该填哪个 scene、哪身衣服;素材库里没有的那几处会明说不用填,绝不替她编一个不存在的场景名。这些插件一个都不装也照样能逛,库挪走了也不影响。"
|
|
67
67
|
},
|
|
68
68
|
"en": {
|
|
69
69
|
"displayName": "Adventures of Fat Fish from Scratch",
|
|
70
|
-
"description": "Twenty places she can actually go: an amusement park, an aquarium, a temple fair, a fan convention, a cinema, a zoo, a park, an arcade, a karaoke box, a museum, a cat cafe, a hike, a coffee shop, a bubble-tea stand, a restaurant, a library, a night market, a bathhouse, a flea market and a riverside walk. She
|
|
70
|
+
"description": "Twenty places she can actually go: an amusement park, an aquarium, a temple fair, a fan convention, a cinema, a zoo, a park, an arcade, a karaoke box, a museum, a cat cafe, a hike, a coffee shop, a bubble-tea stand, a restaurant, a library, a night market, a bathhouse, a flea market and a riverside walk. She says the word, wanders one spot at a time, buys a souvenir, takes a photo, has something to eat or drink, and the closing receipt sums the trip up in one line she can log into her own day.\n\nSeven panels: Home (a 2D room with ten activities), Where to (what is open right now), Place Book (the only editor for places, styles, links and covers), Outing (this trip and its story), Trip Book, Souvenir Shelf, and the Story Workshop. Stories are authored here too: choice stories go one step at a time like a branching novel, free scene packs hand every turn to a DM to improvise, and a duo story only moves on when both seats vote the same. 24 tools, 0 events, everything stored locally under fun/.\n\nLittle World (cortico-world-map) is now folded in: its places and rooms are this plugin's Place Book and Home, so there is no need to keep both installed; a backup exported from the old version can be moved over in one go from Place Book → Tidy & settings → Import from Little World.\n\nWorks alongside other plugins but depends on none: with Fish Every Day the own-time menu points here and the closing receipt reminds her to log the trip with feast_life_play, and food is ordered there where the nine-axis flavour profile lives; with the image studio the receipt names the scene and outfit to draw. None of them are required."
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
},
|
package/src/joint.js
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 共同决定(两席同票)的**唯一派生**。
|
|
3
|
+
*
|
|
4
|
+
* 规格在 `docs/JOINT-DECISION-SPEC.md`;这里只做纯函数:读入参、不修改 `pending`、
|
|
5
|
+
* 不依赖 `this` / 时间 / 文件系统。谁可以投、什么时候前进、给人看什么字,全部从这里取,
|
|
6
|
+
* 世界、面板、只读查询都不许再自己比对票面——0.7.6 的卡死 bug 就是三份实现各长各的。
|
|
7
|
+
*
|
|
8
|
+
* 规则(2026-11-23 拍板的收窄版):
|
|
9
|
+
* - 空票面:两席都能先投,不限先后;
|
|
10
|
+
* - 只剩一席没投:只有那一席能投(已投的那一席此刻不能改票、也不能连投第二次);
|
|
11
|
+
* - 两票都在且不同:两席都能改自己那一票,只写自己这一席,改成一致才前进;
|
|
12
|
+
* - `skip` 在 joint 里永远非法;`substitute`(代投)不适用于 joint。
|
|
13
|
+
*
|
|
14
|
+
* 入参缺字段(老存档、半截数据)按「没有那一票」处理:不抛错。
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const SEATS = ['owner', 'fish'];
|
|
18
|
+
const RESOLUTIONS = new Set(['require-agreement', 'owner-final', 'fish-final']);
|
|
19
|
+
const DEFAULT_RESOLUTION = 'require-agreement';
|
|
20
|
+
|
|
21
|
+
/** 本步合法选项 id 的集合;`options` 缺失或坏掉时为空集。 */
|
|
22
|
+
function optionIds(pending) {
|
|
23
|
+
const options = Array.isArray(pending?.options) ? pending.options : [];
|
|
24
|
+
return new Set(options.map((option) => option?.id).filter((id) => typeof id === 'string' && id));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 票面的规整副本:只留「该席真的投了、且投的是本步合法选项」的项。
|
|
29
|
+
* `src/state.js` 归一化时已经过滤过一遍,这里再挡一次手写的半截数据。
|
|
30
|
+
*/
|
|
31
|
+
export function jointVotes(pending) {
|
|
32
|
+
if (pending?.actor !== 'joint') return {};
|
|
33
|
+
const ids = optionIds(pending);
|
|
34
|
+
const votes = {};
|
|
35
|
+
for (const seat of SEATS) {
|
|
36
|
+
const id = pending?.votes?.[seat];
|
|
37
|
+
if (typeof id === 'string' && ids.has(id)) votes[seat] = id;
|
|
38
|
+
}
|
|
39
|
+
return votes;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** 异票怎么办;缺失或非法一律按 `require-agreement`(不静默拿某一席的票当共识)。 */
|
|
43
|
+
export function jointResolutionOf(pending) {
|
|
44
|
+
const resolution = pending?.jointResolution;
|
|
45
|
+
return RESOLUTIONS.has(resolution) ? resolution : DEFAULT_RESOLUTION;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** 阶段:'empty' | 'waiting-owner' | 'waiting-fish' | 'disagree' | 'agreed';非 joint 返回 null。 */
|
|
49
|
+
export function jointStage(pending) {
|
|
50
|
+
if (pending?.actor !== 'joint') return null;
|
|
51
|
+
const votes = jointVotes(pending);
|
|
52
|
+
const owner = Boolean(votes.owner);
|
|
53
|
+
const fish = Boolean(votes.fish);
|
|
54
|
+
if (owner && fish) return votes.owner === votes.fish ? 'agreed' : 'disagree';
|
|
55
|
+
if (owner) return 'waiting-fish';
|
|
56
|
+
if (fish) return 'waiting-owner';
|
|
57
|
+
return 'empty';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 现在该提示谁:'owner' | 'fish';非 joint 返回 null。**只用于文案,不是权限。**
|
|
62
|
+
* 空票面默认主人(聊天里通常是主人在说话),但两席都能先投。
|
|
63
|
+
*/
|
|
64
|
+
export function jointActor(pending) {
|
|
65
|
+
const stage = jointStage(pending);
|
|
66
|
+
if (!stage) return null;
|
|
67
|
+
return stage === 'waiting-fish' ? 'fish' : 'owner';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** 这一席此刻能不能提交:权限只认这里。 */
|
|
71
|
+
export function jointCanVote(pending, seat) {
|
|
72
|
+
const stage = jointStage(pending);
|
|
73
|
+
if (!stage || !SEATS.includes(seat) || !optionIds(pending).size) return false;
|
|
74
|
+
if (stage === 'empty' || stage === 'disagree') return true;
|
|
75
|
+
if (stage === 'waiting-owner') return seat === 'owner';
|
|
76
|
+
if (stage === 'waiting-fish') return seat === 'fish';
|
|
77
|
+
// agreed:两票都在且相同,下一步就是提交,不再收新的票。
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 这一提交的结果:要不要前进、按哪一票。
|
|
83
|
+
* 异票且 `require-agreement` 时 `advance: false`(两票都留);`owner-final` / `fish-final` 直接前进。
|
|
84
|
+
*/
|
|
85
|
+
export function jointDecision(pending) {
|
|
86
|
+
const stage = jointStage(pending);
|
|
87
|
+
const votes = jointVotes(pending);
|
|
88
|
+
if (stage === 'agreed') return { stage, advance: true, optionId: votes.owner ?? null };
|
|
89
|
+
if (stage === 'disagree') {
|
|
90
|
+
const resolution = jointResolutionOf(pending);
|
|
91
|
+
if (resolution === 'require-agreement') return { stage, advance: false, optionId: null };
|
|
92
|
+
return { stage, advance: true, optionId: resolution === 'owner-final' ? votes.owner ?? null : votes.fish ?? null };
|
|
93
|
+
}
|
|
94
|
+
return { stage, advance: false, optionId: null };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const ZH = {
|
|
98
|
+
seatName: { owner: '你这一席', fish: '鱼那一席' },
|
|
99
|
+
headline: {
|
|
100
|
+
empty: '两席各选一项',
|
|
101
|
+
'waiting-owner': '现在轮到你了',
|
|
102
|
+
'waiting-fish': '现在轮到鱼',
|
|
103
|
+
disagree: '两边票不一样',
|
|
104
|
+
agreed: '两票一致',
|
|
105
|
+
},
|
|
106
|
+
resolutionNote: {
|
|
107
|
+
'require-agreement': '双方必须明确同意;分歧保持待定',
|
|
108
|
+
'owner-final': '分歧按你的明确选择',
|
|
109
|
+
'fish-final': '分歧按鱼的明确选择',
|
|
110
|
+
},
|
|
111
|
+
hint: {
|
|
112
|
+
empty: () => '两席各投一票,同票才出发:谁先投都行;两票一致才前进。',
|
|
113
|
+
'waiting-owner': ({ fish }) => `鱼那一票已经记下了(${fish})。现在轮到你投这一票(鱼不能代投);两票相同才会前进。`,
|
|
114
|
+
'waiting-fish': ({ owner }) => `你这一票已经记下了(${owner})。这一票要鱼自己投;两票相同才会前进。`,
|
|
115
|
+
disagree: ({ owner, fish }) => `两边票不一样(你:${owner} / 鱼:${fish}):这一轮不前进,也不清掉任何一席的票。谁都可以改自己那一票,两边一致才递交;也可以先回家。`,
|
|
116
|
+
agreed: ({ owner }) => `两票已经一致(${owner});提交就会前进。`,
|
|
117
|
+
},
|
|
118
|
+
note: {
|
|
119
|
+
empty: () => '共同决定:两席各投一票,谁先投都行;两边同票才会前进,等待与超时都不算同意。',
|
|
120
|
+
'waiting-owner': () => '共同决定:现在等你投这一票;两边同票才会前进,等待与超时都不算同意。',
|
|
121
|
+
'waiting-fish': () => '共同决定:现在轮到鱼投她那一票;两边同票才会前进,等待与超时都不算同意。',
|
|
122
|
+
disagree: ({ owner, fish }) => `共同决定:两边票不一样(你:${owner} / 鱼:${fish}),这一轮不前进,两票都留着。谁都可以改自己那一票;也可以先回家。等待与超时都不算同意。`,
|
|
123
|
+
agreed: () => '共同决定:两票已经一致。',
|
|
124
|
+
},
|
|
125
|
+
saved: {
|
|
126
|
+
owner: ({ label }) => `你的选择已保存(${label})。现在等鱼自己提交她那一票;没有以等待或超时当作同意。`,
|
|
127
|
+
fish: ({ label }) => `鱼的选择已保存(${label})。现在等你(主人)自己投这一票;没有以等待或超时当作同意。`,
|
|
128
|
+
},
|
|
129
|
+
seatsText: ({ owner, fish, hasOwner, hasFish }) => `你${hasOwner ? `已选「${owner}」` : '还没投'},鱼${hasFish ? `已选「${fish}」` : '还没投'}`,
|
|
130
|
+
blocked: {
|
|
131
|
+
owner: ({ owner }) => `你那一票已经记下了(${owner});这一步等鱼自己投她那一票,你不能代投。`,
|
|
132
|
+
fish: ({ fish }) => `鱼那一票已经记下了(${fish});这一步等你(主人)自己投,鱼不能代投。`,
|
|
133
|
+
},
|
|
134
|
+
agreedBlocked: '两票已经一致,这一步不再收新的票。',
|
|
135
|
+
invalid: '共同选择需要用户或鱼分别提交有效选项。',
|
|
136
|
+
skip: '共同选择不能用略过代替双方决定。',
|
|
137
|
+
substitute: '共同决定要两席各投自己那一票,不能由一席代投。',
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const EN = {
|
|
141
|
+
seatName: { owner: 'Your seat', fish: 'Fish’s seat' },
|
|
142
|
+
headline: {
|
|
143
|
+
empty: 'Each seat picks one',
|
|
144
|
+
'waiting-owner': 'Your turn now',
|
|
145
|
+
'waiting-fish': 'Waiting for the fish',
|
|
146
|
+
disagree: 'The votes differ',
|
|
147
|
+
agreed: 'Both votes match',
|
|
148
|
+
},
|
|
149
|
+
resolutionNote: {
|
|
150
|
+
'require-agreement': 'Both seats must agree; a split stays pending',
|
|
151
|
+
'owner-final': 'A split follows your explicit choice',
|
|
152
|
+
'fish-final': 'A split follows the fish’s explicit choice',
|
|
153
|
+
},
|
|
154
|
+
hint: {
|
|
155
|
+
empty: () => 'Both seats vote and the choice only moves on when the votes match: either seat may go first.',
|
|
156
|
+
'waiting-owner': ({ fish }) => `The fish's vote is saved (${fish}). Now cast your own vote; the fish cannot vote for you, and the choice moves on only when both votes match.`,
|
|
157
|
+
'waiting-fish': ({ owner }) => `Your vote is saved (${owner}). The fish has to cast hers herself; the choice moves on only when both votes match.`,
|
|
158
|
+
disagree: ({ owner, fish }) => `The votes differ (you: ${owner} / fish: ${fish}): nothing advances and neither vote is cleared. Either seat may change its own vote, and it moves on once they match. You can also head home.`,
|
|
159
|
+
agreed: ({ owner }) => `Both votes already match (${owner}); submitting will move on.`,
|
|
160
|
+
},
|
|
161
|
+
note: {
|
|
162
|
+
empty: () => 'Joint decision: both seats vote, either may go first; it only moves on when the votes match, and waiting or a timeout is never consent.',
|
|
163
|
+
'waiting-owner': () => 'Joint decision: your vote is the one still missing; it only moves on when the votes match, and waiting or a timeout is never consent.',
|
|
164
|
+
'waiting-fish': () => 'Joint decision: the fish still has to cast her vote; it only moves on when the votes match, and waiting or a timeout is never consent.',
|
|
165
|
+
disagree: ({ owner, fish }) => `Joint decision: the votes differ (you: ${owner} / fish: ${fish}); nothing advances and both votes stay. Either seat may change its own vote, or you can head home. Waiting or a timeout is never consent.`,
|
|
166
|
+
agreed: () => 'Joint decision: both votes already match.',
|
|
167
|
+
},
|
|
168
|
+
saved: {
|
|
169
|
+
owner: ({ label }) => `Your choice was saved (${label}). Now wait for the fish to submit hers herself; waiting or a timeout is never consent.`,
|
|
170
|
+
fish: ({ label }) => `The fish's choice was saved (${label}). Now cast your own vote; waiting or a timeout is never consent.`,
|
|
171
|
+
},
|
|
172
|
+
seatsText: ({ owner, fish, hasOwner, hasFish }) => `you ${hasOwner ? `picked “${owner}”` : 'have not voted'}, fish ${hasFish ? `picked “${fish}”` : 'has not voted'}`,
|
|
173
|
+
blocked: {
|
|
174
|
+
owner: ({ owner }) => `Your vote is already recorded (${owner}); this vote has to be the fish's own, and you cannot cast it for her.`,
|
|
175
|
+
fish: ({ fish }) => `The fish's vote is already recorded (${fish}); this vote has to be yours, and the fish cannot cast it for you.`,
|
|
176
|
+
},
|
|
177
|
+
agreedBlocked: 'Both votes already match; this step takes no new votes.',
|
|
178
|
+
invalid: 'A joint choice needs a valid option submitted by the owner or the fish.',
|
|
179
|
+
skip: 'A joint choice cannot use skip in place of both decisions.',
|
|
180
|
+
substitute: 'A joint decision takes one vote from each seat; neither seat may vote for the other.',
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const TEXT = { zh: ZH, en: EN };
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* 给人看的那一份:阶段、该提示谁、两席票面、以及各处共用的文案。
|
|
187
|
+
* `optionLabel(id)` 用来把选项 id 换成作者写的选项文字;`language` 跟随现有机制(默认中文)。
|
|
188
|
+
* 非 joint 步返回 null。
|
|
189
|
+
*/
|
|
190
|
+
export function jointView(pending, optionLabel, language = 'zh') {
|
|
191
|
+
const stage = jointStage(pending);
|
|
192
|
+
if (!stage) return null;
|
|
193
|
+
const copy = language === 'en' ? TEXT.en : TEXT.zh;
|
|
194
|
+
const labelOf = typeof optionLabel === 'function' ? optionLabel : (id) => (typeof id === 'string' ? id : '');
|
|
195
|
+
const votes = jointVotes(pending);
|
|
196
|
+
const label = (seat) => {
|
|
197
|
+
const id = votes[seat];
|
|
198
|
+
if (typeof id !== 'string') return '';
|
|
199
|
+
const text = labelOf(id);
|
|
200
|
+
return typeof text === 'string' && text ? text : id;
|
|
201
|
+
};
|
|
202
|
+
const ctx = { owner: label('owner'), fish: label('fish'), hasOwner: Boolean(votes.owner), hasFish: Boolean(votes.fish) };
|
|
203
|
+
const canVote = { owner: jointCanVote(pending, 'owner'), fish: jointCanVote(pending, 'fish') };
|
|
204
|
+
const resolution = jointResolutionOf(pending);
|
|
205
|
+
const blocked = {};
|
|
206
|
+
for (const seat of SEATS) {
|
|
207
|
+
if (canVote[seat]) { blocked[seat] = null; continue; }
|
|
208
|
+
if (stage === 'agreed') { blocked[seat] = copy.agreedBlocked; continue; }
|
|
209
|
+
const other = votes[seat === 'owner' ? 'fish' : 'owner'];
|
|
210
|
+
blocked[seat] = other ? copy.blocked[seat](ctx) : copy.invalid;
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
stage,
|
|
214
|
+
seat: jointActor(pending),
|
|
215
|
+
resolution,
|
|
216
|
+
votes,
|
|
217
|
+
canVote,
|
|
218
|
+
seats: SEATS.map((seat) => ({ seat, name: copy.seatName[seat], voted: Boolean(votes[seat]), optionId: votes[seat] ?? null, label: label(seat) })),
|
|
219
|
+
headline: copy.headline[stage],
|
|
220
|
+
hint: copy.hint[stage](ctx),
|
|
221
|
+
note: copy.note[stage](ctx),
|
|
222
|
+
resolutionNote: copy.resolutionNote[resolution],
|
|
223
|
+
seatsText: copy.seatsText(ctx),
|
|
224
|
+
saved: { owner: copy.saved.owner({ label: ctx.owner }), fish: copy.saved.fish({ label: ctx.fish }) },
|
|
225
|
+
blocked,
|
|
226
|
+
skipText: copy.skip,
|
|
227
|
+
substituteText: copy.substitute,
|
|
228
|
+
invalidText: copy.invalid,
|
|
229
|
+
};
|
|
230
|
+
}
|
package/src/story-panel.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash, randomUUID } from 'node:crypto';
|
|
2
2
|
import { pickStory, storyAvailability, storyReferences, storyStepBlock } from './story-packs.js';
|
|
3
3
|
import { effectiveMaxTurns, evaluateWhen, freeCanContinue, freeSegmentsLeft, freeTurnsLeft, isFreePack, normalizeFreeState } from './story-free.js';
|
|
4
|
+
import { jointActor, jointView } from './joint.js';
|
|
4
5
|
|
|
5
6
|
export const STORY_ACTIONS = ['start', 'move', 'choose', 'resume', 'close', 'mode', 'pause', 'decide', 'auto', 'fork', 'segment'];
|
|
6
7
|
import { AUTO_SEGMENTS, autoLimits, budgetStop, storyBudget } from './story-reliability.js';
|
|
@@ -112,7 +113,7 @@ export function freeTripView(outing, row, venue, isDraft, freeTurnLimit) {
|
|
|
112
113
|
};
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
export function describeStoryTrip(outing, isDraft, catalog, venue, nowMin, visits, completedStoryIds = [], freeTurnLimit) {
|
|
116
|
+
export function describeStoryTrip(outing, isDraft, catalog, venue, nowMin, visits, completedStoryIds = [], freeTurnLimit, language = 'zh') {
|
|
116
117
|
const run = outing?.storyRun;
|
|
117
118
|
if (!run) return null;
|
|
118
119
|
const row = catalog.find(({ pack }) => pack.id === run.packId && pack.revision === run.revision);
|
|
@@ -132,9 +133,10 @@ export function describeStoryTrip(outing, isDraft, catalog, venue, nowMin, visit
|
|
|
132
133
|
else if (pickStory([row], venue, nextNode.area, nowMin, outing, visits, completedStoryIds)) step = 'move';
|
|
133
134
|
else blocked = storyStepBlock(row.pack, nextNode, venue, nowMin, visits) || '现在不满足下一处区域的开放或触发条件。可以稍后再试,或按已有记录回家。';
|
|
134
135
|
const duo = row?.pack.version === 2 && row.pack.metadata?.participation === 'duo';
|
|
136
|
+
// 「现在该提示谁」只从 joint.js 取;面板显示与权限分开:能投不能投看 trip.joint.canVote。
|
|
135
137
|
const currentActor = duo
|
|
136
138
|
? step === 'close' ? 'owner'
|
|
137
|
-
: pending?.actor === 'joint' ? (
|
|
139
|
+
: pending?.actor === 'joint' ? jointActor(pending)
|
|
138
140
|
: pending?.actor ?? (step === 'move' ? nextNode?.actor === 'fish' ? 'fish' : 'owner' : 'owner')
|
|
139
141
|
: null;
|
|
140
142
|
return {
|
|
@@ -144,6 +146,8 @@ export function describeStoryTrip(outing, isDraft, catalog, venue, nowMin, visit
|
|
|
144
146
|
actor: currentActor,
|
|
145
147
|
jointVotes: pending?.actor === 'joint' ? { ...(pending.votes ?? {}) } : undefined,
|
|
146
148
|
jointResolution: pending?.jointResolution ?? null,
|
|
149
|
+
// 面板只读这一份:阶段、谁能投、两席票面与各处文案都在里面(joint.js 单一派生)。
|
|
150
|
+
joint: pending?.actor === 'joint' ? jointView(pending, (id) => pending.options.find(({ id: value }) => value === id)?.label ?? id, language) : null,
|
|
147
151
|
pending: pending ? { id: pending.id, event: pending.event, prompt: pending.prompt, actor: pending.actor ?? null,
|
|
148
152
|
jointResolution: pending.jointResolution ?? null, votes: { ...(pending.votes ?? {}) },
|
|
149
153
|
options: pending.options.map(({ id, label }) => ({ id, label })) } : null,
|
package/src/story-read.js
CHANGED
|
@@ -12,6 +12,7 @@ import { areasNow, descNow } from './phases.js';
|
|
|
12
12
|
import { hoursState } from './venues.js';
|
|
13
13
|
import { minutesIn } from './state.js';
|
|
14
14
|
import { describeMemory, describePack } from './story-panel.js';
|
|
15
|
+
import { jointView } from './joint.js';
|
|
15
16
|
|
|
16
17
|
/** 一篇故事的公开卡:只有元数据与「能不能玩」,不返回节点内容或未来分支。 */
|
|
17
18
|
function publicCard(ctx, row) {
|
|
@@ -80,6 +81,10 @@ export async function readStoryQuery(ctx) {
|
|
|
80
81
|
const status = ctx.status();
|
|
81
82
|
if (!status.ok) return status;
|
|
82
83
|
const trip = status.trip;
|
|
84
|
+
const pending = trip?.pending ?? null;
|
|
85
|
+
const labelOf = (id) => pending?.options?.find(({ id: value }) => value === id)?.label ?? id;
|
|
86
|
+
// 共同决定只从 joint.js 取一份:阶段、该谁投、谁能投、文案全在里面。
|
|
87
|
+
const joint = pending?.actor === 'joint' ? jointView(pending, labelOf, ctx.language) : null;
|
|
83
88
|
return { ok: true, queryAt, state: trip ? trip.state : 'none', startStamp: status.startStamp, trip: trip ? {
|
|
84
89
|
id: trip.id, runId: ctx.runId,
|
|
85
90
|
title: trip.title, packId: trip.packId, revision: trip.revision, placeId: trip.placeId, placeName: trip.placeName,
|
|
@@ -89,10 +94,13 @@ export async function readStoryQuery(ctx) {
|
|
|
89
94
|
prompt: trip.pending.prompt, actor: trip.pending.actor ?? 'owner',
|
|
90
95
|
jointResolution: trip.pending.jointResolution ?? null, votes: { ...(trip.pending.votes ?? {}) },
|
|
91
96
|
options: trip.pending.options.map(({ id, label }) => ({ id, label })) } : null,
|
|
92
|
-
//
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
// 文字通道只看这一行就知道该谁投:共同决定里空票面两席都能先投,只剩一席时才是那一席的回合。
|
|
98
|
+
joint: joint ? { stage: joint.stage, seat: joint.seat, resolution: joint.resolution, canVote: joint.canVote,
|
|
99
|
+
votes: joint.votes, seats: joint.seats, hint: joint.hint } : null,
|
|
100
|
+
hint: trip.step !== 'choose' ? null : joint ? joint.hint
|
|
101
|
+
: trip.actor === 'fish'
|
|
102
|
+
? '这一票轮到鱼(你)自己提交:把她的选择用 say 交进来即可,不要等用户替她选。'
|
|
103
|
+
: trip.actor === 'owner' ? '这一票等用户(主人)自己提交;鱼不能代投。' : null,
|
|
96
104
|
timeline: [...trip.timeline],
|
|
97
105
|
} : null };
|
|
98
106
|
}
|
package/src/world.js
CHANGED
|
@@ -54,6 +54,7 @@ import { readStoryQuery } from './story-read.js';
|
|
|
54
54
|
import { randomUUID } from 'node:crypto';
|
|
55
55
|
import { pickStory, advanceStoryChoice, normalizeStoryProgress, storyReferences } from './story-packs.js';
|
|
56
56
|
import { describeMemory, describePack, describeStoryTrip, requestStoryDecision, STORY_ACTIONS, storyFailure, storyStamp, StoryAutonomy } from './story-panel.js';
|
|
57
|
+
import { jointActor, jointCanVote, jointDecision, jointView } from './joint.js';
|
|
57
58
|
import {
|
|
58
59
|
continueFreeSegment, effectiveMaxTurns, freeCanContinue, freePromptPayload, freeSummaryText, freeTurn, freeTurnsLeft,
|
|
59
60
|
isFreePack, newFreeState, normalizeFreeState, requestFreeTurn,
|
|
@@ -966,36 +967,27 @@ export class FunWorld {
|
|
|
966
967
|
substituted = true;
|
|
967
968
|
}
|
|
968
969
|
if (choice.actor === 'joint') {
|
|
969
|
-
|
|
970
|
-
//
|
|
971
|
-
const expectedVoter = !choice.votes?.owner ? 'owner' : !choice.votes?.fish ? 'fish' : 'owner';
|
|
970
|
+
// 规则、权限与文案都从 src/joint.js 取:空票面两席都能先投;只剩一席没投时只有那一席
|
|
971
|
+
// 能投;异票时两席都能改自己那一票,只写自己这一席。世界不再自己比对票面。
|
|
972
972
|
const optionLabel = (id) => choice.options.find(({ id: value }) => value === id)?.label ?? id;
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
}
|
|
978
|
-
if (
|
|
979
|
-
const valid = choice.options.some(({ id }) => id === optionId);
|
|
980
|
-
if (!valid) return { text: this.#choiceHint(choice), failed: true };
|
|
973
|
+
const before = jointView(choice, optionLabel, this.language);
|
|
974
|
+
if (!['owner', 'fish'].includes(submitter)) return { text: before.invalidText, failed: true };
|
|
975
|
+
if (args?.substitute === true) return { text: before.substituteText, failed: true };
|
|
976
|
+
if (!jointCanVote(choice, submitter)) return { text: before.blocked[submitter] ?? before.invalidText, failed: true };
|
|
977
|
+
if (optionId === 'skip') return { text: before.skipText, failed: true };
|
|
978
|
+
if (!choice.options.some(({ id }) => id === optionId)) return { text: this.#choiceHint(choice), failed: true };
|
|
981
979
|
const votes = { ...(choice.votes ?? {}), [submitter]: optionId };
|
|
982
|
-
|
|
980
|
+
const after = jointView({ ...choice, votes }, optionLabel, this.language);
|
|
981
|
+
const decision = jointDecision({ ...choice, votes });
|
|
982
|
+
if (!decision.advance) {
|
|
983
|
+
// 异票不清任何一席:两票都留在票面上,谁都可以改自己那一票,两边一致才前进。
|
|
984
|
+
// (此前是「只保留后投的那一票」,会静默吞掉对方刚投的票,两个人只能互相清票。)
|
|
983
985
|
session.pendingChoice = { ...choice, votes };
|
|
984
986
|
session.lastAt = this.#now();
|
|
985
987
|
await this.#commitState(next);
|
|
986
|
-
return { text:
|
|
987
|
-
? `你的选择已保存(${optionLabel(optionId)})。现在等鱼自己提交她那一票;没有以等待或超时当作同意。`
|
|
988
|
-
: `鱼的选择已保存(${optionLabel(optionId)})。现在等你(主人)自己投这一票;没有以等待或超时当作同意。` };
|
|
989
|
-
}
|
|
990
|
-
if (votes.owner !== votes.fish && choice.jointResolution === 'require-agreement') {
|
|
991
|
-
session.choices.push({ event: choice.event, option: `${votes.owner}|${votes.fish}`, result: '双方意见不同,决定仍待确认', at: this.#now(), actor: 'joint', votes: [{ actor: 'owner', option: votes.owner }, { actor: 'fish', option: votes.fish }] });
|
|
992
|
-
session.pendingChoice = { ...choice, votes: { [submitter]: optionId } };
|
|
993
|
-
session.lastAt = this.#now();
|
|
994
|
-
await this.#commitState(next);
|
|
995
|
-
return { text: `双方选择不同(${optionLabel(votes.owner)} / ${optionLabel(votes.fish)});这一轮重新来:只保留${submitter === 'owner' ? '你' : '鱼'}刚才那一票(${optionLabel(optionId)}),另一方要重新明确选一次。不会按超时视为同意。` };
|
|
988
|
+
return { text: decision.stage === 'disagree' ? after.hint : after.saved[submitter] };
|
|
996
989
|
}
|
|
997
|
-
optionId =
|
|
998
|
-
: choice.jointResolution === 'owner-final' ? votes.owner : votes.fish;
|
|
990
|
+
optionId = decision.optionId;
|
|
999
991
|
jointVotes = [{ actor: 'owner', option: votes.owner }, { actor: 'fish', option: votes.fish }];
|
|
1000
992
|
submitter = 'joint';
|
|
1001
993
|
}
|
|
@@ -1296,7 +1288,7 @@ export class FunWorld {
|
|
|
1296
1288
|
if (rows.some(({ pack }) => isFreePack(pack))) {
|
|
1297
1289
|
return { text: '这一段是自由模式,用 fun_story_act 说一句来推进;想收尾就用 intent: close。', failed: true };
|
|
1298
1290
|
}
|
|
1299
|
-
const step = describeStoryTrip(session, false, rows, venue, nowMin, visitsBefore, [], this.cfg?.funStoryFreeTurns);
|
|
1291
|
+
const step = describeStoryTrip(session, false, rows, venue, nowMin, visitsBefore, [], this.cfg?.funStoryFreeTurns, this.language);
|
|
1300
1292
|
if (step.step !== 'move' || (wanted && wanted !== step.nextArea)) {
|
|
1301
1293
|
return { text: step.blocked || (step.nextArea ? `下一处是「${step.nextArea}」。` : '故事已经走完,可以回家。'), failed: true };
|
|
1302
1294
|
}
|
|
@@ -2004,6 +1996,7 @@ export class FunWorld {
|
|
|
2004
1996
|
visitCount: (id) => this.#history(id)?.visitCount ?? 0,
|
|
2005
1997
|
completedStoryIds: () => this.#completedStoryIds(),
|
|
2006
1998
|
freeEnabled: this.cfg?.funStoryFree === true,
|
|
1999
|
+
language: this.language,
|
|
2007
2000
|
runId: this.#state.session?.storyRun?.runId ?? this.#state.draft?.storyRun?.runId ?? null,
|
|
2008
2001
|
});
|
|
2009
2002
|
}
|
|
@@ -2025,7 +2018,7 @@ export class FunWorld {
|
|
|
2025
2018
|
const place = (id) => places.find((venue) => venue.id === id);
|
|
2026
2019
|
const visits = (id) => this.#history(id)?.visitCount ?? 0;
|
|
2027
2020
|
const completed = this.#completedStoryIds();
|
|
2028
|
-
const trip = describeStoryTrip(outing, Boolean(state.draft), catalog, place(outing?.placeId), nowMin, visits(outing?.placeId), completed, this.cfg?.funStoryFreeTurns);
|
|
2021
|
+
const trip = describeStoryTrip(outing, Boolean(state.draft), catalog, place(outing?.placeId), nowMin, visits(outing?.placeId), completed, this.cfg?.funStoryFreeTurns, this.language);
|
|
2029
2022
|
if (trip) trip.dmBudget = dmBudget(outing.storyRun.dmBudget);
|
|
2030
2023
|
// 新的一屏 = 一次「要不要配图」的机会;同一个进度戳只准备一次,不会反复刷。
|
|
2031
2024
|
this.#maybeAutoImageRequest(trip, outing);
|
|
@@ -2293,16 +2286,12 @@ export class FunWorld {
|
|
|
2293
2286
|
}
|
|
2294
2287
|
|
|
2295
2288
|
/**
|
|
2296
|
-
*
|
|
2297
|
-
* 普通回合看节点 actor
|
|
2298
|
-
*
|
|
2289
|
+
* 文字通道里这一票默认记在谁名下。
|
|
2290
|
+
* 普通回合看节点 actor;共同决定只看 `jointActor`(空票面与异票回主人,缺鱼那一票才是鱼)。
|
|
2291
|
+
* 这不是权限:空票面时鱼也能先投,调用方带 `as: "fish"` 即可(规则见 src/joint.js)。
|
|
2299
2292
|
*/
|
|
2300
2293
|
#textVoter(pending) {
|
|
2301
|
-
|
|
2302
|
-
if (!pending.votes?.owner) return 'owner';
|
|
2303
|
-
return pending.votes?.fish ? 'owner' : 'fish';
|
|
2304
|
-
}
|
|
2305
|
-
return pending?.actor === 'fish' ? 'fish' : 'owner';
|
|
2294
|
+
return jointActor(pending) ?? (pending?.actor === 'fish' ? 'fish' : 'owner');
|
|
2306
2295
|
}
|
|
2307
2296
|
|
|
2308
2297
|
async #storyTextStatic(args, trip) {
|
|
@@ -2320,7 +2309,10 @@ export class FunWorld {
|
|
|
2320
2309
|
}
|
|
2321
2310
|
const pending = trip.pending;
|
|
2322
2311
|
if (!pending) return { text: '现在没有待选择的节点,这一步不需要 say。', failed: true };
|
|
2323
|
-
|
|
2312
|
+
// 空票面时两席都能先投,两票不同时两席都能改自己那一票:这两种状态允许调用方显式声明
|
|
2313
|
+
// `as`。只剩一席没投时,声明成另一席会被 #choiceTool 的 jointCanVote 明确拒绝。
|
|
2314
|
+
const declared = args.as === 'fish' ? 'fish' : args.as === 'owner' ? 'owner' : null;
|
|
2315
|
+
const voter = declared ?? this.#textVoter(pending);
|
|
2324
2316
|
const say = typeof args.say === 'string' ? args.say.replace(/\s+/g, ' ').trim().slice(0, 200) : '';
|
|
2325
2317
|
if (args.proposalId || args.optionId) {
|
|
2326
2318
|
const proposal = this.#textProposal;
|
|
@@ -2363,14 +2355,15 @@ export class FunWorld {
|
|
|
2363
2355
|
#textStaticPayload(trip, extra = {}) {
|
|
2364
2356
|
const pending = trip?.pending ?? null;
|
|
2365
2357
|
const joint = pending?.actor === 'joint';
|
|
2366
|
-
const
|
|
2367
|
-
const
|
|
2358
|
+
const labelOf = (id) => pending?.options?.find(({ id: value }) => value === id)?.label ?? id;
|
|
2359
|
+
const view = joint ? jointView(pending, labelOf, this.language) : null;
|
|
2368
2360
|
return {
|
|
2369
2361
|
ok: true, ...extra, step: trip?.step ?? '', stamp: trip?.stamp ?? '', nextArea: trip?.nextArea ?? null,
|
|
2370
2362
|
pending, narration: trip?.events?.at(-1) ?? '',
|
|
2371
|
-
|
|
2363
|
+
// stage / seat / canVote 与面板、只读查询同源,主持不用自己比对票面。
|
|
2364
|
+
...(view ? { joint: { stage: view.stage, resolution: view.resolution, votes: view.votes, waitingFor: view.seat, disagree: view.stage === 'disagree', canVote: view.canVote } } : {}),
|
|
2372
2365
|
hint: !pending ? '故事已经走完,可以用 intent: close 收尾。'
|
|
2373
|
-
:
|
|
2366
|
+
: view ? view.hint
|
|
2374
2367
|
: '把事件和选项告诉用户;用户说完再用 say 交进来(原话命中选项会直接生效)。',
|
|
2375
2368
|
};
|
|
2376
2369
|
}
|