@zhin.js/plugin-idiom-chain 1.1.15 → 1.1.16
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/commands/chain/[[action]]/index.js +4 -4
- package/commands/chain/[[action]]/index.ts +4 -4
- package/lib/chain-command.d.ts +1 -0
- package/lib/chain-command.js +27 -20
- package/lib/chain-command.js.map +1 -1
- package/lib/game-flow.js +52 -23
- package/lib/game-flow.js.map +1 -1
- package/lib/idiom-provider.d.ts +4 -3
- package/lib/idiom-provider.js +23 -11
- package/lib/idiom-provider.js.map +1 -1
- package/lib/models.d.ts +4 -1
- package/lib/models.js +2 -1
- package/lib/models.js.map +1 -1
- package/lib/session-service.js +1 -0
- package/lib/session-service.js.map +1 -1
- package/lib/view.js +28 -13
- package/lib/view.js.map +1 -1
- package/middlewares/chain-alias/index.js +5 -3
- package/middlewares/chain-alias/index.ts +5 -3
- package/package.json +7 -7
- package/plugin.js +4 -0
- package/src/chain-command.ts +29 -24
- package/src/game-flow.ts +53 -23
- package/src/idiom-provider.ts +25 -11
- package/src/models.ts +4 -2
- package/src/session-service.ts +1 -0
- package/src/view.ts +29 -13
package/src/view.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createMessages } from 'zhin.js/i18n';
|
|
1
2
|
import { buildChoiceKeyboard } from '@zhin.js/game-kit';
|
|
2
3
|
import type { SendContent } from '@zhin.js/core/runtime';
|
|
3
4
|
import type { ChainSessionRow } from './models.js';
|
|
@@ -17,19 +18,19 @@ export function buildChainView(
|
|
|
17
18
|
const terminal = session.status !== 'active';
|
|
18
19
|
const mode = sessionMode(session);
|
|
19
20
|
const lines = [
|
|
20
|
-
|
|
21
|
+
messages(session.locale ?? undefined, 'text1', { p0: modeLabel(mode, session.locale ?? undefined) }),
|
|
21
22
|
'',
|
|
22
|
-
|
|
23
|
+
messages(session.locale ?? undefined, 'text2', { p0: idiomCount(), p1: session.player_score, p2: session.bot_score, p3: session.streak, p4: session.best_streak }),
|
|
23
24
|
];
|
|
24
25
|
|
|
25
26
|
if (session.last_idiom) {
|
|
26
27
|
const gloss = getGloss(session.last_idiom);
|
|
27
|
-
lines.push('',
|
|
28
|
-
lines.push(promptLine(session.last_idiom, mode));
|
|
28
|
+
lines.push('', messages(session.locale ?? undefined, 'text3', { p0: session.last_idiom }) + (gloss ? `(${gloss})` : ''));
|
|
29
|
+
lines.push(promptLine(session.last_idiom, mode, session.locale ?? undefined));
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
if (session.wrong_count > 0 && session.status === 'active') {
|
|
32
|
-
lines.push(
|
|
33
|
+
lines.push(messages(session.locale ?? undefined, 'text4', { p0: session.wrong_count, p1: MAX_WRONG }));
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
if (eventLines.length) {
|
|
@@ -38,18 +39,18 @@ export function buildChainView(
|
|
|
38
39
|
|
|
39
40
|
if (terminal) {
|
|
40
41
|
lines.push('');
|
|
41
|
-
if (session.status === 'won') lines.push(
|
|
42
|
-
else if (session.status === 'lost') lines.push(
|
|
42
|
+
if (session.status === 'won') lines.push(messages(session.locale ?? undefined, 'text5'));
|
|
43
|
+
else if (session.status === 'lost') lines.push(messages(session.locale ?? undefined, 'text6'));
|
|
43
44
|
} else {
|
|
44
|
-
lines.push('', '
|
|
45
|
+
lines.push('', messages(session.locale ?? undefined, 'text7'));
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
const choices = terminal
|
|
48
|
-
? [{ id: 'restart', label:
|
|
49
|
+
? [{ id: 'restart', label: messages(session.locale ?? undefined, 'text8'), style: 'primary' as const, keepEnabledWhenTerminal: true }]
|
|
49
50
|
: [
|
|
50
|
-
{ id: 'hint', label:
|
|
51
|
-
{ id: 'skip', label:
|
|
52
|
-
{ id: 'quit', label:
|
|
51
|
+
{ id: 'hint', label: messages(session.locale ?? undefined, 'text9'), style: 'secondary' as const },
|
|
52
|
+
{ id: 'skip', label: messages(session.locale ?? undefined, 'text10'), style: 'secondary' as const },
|
|
53
|
+
{ id: 'quit', label: messages(session.locale ?? undefined, 'text11'), style: 'danger' as const },
|
|
53
54
|
];
|
|
54
55
|
|
|
55
56
|
return buildChoiceKeyboard({
|
|
@@ -59,10 +60,25 @@ export function buildChainView(
|
|
|
59
60
|
choices,
|
|
60
61
|
terminal,
|
|
61
62
|
buttonsPerRow: 3,
|
|
62
|
-
fallbackHint:
|
|
63
|
+
fallbackHint: messages(session.locale ?? undefined, 'text12'),
|
|
63
64
|
interactionProfile: terminal ? 'terminal' : 'gameplay',
|
|
64
65
|
channelType,
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
export { MAX_WRONG };
|
|
70
|
+
|
|
71
|
+
const messages = createMessages({
|
|
72
|
+
text1: { 'zh-CN': "📜 **成语接龙** · {p0}", en: "📜 **Chinese Idiom Chain** · {p0}" },
|
|
73
|
+
text2: { 'zh-CN': "词库 **{p0}** 条 · 局分 {p1}:{p2} · 连击 **{p3}**(最佳 {p4})", en: "Dictionary **{p0}** entries · Score {p1}:{p2} · Streak **{p3}** (best {p4})" },
|
|
74
|
+
text3: { 'zh-CN': "上一句:**{p0}**", en: "Last idiom: **{p0}**" },
|
|
75
|
+
text4: { 'zh-CN': "⚠️ 失误 {p0}/{p1}", en: "⚠️ Mistakes: {p0}/{p1}" },
|
|
76
|
+
text5: { 'zh-CN': "🏆 **你赢了本局!** 机器人接不上啦。", en: "🏆 **You won!** The bot has no next idiom." },
|
|
77
|
+
text6: { 'zh-CN': "💀 **机器人获胜。** 点击「再来一局」重新开始。", en: "💀 **The bot won.** Choose “Play again” to start again." },
|
|
78
|
+
text7: { 'zh-CN': "直接回复四字成语,或点下方按钮:", en: "Reply with a four-character Chinese idiom, or choose an option:" },
|
|
79
|
+
text8: { 'zh-CN': "🔄 再来一局", en: "🔄 Play again" },
|
|
80
|
+
text9: { 'zh-CN': "💡 提示", en: "💡 Hint" },
|
|
81
|
+
text10: { 'zh-CN': "⏭️ 跳过", en: "⏭️ Skip" },
|
|
82
|
+
text11: { 'zh-CN': "🏳️ 认输", en: "🏳️ Concede" },
|
|
83
|
+
text12: { 'zh-CN': "回复成语,或 1提示 2跳过 3认输", en: "Reply with an idiom, or 1 Hint · 2 Skip · 3 Concede" },
|
|
84
|
+
});
|