coopani-world-journey 2.2.1 → 2.3.1

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 CHANGED
@@ -1,5 +1,35 @@
1
1
  # 更新日志
2
2
 
3
+ ## 2.3.1 — 2026-11-21(修复 2.1–2.3.0 五组逻辑与边界缺口 + 跨洲机票校准)
4
+
5
+ - **跨洲机票校准 + 整趟算钱按真实可用方式算**:3000km 以上跨国机票按 `2550 + (km - 3000) * 0.56` 计算(11000km ≈ 7030 元,对齐实际报价);`cheapestFare` / `canAffordTrip` / `pledgeAffordable` 传入起终点后按 `usableModesFor` 过滤可用方式,跨海 / 跨洲 / 大陆 ↔ 台湾不再拿 0.21 元/公里的火车价低估票钱;`inviteSomeone` 补齐第二段连通性检查。
6
+ - **参考图与提示词四处防呆**:提前解析出图后端;仅当后端认参考图且真带了人物/服饰/非 `*` 手填图(`hasPersonRef`)时才清空文字 `cast` 并设 `castFromRef`,非方舟后端或仅带 `*` 画风图/场景图不再丢人物描述;后端拒收参考图降级时不再写入 `photos.json`;`castFromRef` 不再在未填 `imageStyle` 时被硬塞写实胶片底色。
7
+ - **同城探针时钟/时区与换城脏数**:`refreshMeetIfDown` 与 `probeNearby` 统一改用目的地当地小时和世界日期(`localMoment(now, city.tz)`),消除倍速与跨时区下的错位;`uiSnapshot().social` 读取 `nearbyProbe` 时先校验 `cityId === hereId`,换城未刷新探针前不再漏出旧城数字。
8
+ - **接约回执与竞态**:`reopenTodayDecision` 拆出 `'here'`(已在目的地或已在会合城等人)并把八点后未判归入 `'reopened'`,消除「已在会合城等人却说这就赶车」与「大白天说太晚/在睡」的自相矛盾;`takeInvite` 返程竞态补上 `isError: true`。
9
+ - **细节补齐**:月报海报水印检查补传 `arkBackend`;手填 `imageRefs` 支持重拍按文件名找回;相册放大层关闭时追加 `removeAttribute('src')`。
10
+
11
+ 测试:新增 6 条回归断言,全量 `test/*.test.mjs` **1195/1195**、`ui-smoke` **25/25**、`clock-sync` **8/8**、`home-e2e` **37/37**、`home-reason` **8/8**、`photo-e2e` **38/38** 通过。
12
+
13
+ ## 2.3.0 — 2026-11-21(钱不够就别接约:算的是整趟,不是一张票)
14
+
15
+ Mr.Q:「钱不够最好让她不要接邀约比较好(花销开关打开的情况下)」。
16
+
17
+ 原来 `takeInvite` 只判了**票**买不买得起(余钱的一半)。可一趟约不是一张票 ——
18
+ 她还得在那儿住几天、吃几天。票买得起、到了那儿第三晚就住不起,第二天只能往回走,
19
+ 那和「买不起票」是同一种难看,只是晚了三天。
20
+
21
+ - **新增「整趟撑得住吗」判据**:`需要 = 票(每段最便宜那张)+(最便宜的一张床 + 一天饭钱)× 天数`,
22
+ 超过余钱就不接。有会合点时两段票都算。
23
+ - **床价不掷骰子**(`cheapestBed()`):同一份状态接不接得上一条约,不该看运气。
24
+ 系数、地板和 `rollLodging` 同一套,不另写一份算价规则。
25
+ - **发约也拦**:自己撑不住的约别发出去 —— 别人接了,到那天只能取消,那边白等一场。
26
+ - **回执把四笔数摆出来**(票 / 床 / 饭 / 手上有多少),否则她只能笼统说「钱不够」,
27
+ 用户没法判断是不是自己预算填错了。
28
+ - **记账关着时一个字不管**:`purseLeft()` 是 `null` 就一律放行,老行为不变。
29
+
30
+ 测试:新增 `test/pledge-purse.test.mjs`(5 条:床价可重放、无钱概念放行、三档预算、
31
+ 接约被拦且回执带数字、钱够照常接)。全量 1189/1189 + `ui-smoke` 25/25。
32
+
3
33
  ## 2.2.1 — 2026-11-21(相册点开看大图)
4
34
 
5
35
  读者来信:「在这个界面做一个一键放大……有时候复制原图路径后打开是一堆桌面的截屏」。
package/README.md CHANGED
@@ -197,6 +197,11 @@ https://cooppetsjourney.top
197
197
  一天最多发 3 条、接 1 条。她在家歇着、在路上、或者已经在往回走的时候接不了 ——
198
198
  那几种状态下这条约一定兑现不了,接了比不接难看。
199
199
 
200
+ **钱不够也不接(2.3.0)。** 打开「记花销」之后,接约前会先算一遍整趟:
201
+ 票钱 + 在那座城住几天、吃几天,超过手上能动的钱就不接,并且把「票 / 一张床 / 一天饭钱 / 还剩多少」
202
+ 四笔数说清楚。发约也一样 —— 自己撑不住的约不往外发。**记账关着时这条不生效**,
203
+ 跟以前完全一样。
204
+
200
205
  **需要服务端支持。** 上面第 2 步那三张表要一起建;如果服务器还是只实现了碰面的旧版,
