@lemoncat7/dsh-partner 2.8.4 → 2.8.6
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/README.md +1 -1
- package/docs/THIRD_PARTY_LICENSES.md +4 -0
- package/docs/director-skills.md +8 -3
- package/docs/dsh-021-compatibility.md +9 -0
- package/docs/package-distribution.md +11 -0
- package/docs/releases/2.8.5.md +23 -0
- package/docs/releases/2.8.6.md +22 -0
- package/lib/channels/direct/message-format.js +13 -8
- package/lib/channels/direct/message-format.js.map +3 -3
- package/lib/client.js +13 -8
- package/lib/client.js.map +3 -3
- package/lib/skills/ai-camera-language-builtin.d.ts +3 -0
- package/lib/skills/ai-camera-language-builtin.d.ts.map +1 -0
- package/lib/skills/ai-camera-language-builtin.js +89 -0
- package/lib/skills/ai-camera-language-builtin.js.map +1 -0
- package/lib/skills/builtin.d.ts.map +1 -1
- package/lib/skills/builtin.js +2 -0
- package/lib/skills/builtin.js.map +1 -1
- package/lib/skills/story-builtins.js +2 -2
- package/lib/skills/story-builtins.js.map +1 -1
- package/package.json +53 -47
- package/resources/skills/ai-camera-language/manifest.json +26 -0
- package/resources/skills/ai-camera-language/references/camera-dictionary.md +315 -0
- package/resources/skills/ai-camera-language/references/prompt-workflow.md +186 -0
- package/resources/skills/ai-camera-language/references/video-summary.md +123 -0
- package/resources/skills/novel-game-creation/manifest.json +2 -245
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/BUILD_BRIEF.md +0 -219
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/.vercelignore +0 -3
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/RUN.md +0 -138
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/bg/compound_new_guofeng.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/finale/fate_coda.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/finale/meng.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/finale/pan.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/finale/pinger.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/finale/xuee.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/finale/yue.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/group/inner_court_accord_five.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/group/inner_court_afterglow_five.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/group/inner_court_alliance.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/group/public_day10.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/group/public_day15.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/group/public_day5.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/group/title_new_guofeng.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/joint/pan_pinger.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/joint/pan_xuee.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/joint/yue_meng.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/joint/yue_pan.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/joint/yue_pinger.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/meng/explicit.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/meng/prelude.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/milestone/meng.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/milestone/pan.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/milestone/pinger.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/milestone/xuee.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/milestone/yue.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/pan/explicit.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/pan/prelude.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/pinger/explicit.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/pinger/prelude.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/xuee/explicit.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/xuee/prelude.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/yue/explicit.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/cg/yue/prelude.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/heroine/meng/night.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/heroine/pan/night.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/heroine/pinger/night.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/heroine/xuee/night.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/heroine/yue/night.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/household/li_jiaoer.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/assets/scene/gate_collector.webp +0 -0
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/css/new-guofeng.css +0 -1494
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/css/style.css +0 -2508
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/index.html +0 -18
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/js/assets.js +0 -147
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/js/audio.js +0 -332
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/js/data.js +0 -7470
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/js/engine.js +0 -13066
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/js/main.js +0 -3051
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/js/text.js +0 -32
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/package.json +0 -11
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/vercel.json +0 -23
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/art/generated-art.json +0 -161
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/example.json +0 -12
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/qa/README.md +0 -26
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/qa/playable-model.json +0 -99
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/qa/verification.json +0 -41
- package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/qa/verify_playable_model.mjs +0 -152
package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/index.html
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="zh-CN">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<meta name="color-scheme" content="light" />
|
|
7
|
-
<meta name="description" content="《金瓶梅·风月总账》20日男性第一人称成人后宫关系模拟:五条深线、四幕危机与证据化结局" />
|
|
8
|
-
<title>金瓶梅·风月总账</title>
|
|
9
|
-
<link rel="icon" href="data:," />
|
|
10
|
-
<link rel="stylesheet" href="css/style.css" />
|
|
11
|
-
<link rel="stylesheet" href="css/new-guofeng.css" />
|
|
12
|
-
</head>
|
|
13
|
-
<body>
|
|
14
|
-
<div id="app"></div>
|
|
15
|
-
<div id="announcer" class="sr-only" aria-live="polite" aria-atomic="true"></div>
|
|
16
|
-
<script type="module" src="js/main.js"></script>
|
|
17
|
-
</body>
|
|
18
|
-
</html>
|
package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/js/assets.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
// 视觉键表:发布模式对所有首屏、人物近景与奖励 CG 采用 fail-closed,不静默回退。
|
|
2
|
-
|
|
3
|
-
export const ASSET_PATHS = Object.freeze({
|
|
4
|
-
// 标题与全套 CG 使用同一批二维新国风叙事母版:角色集中在中右区域,
|
|
5
|
-
// 左侧春庭留白交给真实 HTML 标题,既保留古代世界,也给玩家想象空间。
|
|
6
|
-
cover: 'assets/cg/group/title_new_guofeng.webp',
|
|
7
|
-
compound: 'assets/bg/compound_new_guofeng.webp',
|
|
8
|
-
// 催账到期那两个早晨的门前画面:来人、契纸与受阻门槛承担压力,不靠压黑画面。
|
|
9
|
-
// 不进 CRITICAL_CG_KEYS——报条文字已经把账说清楚,缺图不该拦住一局。
|
|
10
|
-
'scene/gate_collector': 'assets/scene/gate_collector.webp',
|
|
11
|
-
// 门卡与对话使用同一张二维身份母版,脸、发式、衣色与器物贯穿所有剧情 CG。
|
|
12
|
-
'heroine/yue': 'assets/heroine/yue/night.webp',
|
|
13
|
-
'heroine/pan': 'assets/heroine/pan/night.webp',
|
|
14
|
-
'heroine/pinger': 'assets/heroine/pinger/night.webp',
|
|
15
|
-
'heroine/meng': 'assets/heroine/meng/night.webp',
|
|
16
|
-
'heroine/xuee': 'assets/heroine/xuee/night.webp',
|
|
17
|
-
'household/jiaoer': 'assets/household/li_jiaoer.webp',
|
|
18
|
-
// 日常近景、门卡与人物身份母版统一;夜间专属图只改变关系动作与灯月,不更换画风。
|
|
19
|
-
'heroine/yue/close': 'assets/heroine/yue/night.webp',
|
|
20
|
-
'heroine/pan/close': 'assets/heroine/pan/night.webp',
|
|
21
|
-
'heroine/pinger/close': 'assets/heroine/pinger/night.webp',
|
|
22
|
-
'heroine/meng/close': 'assets/heroine/meng/night.webp',
|
|
23
|
-
'heroine/xuee/close': 'assets/heroine/xuee/night.webp',
|
|
24
|
-
'cg/yue/prelude': 'assets/cg/yue/prelude.webp',
|
|
25
|
-
'cg/yue/explicit': 'assets/cg/yue/explicit.webp',
|
|
26
|
-
'cg/pan/prelude': 'assets/cg/pan/prelude.webp',
|
|
27
|
-
'cg/pan/explicit': 'assets/cg/pan/explicit.webp',
|
|
28
|
-
'cg/pinger/prelude': 'assets/cg/pinger/prelude.webp',
|
|
29
|
-
'cg/pinger/explicit': 'assets/cg/pinger/explicit.webp',
|
|
30
|
-
'cg/meng/prelude': 'assets/cg/meng/prelude.webp',
|
|
31
|
-
'cg/meng/explicit': 'assets/cg/meng/explicit.webp',
|
|
32
|
-
'cg/xuee/prelude': 'assets/cg/xuee/prelude.webp',
|
|
33
|
-
'cg/xuee/explicit': 'assets/cg/xuee/explicit.webp',
|
|
34
|
-
'cg/group/public_day5': 'assets/cg/group/public_day5.webp',
|
|
35
|
-
'cg/group/public_day10': 'assets/cg/group/public_day10.webp',
|
|
36
|
-
'cg/group/public_day15': 'assets/cg/group/public_day15.webp',
|
|
37
|
-
'cg/group/inner_court_alliance': 'assets/cg/group/inner_court_alliance.webp',
|
|
38
|
-
'cg/group/inner_court_accord': 'assets/cg/group/inner_court_accord_five.webp',
|
|
39
|
-
'cg/group/inner_court_afterglow': 'assets/cg/group/inner_court_afterglow_five.webp',
|
|
40
|
-
'cg/joint/yue_pan': 'assets/cg/joint/yue_pan.webp',
|
|
41
|
-
'cg/joint/yue_pinger': 'assets/cg/joint/yue_pinger.webp',
|
|
42
|
-
'cg/joint/pan_pinger': 'assets/cg/joint/pan_pinger.webp',
|
|
43
|
-
'cg/joint/yue_meng': 'assets/cg/joint/yue_meng.webp',
|
|
44
|
-
'cg/joint/pan_xuee': 'assets/cg/joint/pan_xuee.webp',
|
|
45
|
-
// 第二十夜的一院终章不是把旧门卡放大:五个人各有一张能读出
|
|
46
|
-
// 她的核心边界与另外四院善后方式的安全终章画面。
|
|
47
|
-
'cg/finale/yue': 'assets/cg/finale/yue.webp',
|
|
48
|
-
'cg/finale/pan': 'assets/cg/finale/pan.webp',
|
|
49
|
-
'cg/finale/pinger': 'assets/cg/finale/pinger.webp',
|
|
50
|
-
'cg/finale/meng': 'assets/cg/finale/meng.webp',
|
|
51
|
-
'cg/finale/xuee': 'assets/cg/finale/xuee.webp',
|
|
52
|
-
// 命数三页不用任何人物遗照消费悲剧;空宅、六把钥匙、五张名签、
|
|
53
|
-
// 药碗与未写完的账页承担第 30—100 回的长期回声。
|
|
54
|
-
'cg/finale/fate_coda': 'assets/cg/finale/fate_coda.webp',
|
|
55
|
-
'cg/milestone/yue': 'assets/cg/milestone/yue.webp',
|
|
56
|
-
'cg/milestone/pan': 'assets/cg/milestone/pan.webp',
|
|
57
|
-
'cg/milestone/pinger': 'assets/cg/milestone/pinger.webp',
|
|
58
|
-
'cg/milestone/meng': 'assets/cg/milestone/meng.webp',
|
|
59
|
-
'cg/milestone/xuee': 'assets/cg/milestone/xuee.webp',
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
export const CRITICAL_CG_KEYS = Object.freeze([
|
|
63
|
-
'cover', 'heroine/yue', 'heroine/pan', 'heroine/pinger', 'heroine/meng', 'heroine/xuee',
|
|
64
|
-
'household/jiaoer',
|
|
65
|
-
'heroine/yue/close', 'heroine/pan/close', 'heroine/pinger/close', 'heroine/meng/close', 'heroine/xuee/close',
|
|
66
|
-
'cg/yue/prelude', 'cg/yue/explicit', 'cg/pan/prelude', 'cg/pan/explicit',
|
|
67
|
-
'cg/pinger/prelude', 'cg/pinger/explicit', 'cg/meng/prelude', 'cg/meng/explicit',
|
|
68
|
-
'cg/xuee/prelude', 'cg/xuee/explicit', 'cg/group/public_day5', 'cg/group/public_day10', 'cg/group/public_day15',
|
|
69
|
-
'cg/group/inner_court_alliance', 'cg/group/inner_court_accord', 'cg/group/inner_court_afterglow',
|
|
70
|
-
'cg/joint/yue_pan', 'cg/joint/yue_pinger', 'cg/joint/pan_pinger', 'cg/joint/yue_meng', 'cg/joint/pan_xuee',
|
|
71
|
-
'cg/finale/yue', 'cg/finale/pan', 'cg/finale/pinger', 'cg/finale/meng', 'cg/finale/xuee', 'cg/finale/fate_coda',
|
|
72
|
-
'cg/milestone/yue', 'cg/milestone/pan', 'cg/milestone/pinger', 'cg/milestone/meng', 'cg/milestone/xuee',
|
|
73
|
-
]);
|
|
74
|
-
|
|
75
|
-
export const BOOT_ASSET_KEYS = Object.freeze(['cover', 'compound']);
|
|
76
|
-
export const ADULT_ASSET_KEYS = Object.freeze([
|
|
77
|
-
'cg/yue/prelude', 'cg/yue/explicit', 'cg/pan/prelude', 'cg/pan/explicit',
|
|
78
|
-
'cg/pinger/prelude', 'cg/pinger/explicit', 'cg/meng/prelude', 'cg/meng/explicit',
|
|
79
|
-
'cg/xuee/prelude', 'cg/xuee/explicit', 'cg/group/inner_court_afterglow',
|
|
80
|
-
]);
|
|
81
|
-
export const FINALE_ASSET_KEYS = Object.freeze([
|
|
82
|
-
'cg/finale/yue', 'cg/finale/pan', 'cg/finale/pinger', 'cg/finale/meng', 'cg/finale/xuee', 'cg/finale/fate_coda',
|
|
83
|
-
]);
|
|
84
|
-
export const MILESTONE_ASSET_KEYS = Object.freeze([
|
|
85
|
-
'cg/milestone/yue', 'cg/milestone/pan', 'cg/milestone/pinger', 'cg/milestone/meng', 'cg/milestone/xuee',
|
|
86
|
-
]);
|
|
87
|
-
// 终章画是安全内容,但不该在玩家刚过年龄门时就把五张结局一起下载。
|
|
88
|
-
// 第四幕再闲时预取,真正进入终章时浏览器也会从相同 URL 直接复用缓存。
|
|
89
|
-
export const SAFE_GAME_ASSET_KEYS = Object.freeze(CRITICAL_CG_KEYS.filter((key) => (
|
|
90
|
-
!ADULT_ASSET_KEYS.includes(key) && !FINALE_ASSET_KEYS.includes(key) && !MILESTONE_ASSET_KEYS.includes(key)
|
|
91
|
-
)));
|
|
92
|
-
|
|
93
|
-
const loaded = new Map();
|
|
94
|
-
const requested = new Set();
|
|
95
|
-
const inflight = new Map();
|
|
96
|
-
|
|
97
|
-
function loadOne(key, path) {
|
|
98
|
-
if (loaded.get(key)?.ok === true) return Promise.resolve();
|
|
99
|
-
if (inflight.has(key)) return inflight.get(key);
|
|
100
|
-
requested.add(key);
|
|
101
|
-
const promise = new Promise((resolve) => {
|
|
102
|
-
const image = new Image();
|
|
103
|
-
image.onload = () => { loaded.set(key, { ok: true, width: image.naturalWidth, height: image.naturalHeight }); inflight.delete(key); resolve(); };
|
|
104
|
-
image.onerror = () => { loaded.set(key, { ok: false, width: 0, height: 0 }); inflight.delete(key); resolve(); };
|
|
105
|
-
image.src = path;
|
|
106
|
-
});
|
|
107
|
-
inflight.set(key, promise);
|
|
108
|
-
return promise;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export async function loadAssets(keys = BOOT_ASSET_KEYS) {
|
|
112
|
-
await Promise.all(keys.map((key) => loadOne(key, ASSET_PATHS[key])));
|
|
113
|
-
return assetReport();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export function preloadSafeAssets() {
|
|
117
|
-
return loadAssets(SAFE_GAME_ASSET_KEYS);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export function preloadFinaleAssets() {
|
|
121
|
-
return loadAssets(FINALE_ASSET_KEYS);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export function assetReport() {
|
|
125
|
-
const missingCritical = CRITICAL_CG_KEYS.filter((key) => requested.has(key) && loaded.get(key)?.ok === false);
|
|
126
|
-
const bootReady = BOOT_ASSET_KEYS.every((key) => loaded.get(key)?.ok === true);
|
|
127
|
-
return {
|
|
128
|
-
missingCritical,
|
|
129
|
-
loaded: Object.fromEntries([...loaded.entries()]),
|
|
130
|
-
requested: [...requested],
|
|
131
|
-
adultRequested: ADULT_ASSET_KEYS.filter((key) => requested.has(key)),
|
|
132
|
-
bootReady,
|
|
133
|
-
complete: CRITICAL_CG_KEYS.every((key) => loaded.get(key)?.ok === true),
|
|
134
|
-
ok: bootReady && missingCritical.length === 0,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export function urlFor(key) {
|
|
139
|
-
const path = ASSET_PATHS[key] ?? '';
|
|
140
|
-
return globalThis.document ? new URL(path, document.baseURI).href : path;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export function assertCriticalAssetSchema() {
|
|
144
|
-
const missingKeys = CRITICAL_CG_KEYS.filter((key) => !ASSET_PATHS[key]);
|
|
145
|
-
if (missingKeys.length) throw new Error(`关键 CG 未登记:${missingKeys.join(', ')}`);
|
|
146
|
-
return true;
|
|
147
|
-
}
|
package/resources/skills/novel-game-creation/upstream/examples/jin-ping-mei/build/app/js/audio.js
DELETED
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
// 音频:Web Audio 程序化合成,零素材零依赖。
|
|
2
|
-
// 明代市井家宅——克制、室内、偏冷。五声音阶(宫商角徵羽),丝竹音色:
|
|
3
|
-
// 笛/箫(正弦+轻噪气声+揉音)、琵琶/古筝(快起音快衰减拨弦)、云板/木鱼(短促打击)。
|
|
4
|
-
// 功能三色通感:明账=清亮金属音,暗账=几乎听不见的闷木音,风声=不安的擦弦音。
|
|
5
|
-
// 一切方法在 AudioContext 不可用时静默降级,绝不影响游戏运行;删掉本模块玩法不变。
|
|
6
|
-
|
|
7
|
-
const PENTA = [0, 2, 4, 7, 9]; // 宫 商 角 徵 羽
|
|
8
|
-
const BASE = 196; // G3,偏冷
|
|
9
|
-
|
|
10
|
-
function freq(degree, octave = 0) {
|
|
11
|
-
const idx = ((degree % 5) + 5) % 5;
|
|
12
|
-
const extra = Math.floor(degree / 5);
|
|
13
|
-
return BASE * Math.pow(2, octave + extra + PENTA[idx] / 12);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// 散板/慢板乐句:[音级(null=休止), 八度, 拍数]。无强拍循环,留白多。
|
|
17
|
-
const SCENES = {
|
|
18
|
-
title: {
|
|
19
|
-
bpm: 50, vol: 0.10, voices: ['di'],
|
|
20
|
-
melody: [[0, 0, 3], [2, 0, 2], [null, 0, 1], [4, 0, 3], [2, 0, 1.5], [null, 0, 2], [1, 0, 2], [0, 0, 4], [null, 0, 3]],
|
|
21
|
-
bass: [],
|
|
22
|
-
},
|
|
23
|
-
act1: {
|
|
24
|
-
bpm: 60, vol: 0.07, voices: ['pluck'],
|
|
25
|
-
melody: [[0, 0, 1], [null, 0, 1], [2, 0, 0.5], [null, 0, 1.5], [4, 0, 1], [null, 0, 2], [2, 0, 0.5], [1, 0, 0.5], [null, 0, 2], [0, 0, 1], [null, 0, 3]],
|
|
26
|
-
bass: [0],
|
|
27
|
-
},
|
|
28
|
-
act2: {
|
|
29
|
-
bpm: 66, vol: 0.08, voices: ['pluck', 'di'],
|
|
30
|
-
melody: [[0, 0, 1], [2, 0, 0.5], [4, 0, 1], [7, 0, 1.5], [4, 0, 0.5], [2, 0, 1], [null, 0, 0.5], [4, 0, 1], [7, 0, 1], [9, 0, 2], [7, 0, 1], [4, 0, 1], [null, 0, 1], [2, 0, 2]],
|
|
31
|
-
melody2: [[0, -1, 2], [null, 0, 1], [4, -1, 2], [null, 0, 1], [0, -1, 3], [null, 0, 2]],
|
|
32
|
-
bass: [0, 3],
|
|
33
|
-
},
|
|
34
|
-
act3: {
|
|
35
|
-
bpm: 46, vol: 0.07, voices: ['di'],
|
|
36
|
-
melody: [[4, -1, 2], [null, 0, 2], [2, -1, 1.5], [null, 0, 3], [0, -1, 3], [null, 0, 4]],
|
|
37
|
-
bass: [],
|
|
38
|
-
},
|
|
39
|
-
act4: {
|
|
40
|
-
bpm: 58, vol: 0.085, voices: ['pluck', 'di'],
|
|
41
|
-
melody: [[0, -1, 1], [4, -1, 1], [7, 0, 1.5], [null, 0, .5], [9, 0, 2], [7, 0, 1], [4, 0, 1], [2, 0, 2], [null, 0, 1], [0, 0, 3]],
|
|
42
|
-
melody2: [[0, -1, 2], [2, -1, 2], [4, -1, 2], [7, -1, 3], [null, 0, 2]],
|
|
43
|
-
bass: [0, 4],
|
|
44
|
-
},
|
|
45
|
-
ending_liyanei: { // 向上收束的完整乐句
|
|
46
|
-
bpm: 54, vol: 0.10, voices: ['di'],
|
|
47
|
-
melody: [[0, 0, 1.5], [2, 0, 1], [4, 0, 1.5], [7, 0, 2], [9, 0, 3], [null, 0, 2], [7, 0, 1.5], [9, 0, 4], [null, 0, 4]],
|
|
48
|
-
bass: [0],
|
|
49
|
-
},
|
|
50
|
-
ending_liuluo: { // 乐句不完整,中途停住
|
|
51
|
-
bpm: 50, vol: 0.09, voices: ['di'],
|
|
52
|
-
melody: [[0, 0, 2], [2, 0, 1.5], [1, 0, 1], [null, 0, 12]],
|
|
53
|
-
bass: [],
|
|
54
|
-
},
|
|
55
|
-
ending_other: {
|
|
56
|
-
bpm: 50, vol: 0.09, voices: ['di'],
|
|
57
|
-
melody: [[4, 0, 2], [2, 0, 1.5], [0, 0, 3], [null, 0, 4], [2, -1, 3], [null, 0, 5]],
|
|
58
|
-
bass: [],
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const MUTE_KEY = 'jpm_mute';
|
|
63
|
-
|
|
64
|
-
class AudioEngine {
|
|
65
|
-
constructor() {
|
|
66
|
-
this.ctx = null;
|
|
67
|
-
this.master = null;
|
|
68
|
-
this.bgmGain = null;
|
|
69
|
-
this.sfxGain = null;
|
|
70
|
-
this.bgm = null;
|
|
71
|
-
this.muted = localStorage.getItem(MUTE_KEY) === '1';
|
|
72
|
-
this._noiseBuf = null;
|
|
73
|
-
this._clearing = false;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
unlock() {
|
|
77
|
-
try {
|
|
78
|
-
if (!this.ctx) {
|
|
79
|
-
const AC = window.AudioContext || window.webkitAudioContext;
|
|
80
|
-
if (!AC) return;
|
|
81
|
-
this.ctx = new AC();
|
|
82
|
-
this.master = this.ctx.createGain();
|
|
83
|
-
this.master.gain.value = this.muted ? 0 : 0.5;
|
|
84
|
-
this.master.connect(this.ctx.destination);
|
|
85
|
-
this.bgmGain = this.ctx.createGain();
|
|
86
|
-
this.bgmGain.gain.value = 0.30; // BGM 明显低于音效
|
|
87
|
-
this.bgmGain.connect(this.master);
|
|
88
|
-
this.sfxGain = this.ctx.createGain();
|
|
89
|
-
this.sfxGain.gain.value = 0.55;
|
|
90
|
-
this.sfxGain.connect(this.master);
|
|
91
|
-
}
|
|
92
|
-
if (this.ctx.state === 'suspended') this.ctx.resume();
|
|
93
|
-
} catch { /* 静默降级 */ }
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
get ready() { return !!this.ctx; }
|
|
97
|
-
get currentScene() { return this.bgm?.scene ?? null; }
|
|
98
|
-
|
|
99
|
-
setMuted(m) {
|
|
100
|
-
this.muted = m;
|
|
101
|
-
localStorage.setItem(MUTE_KEY, m ? '1' : '0');
|
|
102
|
-
if (this.master) this.master.gain.setTargetAtTime(m ? 0 : 0.5, this.ctx.currentTime, 0.05);
|
|
103
|
-
}
|
|
104
|
-
toggleMuted() { this.setMuted(!this.muted); return this.muted; }
|
|
105
|
-
|
|
106
|
-
// ---------- BGM ----------
|
|
107
|
-
playBGM(scene) {
|
|
108
|
-
if (!this.ctx || this._clearing) return;
|
|
109
|
-
if (this.bgm?.scene === scene) return;
|
|
110
|
-
this.stopBGM();
|
|
111
|
-
const cfg = SCENES[scene];
|
|
112
|
-
if (!cfg) return;
|
|
113
|
-
const beatLen = 60 / cfg.bpm;
|
|
114
|
-
const total = cfg.melody.reduce((a, n) => a + n[2], 0);
|
|
115
|
-
const st = { scene, cfg, beatLen, next: this.ctx.currentTime + 0.1, loopLen: total * beatLen };
|
|
116
|
-
st.timer = setInterval(() => this._schedule(st), 400);
|
|
117
|
-
this._schedule(st);
|
|
118
|
-
this.bgm = st;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
stopBGM() {
|
|
122
|
-
if (this.bgm) { clearInterval(this.bgm.timer); this.bgm = null; }
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
_schedule(st) {
|
|
126
|
-
if (!this.ctx) return;
|
|
127
|
-
const horizon = this.ctx.currentTime + 1.2;
|
|
128
|
-
while (st.next < horizon) {
|
|
129
|
-
this._loopOnce(st, st.next);
|
|
130
|
-
st.next += st.loopLen;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
_loopOnce(st, t0) {
|
|
135
|
-
const { cfg, beatLen } = st;
|
|
136
|
-
let t = t0;
|
|
137
|
-
for (const [deg, oct, beats] of cfg.melody) {
|
|
138
|
-
if (deg !== null) this._voice(cfg.voices[0], freq(deg, oct), t, beats * beatLen, cfg.vol);
|
|
139
|
-
t += beats * beatLen;
|
|
140
|
-
}
|
|
141
|
-
if (cfg.melody2) {
|
|
142
|
-
let t2 = t0;
|
|
143
|
-
for (const [deg, oct, beats] of cfg.melody2) {
|
|
144
|
-
if (deg !== null) this._voice('di', freq(deg, oct), t2, beats * beatLen, cfg.vol * 0.7);
|
|
145
|
-
t2 += beats * beatLen;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
const perBeat = st.loopLen / Math.max(1, cfg.bass.length);
|
|
149
|
-
cfg.bass.forEach((deg, i) => {
|
|
150
|
-
this._voice('pluckLow', freq(deg, -1), t0 + i * perBeat, perBeat, cfg.vol * 0.6);
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// 丝竹声部:di=笛/箫(气声+揉音), pluck=琵琶/古筝(拨弦), pluckLow=低音拨弦
|
|
155
|
-
_voice(kind, f, t, dur, vol) {
|
|
156
|
-
if (kind === 'di') this._di(f, t, dur, vol);
|
|
157
|
-
else if (kind === 'pluck') this._pluck(f, t, Math.min(dur, 0.9), vol);
|
|
158
|
-
else this._pluck(f, t, Math.min(dur, 1.2), vol * 0.8);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
_di(f, t, dur, vol) {
|
|
162
|
-
if (!this.ctx) return;
|
|
163
|
-
try {
|
|
164
|
-
const o = this.ctx.createOscillator();
|
|
165
|
-
const g = this.ctx.createGain();
|
|
166
|
-
o.type = 'sine';
|
|
167
|
-
o.frequency.value = f;
|
|
168
|
-
// 揉音
|
|
169
|
-
const lfo = this.ctx.createOscillator();
|
|
170
|
-
const lg = this.ctx.createGain();
|
|
171
|
-
lfo.frequency.value = 4.5;
|
|
172
|
-
lg.gain.value = f * 0.006;
|
|
173
|
-
lfo.connect(lg).connect(o.frequency);
|
|
174
|
-
const atk = Math.min(0.18, dur * 0.3);
|
|
175
|
-
g.gain.setValueAtTime(0, t);
|
|
176
|
-
g.gain.linearRampToValueAtTime(vol, t + atk);
|
|
177
|
-
g.gain.setValueAtTime(vol * 0.85, t + Math.max(atk, dur - 0.25));
|
|
178
|
-
g.gain.linearRampToValueAtTime(0.0001, t + dur);
|
|
179
|
-
o.connect(g).connect(this.bgmGain);
|
|
180
|
-
o.start(t); o.stop(t + dur + 0.05);
|
|
181
|
-
lfo.start(t); lfo.stop(t + dur + 0.05);
|
|
182
|
-
// 轻噪气声
|
|
183
|
-
this._noise(t, Math.min(dur, 0.4), vol * 0.15, this.bgmGain, f * 4, 6);
|
|
184
|
-
} catch { /* ignore */ }
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
_pluck(f, t, dur, vol) {
|
|
188
|
-
if (!this.ctx) return;
|
|
189
|
-
try {
|
|
190
|
-
for (const [mult, v] of [[1, 1], [2, 0.4]]) {
|
|
191
|
-
const o = this.ctx.createOscillator();
|
|
192
|
-
const g = this.ctx.createGain();
|
|
193
|
-
o.type = 'triangle';
|
|
194
|
-
o.frequency.value = f * mult;
|
|
195
|
-
g.gain.setValueAtTime(vol * v, t);
|
|
196
|
-
g.gain.exponentialRampToValueAtTime(0.0001, t + dur);
|
|
197
|
-
o.connect(g).connect(this.bgmGain);
|
|
198
|
-
o.start(t); o.stop(t + dur + 0.05);
|
|
199
|
-
}
|
|
200
|
-
} catch { /* ignore */ }
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
_noise(t, dur, vol, dest, filterFreq = 1200, q = 1) {
|
|
204
|
-
if (!this.ctx) return;
|
|
205
|
-
try {
|
|
206
|
-
if (!this._noiseBuf) {
|
|
207
|
-
const len = this.ctx.sampleRate * 0.5;
|
|
208
|
-
this._noiseBuf = this.ctx.createBuffer(1, len, this.ctx.sampleRate);
|
|
209
|
-
const d = this._noiseBuf.getChannelData(0);
|
|
210
|
-
for (let i = 0; i < len; i++) d[i] = Math.random() * 2 - 1;
|
|
211
|
-
}
|
|
212
|
-
const src = this.ctx.createBufferSource();
|
|
213
|
-
src.buffer = this._noiseBuf;
|
|
214
|
-
const f = this.ctx.createBiquadFilter();
|
|
215
|
-
f.type = 'bandpass';
|
|
216
|
-
f.frequency.value = filterFreq;
|
|
217
|
-
f.Q.value = q;
|
|
218
|
-
const g = this.ctx.createGain();
|
|
219
|
-
g.gain.setValueAtTime(vol, t);
|
|
220
|
-
g.gain.exponentialRampToValueAtTime(0.0001, t + dur);
|
|
221
|
-
src.connect(f).connect(g).connect(dest);
|
|
222
|
-
src.start(t); src.stop(t + dur + 0.02);
|
|
223
|
-
} catch { /* ignore */ }
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
_block(t, f, dur, vol, dest) { // 木鱼/云板基件
|
|
227
|
-
this._tone(f, t, dur, 'sine', vol, dest, 0.002, dur * 0.6);
|
|
228
|
-
this._noise(t, Math.min(0.04, dur), vol * 0.5, dest, f * 3, 4);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
_tone(f, t, dur, wave, vol, dest, attack = 0.005, release = 0.06) {
|
|
232
|
-
if (!this.ctx) return;
|
|
233
|
-
try {
|
|
234
|
-
const o = this.ctx.createOscillator();
|
|
235
|
-
const g = this.ctx.createGain();
|
|
236
|
-
o.type = wave;
|
|
237
|
-
o.frequency.value = f;
|
|
238
|
-
g.gain.setValueAtTime(0, t);
|
|
239
|
-
g.gain.linearRampToValueAtTime(vol, t + attack);
|
|
240
|
-
g.gain.setValueAtTime(vol * 0.8, t + Math.max(attack, dur - release));
|
|
241
|
-
g.gain.linearRampToValueAtTime(0.0001, t + dur);
|
|
242
|
-
o.connect(g).connect(dest);
|
|
243
|
-
o.start(t); o.stop(t + dur + 0.05);
|
|
244
|
-
} catch { /* ignore */ }
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// ---------- 第79回:两秒内抽空,静默3-4秒 ----------
|
|
248
|
-
// 全作最重要的听觉时刻;任何音效不得盖过这段静默。
|
|
249
|
-
playClear(onDone) {
|
|
250
|
-
if (!this.ctx) { onDone?.(); return; }
|
|
251
|
-
this._clearing = true;
|
|
252
|
-
this.stopBGM();
|
|
253
|
-
const t = this.ctx.currentTime;
|
|
254
|
-
const g = this.bgmGain.gain;
|
|
255
|
-
g.cancelScheduledValues(t);
|
|
256
|
-
g.setValueAtTime(g.value, t);
|
|
257
|
-
g.linearRampToValueAtTime(0.0001, t + 2.0); // 抽空
|
|
258
|
-
// 只剩一个衰减的低音
|
|
259
|
-
this._tone(freq(0, -2), t + 0.3, 2.2, 'sine', 0.12, this.master, 0.02, 1.8);
|
|
260
|
-
// 静默 3.4 秒后归还声场
|
|
261
|
-
setTimeout(() => {
|
|
262
|
-
if (!this.ctx) return;
|
|
263
|
-
this.bgmGain.gain.setTargetAtTime(0.30, this.ctx.currentTime, 0.5);
|
|
264
|
-
this._clearing = false;
|
|
265
|
-
onDone?.();
|
|
266
|
-
}, 2000 + 3400);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// ---------- SFX ----------
|
|
270
|
-
sfx(name, opt = {}) {
|
|
271
|
-
if (!this.ctx || this.muted) return;
|
|
272
|
-
const t = this.ctx.currentTime + 0.01;
|
|
273
|
-
const out = this.sfxGain;
|
|
274
|
-
switch (name) {
|
|
275
|
-
case 'ming': // 金:清亮金属泛音,短促上扬
|
|
276
|
-
this._tone(1568, t, 0.14, 'sine', 0.16, out, 0.001, 0.08);
|
|
277
|
-
this._tone(2093, t + 0.05, 0.16, 'sine', 0.12, out, 0.001, 0.1);
|
|
278
|
-
this._tone(2637, t + 0.09, 0.12, 'sine', 0.06, out, 0.001, 0.08);
|
|
279
|
-
break;
|
|
280
|
-
case 'an': // 墨:低而闷的木质轻响,几乎听不见
|
|
281
|
-
this._block(t, 320, 0.06, 0.045, out);
|
|
282
|
-
break;
|
|
283
|
-
case 'wind': // 朱:压抑的擦弦/气声,不安
|
|
284
|
-
this._noise(t, 0.35, 0.09, out, 480, 3);
|
|
285
|
-
this._tone(233, t, 0.3, 'sawtooth', 0.03, out, 0.12, 0.12);
|
|
286
|
-
break;
|
|
287
|
-
case 'submit': // 云板一记
|
|
288
|
-
this._tone(1180, t, 0.1, 'sine', 0.2, out, 0.001, 0.06);
|
|
289
|
-
this._noise(t, 0.05, 0.12, out, 2600, 4);
|
|
290
|
-
break;
|
|
291
|
-
case 'plank': // 木牌翻动
|
|
292
|
-
this._block(t, 640, 0.05, 0.14, out);
|
|
293
|
-
this._block(t + 0.06, 520, 0.05, 0.11, out);
|
|
294
|
-
break;
|
|
295
|
-
case 'paper': // 纸张轻响
|
|
296
|
-
this._noise(t, 0.12, 0.08, out, 3200, 1.2);
|
|
297
|
-
break;
|
|
298
|
-
case 'wang': // 闷实的印章落纸
|
|
299
|
-
this._block(t, 210, 0.1, 0.2, out);
|
|
300
|
-
this._noise(t, 0.07, 0.1, out, 700, 1.5);
|
|
301
|
-
break;
|
|
302
|
-
case 'mou': { // 极轻的连续摩擦,进度越高越明显
|
|
303
|
-
const p = Math.min(1, (opt.progress ?? 30) / 100);
|
|
304
|
-
this._noise(t, 0.3, 0.03 + p * 0.05, out, 900 + p * 600, 5);
|
|
305
|
-
break;
|
|
306
|
-
}
|
|
307
|
-
case 'faluo': { // 沉重的堂木+余响
|
|
308
|
-
this._tone(140, t, 0.4, 'sine', 0.3, out, 0.002, 0.3);
|
|
309
|
-
this._block(t, 260, 0.12, 0.26, out);
|
|
310
|
-
this._noise(t + 0.1, 0.6, 0.08, out, 300, 1);
|
|
311
|
-
break;
|
|
312
|
-
}
|
|
313
|
-
case 'watch': // 远处更漏,两下
|
|
314
|
-
this._block(t, 380, 0.09, 0.07, out);
|
|
315
|
-
this._block(t + 0.5, 340, 0.09, 0.055, out);
|
|
316
|
-
break;
|
|
317
|
-
case 'qing': { // 结局定格:悠长的磬
|
|
318
|
-
this._tone(1047, t, 2.8, 'sine', 0.14, out, 0.004, 2.4);
|
|
319
|
-
this._tone(1568, t, 2.2, 'sine', 0.05, out, 0.004, 1.8);
|
|
320
|
-
this._tone(524, t, 3.0, 'sine', 0.06, out, 0.004, 2.6);
|
|
321
|
-
break;
|
|
322
|
-
}
|
|
323
|
-
case 'click':
|
|
324
|
-
this._block(t, 760, 0.04, 0.1, out);
|
|
325
|
-
break;
|
|
326
|
-
default:
|
|
327
|
-
break;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
export const audio = new AudioEngine();
|