cortico-world-fun 0.1.6 → 0.2.0
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 +18 -1
- package/PUBLISHING.md +18 -1
- package/README.md +26 -3
- package/describe.json +150 -22
- package/dist/webui.js +179 -15
- package/package.json +3 -3
- package/src/ENV_PROMPT.md +8 -40
- package/src/aquarium.js +27 -0
- package/src/choices.js +54 -0
- package/src/definition.js +30 -14
- package/src/events.js +71 -0
- package/src/keepsakes.js +36 -175
- package/src/names.js +9 -0
- package/src/state.js +115 -5
- package/src/venues.js +2 -3
- package/src/wishes.js +114 -0
- package/src/world.js +287 -115
package/dist/webui.js
CHANGED
|
@@ -110,6 +110,10 @@ const CSS = `
|
|
|
110
110
|
.fun-trip-when{font-size:11.5px;color:var(--f-dim);white-space:nowrap}
|
|
111
111
|
.fun-trip-sum{margin-top:3px;font-size:12.5px}
|
|
112
112
|
.fun-trip-extras{margin-top:5px;font-size:12px;color:var(--f-dim)}
|
|
113
|
+
.fun-trip-actions{display:flex;gap:8px;align-items:center;margin-top:7px}
|
|
114
|
+
.fun-trip-actions{display:flex;gap:6px;align-items:center;margin-top:7px}
|
|
115
|
+
.fun-trip-error{font-size:12px;color:#d9534f}
|
|
116
|
+
.fun-toggle[aria-pressed="true"]{border-color:var(--f-accent);background:color-mix(in srgb,var(--f-accent) 12%,var(--f-card))}
|
|
113
117
|
.fun-stats{display:flex;gap:16px;flex-wrap:wrap;margin-bottom:12px;padding:9px 12px;border:1px solid var(--f-line);border-radius:var(--radius-sm,6px);background:var(--f-card)}
|
|
114
118
|
.fun-stat b{display:block;font-size:17px;font-weight:600;line-height:1.25}
|
|
115
119
|
.fun-stat span{font-size:11.5px;color:var(--f-dim)}
|
|
@@ -447,12 +451,19 @@ function mountPlaces(ctx) {
|
|
|
447
451
|
const v = editing.venue ?? {};
|
|
448
452
|
// 预设编辑:改的是覆盖层,不删场所;没改过的字段仍跟着预设升级走。
|
|
449
453
|
const isPreset = Boolean(v.id) && !v.userVenue;
|
|
454
|
+
const phases = isPreset && Array.isArray(v.phases) ? v.phases : [];
|
|
455
|
+
const descPhases = phases.filter((ph) => ph.overridesDesc);
|
|
456
|
+
const areaPhases = phases.filter((ph) => ph.overridesAreas);
|
|
457
|
+
const phaseNames = (items) => items.map((ph) => `${ph.label} ${ph.from}–${ph.to}`).join('、');
|
|
458
|
+
const scopeNote = (items, noun) => items.length
|
|
459
|
+
? `通用${noun}会保存;在${phaseNames(items)}使用预设时段${noun},未命中这些时段时才使用这里的内容。保存不会同步修改时段。`
|
|
460
|
+
: '';
|
|
450
461
|
const verb = v.food?.verb ?? 'none';
|
|
451
462
|
const foodItems = v.food?.items ?? [];
|
|
452
463
|
const errorNode = el('div', { class: 'fun-form-error', text: formError });
|
|
453
464
|
|
|
454
465
|
const field = (label, key, opts = {}) => {
|
|
455
|
-
const { type = 'text', value = '', hint = '', multiline = false, options = null, rows = '3' } = opts;
|
|
466
|
+
const { type = 'text', value = '', hint = '', note = '', multiline = false, options = null, rows = '3' } = opts;
|
|
456
467
|
let input;
|
|
457
468
|
if (options) {
|
|
458
469
|
input = el('select', {});
|
|
@@ -467,7 +478,8 @@ function mountPlaces(ctx) {
|
|
|
467
478
|
}
|
|
468
479
|
fields[key] = input;
|
|
469
480
|
return el('label', { class: 'fun-field' },
|
|
470
|
-
el('span', { class: 'fun-field-label', text: label }), input
|
|
481
|
+
el('span', { class: 'fun-field-label', text: label }), input,
|
|
482
|
+
note ? el('span', { class: 'fun-field-scope fun-note', text: note }) : null);
|
|
471
483
|
};
|
|
472
484
|
|
|
473
485
|
const save = async () => {
|
|
@@ -536,6 +548,12 @@ function mountPlaces(ctx) {
|
|
|
536
548
|
return el('div', { class: 'fun-form' },
|
|
537
549
|
el('div', { class: 'fun-form-title', text: title }),
|
|
538
550
|
el('div', { class: 'fun-form-note', text: note }),
|
|
551
|
+
phases.length ? el('div', { class: 'fun-form-phases' },
|
|
552
|
+
el('div', { class: 'fun-form-note', text: `现在 ${data.nowHm} · ${v.phase ? `当前阶段:${v.phase}` : '当前未命中预设时段,使用通用内容'}。编辑通用字段不会改变以下预设时段及其内容;修改营业时间也不会移动这些时段。` }),
|
|
553
|
+
el('ul', { class: 'fun-list' }, phases.map((ph) => {
|
|
554
|
+
const covered = [ph.overridesDesc ? '描写(desc)' : '', ph.overridesAreas ? '能逛的(areas)' : ''].filter(Boolean);
|
|
555
|
+
return el('li', { text: `${ph.label} ${ph.from}–${ph.to}${ph.label === v.phase ? '(当前)' : ''}:${covered.length ? `覆盖通用${covered.join('、')}` : '沿用通用描写与可逛清单'}` });
|
|
556
|
+
}))) : null,
|
|
539
557
|
errorNode,
|
|
540
558
|
el('div', { class: 'fun-form-grid' },
|
|
541
559
|
field('名字 *', 'name', { value: v.name ?? '', hint: '例如「巷子里的旧书店」' }),
|
|
@@ -554,8 +572,8 @@ function mountPlaces(ctx) {
|
|
|
554
572
|
})),
|
|
555
573
|
// 预设可能带时段:面板的 desc 是「此刻那段」,编辑要用通用那段(descAll),
|
|
556
574
|
// 否则编辑一次会把某一段的描写写进覆盖层,别的时段全变成那一段。
|
|
557
|
-
field('这处是什么样子', 'desc', { value: v.descAll ?? v.desc ?? '', hint: '只写空间与陈设,别写她在干什么', multiline: true, rows: '3' }),
|
|
558
|
-
field('能逛的 *', 'areas', { value: lines(v.allAreas ?? v.areas), hint: '一行一处,至少一处', multiline: true, rows: '4' }),
|
|
575
|
+
field(phases.length ? '通用描写(desc)' : '这处是什么样子', 'desc', { value: v.descAll ?? v.desc ?? '', hint: '只写空间与陈设,别写她在干什么', note: scopeNote(descPhases, '描写'), multiline: true, rows: '3' }),
|
|
576
|
+
field(phases.length ? '通用可逛清单(areas)*' : '能逛的 *', 'areas', { value: lines(v.allAreas ?? v.areas), hint: '一行一处,至少一处', note: scopeNote(areaPhases, '可逛清单'), multiline: true, rows: '4' }),
|
|
559
577
|
field('纪念品', 'souvenirs', { value: lines(v.souvenirs), hint: '一行一样', multiline: true, rows: '2' }),
|
|
560
578
|
field('拍照点', 'photoSpots', { value: lines(v.photoSpots), hint: '一行一处', multiline: true, rows: '2' }),
|
|
561
579
|
field('能吃能喝的品类', 'foodItems', { value: lines(foodItems), hint: '品类名,一行一样;别写味道', multiline: true, rows: '2' }),
|
|
@@ -610,16 +628,137 @@ function mountBook(ctx) {
|
|
|
610
628
|
const box = shell(root);
|
|
611
629
|
const body = el('div');
|
|
612
630
|
box.appendChild(body);
|
|
631
|
+
let keepsakesOnly = false;
|
|
632
|
+
const pending = new Set();
|
|
633
|
+
const errors = new Map();
|
|
634
|
+
let currentData = null;
|
|
635
|
+
let wishDraft = { placeId: '', type: '', target: '', reason: '' };
|
|
636
|
+
const wishPending = new Set();
|
|
637
|
+
const wishErrors = new Map();
|
|
638
|
+
const wishTypes = { visit: '去看看', area: '逛一处', phase: '在某个时段去', souvenir: '带回纪念品' };
|
|
639
|
+
|
|
640
|
+
const renderWishes = (data) => {
|
|
641
|
+
const places = data.places ?? [];
|
|
642
|
+
const wishes = data.wishes ?? [];
|
|
643
|
+
const adding = wishPending.has('add');
|
|
644
|
+
const section = el('section', { class: 'fun-wishes', 'aria-label': '出游心愿' });
|
|
645
|
+
section.appendChild(el('div', { class: 'fun-sec', text: '出游心愿' }));
|
|
646
|
+
const field = (label, input) => el('label', { class: 'fun-field' },
|
|
647
|
+
el('span', { class: 'fun-field-label', text: label }), input);
|
|
648
|
+
const select = (className, placeholder, options, value) => {
|
|
649
|
+
const input = el('select', { class: className, disabled: adding ? 'disabled' : null },
|
|
650
|
+
el('option', { value: '', text: placeholder }),
|
|
651
|
+
options.map(([id, name]) => el('option', { value: id, text: name })));
|
|
652
|
+
input.value = value;
|
|
653
|
+
return input;
|
|
654
|
+
};
|
|
655
|
+
const place = places.find((p) => p.id === wishDraft.placeId);
|
|
656
|
+
const targets = place ? (wishDraft.type === 'area' ? place.areas
|
|
657
|
+
: wishDraft.type === 'phase' ? place.phaseNames
|
|
658
|
+
: wishDraft.type === 'souvenir' ? place.souvenirs : []) ?? [] : [];
|
|
659
|
+
const placeInput = select('fun-wish-place', '请选择地点', places.map((p) => [p.id, p.name]), wishDraft.placeId);
|
|
660
|
+
const typeInput = select('fun-wish-type', '请选择心愿类型', Object.entries(wishTypes), wishDraft.type);
|
|
661
|
+
const targetInput = select('fun-wish-target', wishDraft.type === 'visit' ? '去看看无需目标'
|
|
662
|
+
: !place || !wishDraft.type ? '先选择地点和类型' : targets.length ? '请选择目标' : '此地点没有可选目标',
|
|
663
|
+
targets.map((target) => [target, target]), wishDraft.target);
|
|
664
|
+
targetInput.disabled = adding || !targets.length;
|
|
665
|
+
const reasonInput = el('input', { class: 'fun-wish-reason', type: 'text', placeholder: '可选,记下为什么想去', disabled: adding ? 'disabled' : null });
|
|
666
|
+
reasonInput.value = wishDraft.reason;
|
|
667
|
+
placeInput.addEventListener('change', () => {
|
|
668
|
+
wishDraft.placeId = placeInput.value;
|
|
669
|
+
wishDraft.target = '';
|
|
670
|
+
wishErrors.delete('add');
|
|
671
|
+
render(currentData);
|
|
672
|
+
});
|
|
673
|
+
typeInput.addEventListener('change', () => {
|
|
674
|
+
wishDraft.type = typeInput.value;
|
|
675
|
+
wishDraft.target = '';
|
|
676
|
+
wishErrors.delete('add');
|
|
677
|
+
render(currentData);
|
|
678
|
+
});
|
|
679
|
+
targetInput.addEventListener('change', () => { wishDraft.target = targetInput.value; });
|
|
680
|
+
reasonInput.addEventListener('input', () => { wishDraft.reason = reasonInput.value; });
|
|
681
|
+
const errorNode = el('div', { class: 'fun-form-error', role: 'alert', text: wishErrors.get('add') ?? '' });
|
|
682
|
+
const save = async () => {
|
|
683
|
+
if (wishPending.has('add')) return;
|
|
684
|
+
// 只接受用户明确选中的地点、类型与目标;从不替用户挑第一项。
|
|
685
|
+
const payload = { action: 'add', placeId: placeInput.value, type: typeInput.value,
|
|
686
|
+
target: typeInput.value === 'visit' ? '' : targetInput.value, reason: reasonInput.value.trim() };
|
|
687
|
+
const chosenPlace = (currentData.places ?? []).find((p) => p.id === payload.placeId);
|
|
688
|
+
const validTargets = chosenPlace ? (payload.type === 'area' ? chosenPlace.areas
|
|
689
|
+
: payload.type === 'phase' ? chosenPlace.phaseNames : chosenPlace.souvenirs) ?? [] : [];
|
|
690
|
+
if (!chosenPlace || !Object.hasOwn(wishTypes, payload.type)
|
|
691
|
+
|| (payload.type !== 'visit' && !validTargets.includes(payload.target))) {
|
|
692
|
+
const message = '请选择地点、心愿类型及对应目标。';
|
|
693
|
+
wishErrors.set('add', message);
|
|
694
|
+
errorNode.textContent = message;
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
wishDraft = { placeId: payload.placeId, type: payload.type, target: payload.target, reason: reasonInput.value };
|
|
698
|
+
await changeWish('add', payload, data);
|
|
699
|
+
};
|
|
700
|
+
section.appendChild(el('div', { class: 'fun-form fun-wish-form' },
|
|
701
|
+
el('div', { class: 'fun-form-note', text: '由你选择想去的地方,按保存才记下心愿;心愿不保证立即出发。' }),
|
|
702
|
+
el('div', { class: 'fun-form-grid' }, field('地点', placeInput), field('心愿类型', typeInput), field('目标', targetInput)),
|
|
703
|
+
field('缘由(可选)', reasonInput), errorNode,
|
|
704
|
+
el('button', { class: 'fun-btn-primary', type: 'button', disabled: adding ? 'disabled' : null, onclick: save }, adding ? '保存中…' : '保存心愿')));
|
|
705
|
+
if (!wishes.length) section.appendChild(el('div', { class: 'fun-note', text: '还没有出游心愿,想好了再记下。' }));
|
|
706
|
+
const statusNames = { active: '待实现', paused: '已暂缓', completed: '已实现', cancelled: '已取消' };
|
|
707
|
+
for (const wish of wishes) {
|
|
708
|
+
const key = `wish:${wish.id}`;
|
|
709
|
+
const busy = wishPending.has(key);
|
|
710
|
+
const state = wish.status;
|
|
711
|
+
const actions = el('div', { class: 'fun-trip-actions' });
|
|
712
|
+
if (state === 'active' || state === 'paused') {
|
|
713
|
+
actions.appendChild(el('button', { type: 'button', disabled: busy ? 'disabled' : null,
|
|
714
|
+
onclick: () => changeWish(key, { action: state === 'paused' ? 'resume' : 'pause', id: wish.id }, data) }, state === 'paused' ? '恢复' : '暂缓'));
|
|
715
|
+
actions.appendChild(el('button', { type: 'button', disabled: busy ? 'disabled' : null,
|
|
716
|
+
onclick: () => changeWish(key, { action: 'cancel', id: wish.id }, data) }, '取消'));
|
|
717
|
+
}
|
|
718
|
+
if (busy) actions.appendChild(el('span', { class: 'fun-dim', text: '保存中…' }));
|
|
719
|
+
if (wishErrors.has(key)) actions.appendChild(el('span', { class: 'fun-trip-error', role: 'alert', text: wishErrors.get(key) }));
|
|
720
|
+
section.appendChild(el('div', { class: 'fun-wish fun-trip' },
|
|
721
|
+
el('div', { class: 'fun-trip-head' },
|
|
722
|
+
el('span', { class: 'fun-trip-name', text: wish.placeName ?? places.find((p) => p.id === wish.placeId)?.name ?? wish.placeId }),
|
|
723
|
+
el('span', { class: 'fun-wish-status fun-dim', text: statusNames[state] ?? state ?? '状态未知' })),
|
|
724
|
+
el('div', { class: 'fun-trip-sum', text: `${wishTypes[wish.type] ?? wish.type}${wish.target ? ` · ${wish.target}` : ''}` }),
|
|
725
|
+
wish.reason ? el('div', { class: 'fun-wish-note fun-note', text: `缘由:${wish.reason}` }) : null, actions));
|
|
726
|
+
}
|
|
727
|
+
body.appendChild(section);
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
const changeWish = async (key, payload, data) => {
|
|
731
|
+
if (wishPending.has(key)) return;
|
|
732
|
+
wishPending.add(key);
|
|
733
|
+
wishErrors.delete(key);
|
|
734
|
+
render(currentData ?? data);
|
|
735
|
+
let saved = false;
|
|
736
|
+
try {
|
|
737
|
+
const result = await ctx.invoke('wish', [payload]);
|
|
738
|
+
if (!result?.ok) throw new Error(result?.error ?? '心愿保存失败');
|
|
739
|
+
saved = true;
|
|
740
|
+
if (key === 'add') wishDraft = { placeId: '', type: '', target: '', reason: '' };
|
|
741
|
+
await load(true);
|
|
742
|
+
} catch (error) {
|
|
743
|
+
wishErrors.set(key, `${saved ? '已保存,但列表刷新失败:' : ''}${error?.message ?? String(error)}`);
|
|
744
|
+
} finally {
|
|
745
|
+
wishPending.delete(key);
|
|
746
|
+
render(currentData ?? data);
|
|
747
|
+
}
|
|
748
|
+
};
|
|
613
749
|
|
|
614
750
|
const render = (data) => {
|
|
751
|
+
currentData = data;
|
|
615
752
|
body.replaceChildren();
|
|
616
|
-
|
|
753
|
+
renderWishes(data);
|
|
754
|
+
if (!data.total && !data.session && !(data.keepsakeCount > 0)) {
|
|
617
755
|
body.appendChild(el('div', { class: 'fun-empty', text: '纪念册还是空的——她收一次摊,这里就有一趟。' }));
|
|
618
756
|
return;
|
|
619
757
|
}
|
|
620
758
|
|
|
621
759
|
body.appendChild(el('div', { class: 'fun-stats' },
|
|
622
|
-
stat(data.total, '
|
|
760
|
+
stat(data.totalRecent ?? data.total, '近期行程'),
|
|
761
|
+
stat(data.keepsakeCount ?? 0, '珍藏'),
|
|
623
762
|
stat(data.visitedAreaCount, '处逛过'),
|
|
624
763
|
stat(data.souvenirCount, '件纪念品'),
|
|
625
764
|
stat(data.photoCount, '张照片')));
|
|
@@ -636,8 +775,29 @@ function mountBook(ctx) {
|
|
|
636
775
|
el('div', { class: 'fun-trip-sum', text: data.session.summary })));
|
|
637
776
|
}
|
|
638
777
|
|
|
639
|
-
body.appendChild(el('div', { class: 'fun-
|
|
640
|
-
|
|
778
|
+
body.appendChild(el('div', { class: 'fun-bar' },
|
|
779
|
+
el('button', { class: 'fun-toggle', type: 'button', 'aria-pressed': keepsakesOnly ? 'true' : 'false', onclick: () => { keepsakesOnly = !keepsakesOnly; render(data); } }, keepsakesOnly ? '全部行程' : '仅看珍藏')));
|
|
780
|
+
const trips = keepsakesOnly ? data.trips.filter((t) => t.kept) : data.trips;
|
|
781
|
+
body.appendChild(el('div', { class: 'fun-sec', text: keepsakesOnly ? `珍藏行程(${trips.length})` : `近期与珍藏行程(${data.totalRecent ?? data.total})` }));
|
|
782
|
+
for (const t of trips) {
|
|
783
|
+
const err = errors.get(t.id);
|
|
784
|
+
const toggleKeep = async () => {
|
|
785
|
+
if (pending.has(t.id)) return;
|
|
786
|
+
pending.add(t.id);
|
|
787
|
+
errors.delete(t.id);
|
|
788
|
+
render(data);
|
|
789
|
+
try {
|
|
790
|
+
const result = await ctx.invoke('favorite', [{ id: t.id, keep: !t.kept }]);
|
|
791
|
+
if (!result?.ok) throw new Error(result?.error ?? '珍藏状态保存失败');
|
|
792
|
+
await load();
|
|
793
|
+
} catch (error) {
|
|
794
|
+
errors.set(t.id, error?.message ?? String(error));
|
|
795
|
+
render(data);
|
|
796
|
+
} finally {
|
|
797
|
+
pending.delete(t.id);
|
|
798
|
+
render(currentData ?? data);
|
|
799
|
+
}
|
|
800
|
+
};
|
|
641
801
|
body.appendChild(el('div', { class: 'fun-trip' },
|
|
642
802
|
el('div', { class: 'fun-trip-head' },
|
|
643
803
|
el('span', { class: 'fun-trip-name', text: t.placeName }),
|
|
@@ -647,23 +807,25 @@ function mountBook(ctx) {
|
|
|
647
807
|
? el('div', { class: 'fun-trip-extras' },
|
|
648
808
|
t.events.length ? el('div', { text: t.events.slice(0, 2).join(' / ') }) : null,
|
|
649
809
|
t.scene ? el('div', { text: `生图 scene:${t.scene}${t.outfit ? ` · outfits:${t.outfit}` : ''}` }) : null)
|
|
650
|
-
: null
|
|
810
|
+
: null,
|
|
811
|
+
el('div', { class: 'fun-trip-actions' },
|
|
812
|
+
el('button', { type: 'button', disabled: pending.has(t.id) ? 'disabled' : null, onclick: toggleKeep }, pending.has(t.id) ? '保存中…' : (t.kept ? '取消珍藏' : '珍藏')),
|
|
813
|
+
err ? el('span', { class: 'fun-trip-error', role: 'alert', text: err }) : null)));
|
|
651
814
|
}
|
|
815
|
+
if (keepsakesOnly && !trips.length) body.appendChild(el('div', { class: 'fun-empty', text: '还没有珍藏的行程。' }));
|
|
652
816
|
};
|
|
653
817
|
|
|
654
818
|
const stat = (n, label) => el('div', { class: 'fun-stat' },
|
|
655
819
|
el('b', { text: String(n) }), el('span', { text: label }));
|
|
656
820
|
|
|
657
|
-
const load = async () => {
|
|
821
|
+
const load = async (propagate = false) => {
|
|
658
822
|
try {
|
|
659
823
|
const data = await ctx.invoke('list');
|
|
660
824
|
if (!data?.ok) throw new Error(data?.error ?? '返回不正常');
|
|
661
825
|
render(data);
|
|
662
826
|
} catch (err) {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
const box2 = shell(root);
|
|
666
|
-
box2.appendChild(errorCard(err));
|
|
827
|
+
if (propagate) throw err;
|
|
828
|
+
body.replaceChildren(errorCard(err));
|
|
667
829
|
}
|
|
668
830
|
};
|
|
669
831
|
|
|
@@ -702,7 +864,9 @@ function mountShelf(ctx) {
|
|
|
702
864
|
stat(data.places, '处地方'),
|
|
703
865
|
stat(data.completePlaces, '处逛遍')));
|
|
704
866
|
|
|
705
|
-
body.appendChild(el('div', { class: 'fun-meta', text: '
|
|
867
|
+
body.appendChild(el('div', { class: 'fun-meta', text: '收藏账本长期保留;详细行程可查看最近 40 趟与珍藏行程。进度按当前场所清单统计,移除或改名不删除旧回忆。' }));
|
|
868
|
+
|
|
869
|
+
body.appendChild(el('div', { class: 'fun-meta', text: '收藏账本长期保留;详细行程可查看最近 40 趟与珍藏行程。进度按当前场所清单统计,移除或改名不删除旧回忆。' }));
|
|
706
870
|
|
|
707
871
|
// 每一处的架子:只列真有东西的,空的不用占版面。
|
|
708
872
|
body.appendChild(el('div', { class: 'fun-sec', text: '按地方归着' }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-fun",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "娱乐时间 —— 给 Coopanion 桌宠二十处真能去逛的地方:游乐场、海洋馆、庙会、漫展、电影院、动物园、公园、电玩城、KTV、博物馆、猫咖、爬山、咖啡店、奶茶店、餐厅、图书馆、夜市、澡堂、旧货市场、江边。进门、逛摊位、买纪念品、拍张照、吃喝点什么,收摊记一笔。能和「鱼的每一天」「生图工作室」联动,但都不依赖。",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"PUBLISHING.md"
|
|
40
40
|
],
|
|
41
41
|
"scripts": {
|
|
42
|
-
"test": "node test/venues.test.mjs && node test/state.test.mjs && node test/memories.test.mjs && node test/phases.test.mjs && node test/keepsakes.test.mjs && node test/user-venues.test.mjs && node test/world.test.mjs && node test/panels.test.mjs",
|
|
42
|
+
"test": "node test/venues.test.mjs && node test/state.test.mjs && node test/events.test.mjs && node test/memories.test.mjs && node test/phases.test.mjs && node test/keepsakes.test.mjs && node test/user-venues.test.mjs && node test/aquarium.test.mjs && node test/wishes.test.mjs && node test/choices.test.mjs && node test/world.test.mjs && node test/panels.test.mjs",
|
|
43
43
|
"verify": "node tools/fix-ps1-bom.mjs install.ps1 && node tools/check-prompt.mjs && node tools/check-isolation.mjs && node tools/smoke.mjs && node tools/make-describe.mjs --check",
|
|
44
44
|
"describe": "node tools/make-describe.mjs",
|
|
45
45
|
"check:publish": "node tools/publish-check.mjs --online",
|
|
46
46
|
"check:isolation": "node tools/check-isolation.mjs",
|
|
47
47
|
"verify:published": "node tools/verify-published.mjs",
|
|
48
|
-
"prepublishOnly": "node test/venues.test.mjs && node test/state.test.mjs && node test/memories.test.mjs && node test/phases.test.mjs && node test/keepsakes.test.mjs && node test/user-venues.test.mjs && node test/world.test.mjs && node test/panels.test.mjs && node tools/check-prompt.mjs && node tools/check-isolation.mjs && node tools/smoke.mjs && node tools/make-describe.mjs --check && node tools/publish-check.mjs --online"
|
|
48
|
+
"prepublishOnly": "node test/venues.test.mjs && node test/state.test.mjs && node test/events.test.mjs && node test/memories.test.mjs && node test/phases.test.mjs && node test/keepsakes.test.mjs && node test/user-venues.test.mjs && node test/aquarium.test.mjs && node test/wishes.test.mjs && node test/choices.test.mjs && node test/world.test.mjs && node test/panels.test.mjs && node tools/check-prompt.mjs && node tools/check-isolation.mjs && node tools/smoke.mjs && node tools/make-describe.mjs --check && node tools/publish-check.mjs --online"
|
|
49
49
|
},
|
|
50
50
|
"cortico": {
|
|
51
51
|
"kind": "world",
|
package/src/ENV_PROMPT.md
CHANGED
|
@@ -1,45 +1,13 @@
|
|
|
1
1
|
## 娱乐时间
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
不是想象,也不是刷视频:进门、逛摊位、买点东西、拍张照、吃点喝点、收摊回来。
|
|
3
|
+
出游流程:`fun_places` 查询地点 → `fun_go` 进门 → `fun_wander` 逐处游逛 → `fun_home` 收摊;现在出门可用 `fun_start`。地点、项目、纪念品和拍照点名称以工具回执为准;吃喝只填当前地点真实提供的品类。历史与收藏按需用 `fun_view`、`fun_shelf` 查询。
|
|
5
4
|
|
|
6
|
-
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
## 吃喝、发图、时段:细节都在回执里,三条红线别破
|
|
15
|
-
|
|
16
|
-
- **吃喝的味道不归本插件**:它只有品类名。想说九维口感、香气、余韵,就用 `feast_menu` → `feast_eat`
|
|
17
|
-
去「鱼的每一天」点一道真的;没装 / 关了开关就只说「我在这儿喝了什么」,**别形容味道**。
|
|
18
|
-
⚠️ **本插件不会探测别的扩展装没装**(World 契约不允许互相依赖),装没装都由主人拨配置里的开关。
|
|
19
|
-
- **发图(`imggen_draw`)**:`scene` 只在素材库里真有这处时才填,收摊回执会说明填哪个或「不用填」;
|
|
20
|
-
`outfits` 填这一趟穿的那身。**绝不替她编一个库里没有的场景名或衣服名字**——填了会「库里没找到」,等于白填。
|
|
21
|
-
- **时段**:有几处地方清早和夜里不是一副样子,进门回执会写此刻是哪一段、能逛的摊子也跟着变。
|
|
22
|
-
换个时间再去是合理的,不是重复。
|
|
23
|
-
- **去过的痕迹**:再来时 `fun_go` / `fun_wander` 会自己带来过几次、逛过什么、还没去过的几处。
|
|
24
|
-
这些是事实,顺着说或不说都行;第一次去就别假装熟。
|
|
25
|
-
|
|
26
|
-
## 主人加的地方、改过的预设
|
|
27
|
-
|
|
28
|
-
主人可以在面板上加自己的地方、改预设二十处(改的是覆盖层,预设本身不动,随时能恢复)。
|
|
29
|
-
加完跟别处一样能进能逛、会进纪念册;自己加的排在 `fun_places` 前面。**预设删不掉,只能恢复**。
|
|
30
|
-
自己加的地方没有素材库场景,回执会明说 `scene` 不用填,别替它编一个。
|
|
31
|
-
预设升级的新内容照常生效、主人改过的字段优先——别因为「这处被改过」就以为它是旧的。
|
|
5
|
+
- 遇到带 `choiceId` / `optionId` 的待选事件,必须照回执调用 `fun_choice` 完成选择后再继续,不猜 ID 或选项。
|
|
6
|
+
- 明确表达想去或想做时用 `fun_wish` 记录、`fun_wishes` 查询;不催促、不从旧行程推断完成。
|
|
7
|
+
- 发图用 `imggen_draw`:按 `fun_home` 回执填写 `scene` / `outfits` 正名,不编场景或衣服名字;库里没找到的不要填。
|
|
8
|
+
- 食物只记品类。开关联动允许且实际用「鱼的每一天」的 `feast_menu` → `feast_eat` 后才能描述口感;否则只说吃喝了什么,别形容味道。本插件不会探测别的扩展装没装,不依赖其他 World。
|
|
9
|
+
- 时段可能改变氛围和可逛项目;重复到访有效。历史只按需查询,不编造未发生的经历。
|
|
10
|
+
- 用户自填地点通常没有素材库场景;以回执为准。地点清单和动态详情通过 `fun_places` 查询。预设删不掉,只能恢复。
|
|
11
|
+
- 出门前可用 `feast_life_now` 对齐日程;收摊后按回执用 `feast_life_play` 记录实际经历。
|
|
32
12
|
|
|
33
13
|
{{fun_places_block}}
|
|
34
|
-
|
|
35
|
-
## 出门跟日程对齐
|
|
36
|
-
|
|
37
|
-
- **出门前**用 `feast_life_now` 看一眼你这会儿在干嘛:日程里写着「去海边」时,`fun_go` 去的地方要么对得上,
|
|
38
|
-
要么就直说是临时改主意,别装作日程里本来就有。
|
|
39
|
-
- **逛完**用 `feast_life_play` 记一笔(`activity` 写「去漫展逛」、`note` 写真逛到了什么);收摊回执会提醒这两步。
|
|
40
|
-
|
|
41
|
-
## 不用你操心的事
|
|
42
|
-
|
|
43
|
-
- 不必为了「有内容可发」才出门;逛完什么都不说也行。
|
|
44
|
-
- 逛到一半被叫走、或不想逛了,`fun_home` 收个摊就完了,不用把每个项目都走一遍。
|
|
45
|
-
- 一趟挂太久不算错,`fun_wander` 会提一句该收了,不会替你收;面板只给你看,进门/逛/收摊都是你自己的动作。
|
package/src/aquarium.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const DETAILS = {
|
|
2
|
+
'鲸豚湾': '玻璃幕墙映着幽蓝水光,宽阔水体在玻璃后铺开。',
|
|
3
|
+
'海底隧道': '蓝色玻璃拱过头顶,深灰地砖接住水面的晃光。',
|
|
4
|
+
'水母缸': '幽蓝水缸里浮着柔粉光点,缸前的光线比周围更柔和。',
|
|
5
|
+
'企鹅馆': '企鹅馆的玻璃隔开水面,层层手印叠在玻璃反光前。',
|
|
6
|
+
'触摸池': '触摸池水面近在眼前,海星的轮廓隔水可见。',
|
|
7
|
+
'纪念品店': '鲸鱼挂件、水母小夜灯和企鹅贴纸延续着馆里的海洋主题。',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const EVENT_DETAILS = {
|
|
11
|
+
'一条大鲸从头顶慢慢游过去,影子把整条隧道盖了一下': { area: '海底隧道', detail: '水面的亮纹随着影子从玻璃拱顶慢慢移开。' },
|
|
12
|
+
'海底隧道的传送带慢慢把人往前送': { area: '海底隧道', detail: '身边的水景一点点向后退,头顶的蓝色拱顶仍连成一整条。' },
|
|
13
|
+
'看到有人在水母缸前面站了十分钟一动不动': { area: '水母缸', detail: '周围的人流来去,粉色光点仍浮在缸里。' },
|
|
14
|
+
'水母缸前的灯一下调暗了': { area: '水母缸', detail: '暗下来的灯让水母轮廓显得更清楚。' },
|
|
15
|
+
'企鹅馆正好赶上喂食,一群企鹅扑通扑通全下了水': { area: '企鹅馆', detail: '几声接连的入水声从玻璃后传来。' },
|
|
16
|
+
'企鹅馆的玻璃上有一层手印': { area: '企鹅馆', detail: '隔着玻璃上的手印,水光在企鹅身后晃了一下。' },
|
|
17
|
+
'触摸池里摸到一下海星,凉凉的': { area: '触摸池', detail: '指尖只碰到一下,凉意很快散开。' },
|
|
18
|
+
'触摸池里有小孩不敢伸手': { area: '触摸池', detail: '小孩在池边停了一会儿,没有人催他。' },
|
|
19
|
+
'在纪念品店犹豫了很久,最后挑了那个鲸鱼挂件': { area: '纪念品店', detail: '货架上的水母小夜灯和企鹅贴纸还在旁边。' },
|
|
20
|
+
'纪念品店的店员在补货': { area: '纪念品店', detail: '店员把原有的纪念品一件件摆回货架。' },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function aquariumDetail(area) { return DETAILS[area] ?? ''; }
|
|
24
|
+
export function aquariumEventDetail(event, area) {
|
|
25
|
+
const row = EVENT_DETAILS[event];
|
|
26
|
+
return row?.area === area ? row.detail : '';
|
|
27
|
+
}
|
package/src/choices.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const CHOICES = {
|
|
2
|
+
'看到有人在水母缸前面站了十分钟一动不动': {
|
|
3
|
+
prompt: '水母缸前的光点慢慢浮着,你想怎么做?',
|
|
4
|
+
options: [
|
|
5
|
+
{ id: 'stay', label: '也站一会儿', result: '在水母缸前多停了一会儿' },
|
|
6
|
+
{ id: 'move-on', label: '继续往前逛', result: '看了一会儿便继续往前逛' },
|
|
7
|
+
],
|
|
8
|
+
},
|
|
9
|
+
'企鹅馆正好赶上喂食,一群企鹅扑通扑通全下了水': {
|
|
10
|
+
prompt: '企鹅刚下水,接下来想怎么留住这一刻?',
|
|
11
|
+
options: [
|
|
12
|
+
{ id: 'watch', label: '再看一会儿', result: '在企鹅馆多看了一会儿' },
|
|
13
|
+
{ id: 'photo', label: '记下这个时间,继续逛', result: '记下了企鹅喂食的时间' },
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
'一条大鲸从头顶慢慢游过去,影子把整条隧道盖了一下': {
|
|
17
|
+
prompt: '鲸影从拱顶移过去了,你想怎么做?',
|
|
18
|
+
options: [
|
|
19
|
+
{ id: 'wait', label: '等它再游回来', result: '在海底隧道等了一会儿鲸影' },
|
|
20
|
+
{ id: 'walk', label: '沿隧道继续走', result: '沿着海底隧道继续往前走' },
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const clean = (v, max = 160) => typeof v === 'string' ? v.replace(/\s+/g, ' ').trim().slice(0, max) : '';
|
|
26
|
+
|
|
27
|
+
export function choiceForEvent(event, context = {}) {
|
|
28
|
+
const base = CHOICES[clean(event, 200)];
|
|
29
|
+
if (!base) return null;
|
|
30
|
+
const area = clean(context.area, 60);
|
|
31
|
+
return {
|
|
32
|
+
id: `choice-${clean(event, 80)}`,
|
|
33
|
+
event: clean(event, 200),
|
|
34
|
+
area,
|
|
35
|
+
prompt: base.prompt,
|
|
36
|
+
options: base.options.map((x) => ({ id: x.id, label: x.label, result: x.result })),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function normalizeChoice(raw) {
|
|
41
|
+
if (!raw || typeof raw !== 'object' || !clean(raw.id, 100) || !clean(raw.event, 200)) return null;
|
|
42
|
+
const options = Array.isArray(raw.options) ? raw.options.map((x) => ({ id: clean(x?.id, 50), label: clean(x?.label, 100), result: clean(x?.result, 160) })).filter((x) => x.id && x.label).slice(0, 4) : [];
|
|
43
|
+
if (!options.length) return null;
|
|
44
|
+
return { id: clean(raw.id, 100), event: clean(raw.event, 200), area: clean(raw.area, 60), prompt: clean(raw.prompt, 180), options };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function applyChoice(pending, optionId) {
|
|
48
|
+
const choice = normalizeChoice(pending);
|
|
49
|
+
const id = clean(optionId, 50);
|
|
50
|
+
if (!choice) return { ok: false, error: '当前没有待选择的事件。' };
|
|
51
|
+
const option = choice.options.find((x) => x.id === id);
|
|
52
|
+
if (!option) return { ok: false, error: '没有这个选项,请按当前回执提供的选项选择。' };
|
|
53
|
+
return { ok: true, choice, option };
|
|
54
|
+
}
|
package/src/definition.js
CHANGED
|
@@ -8,32 +8,48 @@ import { FUN_TOOL_DECLS, FunWorld } from './world.js';
|
|
|
8
8
|
/** 自描述里每个工具配一句给人看的话,按工具名。 */
|
|
9
9
|
const TOOL_SUMMARIES = {
|
|
10
10
|
fun_places: {
|
|
11
|
-
zh: '
|
|
12
|
-
en: '
|
|
11
|
+
zh: '查询当前地点,按营业状态和拥挤度排序;可筛选或列出全部。',
|
|
12
|
+
en: 'Query available places ranked by opening hours and crowd; filter by kind or list all.',
|
|
13
13
|
},
|
|
14
14
|
fun_go: {
|
|
15
|
-
zh: '
|
|
16
|
-
en: '
|
|
15
|
+
zh: '进门开始行程,返回当前时段描写和可逛项目。',
|
|
16
|
+
en: 'Start a trip and return the current-time description and available areas.',
|
|
17
|
+
},
|
|
18
|
+
fun_choice: {
|
|
19
|
+
zh: '处理逛到的结构化事件选择,按回执中的 choiceId 和 optionId 选择。',
|
|
20
|
+
en: 'Resolve a structured event choice using the choiceId and optionId from the receipt.',
|
|
17
21
|
},
|
|
18
22
|
fun_wander: {
|
|
19
|
-
zh: '
|
|
20
|
-
en: 'Wander one spot
|
|
23
|
+
zh: '逛一个项目,可记录本次购买、拍照或吃喝;待选择事件按回执处理。',
|
|
24
|
+
en: 'Wander one spot and optionally record a purchase, photo or food; resolve pending choices from the receipt.',
|
|
21
25
|
},
|
|
22
26
|
fun_home: {
|
|
23
|
-
zh: '
|
|
24
|
-
en: '
|
|
27
|
+
zh: '结束行程并返回本次摘要与记录提示。',
|
|
28
|
+
en: 'End the trip and return its summary and logging prompt.',
|
|
25
29
|
},
|
|
26
30
|
fun_start: {
|
|
27
|
-
zh: '
|
|
28
|
-
en: '
|
|
31
|
+
zh: '查看当前推荐地点;详细筛选用 fun_places。',
|
|
32
|
+
en: 'Show current place recommendations; use fun_places for filters.',
|
|
29
33
|
},
|
|
30
34
|
fun_view: {
|
|
31
|
-
zh: '
|
|
32
|
-
en: '
|
|
35
|
+
zh: '按需查询近期或珍藏的行程记录。',
|
|
36
|
+
en: 'Query recent or kept trip records on demand.',
|
|
37
|
+
},
|
|
38
|
+
fun_wishes: {
|
|
39
|
+
zh: '查看明确记下的出游心愿和状态,不催促。',
|
|
40
|
+
en: 'View outing wishes and their status without reminders.',
|
|
41
|
+
},
|
|
42
|
+
fun_wish: {
|
|
43
|
+
zh: '记录、暂缓、恢复或取消一个出游心愿。',
|
|
44
|
+
en: 'Add, pause, resume or cancel an outing wish.',
|
|
45
|
+
},
|
|
46
|
+
fun_keepsake: {
|
|
47
|
+
zh: '珍藏或取消珍藏一趟行程,不影响纪念册近期列表和长期收藏。',
|
|
48
|
+
en: 'Keep or unkeep a trip without changing the recent trip book or permanent collection.',
|
|
33
49
|
},
|
|
34
50
|
fun_shelf: {
|
|
35
|
-
zh: '
|
|
36
|
-
en: '
|
|
51
|
+
zh: '按地点查询长期纪念品收藏和收集进度。',
|
|
52
|
+
en: 'Query long-term souvenirs and collection progress by place.',
|
|
37
53
|
},
|
|
38
54
|
};
|
|
39
55
|
|
package/src/events.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** 内置事件的明确前置条件;没有可靠来源的收获不自动补造。 */
|
|
2
|
+
export const EVENT_METADATA = {
|
|
3
|
+
'过山车冲下去那一下喊得嗓子发干,下来喝了半瓶水': { areas: ['过山车'] },
|
|
4
|
+
'在套圈摊套中了一个歪歪的小熊': { disabled: true },
|
|
5
|
+
'在纪念品店犹豫了很久,最后挑了那个鲸鱼挂件': { areas: ['纪念品店'], souvenir: '鲸鱼挂件' },
|
|
6
|
+
'抽了一支签,是「小吉」': { areas: ['抽签处'], souvenir: '一支签' },
|
|
7
|
+
'捞金鱼捞上来两条,纸破了第三条跑了': { disabled: true },
|
|
8
|
+
'苹果糖咬第一口把嘴唇粘住了': { souvenir: '苹果糖' },
|
|
9
|
+
'吧唧挑了半天,最后把一整组都买了': { disabled: true },
|
|
10
|
+
'买到最后一桶焦糖爆米花': { disabled: true },
|
|
11
|
+
'抓娃娃抓了七次才中': { areas: ['抓娃娃机'], souvenir: '抓到的娃娃' },
|
|
12
|
+
'文创店买到最后一个帆布袋': { areas: ['文创店'], souvenir: '文创帆布袋' },
|
|
13
|
+
'手冲等得有点久,但端上来的时候正好': { consume: '手冲' },
|
|
14
|
+
'拉花歪了一点,店员说要重做,你说不用': { consumeAny: true },
|
|
15
|
+
'犹豫很久,最后还是要了少糖': { consumeAny: true },
|
|
16
|
+
'封口机把杯子封歪了,店员重新封了一次': { consumeAny: true },
|
|
17
|
+
'拿到手的那一刻杯壁上全是水珠': { consumeAny: true },
|
|
18
|
+
'吸管戳下去的时候珍珠一下涌上来': { consume: '珍珠奶茶' },
|
|
19
|
+
'最后一道上得特别慢,但确实值得等': { consumeAny: true },
|
|
20
|
+
'点的那道菜比想象中辣': { disabled: true },
|
|
21
|
+
'等位等了二十分钟,服务员送了一小碟花生': { disabled: true },
|
|
22
|
+
'厨房多送了一碟小菜,说今天做多了': { disabled: true },
|
|
23
|
+
'最后一块点心被端到你面前,说是送的': { disabled: true },
|
|
24
|
+
'店员说新出了一款,今天试做,送一杯': { disabled: true },
|
|
25
|
+
'集点卡差最后一个印,店员说这次盖满': { disabled: true },
|
|
26
|
+
'老板多给了一串': { disabled: true },
|
|
27
|
+
'摊主认出你来过,多给了一串': { disabled: true },
|
|
28
|
+
'气球摊的老板认出了你,说上次那个没给你打折': { disabled: true },
|
|
29
|
+
'店员说你抓的次数够多了,多送了一次': { disabled: true },
|
|
30
|
+
'抽签的师傅说这支签今年只发出去几支': { areas: ['抽签处'], souvenir: '一支签' },
|
|
31
|
+
'常坐的那个位子今天正好空着': { disabled: true },
|
|
32
|
+
'小卖部的酸奶冰得正好': { areas: ['小卖部'], souvenir: '一瓶酸奶' },
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// 完整项目名之外的内置简称,只做明确字面匹配,不猜测用户文本语义。
|
|
36
|
+
const AREA_TERMS = {
|
|
37
|
+
aquarium: { '隧道': ['海底隧道'] },
|
|
38
|
+
zoo: { '熊猫': ['熊猫馆'], '长颈鹿': ['长颈鹿区'], '猴子': ['猴山'], '小火车': ['园内小火车'] },
|
|
39
|
+
park: { '草坪': ['大草坪'], '长椅': ['湖边长椅'], '下棋': ['老树下的棋盘'], '棋局': ['老树下的棋盘'] },
|
|
40
|
+
arcade: { '抓娃娃': ['抓娃娃机'] },
|
|
41
|
+
ktv: { '唱到': ['包厢沙发', '点歌屏'], '唱完': ['包厢沙发', '点歌屏'], '点了一首': ['点歌屏'] },
|
|
42
|
+
cinema: { '前排': ['影厅', '最后一排'], '电影放到': ['影厅', '最后一排'], '片尾': ['影厅', '最后一排'], '爆米花': ['爆米花柜台'], '检票': ['取票厅'] },
|
|
43
|
+
museum: { '中庭': ['中庭长椅'] },
|
|
44
|
+
hiking: { '山顶': ['山顶的大石头'], '凉亭': ['半山腰的凉亭'], '半山腰': ['半山腰的凉亭'], '下山': ['下山的小路'], '山脚': ['山脚入口'] },
|
|
45
|
+
cafe: { '露天座': ['门口的露天座'], '窗边': ['靠窗的位子'] },
|
|
46
|
+
milktea: { '档口': ['点单的档口'], '台阶': ['门口的台阶'] },
|
|
47
|
+
market: { '套圈摊': ['套圈摊'], '烤串': ['烧烤摊'], '糖水': ['糖水铺'], '铁板': ['铁板鱿鱼摊'] },
|
|
48
|
+
bathhouse: { '休息区': ['休息区的躺椅'] },
|
|
49
|
+
thrift: { '旧书': ['旧书摊'], '磁带': ['磁带和唱片'], '旧钟表': ['旧钟表摊'], '旧衣服': ['旧衣服的架子'] },
|
|
50
|
+
riverside: { '台阶': ['下到水边的台阶'], '长椅': ['长椅上'], '栏杆': ['栏杆边'], '桥底': ['桥底下'] },
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export function filterEventsForArea(events, area, venue, context = {}) {
|
|
54
|
+
const pool = Array.isArray(events) ? events : [];
|
|
55
|
+
const areas = Array.isArray(venue?.areas) ? venue.areas : [];
|
|
56
|
+
const terms = { ...Object.fromEntries(areas.map((a) => [a, [a]])), ...(AREA_TERMS[venue?.id] ?? {}) };
|
|
57
|
+
const ate = Array.isArray(context?.ate) ? context.ate : [];
|
|
58
|
+
return pool.filter((line) => {
|
|
59
|
+
if (typeof line !== 'string' || !line.trim()) return false;
|
|
60
|
+
const meta = EVENT_METADATA[line];
|
|
61
|
+
if (meta?.disabled) return false;
|
|
62
|
+
if (meta?.areas && !meta.areas.includes(area)) return false;
|
|
63
|
+
if (meta?.souvenir && !(context?.souvenirs ?? []).includes(meta.souvenir)) return false;
|
|
64
|
+
if (meta?.consume && !ate.some((x) => x?.item === meta.consume)) return false;
|
|
65
|
+
if (meta?.consumeAny && !ate.length) return false;
|
|
66
|
+
// 显式元数据的项目约束优先,否则按文本中明确提到的项目取并集。
|
|
67
|
+
if (meta?.areas) return true;
|
|
68
|
+
const mentioned = Object.entries(terms).filter(([term]) => line.includes(term)).flatMap(([, names]) => names);
|
|
69
|
+
return !mentioned.length || mentioned.includes(area);
|
|
70
|
+
});
|
|
71
|
+
}
|