201
206
  她会直说「那台还是旧版」,而不是假装发出去了。
202
207
 
package/dist/webui.js CHANGED
@@ -1463,6 +1463,7 @@ export default {
1463
1463
  const lbClose = () => {
1464
1464
  lb.hidden = true;
1465
1465
  lbImg.src = '';
1466
+ lbImg.removeAttribute?.('src');
1466
1467
  lbList = [];
1467
1468
  };
1468
1469
  lbX.addEventListener('click', lbClose, { signal: ctx.signal });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coopani-world-journey",
3
- "version": "2.2.1",
3
+ "version": "2.3.1",
4
4
  "type": "module",
5
5
  "description": "大肥鱼环游世界 · 让桌宠真的出门去旅行:走遍 193 座城市,路上耗着真实时间、按当地作息吃饭看日出、写旅行日记,还能在城里偶遇别人的宠物、月底生成一份手账。(需 Coopani 0.2.17+)",
6
6
  "author": {
package/src/photo.ts CHANGED
@@ -2429,7 +2429,7 @@ export function photoPrompt(scene: PhotoScene): string {
2429
2429
  * 「一张真实旅行照片:」+「胶片质感,自然光」把 `anime style` 压过去了。
2430
2430
  * 风格是跟着人物走的,人物说了算,不该再被这几句拽回来。
2431
2431
  */
2432
- const realism = !cast && !custom && !bare;
2432
+ const realism = !cast && !scene.castFromRef && !custom && !bare;
2433
2433
  const lead = bare ? '' : custom ? `${raw}:` : realism ? '一张真实旅行照片:' : '';
2434
2434
 
2435
2435
  /*
@@ -377,6 +377,29 @@ export function rollLodging(
377
377
  return { ...raw, price: withFloor(raw.tier, scaleNum(raw.price, scale)) };
378
378
  }
379
379
 
380
+ /**
381
+ * 这座城最便宜的一张床(只算价,不掷骰子)。
382
+ *
383
+ * ## 为什么要一个「不掷」的版本
384
+ *
385
+ * 用在「接一趟约之前先算整趟撑不撑得住」(2026-11-21,Mr.Q:「钱不够最好让她不要接邀约」)。
386
+ * 那一步要的是**下界**:她到那座城至少要住得下去、吃得上一日三餐。
387
+ *
388
+ * 而 `rollLodging` 是随机的 —— 拿它算判据,同一个决定会时而成立时而不成立:
389
+ * 同一天、同样的钱,接不接得上一条邀约全看那颗骰子。那不像判断,像抽卡。
390
+ *
391
+ * 取 `budget` 与 `dingy` 两张池子里最低的那一档,套上和 `rollLodging`
392
+ * **同一套系数**(国内乘 `priceIdx`、国外乘 `abroadFactor`),
393
+ * 地板也一样走 `withFloor` —— 两处算价不能有第二套规则。
394
+ */
395
+ export function cheapestBed(priceIdx: number, abroad = false, terrain?: Terrain): number {
396
+ const P = poolsOf(abroad, terrain);
397
+ const raw = Math.min(...[...P.budget, ...P.dingy].map((x) => x.price));
398
+ const scale = abroad ? abroadFactor(priceIdx) : priceIdx;
399
+ /* 走 `scaleNum`,不自己 `Math.round` —— 那一行会把价格取整到 10 的倍数,两处算价要同一个数。 */
400
+ return withFloor('dingy', Math.max(1, scaleNum(raw, scale)));
401
+ }
402
+
380
403
  /**
381
404
  * 真名的语义 → 更贴的类别。**档次不动,只换说法。**
382
405
  *
@@ -653,6 +653,13 @@ export const photoMethods: Record<string, any> = {
653
653
  */
654
654
  const castOn = !!this.cfg.imageCast
655
655
  && seededRandom(`${dateKey}:${sceneId}:cast`)() <= this.cfg.imageCastChance;
656
+ const backend = resolveImageBackend(this.cfg);
657
+ if (backend.sizeNote && !this.imageSizeNoted) {
658
+ this.imageSizeNoted = true;
659
+ this.log?.info(backend.sizeNote);
660
+ }
661
+ const canSendRefs = backend.protocol !== 'comfyui' && this.refsAllowedBackend(backend);
662
+
656
663
  /*
657
664
  * 参考图(2026-11-20)。**默认关**,开了才读图鉴与手填路径。
658
665
  *
@@ -661,11 +668,15 @@ export const photoMethods: Record<string, any> = {
661
668
  * 并在日志里说一句,免得他以为"重拍还是原来那张脸"。
662
669
  */
663
670
  const refPick = (() => {
664
- if (!this.cfg.imageUseRefs) return { paths: [] as string[], labels: [] as string[], dropped: [] as string[] };
671
+ if (!this.cfg.imageUseRefs) {
672
+ return { paths: [] as string[], labels: [] as string[], dropped: [] as string[], hasPersonRef: false };
673
+ }
665
674
  const remembered = override?.refs ?? [];
666
675
  if (remembered.length) {
667
676
  const found = this.findLibraryRefsByName(remembered);
668
- if (found.length) return { paths: found, labels: remembered, dropped: [] as string[] };
677
+ if (found.paths.length) {
678
+ return { paths: found.paths, labels: remembered, dropped: [] as string[], hasPersonRef: found.hasPersonRef };
679
+ }
669
680
  this.log?.info(`重拍沿用的参考图已不在图鉴里(${remembered.join('、')}),改按当前配置重新取。`);
670
681
  }
671
682
  return this.collectRefPaths(subject, castOn, spot, String(this.cfg.imageCast ?? ''), this.photoDoingNow(city, hour));
@@ -676,6 +687,13 @@ export const photoMethods: Record<string, any> = {
676
687
  this.log?.warn(`参考图跳过 ${gone.length} 张(读不到或太大,单张上限 4MB):${gone.slice(0, 3).join('、')}`);
677
688
  }
678
689
  const refsOn = refPack.urls.length > 0;
690
+ /*
691
+ * 只有「后端真的收参考图」且「这批参考图里真有人物/服饰/手填人物图」时,
692
+ * 才把文字 `cast` 交给参考图接管。
693
+ * - 非方舟后端不发 `image` 字段,抹掉 `cast` 会导致画面彻底丢掉人物描述;
694
+ * - 只有场景参考图或 `*` 画风图时抹掉 `cast`,会让模型拿风景照当人脸。
695
+ */
696
+ const personRefActive = refsOn && canSendRefs && refPick.hasPersonRef;
679
697
  /*
680
698
  * 有人那几张可以用另一套风格(`imageStyleCast`)。留空就还是 `imageStyle`。
681
699
  * 这样「风景写实 + 自拍二次元」才成立 —— 风格和有没有人本来就是两件事。
@@ -714,8 +732,8 @@ export const photoMethods: Record<string, any> = {
714
732
  * 有参考图时**不写人物描述**:两套外观同时给,模型会各听一半。
715
733
  * 外观交给图,提示词只留「画面里只有这一个人」这条存在性约束。
716
734
  */
717
- cast: castOn && !refsOn ? this.cfg.imageCast : '',
718
- ...(castOn && refsOn ? { castFromRef: true } : {}),
735
+ cast: castOn && !personRefActive ? this.cfg.imageCast : '',
736
+ ...(castOn && personRefActive ? { castFromRef: true } : {}),
719
737
  // 抬头还是看脚下。天空照仍受当地时刻和天气约束。
720
738
  view,
721
739
  /* 她自己写的那一句(2026-11-10)。空 = 不出现,老行为不变。 */
@@ -821,11 +839,6 @@ export const photoMethods: Record<string, any> = {
821
839
  *
822
840
  * `sizeNote` 只在第一次说一遍:它每次都成立,刷屏没有信息量。
823
841
  */
824
- const backend = resolveImageBackend(this.cfg);
825
- if (backend.sizeNote && !this.imageSizeNoted) {
826
- this.imageSizeNoted = true;
827
- this.log?.info(backend.sizeNote);
828
- }
829
842
  const shot = backend.protocol === 'comfyui'
830
843
  ? await shootComfy({
831
844
  api: backend.api,
@@ -883,9 +896,9 @@ export const photoMethods: Record<string, any> = {
883
896
  ...(this.cfg.imageTimeoutSec > 0 ? { timeoutMs: this.cfg.imageTimeoutSec * 1000 } : {}),
884
897
  ...(signal ? { signal } : {}),
885
898
  size: backend.size,
886
- ...(refsOn && this.refsAllowedBackend(backend) ? { refs: refPack.urls } : {}),
899
+ ...(refsOn && canSendRefs ? { refs: refPack.urls } : {}),
887
900
  });
888
- if (refsOn && !this.refsAllowedBackend(backend)) {
901
+ if (refsOn && !canSendRefs) {
889
902
  this.log?.warn(
890
903
  `配了 ${refPack.urls.length} 张参考图,但当前服务端(${backend.model || backend.api})不认 image 字段,`
891
904
  + '这一张按纯文生图发;要用参考图请换成火山方舟的 seedream 系模型。',
@@ -1010,7 +1023,7 @@ export const photoMethods: Record<string, any> = {
1010
1023
  */
1011
1024
  const rec: PhotoRecord = {
1012
1025
  handle,
1013
- ...(refPack.names.length ? { refs: refPack.names } : {}),
1026
+ ...(refsOn && canSendRefs && !shot.refsDropped && refPack.names.length ? { refs: refPack.names } : {}),
1014
1027
  cityId: sceneId,
1015
1028
  cityName: onRoad ? '路上' : city.name,
1016
1029
  dateKey,
@@ -1326,7 +1339,7 @@ export const photoMethods: Record<string, any> = {
1326
1339
  ...(this.cfg.imageTimeoutSec > 0 ? { timeoutMs: this.cfg.imageTimeoutSec * 1000 } : {}),
1327
1340
  size: posterBackend.size,
1328
1341
  });
1329
- const bytes = shouldCropWatermark(this.cfg.imageWatermark, this.cfg.imageProtocol)
1342
+ const bytes = shouldCropWatermark(this.cfg.imageWatermark, this.cfg.imageProtocol, this.arkBackend(posterBackend))
1330
1343
  && shot.mime === 'image/png'
1331
1344
  ? cropBottom(shot.bytes, WATERMARK_CROP_RATIO)
1332
1345
  : shot.bytes;
@@ -1497,14 +1510,16 @@ export const photoMethods: Record<string, any> = {
1497
1510
  spot: string,
1498
1511
  castHint: string,
1499
1512
  doing: string,
1500
- ): { paths: string[]; labels: string[]; dropped: string[] } {
1501
- const out: { paths: string[]; labels: string[]; dropped: string[] } = { paths: [], labels: [], dropped: [] };
1513
+ ): { paths: string[]; labels: string[]; dropped: string[]; hasPersonRef: boolean } {
1514
+ const out: { paths: string[]; labels: string[]; dropped: string[]; hasPersonRef: boolean } = {
1515
+ paths: [], labels: [], dropped: [], hasPersonRef: false,
1516
+ };
1502
1517
  if (!this.cfg.imageUseRefs) return out;
1503
1518
  // 抬头拍天:带人物参考图只会让模型往天上塞人。
1504
1519
  if (subject === 'sky') return out;
1505
1520
 
1506
- const addEntry = (root: string, cat: string, entry: LibEntry | null, max: number): void => {
1507
- if (!entry) return;
1521
+ const addEntry = (root: string, cat: string, entry: LibEntry | null, max: number): number => {
1522
+ if (!entry) return 0;
1508
1523
  let n = 0;
1509
1524
  for (const img of entry.images) {
1510
1525
  if (n >= max) break;
@@ -1515,18 +1530,20 @@ export const photoMethods: Record<string, any> = {
1515
1530
  out.labels.push(img);
1516
1531
  n += 1;
1517
1532
  }
1533
+ return n;
1518
1534
  };
1519
1535
 
1520
1536
  try {
1521
1537
  const pack = this.libraryPack();
1522
1538
  if (pack) {
1523
1539
  // 人物最多两张:第一张定脸,第二张补侧面/全身;再多只是把请求体撑大。
1524
- addEntry(pack.root, 'characters', castOn ? matchLibraryEntry(
1540
+ const charAdded = addEntry(pack.root, 'characters', castOn ? matchLibraryEntry(
1525
1541
  loadLibraryCategory(pack.root, 'characters'), [castHint, this.opts.botName ?? ''], true,
1526
1542
  ) : null, 2);
1527
- addEntry(pack.root, 'outfits', castOn ? matchLibraryEntry(
1543
+ const outfitAdded = addEntry(pack.root, 'outfits', castOn ? matchLibraryEntry(
1528
1544
  loadLibraryCategory(pack.root, 'outfits'), [pack.outfitHint, doing, castHint], false,
1529
1545
  ) : null, 1);
1546
+ if (charAdded > 0 || outfitAdded > 0) out.hasPersonRef = true;
1530
1547
  addEntry(pack.root, 'scenes', matchLibraryEntry(
1531
1548
  loadLibraryCategory(pack.root, 'scenes'), [spot], false,
1532
1549
  ), 1);
@@ -1560,6 +1577,7 @@ export const photoMethods: Record<string, any> = {
1560
1577
  if (out.paths.includes(fp)) continue;
1561
1578
  out.paths.push(fp);
1562
1579
  out.labels.push(fp);
1580
+ if (!always) out.hasPersonRef = true;
1563
1581
  }
1564
1582
  return out;
1565
1583
  },
@@ -1622,24 +1640,47 @@ export const photoMethods: Record<string, any> = {
1622
1640
  return /volces\.com|ark\.cn-beijing/.test(host) || /doubao-seedream/.test(model);
1623
1641
  },
1624
1642
 
1625
- /** 按文件名在库内找回参考图(重拍沿用旧名单用)。找不到就返回空,交给调用方回退。 */
1626
- findLibraryRefsByName(names: readonly string[]): string[] {
1627
- if (!names.length) return [];
1628
- const pack = this.libraryPack();
1629
- if (!pack) return [];
1643
+ /** 按文件名在库内及手填路径里找回参考图(重拍沿用旧名单用)。找不到就返回空,交给调用方回退。 */
1644
+ findLibraryRefsByName(names: readonly string[]): { paths: string[]; hasPersonRef: boolean } {
1645
+ if (!names.length) return { paths: [], hasPersonRef: false };
1630
1646
  const out: string[] = [];
1631
- for (const cat of ['characters', 'outfits', 'scenes', 'props']) {
1632
- const dir = join(pack.root, cat);
1633
- if (!existsSync(dir)) continue;
1634
- for (const sub of readdirSync(dir).sort()) {
1635
- for (const nm of names) {
1636
- if (!nm || nm.includes('/') || nm.includes('\\')) continue;
1637
- const fp = join(dir, sub, nm);
1638
- if (existsSync(fp) && !out.includes(fp)) out.push(fp);
1647
+ let hasPersonRef = false;
1648
+ const pack = this.libraryPack();
1649
+ if (pack) {
1650
+ for (const cat of ['characters', 'outfits', 'scenes', 'props']) {
1651
+ const dir = join(pack.root, cat);
1652
+ if (!existsSync(dir)) continue;
1653
+ for (const sub of readdirSync(dir).sort()) {
1654
+ for (const nm of names) {
1655
+ if (!nm || nm.includes('/') || nm.includes('\\')) continue;
1656
+ const fp = join(dir, sub, nm);
1657
+ if (existsSync(fp) && !out.includes(fp)) {
1658
+ out.push(fp);
1659
+ if (cat === 'characters' || cat === 'outfits') hasPersonRef = true;
1660
+ }
1661
+ }
1639
1662
  }
1640
1663
  }
1641
1664
  }
1642
- return out;
1665
+ // 兜底匹配手填参考图里的文件名,避免非图鉴用户重拍时每次都回退重建。
1666
+ const manualLines = String(this.cfg.imageRefs ?? '').split(/\r?\n/);
1667
+ for (const nm of names) {
1668
+ if (!nm || nm.includes('/') || nm.includes('\\')) continue;
1669
+ for (const line of manualLines) {
1670
+ const marked = line.trim();
1671
+ if (!marked) continue;
1672
+ const always = marked.startsWith('*');
1673
+ const raw = always ? marked.slice(1).trim() : marked;
1674
+ if (!raw) continue;
1675
+ const fp = raw.startsWith('/') || /^[a-zA-Z]:[\\/]/.test(raw) ? raw : resolve(this.opts.dataDir, raw);
1676
+ const base = fp.split(/[\\/]/).pop();
1677
+ if (base === nm && existsSync(fp) && !out.includes(fp)) {
1678
+ out.push(fp);
1679
+ if (!always) hasPersonRef = true;
1680
+ }
1681
+ }
1682
+ }
1683
+ return { paths: out, hasPersonRef };
1643
1684
  },
1644
1685
 
1645
1686
  photoDoingNow(city: { id: string; tz: string }, hour: number): string {
@@ -30,7 +30,7 @@ import { actionsPrompt } from './pet-vocab.ts';
30
30
  import { VersionCheck } from './version-check.ts';
31
31
  import { AMAP_KEY_NAME, IMAGE_KEY_NAME, adoptKey, readKey, type KeyPorts } from './secrets.ts';
32
32
  import {
33
- rollLodging, rerollLodging, withHotel, lodgingLabel,
33
+ rollLodging, rerollLodging, withHotel, lodgingLabel, cheapestBed,
34
34
  type Lodging, type LodgingWant,
35
35
  } from './plan/lodging.ts';
36
36
  import { HotelDirectory } from './geo/hotels.ts';
@@ -426,10 +426,14 @@ export const purseMethods: Record<string, any> = {
426
426
  *
427
427
  * 2026-11-03 模拟抓到的:不分国内国际的话,兰州飞大阪 2600 公里只要 1040 块,
428
428
  * 比现实便宜一半 —— 她于是动不动就飞出去,预算 3000 的人 48 天花掉四万七。
429
+ *
430
+ * 2026-11-21 Mr.Q 实查跨洲机票约 7000 元(兰州 → 纽约 ~11000km):
431
+ * 3000km 处接上 3000 × 0.85 = 2550,往后按 0.56 元/公里递加(11000km ≈ 7030 元)。
429
432
  */
430
433
  const per = crossBorder ? 0.85 : 0.4;
431
- const base = crossBorder ? 2400 : 1200;
432
- return (km <= 3000 ? km * per : base + (km - 3000) * 0.9) * seatMult;
434
+ const base = crossBorder ? 2550 : 1200;
435
+ const tailPer = crossBorder ? 0.56 : 0.9;
436
+ return (km <= 3000 ? km * per : base + (km - 3000) * tailPer) * seatMult;
433
437
  }
434
438
  /*
435
439
  * 铁路分段算(2026-11-08):短途高铁、长途卧铺,单价差一倍。
@@ -569,15 +573,73 @@ export const purseMethods: Record<string, any> = {
569
573
  * 门槛是余钱的八成:留两成,到家之后还要过日子。
570
574
  * 没记账、预算填 0 时一律算回得去。
571
575
  */
572
- canAffordTrip(km: number, crossBorder = false): boolean {
576
+ canAffordTrip(km: number, crossBorder = false, pair?: { from: City; to: City }): boolean {
573
577
  const left = this.purseLeft();
574
578
  if (left === null) return true;
575
579
  if (left <= 0) return false;
576
- const cheapest = Math.min(...(['bus', 'train', 'plane', 'ship', 'car'] as const)
577
- .map((id) => this.fareOf(id, km, crossBorder)));
580
+ const cheapest = this.cheapestFare(km, crossBorder, pair);
578
581
  return cheapest <= left * 0.8;
579
582
  },
580
583
 
584
+ /**
585
+ * 这一对上最便宜那张票。
586
+ *
587
+ * 给了 `from / to` 时,只算这对城市间**真能走的方式**(`usableModesFor`):
588
+ * 跨海 / 跨洲 / 大陆 ↔ 台湾不能坐火车,不算不存在的 0.21 元/公里地面票。
589
+ */
590
+ cheapestFare(km: number, crossBorder = false, pair?: { from: City; to: City }): number {
591
+ const usable = pair ? usableModesFor(pair.from, pair.to, km).map((m) => m.id) : [];
592
+ const ids = usable.length ? usable : (['bus', 'train', 'plane', 'ship', 'car'] as const);
593
+ return Math.min(...ids.map((id) => this.fareOf(id, km, crossBorder)));
594
+ },
595
+
596
+
597
+ /**
598
+ * 接一趟约,**整趟**撑不撑得住(2026-11-21,Mr.Q:「钱不够最好让她不要接邀约」)。
599
+ *
600
+ * ## 为什么票钱那道闸不够
601
+ *
602
+ * `takeInvite` 早就判了「票买不买得起」,判据是 `affordMode` 的一半余钱。
603
+ * 但一趟约不是一张票:她还要在那儿住 `days` 天、吃 `days` 天。
604
+ * 票买得起、到了那儿第三晚就住不起,第二天只能往回走 ——
605
+ * 那和「没买起票」是同一种难看,只是晚了三天。
606
+ *
607
+ * ## 判据只有一条:下界 ≤ 余钱
608
+ *
609
+ * ```
610
+ * 需要 = 票(每段最便宜那张) + (最便宜的一张床 + 一日三餐)× 天数
611
+ * ```
612
+ *
613
+ * - 床用 `cheapestBed()`,**不掷骰子**:同一份状态接不接得上一条约,不该看运气。
614
+ * - 不乘折扣系数:票钱那一层已经卡在「余钱一半」,这里再乘一遍等于双重要求,
615
+ * 结果是她几乎再也接不上任何约。要的是「撑得住」,不是「宽裕」。
616
+ * - 记账关着 / 预算不限时 `purseLeft()` 是 `null` → **一律放行**(老行为一个字不变)。
617
+ *
618
+ * 回执要把四笔数都摆出来,否则她只能笼统说「钱不够」,用户没法判断是不是自己预算填错了。
619
+ */
620
+ pledgeAffordable(
621
+ legs: readonly { readonly km: number; readonly crossBorder?: boolean; readonly from?: City; readonly to?: City }[],
622
+ days: number,
623
+ to: City,
624
+ ): {
625
+ ok: boolean; need: number; left: number | null;
626
+ fare: number; bed: number; meals: number; days: number;
627
+ } {
628
+ const left = this.purseLeft();
629
+ const n = Math.min(14, Math.max(1, Math.round(Number(days) || 1)));
630
+ const bed = cheapestBed(to.priceIdx ?? 1, to.country !== 'CN', terrainOf(to));
631
+ /*
632
+ * **票钱取整**。`fareOf` 是 0.33 元/公里那种算式,直接拼进回执会变成
633
+ * 「票 204.60000000000002」—— 浮点尾巴进了给人看的句子,一眼就是机器写的。
634
+ */
635
+ const fare = Math.round(legs.reduce((sum, l) => {
636
+ const pair = l.from && l.to ? { from: l.from, to: l.to } : undefined;
637
+ return sum + this.cheapestFare(l.km, l.crossBorder === true, pair);
638
+ }, 0));
639
+ const need = fare + (bed + MEALS_PER_DAY) * n;
640
+ return { ok: left === null || need <= left, need, left, fare, bed, meals: MEALS_PER_DAY, days: n };
641
+ },
642
+
581
643
 
582
644
  /**
583
645
  * 买得起哪种票。
@@ -562,7 +562,7 @@ export const socialMethods: Record<string, any> = {
562
562
  this.meetRetryStep = Math.min(this.meetRetryStep + 1, 8);
563
563
  const here = this.cityOrNull(this.st.hereId);
564
564
  if (!here) return;
565
- const slot = slotOf(now.getHours());
565
+ const slot = slotOf(localMoment(now, here.tz).hour);
566
566
  const b = await findNeighbors(meet, here.id, slot).catch(() => null);
567
567
  if (!b?.ok) return;
568
568
  /*
@@ -572,7 +572,7 @@ export const socialMethods: Record<string, any> = {
572
572
  * (失败也占住那一小时),面板上的「今天来过几只」还要再等近一小时 ——
573
573
  * 灯绿了、数字还是错的,等于只修了一半。
574
574
  */
575
- this.noteNeighbors(here.id, localMoment(this.realNow(), here.tz).dateKey, b, real);
575
+ this.noteNeighbors(here.id, localMoment(now, here.tz).dateKey, b, real);
576
576
  },
577
577
 
578
578
 
@@ -635,7 +635,8 @@ export const socialMethods: Record<string, any> = {
635
635
  if (!city) return;
636
636
  const realDate = this.realNow();
637
637
  const real = realDate.getTime();
638
- const day = localMoment(realDate, city.tz).dateKey;
638
+ const moment = localMoment(now, city.tz);
639
+ const day = moment.dateKey;
639
640
  const same = this.nearbyProbe?.cityId === city.id && this.nearbyProbe?.day === day;
640
641
  if (same && real - (this.nearbyProbe?.at ?? 0) < STATUS_PROBE_MS) return;
641
642
  /*
@@ -647,7 +648,7 @@ export const socialMethods: Record<string, any> = {
647
648
  here: same ? (this.nearbyProbe?.here ?? 0) : 0,
648
649
  n: same ? (this.nearbyProbe?.n ?? 0) : 0,
649
650
  };
650
- const b = await findNeighbors(meet, city.id, slotOf(now.getHours())).catch(() => null);
651
+ const b = await findNeighbors(meet, city.id, slotOf(moment.hour)).catch(() => null);
651
652
  if (!b?.ok) {
652
653
  /*
653
654
  * 断线要亮灯,并且占住退避位(2026-11-20 回补)。
@@ -885,8 +886,38 @@ export const socialMethods: Record<string, any> = {
885
886
  }
886
887
  /* 见面城和目的地相同时没有「见面」这一级,按老口径发。 */
887
888
  if (meetCity && meetCity.id === c.id) meetCity = null;
889
+ const fromStop = meetCity ?? here;
890
+ if (!canTravel(fromStop, c)) {
891
+ return {
892
+ text: `${meetCity ? `从见面的${meetCity.name}` : `从${here.name}这儿`}没路去${c.name}(隔着海,或者那边没有机场)—— 先别约人,约了也走不成。`,
893
+ isError: true,
894
+ };
895
+ }
888
896
 
889
897
  const d = Math.min(14, Math.max(1, Math.round(Number(days) || 2)));
898
+ /*
899
+ * **自己撑不住的约不要发**(2026-11-21,和 `takeInvite` 同一条判据)。
900
+ *
901
+ * 发出去之后别人接了,这趟就变成「她已经答应过的事」—— 到那天发现钱不够,
902
+ * 只能再去取消,那边的人白等一场。**入口拦一次,比事后取消两次便宜。**
903
+ */
904
+ const legs = meetCity
905
+ ? [
906
+ { from: here, to: meetCity, km: Math.round(distanceKm(here, meetCity)), crossBorder: here.country !== meetCity.country },
907
+ { from: meetCity, to: c, km: Math.round(distanceKm(meetCity, c)), crossBorder: meetCity.country !== c.country },
908
+ ]
909
+ : [{ from: here, to: c, km: Math.round(distanceKm(here, c)), crossBorder: here.country !== c.country }];
910
+ const trip = this.pledgeAffordable(legs, d, c);
911
+ if (!trip.ok) {
912
+ return {
913
+ text: `这趟她自己算下来撑不住:票 ${trip.fare} + ${trip.days} 天住吃`
914
+ + `(一张床最低 ${trip.bed}、一天饭钱 ${trip.meals})≈ ${trip.need},`
915
+ + `手上能动用的只有 ${trip.left}。`
916
+ + '先别约人 —— 发出去别人接了,到那天她只能取消,那边白等一场。'
917
+ + '换个近点的地方、少待几天,或者先把花销关掉。',
918
+ isError: true,
919
+ };
920
+ }
890
921
  const r = await sendInvite(meet, {
891
922
  from: here.id,
892
923
  to: c.id,
@@ -1180,6 +1211,33 @@ export const socialMethods: Record<string, any> = {
1180
1211
  isError: true,
1181
1212
  };
1182
1213
  }
1214
+ /*
1215
+ * **整趟撑不住也不接**(2026-11-21,Mr.Q:「钱不够最好让她不要接邀约(花销开关打开的情况下)」)。
1216
+ *
1217
+ * 上面那条只判了票。一趟约不是一张票:她还得在那儿住几天、吃几天。
1218
+ * 票买得起、到了那儿第三晚住不起,第二天只能往回走 —— 和「买不起票」是同一种难看,
1219
+ * 只是晚了三天才丢人。
1220
+ *
1221
+ * 有会合点的时候两段票都要算:去成都的票和从成都去拉萨的票不是一个价。
1222
+ * 记账关着时 `purseLeft()` 是 `null`,`pledgeAffordable` 一律放行 —— 老行为不变。
1223
+ */
1224
+ const legs = useMeet
1225
+ ? [
1226
+ { from: here, to: useMeet, km: Math.round(distanceKm(here, useMeet)), crossBorder: here.country !== useMeet.country },
1227
+ { from: useMeet, to: dest, km: Math.round(distanceKm(useMeet, dest)), crossBorder: useMeet.country !== dest.country },
1228
+ ]
1229
+ : [{ from: here, to: firstStop, km, crossBorder: here.country !== firstStop.country }];
1230
+ const trip = this.pledgeAffordable(legs, one.days, dest);
1231
+ if (!trip.ok) {
1232
+ return {
1233
+ text: `这趟她撑不住:票 ${trip.fare}(最便宜那种)+ ${trip.days} 天住吃`
1234
+ + `(一张床最低 ${trip.bed}、一天饭钱 ${trip.meals})≈ ${trip.need},`
1235
+ + `手上能动用的只有 ${trip.left}。`
1236
+ + '先别接 —— 到了那儿住不了两晚就得往回走,比不答应更难看。'
1237
+ + '(要把花销关掉、或者把预算调大,这条才会放开。)',
1238
+ isError: true,
1239
+ };
1240
+ }
1183
1241
  /*
1184
1242
  * **赶得到吗**(2026-11-07 的 invite 档抓到)。
1185
1243
  *
@@ -1242,7 +1300,7 @@ export const socialMethods: Record<string, any> = {
1242
1300
  * 她已经往家走了,接了也兑现不了 —— 那才是真的「答应了做不到」。
1243
1301
  */
1244
1302
  if (this.st.returning) {
1245
- return { text: '她已经在往回走了,这时候接不了新的约 —— 先到家再说。' };
1303
+ return { text: '她已经在往回走了,这时候接不了新的约 —— 先到家再说。', isError: true };
1246
1304
  }
1247
1305
  const r = await acceptInvite(meet, id);
1248
1306
  if (!r.ok) return { text: `没接成:${r.reason}。`, isError: true };
@@ -1355,7 +1413,9 @@ export const socialMethods: Record<string, any> = {
1355
1413
  : reopen === 'at-hour'
1356
1414
  // 八点前接的。那天还没判过 —— 说「明天才走」同样是假话。
1357
1415
  ? '\n(今天八点那个点会判走不走,到时候多半就直接动身了。别把时间说死。)'
1358
- : '\n(今天这一趟不安排动身了:这会儿太晚,或者她在睡。别跟他说「这就走」。)')
1416
+ : reopen === 'here'
1417
+ ? ''
1418
+ : '\n(今天这一趟不安排动身了:这会儿太晚,或者她在睡。别跟他说「这就走」。)')
1359
1419
  + '这件事该跟他说一句 —— 说清跟谁、先去哪儿碰头、去哪儿、几天,别当成通知念。',
1360
1420
  };
1361
1421
  },
@@ -1087,7 +1087,8 @@ export const webUiMethods: Record<string, any> = {
1087
1087
  social: (() => {
1088
1088
  const p = this.activePledge(now);
1089
1089
  const configured = String(this.cfg.meetUrl ?? '').trim() !== '';
1090
- const nearby = this.plan?.neighbors.length ?? this.nearbyProbe?.n ?? 0;
1090
+ const probed = this.nearbyProbe?.cityId === this.st.hereId ? this.nearbyProbe : null;
1091
+ const nearby = this.plan?.neighbors.length ?? probed?.n ?? 0;
1091
1092
  /*
1092
1093
  * 今天这座城来过几只**别人**(2026-11-20)。
1093
1094
  *
@@ -1102,9 +1103,7 @@ export const webUiMethods: Record<string, any> = {
1102
1103
  *
1103
1104
  * 两个都同城同日才减一;其余情况原样报。
1104
1105
  */
1105
- const probed = this.nearbyProbe;
1106
1106
  const ownCounted = !!probed
1107
- && probed.cityId === this.st.hereId
1108
1107
  && this.presenceReported?.cityId === probed.cityId
1109
1108
  && this.presenceReported?.day === probed.day;
1110
1109
  const hereToday = Math.max(0, (probed?.here ?? 0) - (ownCounted ? 1 : 0));
package/src/world.ts CHANGED
@@ -2776,10 +2776,16 @@ export class JourneyWorld implements World {
2776
2776
  * - `at-hour`:今天的决策点还没到(当地 8 点前),那一拍自己会读到
2777
2777
  * - `later`:太晚、在睡、或者本来就在那座城 —— 今天不安排动身
2778
2778
  */
2779
- private reopenTodayDecision(now: Date): 'reopened' | 'at-hour' | 'later' {
2779
+ private reopenTodayDecision(now: Date): 'reopened' | 'at-hour' | 'here' | 'later' {
2780
2780
  if (this.st.phase !== 'staying') return 'later';
2781
2781
  const here = this.cityOrNull(this.st.hereId);
2782
2782
  if (!here) return 'later';
2783
+ /* 约定的下一站就是脚下这座城(或就在会合城等人)—— 本来就在,不用赶车。 */
2784
+ const pledge = this.activePledge(now);
2785
+ if (pledge && (this.pledgeStop(pledge) === here.id
2786
+ || (pledge.meetCityId && !pledge.arrivedAt && pledge.meetArrivedAt && here.id === pledge.meetCityId))) {
2787
+ return 'here';
2788
+ }
2783
2789
  const moment = localMoment(now, here.tz);
2784
2790
  /*
2785
2791
  * 21 点之后不重开。`depart` 本身有 7–21 这个窗口,`moveOn` 却没有 ——
@@ -2787,15 +2793,13 @@ export class JourneyWorld implements World {
2787
2793
  */
2788
2794
  if (moment.decimal >= 21) return 'later';
2789
2795
  if (this.asleepUntil() > this.realNow().getTime()) return 'later';
2790
- /* 约定的下一站就是脚下这座城 —— 她本来就在,没有什么可动身的。 */
2791
- const pledge = this.activePledge(now);
2792
- if (pledge && this.pledgeStop(pledge) === here.id) return 'later';
2793
2796
  /*
2794
2797
  * 今天的决策点还没到(当地八点前):不用清,那一拍自己会读到 pledge。
2795
2798
  * **但也不能说「今天不动身」** —— 那是另一句错话。
2796
2799
  */
2797
2800
  if (moment.decimal < DECIDE_HOUR) return 'at-hour';
2798
- if (this.st.decidedOn !== moment.dateKey) return 'at-hour';
2801
+ /* 八点已过且今天还没判过:下一拍会立刻进决策并动身,语义等同 reopened。 */
2802
+ if (this.st.decidedOn !== moment.dateKey) return 'reopened';
2799
2803
 
2800
2804
  this.st = { ...this.st, decidedOn: null };
2801
2805
  this.persist();