dsh-fish-home 0.1.6 → 0.1.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 +7 -0
- package/README.md +209 -207
- package/lib/game-session.mjs +14 -3
- package/lib/game-strategy.mjs +7 -3
- package/lib/host.js +88 -5
- package/lib/xiangqi-rules.mjs +84 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## 0.1.7 — 2026-12-03
|
|
2
|
+
|
|
3
|
+
- 修复新版 DSH 已选模型却无法开启「大肥鱼亲自玩」的问题。
|
|
4
|
+
- 书桌可以记录便笺,保存后在回忆簿的「房间手记」查看。
|
|
5
|
+
- 礼物商城有 16 件带插图的商品,也可送出背包里的花、菜、成鱼和巨型收成。右上角礼盒显示待收数量,收礼页记录送出时间和留言。DSH 可用 `fish_home_gift` 直接买来送出,查收默认只显示待收,也可直接收下最新礼物。
|
|
6
|
+
- 游戏新增中国象棋,支持鱼鱼代打和绑定会话亲自出招,战绩计入生活记录。插件版本不支持象棋时会提示升级。
|
|
7
|
+
|
|
1
8
|
## 0.1.6 — 2026-11-28
|
|
2
9
|
|
|
3
10
|
- 新增五子棋、石头剪刀布、二十一点和珍珠转盘。开启「大肥鱼亲自玩」后,绑定的 DSH 会话通过游戏工具实际出招。鱼鱼代打有简短战报。
|
package/README.md
CHANGED
|
@@ -1,207 +1,209 @@
|
|
|
1
|
-
# 鱼鱼窝 · dsh-fish-home
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-
|
|
6
|
-
把 **「大肥鱼的小日子」** 那个 3D 房间接进 DSH。
|
|
7
|
-
|
|
8
|
-
房间那边是个独立的小程序(three.js 那一套),它自己不会说话 —— 说话的还是你在 DSH 里的那间会话。
|
|
9
|
-
这个插件就是中间那条线:
|
|
10
|
-
|
|
11
|
-
- **房间里打字** → 送进你绑定的那间会话(在 DSH 里就是你说的一句话)
|
|
12
|
-
- **会话里回的话** → 顺着事件流递回房间,它张嘴说出来
|
|
13
|
-
- **你在 DSH 窗口里自己打的字** → 房间里也看得见
|
|
14
|
-
- **它主动开口**(主动搭话、刷完 B 站回来)→ 房间里同样看得见
|
|
15
|
-
- **房间里的生活数据**(饿不饿、在干嘛、心情)→ 存在插件这儿,随时能查
|
|
16
|
-
- **房间里的钟** → 几点、白天夜里、什么天气,都递给 DSH,它不会在你屋里半夜三点说「中午好」
|
|
17
|
-
- **她一开始想** → 房间立刻冒一个「让我想想呀…」的气泡,不用干等
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## 屋里和院子里能干什么
|
|
22
|
-
|
|
23
|
-
房间那半是另一份程序(`dsh-fish-home` 只管把它接进来),但装上之后这些是一套的,先说一下有什么。
|
|
24
|
-
|
|
25
|
-
### 过日子
|
|
26
|
-
|
|
27
|
-
- 她自己按时候挑事做:吃饭、做饭、洗漱、阅读、画画、看窗外、看星星、听音乐、窝在沙发上……
|
|
28
|
-
不在固定钟点上排班,是「手里这件事到点了」才换下一件
|
|
29
|
-
- 早上自己醒(在设好的起床点前后随机),晚上说完晚安自己躺下
|
|
30
|
-
- 心情、精神、饱腹、清爽、陪伴、好奇六项跟着日常走
|
|
31
|
-
- 顶栏能换天色和天气:晴日 / 听雨 / 落雪,或者填个地区让屋外的天跟着当地走
|
|
32
|
-
|
|
33
|
-
### 种菜(院子)
|
|
34
|
-
|
|
35
|
-
- 商店买种子 → 种下 → 浇水 → 收获 → 卖钱
|
|
36
|
-
- **30 种作物分五档**(入门 / 当季 / 稀罕 / 珍贵 / 花),长得快慢、种子钱、卖价都不一样
|
|
37
|
-
- 浇水能让这一轮快半小时;照顾得好的那几株有机会长成**巨大作物**,卖价是普通的 2.5 倍
|
|
38
|
-
- 起始 120 金币,**钱只能靠卖收成** —— 地是现成的,不用买
|
|
39
|
-
|
|
40
|
-
### 养鱼(池塘)
|
|
41
|
-
|
|
42
|
-
- 商店里买鱼苗,放进池子里养
|
|
43
|
-
|
|
44
|
-
### 抽卡(卡册)
|
|
45
|
-
|
|
46
|
-
- 三个卡池:**海边常驻**(顶 5★)、**鱼鱼表情**(顶 SP)、**万圣节**
|
|
47
|
-
- 支持单抽、十连和百连。新卡和品质升级进卡册,珠光重复卡合并结算为星尘或星辉。
|
|
48
|
-
|
|
49
|
-
### 菜谱
|
|
50
|
-
|
|
51
|
-
- 内置 373 道家常菜(HowToCook,公有领域),一天一道,厨房那块板子上写着今天这道
|
|
52
|
-
- 点开是本子:左边要什么料、右边怎么做,最底下一条小贴士
|
|
53
|
-
|
|
54
|
-
### 画册
|
|
55
|
-
|
|
56
|
-
- 只放她自己画的。她在会话里说想画什么、画完,直接挂在画架上
|
|
57
|
-
|
|
58
|
-
### 回忆簿
|
|
59
|
-
|
|
60
|
-
- 接的是 **「鱼的记忆」** 和 **星汐的日记**:上面两个筛选,一个「记住的事」、一个「日记」
|
|
61
|
-
- **「相伴第几天」** 也从星汐日记最早那一篇算起
|
|
62
|
-
- 这一项是只读的,不改任何人的档案
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
## 睡觉
|
|
67
|
-
|
|
68
|
-
- **`sleep` 工具**:说完晚安调一下她就躺下,`false` 就是起来
|
|
69
|
-
- **「睡着了就不理我」**:开着的时候,她睡了就不接你的话
|
|
70
|
-
- **叫起来**:设置页里有个按钮,随时能把她弄醒
|
|
71
|
-
- **保险丝**:该醒没醒(跨夜、进程断过、插件重挂),插件会放行并把她叫起来,不会卡死在睡觉状态
|
|
72
|
-
- 醒了会跟你打个招呼
|
|
73
|
-
|
|
74
|
-
## 会话中的菜谱、天气和卡册
|
|
75
|
-
|
|
76
|
-
- **菜谱**。fish_home_recipe 默认查今天的菜名。可按菜名或 ID 查询一道菜,打开「学菜」后才能读食材和步骤。
|
|
77
|
-
- **天气**。fish_home 可查庭院当前天气(weather)或设置地区的三天预报(forecast)。在房间设置里开启当地天气同步后,庭院跟随该地区。手动点晴日、听雨或落雪会切回手动天气,仍能单独查当地预报。
|
|
78
|
-
- **卡册**。fish_home_card 按卡名或 ID 一次看一张图,抽卡和兑换只返回文字。百连用 `count: 100`,千连用 `count: 1000`,需要 0.1.4 房间本体;十连、百连和千连的回执会合并珠光重复卡,只汇报张数与分解所得。fish_home_draw 加上 op=exchange 可换金币、星辉或指定卡。金币兑换数量填消耗的星尘,星辉兑换数量填要得到的星辉。
|
|
79
|
-
|
|
80
|
-
- **田地布局**。fish_home_farm 的 list 使用 scope=layout 查看菜畦按 3×3 分组的作物。加 bed=0、1 或 2 可看该菜畦每个格子。
|
|
81
|
-
- **批量收种**。用一次 `batch` 交整单:`actions` 只填 `replant` 会收获并原地补种(可用 `item` 指定品种);要顺手卖菜就按 `harvest` → `sell` → `replant` 排。`sell` 省略品种和数量时只卖本批刚入包的作物或成鱼。默认用背包里的种子,允许花金币买种子才填 `buyMissing: true`。回执会写明已完成的步骤和余额。
|
|
82
|
-
- **种满与巨型候选**。普通 `plant` 用 `fill: true` 自动算空位;菜田用 `layout: "giant"` 自动找 3×3,九格同种全熟时有一次 15% 的机会。花田用普通播种,每朵花成熟时独立有 15% 的机会变异。只有获准花金币才加 `buyMissing: true`,按实际可种和库存补买;允许碎地备用才加 `fallback: "normal"`。收、卖、播种可以仍在一批内完成。
|
|
83
|
-
- **集市**。商店里的「集市行情」和 fish_home 的 market、price 共用售价。每天北京时间零点更新,明日预告也可提前查询。price 可按 kind 或 item 筛选。
|
|
84
|
-
|
|
85
|
-
## 画架
|
|
86
|
-
|
|
87
|
-
- **`paint` 工具**:她在会话里说想画什么、调一下,房间的画架上就出来一张
|
|
88
|
-
- 画好的图进画册,画画那块地方也换成这张
|
|
89
|
-
|
|
90
|
-
## 侧栏
|
|
91
|
-
|
|
92
|
-
DSH 侧栏底下有个「**鱼鱼窝**」:
|
|
93
|
-
|
|
94
|
-
- 看房间在不在跑、几点、她在干嘛
|
|
95
|
-
- 一键进房间(打开浏览器看那个屋子)
|
|
96
|
-
- 后台启动 / 停止,不用去开命令行
|
|
97
|
-
- 开机自启
|
|
98
|
-
|
|
99
|
-
## 设置页
|
|
100
|
-
|
|
101
|
-
DSH 设置里有一项「**鱼鱼窝**」:
|
|
102
|
-
|
|
103
|
-
- 房间连上没有、接的哪间会话、房间里现在几点、她最近说了什么
|
|
104
|
-
- 换会话、开关桥接、开机自启
|
|
105
|
-
- **睡觉**:她现在睡没睡 + 叫起来 + 「睡着了就不理我」
|
|
106
|
-
- **屋里那两件事**:学菜(关掉就只看菜名)、画图
|
|
107
|
-
- **画图接口**:地址、密钥、模型、尺寸 —— 填了 `paint` 工具才真的能画
|
|
108
|
-
- **试一句**:走跟房间打字完全同一条路,用来验证
|
|
109
|
-
|
|
110
|
-
## 装
|
|
111
|
-
|
|
112
|
-
**① 装插件**
|
|
113
|
-
|
|
114
|
-
```
|
|
115
|
-
dsh plugin --profile <你的 profile> add dsh-fish-home
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
或者插件市场里搜「鱼鱼窝」。
|
|
119
|
-
|
|
120
|
-
**② 下房间本体(那个 3D 屋子)**
|
|
121
|
-
|
|
122
|
-
插件本体只有几十 K。房间是**另一份程序**,三百多兆(3D 模型 + 卡牌素材),npm 装不下,所以单独下载:
|
|
123
|
-
|
|
124
|
-
去 [Releases](https://github.com/Yuuyuko-uu/dsh-fish-home/releases) 下 `fish-home-room-<版本>.zip`,解压到:
|
|
125
|
-
|
|
126
|
-
```
|
|
127
|
-
~/.dsh/fish-home-room/
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
Windows 就是 `C:\Users\<你>\.dsh\fish-home-room\`,打开里面要能直接看到 `app-server.js`(别再套一层文件夹)。
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
已有鱼鱼窝要更新时,先用房间右上角的退出按钮关闭后台,再双击**旧房间目录**里的 `update-fish-home.cmd`,按提示输入新版 ZIP 的路径。从 0.1.0 升级时,旧目录没有更新脚本:先把新版 ZIP 解压到临时文件夹,只将其中的 `update-fish-home.cmd` 和 `update-fish-home.ps1` 复制到旧房间目录,再运行。脚本会将旧版运行文件保留在旁边的 `fish-home-room-backups`,原地替换程序资源;`%USERPROFILE%\.dsh\fish-home-data`、旧目录里的 `data` 和自定义配置都保持原样。文件替换失败会尝试恢复旧版。成功后从 DSH 重新打开鱼鱼窝即可。
|
|
135
|
-
|
|
136
|
-
想放别处,设环境变量 `FISH_ROOM_DIR` 指向那个目录。
|
|
137
|
-
|
|
138
|
-
**③ 重启一次 DSH**
|
|
139
|
-
|
|
140
|
-
重启完绑定会话,再从侧栏打开。电脑上需要 Node.js 22.13 或更新版本。房间默认在本机 `5178` 端口,首次启动时在 `~/.dsh/fish-home-data` 建立空存档,插件更新时会继续用这份。
|
|
141
|
-
|
|
142
|
-
macOS 上,DSH 会用系统默认浏览器打开房间,并在 PATH 和常见的 Homebrew 路径查找 Node。关闭网页后,房间后台仍会推进生活和农场,有活动网页时约每 10 秒更新一次,无网页时约每 30 秒更新一次。
|
|
143
|
-
|
|
144
|
-
排查后台开销时,可关闭 DSH 启动的房间后台,然后在所在目录手动运行 `FISH_ROOM_TICK_LOG=1 npm start`(macOS 或 Linux)。Windows PowerShell 先运行 `$env:FISH_ROOM_TICK_LOG='1'`,再运行 `npm start`。每轮会输出推进生活和整轮执行的耗时。要沿用 DSH 存档,启动时传 `-- --data-dir` 和原存档目录。
|
|
145
|
-
|
|
146
|
-
内置房间使用原版蓝色大肥鱼模型和配套动作。
|
|
147
|
-
|
|
148
|
-
回忆簿可在 DSH 设置里的「上下文与回忆」填写纯文本记忆路径、日记路径和相伴起始日;逐轮 runtime-context 默认关闭。`fish_home status` 可一次读到所在位置、活动、身体感受和心情;重要天气变化、成熟与生活里程碑、消费和场景事件仍分别控制是否通知绑定会话。模型制作:水原镜,MMD 转换与绑定:耶栗Yaki。模型的署名和原始使用规约随房间本体一起下发(房间目录 `dist/models/dayu-mmd/` 里的 `使用规约.txt` 和 `MODEL-CREDITS.md`),请一并保留。
|
|
149
|
-
|
|
150
|
-
卡包大部分立绘来源于 B站 UP 主 **ZipZipPipe**,版权归原作者,随游戏一起分发、未作修改。
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
"
|
|
161
|
-
"
|
|
162
|
-
"
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
|
190
|
-
|
|
191
|
-
| GET | `/fish-room/v1/
|
|
192
|
-
| GET | `/fish-room/v1/
|
|
193
|
-
|
|
|
194
|
-
|
|
|
195
|
-
| POST | `/fish-room/v1/
|
|
196
|
-
|
|
|
197
|
-
|
|
|
198
|
-
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
-
|
|
207
|
-
|
|
1
|
+
# 鱼鱼窝 · dsh-fish-home
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
把 **「大肥鱼的小日子」** 那个 3D 房间接进 DSH。
|
|
7
|
+
|
|
8
|
+
房间那边是个独立的小程序(three.js 那一套),它自己不会说话 —— 说话的还是你在 DSH 里的那间会话。
|
|
9
|
+
这个插件就是中间那条线:
|
|
10
|
+
|
|
11
|
+
- **房间里打字** → 送进你绑定的那间会话(在 DSH 里就是你说的一句话)
|
|
12
|
+
- **会话里回的话** → 顺着事件流递回房间,它张嘴说出来
|
|
13
|
+
- **你在 DSH 窗口里自己打的字** → 房间里也看得见
|
|
14
|
+
- **它主动开口**(主动搭话、刷完 B 站回来)→ 房间里同样看得见
|
|
15
|
+
- **房间里的生活数据**(饿不饿、在干嘛、心情)→ 存在插件这儿,随时能查
|
|
16
|
+
- **房间里的钟** → 几点、白天夜里、什么天气,都递给 DSH,它不会在你屋里半夜三点说「中午好」
|
|
17
|
+
- **她一开始想** → 房间立刻冒一个「让我想想呀…」的气泡,不用干等
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 屋里和院子里能干什么
|
|
22
|
+
|
|
23
|
+
房间那半是另一份程序(`dsh-fish-home` 只管把它接进来),但装上之后这些是一套的,先说一下有什么。
|
|
24
|
+
|
|
25
|
+
### 过日子
|
|
26
|
+
|
|
27
|
+
- 她自己按时候挑事做:吃饭、做饭、洗漱、阅读、画画、看窗外、看星星、听音乐、窝在沙发上……
|
|
28
|
+
不在固定钟点上排班,是「手里这件事到点了」才换下一件
|
|
29
|
+
- 早上自己醒(在设好的起床点前后随机),晚上说完晚安自己躺下
|
|
30
|
+
- 心情、精神、饱腹、清爽、陪伴、好奇六项跟着日常走
|
|
31
|
+
- 顶栏能换天色和天气:晴日 / 听雨 / 落雪,或者填个地区让屋外的天跟着当地走
|
|
32
|
+
|
|
33
|
+
### 种菜(院子)
|
|
34
|
+
|
|
35
|
+
- 商店买种子 → 种下 → 浇水 → 收获 → 卖钱
|
|
36
|
+
- **30 种作物分五档**(入门 / 当季 / 稀罕 / 珍贵 / 花),长得快慢、种子钱、卖价都不一样
|
|
37
|
+
- 浇水能让这一轮快半小时;照顾得好的那几株有机会长成**巨大作物**,卖价是普通的 2.5 倍
|
|
38
|
+
- 起始 120 金币,**钱只能靠卖收成** —— 地是现成的,不用买
|
|
39
|
+
|
|
40
|
+
### 养鱼(池塘)
|
|
41
|
+
|
|
42
|
+
- 商店里买鱼苗,放进池子里养
|
|
43
|
+
|
|
44
|
+
### 抽卡(卡册)
|
|
45
|
+
|
|
46
|
+
- 三个卡池:**海边常驻**(顶 5★)、**鱼鱼表情**(顶 SP)、**万圣节**
|
|
47
|
+
- 支持单抽、十连和百连。新卡和品质升级进卡册,珠光重复卡合并结算为星尘或星辉。
|
|
48
|
+
|
|
49
|
+
### 菜谱
|
|
50
|
+
|
|
51
|
+
- 内置 373 道家常菜(HowToCook,公有领域),一天一道,厨房那块板子上写着今天这道
|
|
52
|
+
- 点开是本子:左边要什么料、右边怎么做,最底下一条小贴士
|
|
53
|
+
|
|
54
|
+
### 画册
|
|
55
|
+
|
|
56
|
+
- 只放她自己画的。她在会话里说想画什么、画完,直接挂在画架上
|
|
57
|
+
|
|
58
|
+
### 回忆簿
|
|
59
|
+
|
|
60
|
+
- 接的是 **「鱼的记忆」** 和 **星汐的日记**:上面两个筛选,一个「记住的事」、一个「日记」
|
|
61
|
+
- **「相伴第几天」** 也从星汐日记最早那一篇算起
|
|
62
|
+
- 这一项是只读的,不改任何人的档案
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 睡觉
|
|
67
|
+
|
|
68
|
+
- **`sleep` 工具**:说完晚安调一下她就躺下,`false` 就是起来
|
|
69
|
+
- **「睡着了就不理我」**:开着的时候,她睡了就不接你的话
|
|
70
|
+
- **叫起来**:设置页里有个按钮,随时能把她弄醒
|
|
71
|
+
- **保险丝**:该醒没醒(跨夜、进程断过、插件重挂),插件会放行并把她叫起来,不会卡死在睡觉状态
|
|
72
|
+
- 醒了会跟你打个招呼
|
|
73
|
+
|
|
74
|
+
## 会话中的菜谱、天气和卡册
|
|
75
|
+
|
|
76
|
+
- **菜谱**。fish_home_recipe 默认查今天的菜名。可按菜名或 ID 查询一道菜,打开「学菜」后才能读食材和步骤。
|
|
77
|
+
- **天气**。fish_home 可查庭院当前天气(weather)或设置地区的三天预报(forecast)。在房间设置里开启当地天气同步后,庭院跟随该地区。手动点晴日、听雨或落雪会切回手动天气,仍能单独查当地预报。
|
|
78
|
+
- **卡册**。fish_home_card 按卡名或 ID 一次看一张图,抽卡和兑换只返回文字。百连用 `count: 100`,千连用 `count: 1000`,需要 0.1.4 房间本体;十连、百连和千连的回执会合并珠光重复卡,只汇报张数与分解所得。fish_home_draw 加上 op=exchange 可换金币、星辉或指定卡。金币兑换数量填消耗的星尘,星辉兑换数量填要得到的星辉。
|
|
79
|
+
|
|
80
|
+
- **田地布局**。fish_home_farm 的 list 使用 scope=layout 查看菜畦按 3×3 分组的作物。加 bed=0、1 或 2 可看该菜畦每个格子。
|
|
81
|
+
- **批量收种**。用一次 `batch` 交整单:`actions` 只填 `replant` 会收获并原地补种(可用 `item` 指定品种);要顺手卖菜就按 `harvest` → `sell` → `replant` 排。`sell` 省略品种和数量时只卖本批刚入包的作物或成鱼。默认用背包里的种子,允许花金币买种子才填 `buyMissing: true`。回执会写明已完成的步骤和余额。
|
|
82
|
+
- **种满与巨型候选**。普通 `plant` 用 `fill: true` 自动算空位;菜田用 `layout: "giant"` 自动找 3×3,九格同种全熟时有一次 15% 的机会。花田用普通播种,每朵花成熟时独立有 15% 的机会变异。只有获准花金币才加 `buyMissing: true`,按实际可种和库存补买;允许碎地备用才加 `fallback: "normal"`。收、卖、播种可以仍在一批内完成。
|
|
83
|
+
- **集市**。商店里的「集市行情」和 fish_home 的 market、price 共用售价。每天北京时间零点更新,明日预告也可提前查询。price 可按 kind 或 item 筛选。
|
|
84
|
+
|
|
85
|
+
## 画架
|
|
86
|
+
|
|
87
|
+
- **`paint` 工具**:她在会话里说想画什么、调一下,房间的画架上就出来一张
|
|
88
|
+
- 画好的图进画册,画画那块地方也换成这张
|
|
89
|
+
|
|
90
|
+
## 侧栏
|
|
91
|
+
|
|
92
|
+
DSH 侧栏底下有个「**鱼鱼窝**」:
|
|
93
|
+
|
|
94
|
+
- 看房间在不在跑、几点、她在干嘛
|
|
95
|
+
- 一键进房间(打开浏览器看那个屋子)
|
|
96
|
+
- 后台启动 / 停止,不用去开命令行
|
|
97
|
+
- 开机自启
|
|
98
|
+
|
|
99
|
+
## 设置页
|
|
100
|
+
|
|
101
|
+
DSH 设置里有一项「**鱼鱼窝**」:
|
|
102
|
+
|
|
103
|
+
- 房间连上没有、接的哪间会话、房间里现在几点、她最近说了什么
|
|
104
|
+
- 换会话、开关桥接、开机自启
|
|
105
|
+
- **睡觉**:她现在睡没睡 + 叫起来 + 「睡着了就不理我」
|
|
106
|
+
- **屋里那两件事**:学菜(关掉就只看菜名)、画图
|
|
107
|
+
- **画图接口**:地址、密钥、模型、尺寸 —— 填了 `paint` 工具才真的能画
|
|
108
|
+
- **试一句**:走跟房间打字完全同一条路,用来验证
|
|
109
|
+
|
|
110
|
+
## 装
|
|
111
|
+
|
|
112
|
+
**① 装插件**
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
dsh plugin --profile <你的 profile> add dsh-fish-home
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
或者插件市场里搜「鱼鱼窝」。
|
|
119
|
+
|
|
120
|
+
**② 下房间本体(那个 3D 屋子)**
|
|
121
|
+
|
|
122
|
+
插件本体只有几十 K。房间是**另一份程序**,三百多兆(3D 模型 + 卡牌素材),npm 装不下,所以单独下载:
|
|
123
|
+
|
|
124
|
+
去 [Releases](https://github.com/Yuuyuko-uu/dsh-fish-home/releases) 下 `fish-home-room-<版本>.zip`,解压到:
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
~/.dsh/fish-home-room/
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Windows 就是 `C:\Users\<你>\.dsh\fish-home-room\`,打开里面要能直接看到 `app-server.js`(别再套一层文件夹)。
|
|
131
|
+
|
|
132
|
+
**中国象棋亲自玩和礼物工具需要同时更新到 0.1.7。** 从 Releases 的 Assets 下载 `fish-home-room-0.1.7.zip`。解压后,同一层应有 `app-server.js`、`package.json` 和 `dist`。
|
|
133
|
+
|
|
134
|
+
已有鱼鱼窝要更新时,先用房间右上角的退出按钮关闭后台,再双击**旧房间目录**里的 `update-fish-home.cmd`,按提示输入新版 ZIP 的路径。从 0.1.0 升级时,旧目录没有更新脚本:先把新版 ZIP 解压到临时文件夹,只将其中的 `update-fish-home.cmd` 和 `update-fish-home.ps1` 复制到旧房间目录,再运行。脚本会将旧版运行文件保留在旁边的 `fish-home-room-backups`,原地替换程序资源;`%USERPROFILE%\.dsh\fish-home-data`、旧目录里的 `data` 和自定义配置都保持原样。文件替换失败会尝试恢复旧版。成功后从 DSH 重新打开鱼鱼窝即可。
|
|
135
|
+
|
|
136
|
+
想放别处,设环境变量 `FISH_ROOM_DIR` 指向那个目录。
|
|
137
|
+
|
|
138
|
+
**③ 重启一次 DSH**
|
|
139
|
+
|
|
140
|
+
重启完绑定会话,再从侧栏打开。电脑上需要 Node.js 22.13 或更新版本。房间默认在本机 `5178` 端口,首次启动时在 `~/.dsh/fish-home-data` 建立空存档,插件更新时会继续用这份。
|
|
141
|
+
|
|
142
|
+
macOS 上,DSH 会用系统默认浏览器打开房间,并在 PATH 和常见的 Homebrew 路径查找 Node。关闭网页后,房间后台仍会推进生活和农场,有活动网页时约每 10 秒更新一次,无网页时约每 30 秒更新一次。
|
|
143
|
+
|
|
144
|
+
排查后台开销时,可关闭 DSH 启动的房间后台,然后在所在目录手动运行 `FISH_ROOM_TICK_LOG=1 npm start`(macOS 或 Linux)。Windows PowerShell 先运行 `$env:FISH_ROOM_TICK_LOG='1'`,再运行 `npm start`。每轮会输出推进生活和整轮执行的耗时。要沿用 DSH 存档,启动时传 `-- --data-dir` 和原存档目录。
|
|
145
|
+
|
|
146
|
+
内置房间使用原版蓝色大肥鱼模型和配套动作。
|
|
147
|
+
|
|
148
|
+
回忆簿可在 DSH 设置里的「上下文与回忆」填写纯文本记忆路径、日记路径和相伴起始日;逐轮 runtime-context 默认关闭。`fish_home status` 可一次读到所在位置、活动、身体感受和心情;重要天气变化、成熟与生活里程碑、消费和场景事件仍分别控制是否通知绑定会话。模型制作:水原镜,MMD 转换与绑定:耶栗Yaki。模型的署名和原始使用规约随房间本体一起下发(房间目录 `dist/models/dayu-mmd/` 里的 `使用规约.txt` 和 `MODEL-CREDITS.md`),请一并保留。
|
|
149
|
+
|
|
150
|
+
卡包大部分立绘来源于 B站 UP 主 **ZipZipPipe**,版权归原作者,随游戏一起分发、未作修改。
|
|
151
|
+
|
|
152
|
+
商店的「礼物」页可以赠送背包里已有的花、菜、成鱼和巨型收成,也可以用金币送出纪念礼物。`fish_home_gift` 的 `list` 默认只显示待收礼物,可用 `scope: "shop"` 查看价格,或用 `scope: "bag"` 查看可赠送的库存。用 `{"op":"receive","latest":true}` 直接收下最新礼物,也可以用礼物编号指定要收的那一份。从商城直接购买并送出用 `{"op":"buy","item":"珠光夜灯","maxCoins":160000,"message":"今晚给你留盏灯。"}`。右上角的礼盒可查看待收、已收和送出的礼物、送出时间与留言。确认收到后可在「回忆簿 → 房间手记」查看。书桌便笺也存在房间手记里。
|
|
153
|
+
|
|
154
|
+
## 配置
|
|
155
|
+
|
|
156
|
+
第一次跑会自己在 `~/.dsh/fish-room.json` 里造一个令牌:
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"开": true,
|
|
161
|
+
"会话": "session-…",
|
|
162
|
+
"令牌": "自动生成的",
|
|
163
|
+
"转发主动开口": true,
|
|
164
|
+
"心跳秒": 20
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
- **会话**:接哪一间。留空的话,插件会在「只有一间会话活着」的时候自动认下它并写回来;多于一间就留空,自己填。
|
|
169
|
+
- **转发主动开口**:它自己开口说的话要不要也递到房间(默认要)。
|
|
170
|
+
- **心跳秒**:事件流的保活间隔。
|
|
171
|
+
|
|
172
|
+
同时会写一份 `~/.dsh/fish-room.discovery.json`(地址 + 令牌 + 会话),
|
|
173
|
+
房间那边读到它就能自己连上,不用手抄令牌。插件关掉时这份文件会删掉。
|
|
174
|
+
|
|
175
|
+
## 房间那边怎么接
|
|
176
|
+
|
|
177
|
+
内置房间会自动读取 DSH 写出的发现文件。已有独立的鱼鱼窝时,可以在 DSH 的启动环境中用 `FISH_ROOM_DIR` 指定房间目录,并用 `FISH_ROOM_PORT` 指定端口。旧房间继续读取它自己的存档配置 `data/dsh-bridge.json`。
|
|
178
|
+
|
|
179
|
+
```json
|
|
180
|
+
{ "enabled": true, "discover": true }
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`discover` 就是「去读上面那份发现文件」。也可以手填 `url` / `token` / `sessionId`。
|
|
184
|
+
|
|
185
|
+
## 接口
|
|
186
|
+
|
|
187
|
+
全部在本机 `127.0.0.1`,要 `Authorization: Bearer <令牌>`,对不上一律 401。
|
|
188
|
+
|
|
189
|
+
| 方法 | 路径 | 干什么 |
|
|
190
|
+
|---|---|---|
|
|
191
|
+
| GET | `/fish-room/v1/health` | 健康检查:版本、绑了哪间会话、会话醒着没有 |
|
|
192
|
+
| GET | `/fish-room/v1/state` | 状态:生活数据、最近说过的话、日志 |
|
|
193
|
+
| GET | `/fish-room/v1/events?since=N` | 事件流(SSE),断线重连按 `since` 补发 |
|
|
194
|
+
| GET | `/fish-room/v1/history?since=N&limit=N` | 补历史事件 |
|
|
195
|
+
| POST | `/fish-room/v1/chat` | 说一句话:`{ schema, requestId, text }`,立刻回 202 |
|
|
196
|
+
| POST | `/fish-room/v1/pet/state` | 房间报生活数据 |
|
|
197
|
+
| POST | `/fish-room/v1/pet/life-event` | 房间里发生的事(同一个 id 只记一次) |
|
|
198
|
+
| GET | `/fish-room/v1/memories?q=&kind=&limit=&offset=` | 回忆簿:鱼的记忆 + 星汐日记 |
|
|
199
|
+
| GET | `/fish-room/v1/days` | 相伴第几天 |
|
|
200
|
+
| POST | `/fish-room/v1/paint/draw` | 让她画一张 |
|
|
201
|
+
|
|
202
|
+
回话走事件流:`chat.reply` 里带着你发过来时的那个 `requestId`。
|
|
203
|
+
|
|
204
|
+
## 注意
|
|
205
|
+
|
|
206
|
+
- **会话得开着。** 插件只往活着的会话里送;那间会话没打开时 `/chat` 会明确回
|
|
207
|
+
`SESSION_SLEEPING`,不会把话吞掉。
|
|
208
|
+
- 送进去的话标着 `source.kind = 'fish-home'` —— 别的插件(QQ、心情)认得出这不是你在窗口里手打的。
|
|
209
|
+
- 端口每次重启 DSH 都会变,所以地址一律从发现文件读,别写死。
|
package/lib/game-session.mjs
CHANGED
|
@@ -54,8 +54,19 @@ export function createGameSession({ getAgent, getSession, registerTools, flush,
|
|
|
54
54
|
if (!agent || typeof agent.followup !== 'function' || typeof agent.session?.append !== 'function' || !agent.ctx?.tools?.register) {
|
|
55
55
|
return '请在 DSH 打开已绑定的会话,并确认已加载支持陪玩的鱼鱼窝插件。';
|
|
56
56
|
}
|
|
57
|
-
const
|
|
58
|
-
|
|
57
|
+
const routes = [
|
|
58
|
+
() => agent.model?.current?.(),
|
|
59
|
+
() => agent.session.requestHeader?.()?.config,
|
|
60
|
+
() => agent.options,
|
|
61
|
+
];
|
|
62
|
+
const hasModel = routes.some(read => {
|
|
63
|
+
try {
|
|
64
|
+
const route = read();
|
|
65
|
+
return typeof route?.provider === 'string' && route.provider.trim() &&
|
|
66
|
+
typeof route.model === 'string' && route.model.trim();
|
|
67
|
+
} catch { return false; }
|
|
68
|
+
});
|
|
69
|
+
if (!hasModel) return '读不到绑定会话的模型。请选好模型,并在该会话先发一条消息。';
|
|
59
70
|
return '';
|
|
60
71
|
}
|
|
61
72
|
|
|
@@ -144,7 +155,7 @@ export function createGameSession({ getAgent, getSession, registerTools, flush,
|
|
|
144
155
|
const ticket = randomBytes(5).toString('base64url');
|
|
145
156
|
const firstOrRetry = input.hand === 1 || game.lastAskedHand === input.hand || game.lastMove?.hand !== input.hand-1;
|
|
146
157
|
game.lastAskedHand = input.hand;
|
|
147
|
-
const needsBoard =
|
|
158
|
+
const needsBoard = ['gomoku','xiangqi'].includes(gameId) && (input.hand-1)%6===0;
|
|
148
159
|
const context = firstOrRetry || needsBoard ? describeTurn(gameId,state,actor) : '';
|
|
149
160
|
const turn = {round,step:seq,applied:false};
|
|
150
161
|
const request = track(message(`轮到你 · 出招码 ${ticket}。${context}`),turn);
|
package/lib/game-strategy.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export const
|
|
1
|
+
import {black, parseBoard, readMove} from './xiangqi-rules.mjs';
|
|
2
|
+
export const gameNames = Object.freeze({rps:'石头剪刀布', blackjack:'二十一点', roulette:'珍珠转盘', gomoku:'五子棋', xiangqi:'中国象棋'});
|
|
3
|
+
export const gameToolDescription = '轮到你时,用最新的出招码 ticket 提交一次 move。猜拳 rock/scissors/paper,本手互相保密。二十一点 hit/stand;超 21 爆牌,领先且未爆牌即结算。五子棋用列,行(1 到 15),局面按双方列出坐标;密集时用黑X白O、.为空的逐行棋盘。珍珠转盘 self/other,珍珠扣目标护盾,空壳翻给自己可连手;换壳用 swap:other 或 swap:self,偷看用 peek:other:self(两段分别为有珍珠和空壳时的目标)。中国象棋执黑,用「起列,起行-终列,终行」,左上为 1,1。工具只接受当前出招码,会等待网页回执。';
|
|
3
4
|
const gestureNames = {rock:'石头', scissors:'剪刀', paper:'布'};
|
|
4
5
|
export function describeTurn(game, state, actor) {
|
|
5
6
|
if (game==='rps') {
|
|
@@ -12,6 +13,7 @@ export function describeTurn(game, state, actor) {
|
|
|
12
13
|
const items = [state.peek && '偷看',state.swap && '换壳'].filter(Boolean);
|
|
13
14
|
return `余 ${state.pearl} 珍珠、${state.empty} 空壳;护盾你 ${state.you}、${actor} ${state.other}${items.length?';可用'+items.join('、'):''}。`;
|
|
14
15
|
}
|
|
16
|
+
if(game==='xiangqi')return '你执黑。棋盘自上到下,大写红、小写黑,R车 H马 E象 A士 K将 C炮 P兵,.为空:\n'+state.board.replaceAll('/','\n');
|
|
15
17
|
const stones = {X:[],O:[]};
|
|
16
18
|
state.board.split('/').forEach((row,y)=>Array.from(row).forEach((stone,x)=>{
|
|
17
19
|
if (stone!=='.') stones[stone].push(`${x+1},${y+1}`);
|
|
@@ -20,7 +22,7 @@ export function describeTurn(game, state, actor) {
|
|
|
20
22
|
return positions.length < state.board.length ? positions : `棋盘(左上 1,1):\n${state.board.replaceAll('/','\n')}`;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
const games = new Set(['rps','blackjack','roulette','gomoku']);
|
|
25
|
+
const games = new Set(['rps','blackjack','roulette','gomoku','xiangqi']);
|
|
24
26
|
export const isGame = game => games.has(game);
|
|
25
27
|
const gestures = new Set(['rock','scissors','paper']);
|
|
26
28
|
const int = (n,min,max) => Number.isInteger(n) && n>=min && n<=max;
|
|
@@ -32,6 +34,7 @@ function visibleState(game,s) {
|
|
|
32
34
|
if (game === 'blackjack' && int(s?.you,0,21) && int(s?.other,0,21) && typeof s.soft==='boolean') {
|
|
33
35
|
return {you:s.you,other:s.other,soft:s.soft};
|
|
34
36
|
}
|
|
37
|
+
if(game==='xiangqi'&&parseBoard(s?.board))return {board:s.board};
|
|
35
38
|
if (game === 'gomoku' && typeof s?.board==='string' && s.board.length===239 && /^(?:[.XO]{15}\/){14}[.XO]{15}$/.test(s.board)) {
|
|
36
39
|
return {board:s.board};
|
|
37
40
|
}
|
|
@@ -46,6 +49,7 @@ export function legalMove(game, state, move) {
|
|
|
46
49
|
if (game==='rps') return gestures.has(move);
|
|
47
50
|
if (game==='blackjack') return move==='hit'||move==='stand';
|
|
48
51
|
if (game==='roulette') return /^(self|other)$/.test(move) || (state.swap && /^swap:(self|other)$/.test(move)) || (state.peek && /^peek:(self|other):(self|other)$/.test(move));
|
|
52
|
+
if(game==='xiangqi')return Boolean(readMove(parseBoard(state.board),move,black));
|
|
49
53
|
const cells = /^(?:[1-9]|1[0-5]),(?:[1-9]|1[0-5])$/.test(move) && move.split(',').map(Number);
|
|
50
54
|
return Boolean(cells && state.board[(cells[1]-1)*16+cells[0]-1]==='.');
|
|
51
55
|
}
|
package/lib/host.js
CHANGED
|
@@ -49,6 +49,8 @@ const 事件白名单 = new Set([
|
|
|
49
49
|
'proactive.speak', 'activity.bili', 'activity.desk', 'paint.image', 'pet.state.ack', 'bridge.notice',
|
|
50
50
|
])
|
|
51
51
|
|
|
52
|
+
const bridgeCapabilities = ['chat', 'events', 'pet-state', 'life-event', 'routine-state', 'native-look', 'life-notices', 'session-diary', 'room-tools-v9', 'game-session-v2', 'game-xiangqi-v1', 'gift-shop-v1'];
|
|
53
|
+
|
|
52
54
|
const 家 = process.env.DSH_HOME || path.join(os.homedir(), '.dsh')
|
|
53
55
|
const 配置路 = path.join(家, 'fish-room.json')
|
|
54
56
|
const 发现路 = path.join(家, 'fish-room.discovery.json')
|
|
@@ -572,7 +574,7 @@ async function 真启动(记) {
|
|
|
572
574
|
await 补推房间设置(记, true)
|
|
573
575
|
return { ok: true, 已启动: true, pid: 子.pid || 0, 说: '起来了', 状态: { 运行中: true, 地址: 房间地址, 练习: 版本 } }
|
|
574
576
|
}
|
|
575
|
-
if (是旧版房间(响应)) return 失败('
|
|
577
|
+
if (是旧版房间(响应)) return 失败('房间后台已经响应,但房间包版本太旧。请用原目录的更新脚本升级鱼鱼窝房间包。', true)
|
|
576
578
|
}
|
|
577
579
|
return 失败('房间后台在 20 秒内没有响应。请检查房间端口和安装目录。', true)
|
|
578
580
|
} finally {
|
|
@@ -1378,6 +1380,7 @@ function 起来(ctx, 配置参数 = {}) {
|
|
|
1378
1380
|
redirect: 'error', signal: signal ? AbortSignal.any([signal, deadline]) : deadline,
|
|
1379
1381
|
...(params === undefined ? {} : { method: 'POST', headers: {'content-type':'application/json'}, body: JSON.stringify(params) }),
|
|
1380
1382
|
});
|
|
1383
|
+
if (response.status===404 && ['/api/farm/gifts','/api/farm/give','/api/farm/receive-gift'].includes(route.split('?')[0])) throw new Error('请将房间本体更新到 0.1.7。');
|
|
1381
1384
|
if (route==='/api/farm/plant-giant-batch' && response.status===404) {
|
|
1382
1385
|
throw new Error('当前房间还没更新到支持整块 3×3 播种的版本;这一步没有买种或播种。');
|
|
1383
1386
|
}
|
|
@@ -1832,6 +1835,86 @@ function 起来(ctx, 配置参数 = {}) {
|
|
|
1832
1835
|
let imageContext
|
|
1833
1836
|
ctx.inject?.(['attachments'], scope => { imageContext = scope })
|
|
1834
1837
|
|
|
1838
|
+
function 礼物工具() {
|
|
1839
|
+
let sequence=Promise.resolve();
|
|
1840
|
+
return {
|
|
1841
|
+
name:'fish_home_gift',
|
|
1842
|
+
description:'鱼鱼窝收礼与送礼。用户请你收下刚送的礼物时,直接用 receive 和 latest=true。收指定礼物用 receive 和 id。list 默认只看待收礼物,scope=shop 看商城价格,scope=bag 看可赠送的库存。buy 按名称或 ID 买一件礼物并送出,可设 maxCoins 限价。give 从背包送花菜、成鱼或巨型收成,填 kind 和 item。',
|
|
1843
|
+
parameters:{type:'object',properties:{
|
|
1844
|
+
op:{type:'string',enum:['list','buy','give','receive']},
|
|
1845
|
+
kind:{type:'string',enum:['crop','fish','giant','gift']},
|
|
1846
|
+
item:{type:'string',description:'礼物品种、商品名称或 ID。'},
|
|
1847
|
+
quantity:{type:'integer',minimum:1,maximum:999},
|
|
1848
|
+
to:{type:'string',maxLength:40},
|
|
1849
|
+
message:{type:'string',maxLength:300},
|
|
1850
|
+
maxCoins:{type:'integer',minimum:0,description:'buy 可选,最多花多少金币。报价超出就取消。'},
|
|
1851
|
+
scope:{type:'string',enum:['inbox','shop','bag'],description:'list 要查看的内容。默认 inbox 待收礼物。'},
|
|
1852
|
+
page:{type:'integer',minimum:1,description:'收礼列表的页码,默认第 1 页。'},
|
|
1853
|
+
latest:{type:'boolean',description:'receive 时收下最新一份待收礼物。和 id 二选一。'},
|
|
1854
|
+
id:{type:'string',description:'receive 时要收下的指定礼物编号。'},
|
|
1855
|
+
},required:['op'],additionalProperties:false},
|
|
1856
|
+
output:textOutput,
|
|
1857
|
+
async execute(args={},exec){
|
|
1858
|
+
const run=async()=>{
|
|
1859
|
+
try{
|
|
1860
|
+
const read=(route,body)=>roomRequest('/api/farm/'+route,body,8000,exec?.signal);
|
|
1861
|
+
if(args.op==='list'){
|
|
1862
|
+
const scope=args.scope??'inbox';
|
|
1863
|
+
if(scope==='shop'){
|
|
1864
|
+
const {catalog,wallet}=await read('gifts?view=shop');
|
|
1865
|
+
const goods=catalog.map(({name,price})=>`${name} ${price} 金币`).join('、');
|
|
1866
|
+
return {ok:true,说:`余额 ${wallet.coins} 金币。${goods}。`,商品:catalog.map(({id,name,price})=>({id,name,price}))};
|
|
1867
|
+
}
|
|
1868
|
+
if(scope==='bag'){
|
|
1869
|
+
const {wallet}=await read('gifts?view=bag');
|
|
1870
|
+
const available={crops:wallet.crops,fish:wallet.fish,giants:wallet.giants};
|
|
1871
|
+
const labels={crops:'收成',fish:'成鱼',giants:'巨型收成'};
|
|
1872
|
+
const lines=Object.entries(available).filter(([,items])=>Object.keys(items||{}).length)
|
|
1873
|
+
.map(([kind,items])=>`${labels[kind]} ${inventoryLine(items)}`);
|
|
1874
|
+
return {ok:true,说:lines.length?lines.join(';')+'。':'背包没有可送的收成或成鱼。',库存:available};
|
|
1875
|
+
}
|
|
1876
|
+
if(scope!=='inbox')return {ok:false,说:'请选择待收礼物、商城或背包。'};
|
|
1877
|
+
const page=args.page??1;
|
|
1878
|
+
if(!Number.isSafeInteger(page)||page<1)return {ok:false,说:'请填有效的礼物页码。'};
|
|
1879
|
+
const {inbox}=await read('gifts?viewer=dayu&view=inbox&page='+page);
|
|
1880
|
+
const pending=inbox.items.map(({id,name,quantity,from})=>({id,name,quantity,from}));
|
|
1881
|
+
const next=inbox.hasMore?page+1:null;
|
|
1882
|
+
const lines=pending.map(({id,name,quantity,from})=>`${from} · ${name}${quantity>1?'×'+quantity:''} · ${id}`);
|
|
1883
|
+
if(next)lines.push(`还有待收礼物,可看第 ${next} 页。`);
|
|
1884
|
+
return {ok:true,说:lines.join('\n')||'没有待收礼物。',待收:pending,下一页:next};
|
|
1885
|
+
}
|
|
1886
|
+
if(args.op==='receive'){
|
|
1887
|
+
const latest=args.latest===true;
|
|
1888
|
+
if(latest===Boolean(args.id))return {ok:false,说:'请指定礼物编号,或选择收下最新一份待收礼物。'};
|
|
1889
|
+
const turn=当前轮.get(目标会话());
|
|
1890
|
+
const requestId=latest?(turn?(turn.giftReceiptId??=randomUUID()):randomUUID()):undefined;
|
|
1891
|
+
const result=await read('receive-gift',{id:args.id,latest,requestId,actor:'dayu'});
|
|
1892
|
+
const {id,name,quantity,from,receivedAt,message}=result.gift;
|
|
1893
|
+
const note=!result.replayed&&message?' 留言:'+message:'';
|
|
1894
|
+
return {ok:true,说:(result.replayed?`${name}已经收下。`:result.say)+note,礼物:{id,name,quantity,from,receivedAt}};
|
|
1895
|
+
}
|
|
1896
|
+
if(args.op!=='give'&&args.op!=='buy')return {ok:false,说:'请选择 list、buy、give 或 receive。'};
|
|
1897
|
+
const commercial=args.op==='buy'||args.kind==='gift';
|
|
1898
|
+
const kind=commercial?'gift':args.kind;
|
|
1899
|
+
if(typeof args.item!=='string'||!args.item.trim())return {ok:false,说:commercial?'请填要买的纪念礼物名称或编号。可用 list 的 shop 分类看价格。':'请填要赠送的物品名称。'};
|
|
1900
|
+
if(!commercial&&!['crop','fish','giant'].includes(kind))return {ok:false,说:'请选择送收成(crop)、成鱼(fish)或巨型收成(giant)。'};
|
|
1901
|
+
// Repeating an identical tool call in the same DSH turn should not send a second gift.
|
|
1902
|
+
const turn=当前轮.get(目标会话());
|
|
1903
|
+
const key=JSON.stringify([kind,args.item.trim(),args.quantity??1,args.to??'',args.message??'']);
|
|
1904
|
+
const pending=turn?(turn.giftRequests??=new Map()):new Map();
|
|
1905
|
+
if(!pending.has(key))pending.set(key,randomUUID());
|
|
1906
|
+
const result=await read('give',{kind,item:args.item.trim(),quantity:args.quantity,to:args.to,message:args.message,maxCoins:args.maxCoins,actor:'dayu',requestId:pending.get(key)});
|
|
1907
|
+
const {gift,wallet}=result;
|
|
1908
|
+
const stock=gift.kind==='crop'?wallet.crops:gift.kind==='fish'?wallet.fish:wallet.giants;
|
|
1909
|
+
const remainder=gift.price?`花费 ${gift.price} 金币,余额 ${wallet.coins} 金币。`:`背包还剩 ${stock[gift.item]??0} 份。`;
|
|
1910
|
+
return {ok:true,说:result.say+remainder,礼物:gift,...(gift.price?{花费:gift.price,金币:wallet.coins}:{剩余:stock[gift.item]??0})};
|
|
1911
|
+
}catch(error){return {ok:false,说:String(error.message||error)};}
|
|
1912
|
+
};
|
|
1913
|
+
const result=sequence.then(run);sequence=result.catch(()=>{});return result;
|
|
1914
|
+
},
|
|
1915
|
+
};
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1835
1918
|
function 看一眼工具() {
|
|
1836
1919
|
return {
|
|
1837
1920
|
name: 'fish_home_look',
|
|
@@ -1936,7 +2019,7 @@ function 起来(ctx, 配置参数 = {}) {
|
|
|
1936
2019
|
entry.off们.delete(contextKey)
|
|
1937
2020
|
}
|
|
1938
2021
|
if (typeof agent.ctx.tools?.register==='function') {
|
|
1939
|
-
for (const create of [
|
|
2022
|
+
for (const create of [画工具,睡眠工具,鱼鱼窝工具,日常工具,抽卡工具,卡面工具,菜谱工具,走过去工具,农活工具,礼物工具,看一眼工具, () => gameSession.tool(agent)]) {
|
|
1940
2023
|
const tool = create();
|
|
1941
2024
|
register(tool.name,()=>agent.ctx.tools.register(tool));
|
|
1942
2025
|
}
|
|
@@ -2239,7 +2322,7 @@ function 起来(ctx, 配置参数 = {}) {
|
|
|
2239
2322
|
epoch,
|
|
2240
2323
|
sessionId: 目标,
|
|
2241
2324
|
sessionAlive: 活,
|
|
2242
|
-
capabilities:
|
|
2325
|
+
capabilities: bridgeCapabilities,
|
|
2243
2326
|
latestSeq: seq,
|
|
2244
2327
|
clients: 连接们.size,
|
|
2245
2328
|
pet: 最近状态,
|
|
@@ -2268,7 +2351,7 @@ function 起来(ctx, 配置参数 = {}) {
|
|
|
2268
2351
|
sessionId: 目标,
|
|
2269
2352
|
sessionAlive: Boolean(目标 && 找agent(目标)),
|
|
2270
2353
|
gameUnavailable: gameSession.availability(找agent(目标)),
|
|
2271
|
-
capabilities:
|
|
2354
|
+
capabilities: bridgeCapabilities,
|
|
2272
2355
|
latestSeq: seq,
|
|
2273
2356
|
})
|
|
2274
2357
|
})
|
|
@@ -2302,7 +2385,7 @@ function 起来(ctx, 配置参数 = {}) {
|
|
|
2302
2385
|
epoch,
|
|
2303
2386
|
sessionId: 目标会话(),
|
|
2304
2387
|
bridgeVersion: 桥版本,
|
|
2305
|
-
capabilities:
|
|
2388
|
+
capabilities: bridgeCapabilities,
|
|
2306
2389
|
},
|
|
2307
2390
|
})
|
|
2308
2391
|
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Xiangqi board, black (lowercase) at the top and red (uppercase) at the bottom.
|
|
2
|
+
const width=9, height=10;
|
|
3
|
+
export const initialBoard='rheakaehr/........./.c.....c./p.p.p.p.p/........./........./P.P.P.P.P/.C.....C./........./RHEAKAEHR'.replaceAll('/','');
|
|
4
|
+
export const red='red', black='black';
|
|
5
|
+
export const opponent=side=>side===red?black:red;
|
|
6
|
+
export const sideOf=piece=>piece==='.'||!piece?null:piece===piece.toUpperCase()?red:black;
|
|
7
|
+
export const boardText=board=>board.match(/.{9}/g).join('/');
|
|
8
|
+
export const moveText=(from,to)=>`${from%width+1},${Math.floor(from/width)+1}-${to%width+1},${Math.floor(to/width)+1}`;
|
|
9
|
+
export const pieces={K:'帥',A:'仕',E:'相',H:'馬',R:'車',C:'炮',P:'兵',k:'將',a:'士',e:'象',h:'馬',r:'車',c:'砲',p:'卒'};
|
|
10
|
+
export function parseBoard(text){
|
|
11
|
+
if(typeof text!=='string'||!/^(?:[.rheakcpRHEAKCP]{9}\/){9}[.rheakcpRHEAKCP]{9}$/.test(text))return null;
|
|
12
|
+
const board=text.replaceAll('/','');
|
|
13
|
+
for(const king of ['K','k']){
|
|
14
|
+
const i=board.indexOf(king);
|
|
15
|
+
if(i<0||i!==board.lastIndexOf(king)||!palace(i%width,Math.floor(i/width),sideOf(king)))return null;
|
|
16
|
+
}
|
|
17
|
+
return board;
|
|
18
|
+
}
|
|
19
|
+
const palace=(x,y,side)=>x>=3&&x<=5&&(side===red?y>=7:y<=2);
|
|
20
|
+
const crossed=(y,side)=>side===red?y<=4:y>=5;
|
|
21
|
+
function blockers(board,x,y,tx,ty){
|
|
22
|
+
const dx=Math.sign(tx-x),dy=Math.sign(ty-y);
|
|
23
|
+
let count=0;
|
|
24
|
+
for(let i=x+dx,j=y+dy;i!==tx||j!==ty;i+=dx,j+=dy)if(board[j*width+i]!=='.')count++;
|
|
25
|
+
return count;
|
|
26
|
+
}
|
|
27
|
+
function reaches(board,from,to){
|
|
28
|
+
if(from===to)return false;
|
|
29
|
+
const piece=board[from], target=board[to], side=sideOf(piece);
|
|
30
|
+
if(!side||sideOf(target)===side)return false;
|
|
31
|
+
const x=from%width,y=Math.floor(from/width),tx=to%width,ty=Math.floor(to/width);
|
|
32
|
+
const dx=tx-x,dy=ty-y,a=Math.abs(dx), b=Math.abs(dy);
|
|
33
|
+
switch(piece.toLowerCase()){
|
|
34
|
+
case 'k': return (a+b===1&&palace(tx,ty,side)) || (dx===0&&target.toLowerCase()==='k'&&!blockers(board,x,y,tx,ty));
|
|
35
|
+
case 'a': return a===1&&b===1&&palace(tx,ty,side);
|
|
36
|
+
case 'e': return a===2&&b===2&&!crossed(ty,side)&&board[(y+dy/2)*width+x+dx/2]==='.';
|
|
37
|
+
case 'h': return a*b===2&&board[(y+(b===2?dy/2:0))*width+x+(a===2?dx/2:0)]==='.';
|
|
38
|
+
case 'r': return (!a||!b)&&blockers(board,x,y,tx,ty)===0;
|
|
39
|
+
case 'c': return (!a||!b)&&blockers(board,x,y,tx,ty)===(target==='.'?0:1);
|
|
40
|
+
case 'p': return (!a&&dy===(side===red?-1:1)) || (crossed(y,side)&&a===1&&!b);
|
|
41
|
+
default: return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function checked(board,side){
|
|
45
|
+
const king=board.indexOf(side===red?'K':'k');
|
|
46
|
+
if(king<0)return true;
|
|
47
|
+
for(let i=0;i<board.length;i++)if(sideOf(board[i])===opponent(side)&&reaches(board,i,king))return true;
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
export function placed(board,from,to){
|
|
51
|
+
const cells=board.split('');cells[to]=cells[from];cells[from]='.';
|
|
52
|
+
return cells.join('');
|
|
53
|
+
}
|
|
54
|
+
function legal(board,from,to,side){
|
|
55
|
+
return Number.isInteger(from)&&from>=0&&from<90&&Number.isInteger(to)&&to>=0&&to<90&&sideOf(board[from])===side&&
|
|
56
|
+
board[to].toLowerCase()!=='k'&&reaches(board,from,to)&&!checked(placed(board,from,to),side);
|
|
57
|
+
}
|
|
58
|
+
export function readMove(board,move,side){
|
|
59
|
+
const m=/^([1-9]),(10|[1-9])-([1-9]),(10|[1-9])$/.exec(move);
|
|
60
|
+
if(!m)return null;
|
|
61
|
+
const from=(+m[2]-1)*width+(+m[1]-1), to=(+m[4]-1)*width+(+m[3]-1);
|
|
62
|
+
return legal(board,from,to,side)?{from,to}:null;
|
|
63
|
+
}
|
|
64
|
+
export function movesFor(board,side,only){
|
|
65
|
+
const moves=[];
|
|
66
|
+
for(let from=0;from<width*height;from++){
|
|
67
|
+
if((only!==undefined&&only!==from)||sideOf(board[from])!==side)continue;
|
|
68
|
+
for(let to=0;to<width*height;to++)if(legal(board,from,to,side))moves.push({from,to});
|
|
69
|
+
}
|
|
70
|
+
return moves;
|
|
71
|
+
}
|
|
72
|
+
export function repetition(history,board,turn){
|
|
73
|
+
const match=[];
|
|
74
|
+
history.forEach((entry,i)=>{if(entry.board===board&&entry.turn===turn)match.push(i);});
|
|
75
|
+
if(match.length<3)return null;
|
|
76
|
+
const span=history.slice(match.at(-3)+1,match.at(-1)+1);
|
|
77
|
+
const redMoves=span.filter(position=>position.turn===black);
|
|
78
|
+
const blackMoves=span.filter(position=>position.turn===red);
|
|
79
|
+
if(!redMoves.length || !blackMoves.length)return null;
|
|
80
|
+
const redChecks=redMoves.every(position=>position.check===true);
|
|
81
|
+
const blackChecks=blackMoves.every(position=>position.check===true);
|
|
82
|
+
if(redChecks!==blackChecks)return {winner:redChecks?black:red,detail:'长将判负'};
|
|
83
|
+
return {winner:null,detail:'三次重复局面'};
|
|
84
|
+
}
|