@sia.soul/sia-react-ui 0.1.106 → 0.1.107
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/dist/Button-BiL3Wjsd.d.ts +44 -0
- package/dist/Button-O_pNB3SQ.d.cts +44 -0
- package/dist/{Select-DmT9pFRW.d.ts → Select-BddM4uXC.d.ts} +4 -42
- package/dist/{Select-DQpfyK7I.d.cts → Select-Cf0xz1Tg.d.cts} +4 -42
- package/dist/chart.js +5 -3
- package/dist/chunk-4TTHKFJ7.js +706 -0
- package/dist/chunk-CZ2ITBRW.js +65 -0
- package/dist/{chunk-EYB55TC5.js → chunk-D3HXXEEZ.js} +9 -5
- package/dist/{chunk-X4OLHWC3.js → chunk-JEDJQ257.js} +11 -7
- package/dist/chunk-KY6A5IJH.js +18 -0
- package/dist/{chunk-NURPAO7G.js → chunk-MMSYWDTR.js} +9 -5
- package/dist/{chunk-PUZWLIIJ.js → chunk-NZMUW5XI.js} +1 -13
- package/dist/{chunk-D456SSL3.js → chunk-OJ2WDC66.js} +6 -4
- package/dist/{chunk-V6CRVCSB.js → chunk-QV3AP6A2.js} +40 -729
- package/dist/chunk-RX242MUO.js +0 -0
- package/dist/chunk-SCEHVGKV.js +75 -0
- package/dist/{chunk-TUXNOSCT.js → chunk-SO7IJZIR.js} +4 -2
- package/dist/{chunk-T3EGAN7O.js → chunk-WD56MJO2.js} +5 -3
- package/dist/{core-_1K1jLyH.d.ts → core-Bm-1bOjF.d.ts} +8 -1
- package/dist/{core-DF7gei-P.d.cts → core-zpQkbNf_.d.cts} +8 -1
- package/dist/core.cjs +3 -1
- package/dist/core.css +31 -0
- package/dist/core.d.cts +3 -2
- package/dist/core.d.ts +3 -2
- package/dist/core.js +12 -7
- package/dist/game.cjs +2801 -0
- package/dist/game.css +8919 -0
- package/dist/game.d.cts +416 -0
- package/dist/game.d.ts +416 -0
- package/dist/game.js +1020 -0
- package/dist/index.cjs +5518 -5460
- package/dist/index.css +71 -0
- package/dist/index.d.cts +45 -10
- package/dist/index.d.ts +45 -10
- package/dist/index.js +718 -656
- package/dist/markdown-editor.js +3 -2
- package/dist/rich-text-editor.cjs +3 -1
- package/dist/rich-text-editor.js +7 -4
- package/dist/{select-date-range-BT71tp7y.d.cts → select-date-range-Cm5o2xPp.d.cts} +1 -1
- package/dist/{select-date-range-CFGzoyLs.d.ts → select-date-range-yGDEA1RP.d.ts} +1 -1
- package/dist/select-date-range.d.cts +3 -2
- package/dist/select-date-range.d.ts +3 -2
- package/dist/select-date-range.js +8 -5
- package/package.json +9 -3
- package/dist/chunk-SJFT5OSX.js +0 -131
package/dist/game.js
ADDED
|
@@ -0,0 +1,1020 @@
|
|
|
1
|
+
import "./chunk-RX242MUO.js";
|
|
2
|
+
import {
|
|
3
|
+
Modal
|
|
4
|
+
} from "./chunk-QV3AP6A2.js";
|
|
5
|
+
import {
|
|
6
|
+
Button
|
|
7
|
+
} from "./chunk-CZ2ITBRW.js";
|
|
8
|
+
import "./chunk-NZMUW5XI.js";
|
|
9
|
+
|
|
10
|
+
// src/game/engine.ts
|
|
11
|
+
function createIdleEngine(definition) {
|
|
12
|
+
const MAPS = definition.maps, PETS = definition.pets, slots = definition.slots, RARITIES = definition.rarities;
|
|
13
|
+
const slotKeys = Object.keys(slots), SLOTS = Object.fromEntries(slotKeys.map((key) => [key, slots[key].name]));
|
|
14
|
+
const positive = (value) => Number.isFinite(value) && value > 0;
|
|
15
|
+
if (!MAPS.length || !PETS.length || !slotKeys.length || RARITIES.length < 3 || new Set(PETS.map((p) => p.id)).size !== PETS.length || MAPS.some((m, i) => m.id !== i || !slots[m.rewardSlot] || !positive(m.hp) || !positive(m.bossHp) || [m.atk, m.bossAtk, m.xp, m.gold].some((n) => !Number.isFinite(n) || n < 0)) || PETS.some((p) => !p.id || !Number.isFinite(p.cost) || p.cost < 0 || !Number.isFinite(p.base) || p.base < 0) || slotKeys.some((k) => slots[k].names.length !== RARITIES.length || Object.values(slots[k].base).some((n) => !Number.isFinite(n) || n < 0)) || definition.offlineCapSeconds !== void 0 && (!Number.isInteger(definition.offlineCapSeconds) || definition.offlineCapSeconds < 0 || definition.offlineCapSeconds > 43200))
|
|
16
|
+
throw new Error("\u6E38\u620F\u5185\u5BB9\u914D\u7F6E\u4E0D\u6B63\u786E");
|
|
17
|
+
const busy2 = (s) => Boolean(s.fight?.boss && s.fight.status === "active");
|
|
18
|
+
const copy = (value) => JSON.parse(JSON.stringify(value));
|
|
19
|
+
function makeGear(slot, tier = 0, rank = 0, id = Date.now()) {
|
|
20
|
+
const scale = (1 + tier * 0.75) * (1 + rank * 0.45);
|
|
21
|
+
return { id: String(id), slot, tier, rank, name: slots[slot].names[tier], atk: Math.round(slots[slot].base.atk * scale), def: Math.round(slots[slot].base.def * scale), hp: Math.round(slots[slot].base.hp * scale), locked: false };
|
|
22
|
+
}
|
|
23
|
+
function freshState(now = Date.now()) {
|
|
24
|
+
return { version: 1, name: definition.heroName, level: 1, xp: 0, gold: 120, essence: 30, material: 0, map: 0, unlocked: 0, cleared: [], idle: false, kills: 0, bossWins: 0, inventory: [], equipment: Object.fromEntries(slotKeys.map((key) => [key, slots[key].starter ? makeGear(key, 0, 0, `starter-${key}`) : null])), upgrades: Object.fromEntries(slotKeys.map((key) => [key, 0])), pet: PETS[0].id, pets: { [PETS[0].id]: 1 }, nextId: 1, savedAt: now, sessionGold: 0, sessionXp: 0, sessionDrops: 0, logs: [], fight: null };
|
|
25
|
+
}
|
|
26
|
+
const xpNeeded = (s) => 50 + s.level * 30;
|
|
27
|
+
function stats(s) {
|
|
28
|
+
const result = { power: 0, atk: 16 + (s.level - 1) * 4, def: 3 + (s.level - 1) * 2, hp: 165 + (s.level - 1) * 23 };
|
|
29
|
+
for (const [slot, item] of Object.entries(s.equipment))
|
|
30
|
+
if (item) {
|
|
31
|
+
const multiplier = 1 + s.upgrades[slot] * 0.16;
|
|
32
|
+
for (const key of ["atk", "def", "hp"])
|
|
33
|
+
result[key] += Math.round(item[key] * multiplier);
|
|
34
|
+
}
|
|
35
|
+
result.power = result.atk * 5 + result.def * 3 + Math.round(result.hp / 5) + (s.pets[s.pet] || 0) * 18;
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
function addLog(s, text, type = "info") {
|
|
39
|
+
s.logs.unshift({ text, type, time: Date.now() });
|
|
40
|
+
s.logs = s.logs.slice(0, 60);
|
|
41
|
+
}
|
|
42
|
+
function addDrop(s, item) {
|
|
43
|
+
s.sessionDrops++;
|
|
44
|
+
if (s.inventory.length >= 80) {
|
|
45
|
+
s.material += 2 + item.tier * 2;
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
s.inventory.push(item);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
function grant(s, xp, gold) {
|
|
52
|
+
s.xp += xp;
|
|
53
|
+
s.gold += gold;
|
|
54
|
+
s.sessionGold += gold;
|
|
55
|
+
s.sessionXp += xp;
|
|
56
|
+
while (s.xp >= xpNeeded(s) && s.level < 60) {
|
|
57
|
+
s.xp -= xpNeeded(s);
|
|
58
|
+
s.level++;
|
|
59
|
+
addLog(s, `\u5883\u754C\u7CBE\u8FDB\uFF0C\u5347\u81F3 ${s.level} \u7EA7\uFF01`, "rare");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function beginFight(s, boss = false) {
|
|
63
|
+
if (boss && busy2(s))
|
|
64
|
+
return;
|
|
65
|
+
const m = MAPS[s.map], st = stats(s);
|
|
66
|
+
s.fight = { boss, hp: st.hp, maxHp: st.hp, enemyHp: boss ? m.bossHp : m.hp, enemyMax: boss ? m.bossHp : m.hp, turn: 0, status: "active", recovery: 0 };
|
|
67
|
+
if (boss)
|
|
68
|
+
addLog(s, `\u5411 ${m.boss} \u53D1\u8D77\u6311\u6218\u3002`, "boss");
|
|
69
|
+
}
|
|
70
|
+
function tick(s, rng = Math.random) {
|
|
71
|
+
if (!s.idle && !s.fight?.boss)
|
|
72
|
+
return null;
|
|
73
|
+
if (!s.fight)
|
|
74
|
+
beginFight(s);
|
|
75
|
+
let f = s.fight;
|
|
76
|
+
if (f.status !== "active") {
|
|
77
|
+
if (++f.recovery < 2)
|
|
78
|
+
return null;
|
|
79
|
+
if (!s.idle) {
|
|
80
|
+
s.fight = null;
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
beginFight(s);
|
|
84
|
+
f = s.fight;
|
|
85
|
+
}
|
|
86
|
+
const st = stats(s), m = MAPS[s.map];
|
|
87
|
+
f.turn++;
|
|
88
|
+
const skill = f.turn % 3 === 0, crit = rng() < 0.13;
|
|
89
|
+
const damage = Math.round(st.atk * (skill ? 1.65 : 1) * (crit ? 1.5 : 1));
|
|
90
|
+
const pet = PETS.find((p) => p.id === s.pet), petLevel = s.pets[s.pet] || 1;
|
|
91
|
+
const petDamage = pet.base + (petLevel - 1) * 3;
|
|
92
|
+
f.enemyHp = Math.max(0, f.enemyHp - damage - petDamage);
|
|
93
|
+
if (pet.effect === "heal")
|
|
94
|
+
f.hp = Math.min(f.maxHp, f.hp + 7 + petLevel * 3);
|
|
95
|
+
const event = { damage, petDamage, crit, skill, incoming: 0 };
|
|
96
|
+
if (f.enemyHp === 0) {
|
|
97
|
+
f.status = "won";
|
|
98
|
+
s.kills++;
|
|
99
|
+
if (f.boss) {
|
|
100
|
+
s.bossWins++;
|
|
101
|
+
const first = !s.cleared.includes(s.map);
|
|
102
|
+
grant(s, m.xp * (first ? 6 : 2), m.gold * (first ? 8 : 3));
|
|
103
|
+
s.essence += first ? 50 : 12;
|
|
104
|
+
if (first) {
|
|
105
|
+
s.cleared.push(s.map);
|
|
106
|
+
s.unlocked = Math.min(MAPS.length - 1, Math.max(s.unlocked, s.map + 1));
|
|
107
|
+
const item = makeGear(m.rewardSlot, 1, s.map, `drop-${s.nextId++}`);
|
|
108
|
+
addDrop(s, item);
|
|
109
|
+
event.reward = item.name;
|
|
110
|
+
addLog(s, `\u9996\u901A ${m.boss}\uFF01\u83B7\u5F97 ${item.name}\uFF0C${s.map < MAPS.length - 1 ? "\u65B0\u7684\u897F\u884C\u5730\u56FE\u5DF2\u89E3\u9501\u3002" : "\u5168\u90E8\u7AE0\u8282\u8BD5\u70BC\u5B8C\u6210\uFF01"}`, "rare");
|
|
111
|
+
} else
|
|
112
|
+
addLog(s, `\u518D\u6B21\u51FB\u8D25 ${m.boss}\uFF0C\u83B7\u5F97\u4FEE\u884C\u5956\u52B1\u3002`, "rare");
|
|
113
|
+
event.bossWin = true;
|
|
114
|
+
event.first = first;
|
|
115
|
+
} else {
|
|
116
|
+
grant(s, m.xp, m.gold);
|
|
117
|
+
s.essence += 2;
|
|
118
|
+
if (rng() < 0.38) {
|
|
119
|
+
const item = makeGear(Object.keys(SLOTS)[Math.min(slotKeys.length - 1, Math.floor(rng() * slotKeys.length))], rng() < 0.12 ? 2 : rng() < 0.45 ? 1 : 0, s.map, `drop-${s.nextId++}`);
|
|
120
|
+
const kept = addDrop(s, item);
|
|
121
|
+
addLog(s, kept ? `\u62FE\u5F97 ${RARITIES[item.tier]} \xB7 ${item.name}` : "\u80CC\u5305\u5DF2\u6EE1\uFF0C\u65B0\u6389\u843D\u5DF2\u8F6C\u4E3A\u953B\u6750\u3002", "loot");
|
|
122
|
+
event.drop = item.name;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return event;
|
|
126
|
+
}
|
|
127
|
+
const incoming = Math.max(1, Math.round(((f.boss ? m.bossAtk : m.atk) * (f.boss && f.turn % 4 === 0 ? 1.5 : 1) - st.def) * (pet.effect === "guard" ? 0.75 : 1)));
|
|
128
|
+
f.hp = Math.max(0, f.hp - incoming);
|
|
129
|
+
event.incoming = incoming;
|
|
130
|
+
if (f.hp === 0 || f.turn >= 60) {
|
|
131
|
+
f.status = "lost";
|
|
132
|
+
event.lost = true;
|
|
133
|
+
addLog(s, `${f.boss ? m.boss : m.enemy}\u6311\u6218\u5931\u5229\uFF1A${f.hp === 0 ? "\u6C14\u8840\u8017\u5C3D\uFF0C\u53EF\u5F3A\u5316\u8863\u888D\u6216\u57F9\u517B\u7075\u5BA0\u3002" : "\u8F93\u51FA\u4E0D\u8DB3\uFF0C\u53EF\u66F4\u6362\u6B66\u5668\u3002"}\u4F11\u6574\u540E\u7EE7\u7EED\u3002`, "boss");
|
|
134
|
+
}
|
|
135
|
+
return event;
|
|
136
|
+
}
|
|
137
|
+
function equip(s, id) {
|
|
138
|
+
if (busy2(s))
|
|
139
|
+
return false;
|
|
140
|
+
const index = s.inventory.findIndex((i) => i.id === id);
|
|
141
|
+
if (index < 0)
|
|
142
|
+
return false;
|
|
143
|
+
const item = s.inventory.splice(index, 1)[0], old = s.equipment[item.slot];
|
|
144
|
+
if (old)
|
|
145
|
+
s.inventory.push(old);
|
|
146
|
+
s.equipment[item.slot] = item;
|
|
147
|
+
addLog(s, `\u88C5\u5907\u4E86 ${item.name}\u3002`, "loot");
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
const upgradeCost = (s, slot) => 45 + s.upgrades[slot] * 35;
|
|
151
|
+
function upgrade(s, slot) {
|
|
152
|
+
if (busy2(s))
|
|
153
|
+
return false;
|
|
154
|
+
if (!s.equipment[slot] || s.upgrades[slot] >= 10 || s.gold < upgradeCost(s, slot))
|
|
155
|
+
return false;
|
|
156
|
+
s.gold -= upgradeCost(s, slot);
|
|
157
|
+
s.upgrades[slot]++;
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
function dismantle(s, id) {
|
|
161
|
+
if (busy2(s))
|
|
162
|
+
return false;
|
|
163
|
+
const index = s.inventory.findIndex((i) => i.id === id && !i.locked);
|
|
164
|
+
if (index < 0)
|
|
165
|
+
return false;
|
|
166
|
+
const [item] = s.inventory.splice(index, 1);
|
|
167
|
+
s.material += 2 + item.tier * 2;
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
function forge(s) {
|
|
171
|
+
if (busy2(s))
|
|
172
|
+
return false;
|
|
173
|
+
if (s.material < 12)
|
|
174
|
+
return false;
|
|
175
|
+
s.material -= 12;
|
|
176
|
+
const slots2 = Object.keys(SLOTS), slot = slots2[(s.nextId - 1) % slotKeys.length];
|
|
177
|
+
addDrop(s, makeGear(slot, 2, s.map, `drop-${s.nextId++}`));
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
function trainPet(s, id) {
|
|
181
|
+
if (busy2(s))
|
|
182
|
+
return false;
|
|
183
|
+
const level = s.pets[id];
|
|
184
|
+
if (!level || level >= 20)
|
|
185
|
+
return false;
|
|
186
|
+
const cost = level * 15;
|
|
187
|
+
if (s.essence < cost)
|
|
188
|
+
return false;
|
|
189
|
+
s.essence -= cost;
|
|
190
|
+
s.pets[id]++;
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
function unlockPet(s, id) {
|
|
194
|
+
if (busy2(s))
|
|
195
|
+
return false;
|
|
196
|
+
const pet = PETS.find((p) => p.id === id);
|
|
197
|
+
if (!pet || s.pets[id] || s.essence < pet.cost)
|
|
198
|
+
return false;
|
|
199
|
+
s.essence -= pet.cost;
|
|
200
|
+
s.pets[id] = 1;
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
function hydrate(input, now = Date.now()) {
|
|
204
|
+
if (!input || typeof input !== "object")
|
|
205
|
+
throw new Error("\u5B58\u6863\u683C\u5F0F\u4E0D\u6B63\u786E");
|
|
206
|
+
const raw = input;
|
|
207
|
+
if (!raw || raw.version !== 1 || !Array.isArray(raw.inventory) || !raw.equipment || !raw.pets)
|
|
208
|
+
throw new Error("\u5B58\u6863\u683C\u5F0F\u4E0D\u6B63\u786E");
|
|
209
|
+
const s = freshState(now), number = (v, min, max) => typeof v === "number" && Number.isFinite(v) ? Math.max(min, Math.min(max, Math.floor(v))) : min;
|
|
210
|
+
for (const key of ["gold", "xp", "essence", "material", "kills", "bossWins", "sessionGold", "sessionXp", "sessionDrops"])
|
|
211
|
+
s[key] = number(raw[key], 0, 1e9);
|
|
212
|
+
s.level = number(raw.level, 1, 60);
|
|
213
|
+
s.unlocked = number(raw.unlocked, 0, MAPS.length - 1);
|
|
214
|
+
s.map = number(raw.map, 0, s.unlocked);
|
|
215
|
+
s.nextId = number(raw.nextId, 1, 1e9);
|
|
216
|
+
s.savedAt = number(raw.savedAt, 0, now);
|
|
217
|
+
s.idle = raw.idle === true;
|
|
218
|
+
s.cleared = [...new Set((Array.isArray(raw.cleared) ? raw.cleared : []).filter((v) => Number.isInteger(v) && v >= 0 && v < MAPS.length))];
|
|
219
|
+
const validItem = (item) => !!item && typeof item.id === "string" && item.id.length < 80 && /^[a-zA-Z0-9_-]+$/.test(item.id) && Object.hasOwn(SLOTS, item.slot) && Number.isInteger(item.tier) && item.tier >= 0 && item.tier < RARITIES.length;
|
|
220
|
+
const cleanItem = (item) => ({ ...makeGear(item.slot, item.tier, number(item.rank, 0, MAPS.length - 1), item.id), locked: item.locked === true });
|
|
221
|
+
s.inventory = raw.inventory.slice(0, 80).filter(validItem).map(cleanItem);
|
|
222
|
+
for (const slot of Object.keys(SLOTS)) {
|
|
223
|
+
s.equipment[slot] = validItem(raw.equipment[slot]) && raw.equipment[slot].slot === slot ? cleanItem(raw.equipment[slot]) : null;
|
|
224
|
+
s.upgrades[slot] = number(raw.upgrades?.[slot], 0, 10);
|
|
225
|
+
}
|
|
226
|
+
for (const pet of PETS)
|
|
227
|
+
if (raw.pets[pet.id])
|
|
228
|
+
s.pets[pet.id] = number(raw.pets[pet.id], 1, 20);
|
|
229
|
+
s.pet = Object.hasOwn(s.pets, raw.pet) ? raw.pet : PETS[0].id;
|
|
230
|
+
return s;
|
|
231
|
+
}
|
|
232
|
+
function settleOffline(s, now = Date.now(), rng = Math.random) {
|
|
233
|
+
const seconds = Math.min(definition.offlineCapSeconds ?? 43200, Math.max(0, Math.floor((now - s.savedAt) / 1e3)));
|
|
234
|
+
if (!s.idle || seconds < 15) {
|
|
235
|
+
s.savedAt = now;
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
const before = { xp: s.sessionXp, gold: s.gold, drops: s.sessionDrops, essence: s.essence, kills: s.kills };
|
|
239
|
+
s.fight = null;
|
|
240
|
+
for (let i = 0; i < seconds; i++)
|
|
241
|
+
tick(s, rng);
|
|
242
|
+
s.fight = null;
|
|
243
|
+
s.savedAt = now;
|
|
244
|
+
return { seconds, xp: s.sessionXp - before.xp, gold: s.gold - before.gold, drops: s.sessionDrops - before.drops, essence: s.essence - before.essence, kills: s.kills - before.kills };
|
|
245
|
+
}
|
|
246
|
+
function serialize(s, now = Date.now()) {
|
|
247
|
+
const saved = copy(s);
|
|
248
|
+
saved.savedAt = now;
|
|
249
|
+
saved.fight = null;
|
|
250
|
+
saved.logs = [];
|
|
251
|
+
return JSON.stringify(saved);
|
|
252
|
+
}
|
|
253
|
+
return { definition, freshState, makeGear, xpNeeded, stats, addLog, grant, beginFight, tick, equip, upgradeCost, upgrade, dismantle, forge, trainPet, unlockPet, hydrate, settleOffline, serialize };
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// src/game/components.tsx
|
|
257
|
+
import { useRef, useState } from "react";
|
|
258
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
259
|
+
function GameSprite({ asset, className = "" }) {
|
|
260
|
+
return /* @__PURE__ */ jsx("img", { className: `unit-art ${asset.flip ? "face-left" : ""} ${className}`, src: asset.src, alt: "", "aria-hidden": "true", draggable: false, decoding: "async" });
|
|
261
|
+
}
|
|
262
|
+
function GameButton({ className = "", ...props }) {
|
|
263
|
+
return /* @__PURE__ */ jsx(Button, { ...props, className: `game-button ${className}` });
|
|
264
|
+
}
|
|
265
|
+
var fmt = (n) => Math.floor(n).toLocaleString("zh-CN");
|
|
266
|
+
var busy = (s) => Boolean(s.fight?.boss && s.fight.status === "active");
|
|
267
|
+
var command = (fn, type, id) => () => fn({ type, id });
|
|
268
|
+
function Title({ kicker, title, children }) {
|
|
269
|
+
return /* @__PURE__ */ jsxs("div", { className: "view-title", children: [
|
|
270
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
271
|
+
/* @__PURE__ */ jsx("span", { className: "eyebrow", children: kicker }),
|
|
272
|
+
/* @__PURE__ */ jsx("h1", { children: title })
|
|
273
|
+
] }),
|
|
274
|
+
children
|
|
275
|
+
] });
|
|
276
|
+
}
|
|
277
|
+
function ItemStats({ item }) {
|
|
278
|
+
return /* @__PURE__ */ jsxs("div", { className: "item-stats", children: [
|
|
279
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
280
|
+
"\u653B\u51FB +",
|
|
281
|
+
item.atk
|
|
282
|
+
] }),
|
|
283
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
284
|
+
"\u9632\u5FA1 +",
|
|
285
|
+
item.def
|
|
286
|
+
] }),
|
|
287
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
288
|
+
"\u6C14\u8840 +",
|
|
289
|
+
item.hp
|
|
290
|
+
] })
|
|
291
|
+
] });
|
|
292
|
+
}
|
|
293
|
+
function GameShell({ engine, state, onAction, page, children }) {
|
|
294
|
+
const d = engine.definition, view = { engine, state, onAction };
|
|
295
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
296
|
+
/* @__PURE__ */ jsxs("header", { className: "topbar", children: [
|
|
297
|
+
/* @__PURE__ */ jsxs("div", { className: "brand", children: [
|
|
298
|
+
/* @__PURE__ */ jsx("span", { className: "brand-seal", children: d.title[0] }),
|
|
299
|
+
/* @__PURE__ */ jsxs("span", { className: "brand-title", children: [
|
|
300
|
+
d.title,
|
|
301
|
+
/* @__PURE__ */ jsx("small", { children: d.subtitle })
|
|
302
|
+
] })
|
|
303
|
+
] }),
|
|
304
|
+
/* @__PURE__ */ jsxs("div", { className: "realm", children: [
|
|
305
|
+
/* @__PURE__ */ jsx("span", { className: "live-dot" }),
|
|
306
|
+
"\u5355\u4EBA\u4FEE\u884C / \u653E\u7F6E\u5386\u7EC3"
|
|
307
|
+
] }),
|
|
308
|
+
/* @__PURE__ */ jsxs("div", { className: "top-actions", children: [
|
|
309
|
+
/* @__PURE__ */ jsx("span", { className: "version", children: "Sia Game \xB7 v0.3" }),
|
|
310
|
+
/* @__PURE__ */ jsx(GameButton, { className: "icon-button", "aria-label": "\u8BBE\u7F6E\u4E0E\u5B58\u6863", onClick: command(onAction, "settings"), children: "\u2699" })
|
|
311
|
+
] })
|
|
312
|
+
] }),
|
|
313
|
+
/* @__PURE__ */ jsxs("nav", { className: "navigation", "aria-label": "\u4E3B\u5BFC\u822A", children: [
|
|
314
|
+
[["battle", "\u2694", "\u6302\u673A\u5386\u7EC3"], ["maps", "\u25A7", "\u4E16\u754C\u5730\u56FE"], ["gear", "\u25A3", "\u88C5\u5907\u80CC\u5305"], ["pets", "\u2667", "\u4F19\u4F34\u56FE\u9274"]].map(([id, icon, text]) => /* @__PURE__ */ jsxs(GameButton, { className: `nav-item ${page === id ? "active" : ""}`, "aria-current": page === id ? "page" : void 0, onClick: command(onAction, "page", id), children: [
|
|
315
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: icon }),
|
|
316
|
+
d.labels?.[id] || text,
|
|
317
|
+
id === "gear" && /* @__PURE__ */ jsx("span", { className: "nav-count", children: state.inventory.length })
|
|
318
|
+
] }, id)),
|
|
319
|
+
/* @__PURE__ */ jsx("span", { className: "nav-verse", children: d.subtitle })
|
|
320
|
+
] }),
|
|
321
|
+
/* @__PURE__ */ jsxs("div", { className: "workspace", children: [
|
|
322
|
+
/* @__PURE__ */ jsx("aside", { className: "character-panel", children: /* @__PURE__ */ jsx(GameCharacterPanel, { ...view }) }),
|
|
323
|
+
/* @__PURE__ */ jsx("main", { children }),
|
|
324
|
+
/* @__PURE__ */ jsxs("aside", { className: "right-panel", children: [
|
|
325
|
+
/* @__PURE__ */ jsx(GameBossPanel, { ...view }),
|
|
326
|
+
/* @__PURE__ */ jsx(GameLogPanel, { ...view }),
|
|
327
|
+
/* @__PURE__ */ jsxs("div", { className: "save-state", children: [
|
|
328
|
+
"\u672C\u5730\u81EA\u52A8\u5B58\u6863 \xB7 \u79BB\u7EBF\u4E0A\u9650 ",
|
|
329
|
+
(d.offlineCapSeconds ?? 43200) / 3600,
|
|
330
|
+
" \u5C0F\u65F6"
|
|
331
|
+
] })
|
|
332
|
+
] })
|
|
333
|
+
] }),
|
|
334
|
+
/* @__PURE__ */ jsxs("footer", { children: [
|
|
335
|
+
d.title,
|
|
336
|
+
" / ",
|
|
337
|
+
d.subtitle,
|
|
338
|
+
/* @__PURE__ */ jsx("span", { children: "\u7531 SiaWebUI Game Framework \u9A71\u52A8" })
|
|
339
|
+
] })
|
|
340
|
+
] });
|
|
341
|
+
}
|
|
342
|
+
function GameCharacterPanel({ engine, state: s, onAction }) {
|
|
343
|
+
const d = engine.definition, st = engine.stats(s), pet = d.pets.find((p) => p.id === s.pet);
|
|
344
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
345
|
+
/* @__PURE__ */ jsxs("div", { className: "profile-top", children: [
|
|
346
|
+
/* @__PURE__ */ jsx("div", { className: "avatar", children: /* @__PURE__ */ jsx(GameSprite, { asset: d.hero }) }),
|
|
347
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
348
|
+
/* @__PURE__ */ jsx("span", { className: "eyebrow", children: d.hero.identity }),
|
|
349
|
+
/* @__PURE__ */ jsx("h2", { children: s.name }),
|
|
350
|
+
/* @__PURE__ */ jsxs("span", { className: "level-tag", children: [
|
|
351
|
+
"Lv.",
|
|
352
|
+
s.level,
|
|
353
|
+
" ",
|
|
354
|
+
/* @__PURE__ */ jsx("span", { children: "\u4FEE\u884C\u8005" })
|
|
355
|
+
] })
|
|
356
|
+
] })
|
|
357
|
+
] }),
|
|
358
|
+
/* @__PURE__ */ jsxs("div", { className: "power", children: [
|
|
359
|
+
/* @__PURE__ */ jsx("span", { children: "\u7EFC\u5408\u6218\u529B" }),
|
|
360
|
+
/* @__PURE__ */ jsx("strong", { children: fmt(st.power) })
|
|
361
|
+
] }),
|
|
362
|
+
/* @__PURE__ */ jsxs("div", { className: "experience", children: [
|
|
363
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
364
|
+
/* @__PURE__ */ jsx("span", { children: "\u4FEE\u884C\u7ECF\u9A8C" }),
|
|
365
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
366
|
+
fmt(s.xp),
|
|
367
|
+
" / ",
|
|
368
|
+
engine.xpNeeded(s)
|
|
369
|
+
] })
|
|
370
|
+
] }),
|
|
371
|
+
/* @__PURE__ */ jsx("div", { className: "progress", role: "progressbar", "aria-label": "\u4FEE\u884C\u7ECF\u9A8C", "aria-valuenow": s.xp, "aria-valuemin": 0, "aria-valuemax": engine.xpNeeded(s), children: /* @__PURE__ */ jsx("i", { style: { width: `${Math.min(100, s.xp / engine.xpNeeded(s) * 100)}%` } }) })
|
|
372
|
+
] }),
|
|
373
|
+
/* @__PURE__ */ jsx("div", { className: "attributes", children: [["\u6C14\u8840", st.hp], ["\u653B\u51FB", st.atk], ["\u9632\u5FA1", st.def], ["\u66B4\u51FB", "13%"]].map(([name, value]) => /* @__PURE__ */ jsxs("div", { children: [
|
|
374
|
+
/* @__PURE__ */ jsx("span", { children: name }),
|
|
375
|
+
/* @__PURE__ */ jsx("b", { children: value })
|
|
376
|
+
] }, name)) }),
|
|
377
|
+
/* @__PURE__ */ jsx("div", { className: "line-heading", children: "\u968F\u8EAB\u8D44\u8D22" }),
|
|
378
|
+
/* @__PURE__ */ jsx("div", { className: "wallet", children: [["\u94DC\u94B1", s.gold], ["\u7075\u8574", s.essence], ["\u953B\u6750", s.material]].map(([name, value]) => /* @__PURE__ */ jsxs("div", { children: [
|
|
379
|
+
/* @__PURE__ */ jsx("span", { children: name }),
|
|
380
|
+
/* @__PURE__ */ jsx("b", { children: fmt(Number(value)) })
|
|
381
|
+
] }, name)) }),
|
|
382
|
+
/* @__PURE__ */ jsxs("div", { className: "line-heading", children: [
|
|
383
|
+
/* @__PURE__ */ jsx("span", { children: "\u8EAB\u4E0A\u88C5\u5907" }),
|
|
384
|
+
/* @__PURE__ */ jsx(GameButton, { className: "text-button", onClick: command(onAction, "page", "gear"), children: "\u7BA1\u7406 \u203A" })
|
|
385
|
+
] }),
|
|
386
|
+
/* @__PURE__ */ jsx("div", { className: "equipped-list", children: Object.entries(d.slots).map(([key, slot]) => /* @__PURE__ */ jsxs(GameButton, { className: "equipped-item", onClick: command(onAction, "page", "gear"), children: [
|
|
387
|
+
/* @__PURE__ */ jsx("span", { className: "slot-symbol", children: "\u25C7" }),
|
|
388
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
389
|
+
/* @__PURE__ */ jsx("small", { children: slot.name }),
|
|
390
|
+
/* @__PURE__ */ jsx("b", { children: s.equipment[key]?.name || "\u5C1A\u672A\u88C5\u5907" })
|
|
391
|
+
] }),
|
|
392
|
+
/* @__PURE__ */ jsx("em", { children: s.upgrades[key] ? `+${s.upgrades[key]}` : "\u203A" })
|
|
393
|
+
] }, key)) }),
|
|
394
|
+
/* @__PURE__ */ jsxs(GameButton, { className: "pet-mini", onClick: command(onAction, "page", "pets"), children: [
|
|
395
|
+
/* @__PURE__ */ jsx("span", { className: "pet-mini-art", children: /* @__PURE__ */ jsx(GameSprite, { asset: pet.art }) }),
|
|
396
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
397
|
+
/* @__PURE__ */ jsx("small", { children: "\u51FA\u6218\u7075\u5BA0" }),
|
|
398
|
+
/* @__PURE__ */ jsxs("b", { children: [
|
|
399
|
+
pet.name,
|
|
400
|
+
" ",
|
|
401
|
+
/* @__PURE__ */ jsxs("em", { children: [
|
|
402
|
+
"Lv.",
|
|
403
|
+
s.pets[s.pet]
|
|
404
|
+
] })
|
|
405
|
+
] })
|
|
406
|
+
] })
|
|
407
|
+
] }),
|
|
408
|
+
/* @__PURE__ */ jsx("div", { className: "character-bottom", children: s.idle ? "\u25CF \u6B63\u5728\u6302\u673A\u4FEE\u884C" : "\u25CB \u95F2\u5EAD\u4FE1\u6B65 \xB7 \u7B49\u5F85\u5386\u7EC3" })
|
|
409
|
+
] });
|
|
410
|
+
}
|
|
411
|
+
function GameBattleStage({ engine, state: s, onAction, event, sequence = 0 }) {
|
|
412
|
+
const d = engine.definition, m = d.maps[s.map], f = s.fight, st = engine.stats(s), isBoss = Boolean(f?.boss), pet = d.pets.find((p) => p.id === s.pet);
|
|
413
|
+
const units = [{ side: "hero", name: s.name, identity: d.hero.identity, asset: d.hero, hp: f?.hp ?? st.hp, max: f?.maxHp ?? st.hp, damage: event?.incoming }, { side: "enemy", name: isBoss ? `\u5996\u738B \xB7 ${m.boss}` : m.enemy, identity: (isBoss ? m.bossArt : m.enemyArt).identity, asset: isBoss ? m.bossArt : m.enemyArt, hp: f?.enemyHp ?? m.hp, max: f?.enemyMax ?? m.hp, damage: event ? event.damage + event.petDamage : 0 }];
|
|
414
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
415
|
+
/* @__PURE__ */ jsx(Title, { kicker: `\u897F\u884C\u5386\u7EC3 / \u7B2C ${s.map + 1} \u7AE0`, title: m.name, children: /* @__PURE__ */ jsx(GameButton, { className: "subtle-button", disabled: busy(s), onClick: command(onAction, "page", "maps"), children: "\u25A7 \u5207\u6362\u5730\u56FE" }) }),
|
|
416
|
+
/* @__PURE__ */ jsxs("div", { className: `scene ${isBoss ? "boss-fight" : ""}`, children: [
|
|
417
|
+
/* @__PURE__ */ jsx("div", { className: "scene-art", children: /* @__PURE__ */ jsx("img", { className: "landscape", src: m.scene, alt: "" }) }),
|
|
418
|
+
/* @__PURE__ */ jsxs("div", { className: "scene-top", children: [
|
|
419
|
+
/* @__PURE__ */ jsxs("span", { className: "scene-label", children: [
|
|
420
|
+
"\u263C ",
|
|
421
|
+
m.subtitle
|
|
422
|
+
] }),
|
|
423
|
+
/* @__PURE__ */ jsx("span", { className: "scene-label", children: busy(s) ? "\u5996\u738B\u6311\u6218\u4E2D" : s.idle ? "\u6302\u673A\u4FEE\u884C\u4E2D" : "\u5C1A\u672A\u5F00\u59CB" })
|
|
424
|
+
] }),
|
|
425
|
+
/* @__PURE__ */ jsxs("div", { className: "scene-inscription", children: [
|
|
426
|
+
/* @__PURE__ */ jsx("span", { children: m.name }),
|
|
427
|
+
/* @__PURE__ */ jsx("small", { children: "\u5C71 \u6D77 \u6709 \u7075 \xB7 \u897F \u884C \u65E0 \u5C3D" })
|
|
428
|
+
] }),
|
|
429
|
+
units.map((u) => /* @__PURE__ */ jsxs("div", { className: `fighter ${u.side}`, children: [
|
|
430
|
+
/* @__PURE__ */ jsxs("div", { className: "unit-label", children: [
|
|
431
|
+
u.name,
|
|
432
|
+
u.side === "hero" && /* @__PURE__ */ jsxs("em", { children: [
|
|
433
|
+
" Lv.",
|
|
434
|
+
s.level
|
|
435
|
+
] })
|
|
436
|
+
] }),
|
|
437
|
+
/* @__PURE__ */ jsx("div", { className: "unit-identity", children: u.identity }),
|
|
438
|
+
/* @__PURE__ */ jsx("div", { className: `unit-health ${u.side === "enemy" ? "red" : ""}`, children: /* @__PURE__ */ jsx("i", { style: { width: `${u.hp / u.max * 100}%` } }) }),
|
|
439
|
+
/* @__PURE__ */ jsxs("div", { className: "health-text", children: [
|
|
440
|
+
u.hp,
|
|
441
|
+
" / ",
|
|
442
|
+
u.max
|
|
443
|
+
] }),
|
|
444
|
+
/* @__PURE__ */ jsx("div", { className: `sprite ${event ? u.side === "hero" ? "attack" : "hit" : ""}`, children: /* @__PURE__ */ jsx(GameSprite, { asset: u.asset }) }, sequence),
|
|
445
|
+
Boolean(u.damage) && /* @__PURE__ */ jsxs("div", { className: "damage float", children: [
|
|
446
|
+
u.side === "enemy" && event?.skill ? d.skillName + " " : "",
|
|
447
|
+
"\u2212",
|
|
448
|
+
u.damage
|
|
449
|
+
] }, `damage-${sequence}`)
|
|
450
|
+
] }, u.side)),
|
|
451
|
+
/* @__PURE__ */ jsxs("div", { className: "companion", children: [
|
|
452
|
+
/* @__PURE__ */ jsx(GameSprite, { asset: pet.art }),
|
|
453
|
+
/* @__PURE__ */ jsx("span", { children: pet.name })
|
|
454
|
+
] }),
|
|
455
|
+
event?.skill && /* @__PURE__ */ jsx("div", { className: "attack-flash cast", children: "\u6555" }, sequence),
|
|
456
|
+
/* @__PURE__ */ jsxs("div", { className: "scene-bottom", children: [
|
|
457
|
+
/* @__PURE__ */ jsx("span", { children: "\u25C7 \u81EA\u52A8\u62FE\u53D6\u5DF2\u5F00\u542F" }),
|
|
458
|
+
/* @__PURE__ */ jsx("span", { children: f ? `\u7B2C ${f.turn} \u56DE\u5408 / 60` : "\u9759\u5019\u51FA\u53D1" })
|
|
459
|
+
] })
|
|
460
|
+
] }),
|
|
461
|
+
/* @__PURE__ */ jsxs("div", { className: "battle-controls", children: [
|
|
462
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
463
|
+
/* @__PURE__ */ jsx("div", { className: "status-label", children: s.idle ? "\u884C\u8DEF\u4E0D\u6B47\uFF0C\u4FEE\u4E3A\u6E10\u957F" : "\u4E07\u91CC\u897F\u884C\uFF0C\u4ECE\u8FD9\u91CC\u5F00\u59CB" }),
|
|
464
|
+
/* @__PURE__ */ jsx("small", { children: "\u81EA\u52A8\u6218\u6597 \xB7 \u81EA\u52A8\u62FE\u53D6 \xB7 \u6301\u7EED\u6210\u957F" })
|
|
465
|
+
] }),
|
|
466
|
+
/* @__PURE__ */ jsx(GameButton, { className: "primary-button", disabled: busy(s), onClick: command(onAction, "idle"), children: s.idle ? "\u2161 \u6682\u505C\u6302\u673A" : "\u25B6 \u5F00\u59CB\u6302\u673A" })
|
|
467
|
+
] }),
|
|
468
|
+
/* @__PURE__ */ jsx(GameResourceSummary, { state: s }),
|
|
469
|
+
/* @__PURE__ */ jsxs("div", { className: "tip", children: [
|
|
470
|
+
/* @__PURE__ */ jsxs("p", { children: [
|
|
471
|
+
"\u6BCF\u4E09\u6B21\u51FA\u624B\u81EA\u52A8\u65BD\u653E\u300C",
|
|
472
|
+
d.skillName,
|
|
473
|
+
"\u300D\u3002\u88C5\u5907\u4E0E\u7075\u5BA0\u7684\u63D0\u5347\uFF0C\u4E5F\u4F1A\u8BA1\u5165\u79BB\u7EBF\u4FEE\u884C\u3002"
|
|
474
|
+
] }),
|
|
475
|
+
/* @__PURE__ */ jsx(GameButton, { className: "text-button", onClick: command(onAction, "help"), children: "\u73A9\u6CD5\u8BF4\u660E \u203A" })
|
|
476
|
+
] })
|
|
477
|
+
] });
|
|
478
|
+
}
|
|
479
|
+
function GameResourceSummary({ state: s }) {
|
|
480
|
+
return /* @__PURE__ */ jsxs("section", { className: "income", children: [
|
|
481
|
+
/* @__PURE__ */ jsxs("div", { className: "panel-heading", children: [
|
|
482
|
+
/* @__PURE__ */ jsx("h3", { children: "\u4FEE\u884C\u7D2F\u8BA1\u6240\u5F97" }),
|
|
483
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
484
|
+
"\u7D2F\u8BA1\u51FB\u8D25 ",
|
|
485
|
+
fmt(s.kills),
|
|
486
|
+
" \u4E2A\u654C\u4EBA"
|
|
487
|
+
] })
|
|
488
|
+
] }),
|
|
489
|
+
/* @__PURE__ */ jsx("div", { className: "income-grid", children: [["\u7ECF\u9A8C", s.sessionXp], ["\u94DC\u94B1", s.sessionGold], ["\u88C5\u5907", s.sessionDrops]].map(([label, value]) => /* @__PURE__ */ jsxs("div", { children: [
|
|
490
|
+
/* @__PURE__ */ jsx("span", { children: label }),
|
|
491
|
+
/* @__PURE__ */ jsxs("b", { children: [
|
|
492
|
+
fmt(Number(value)),
|
|
493
|
+
label === "\u88C5\u5907" ? " \u4EF6" : ""
|
|
494
|
+
] })
|
|
495
|
+
] }, label)) })
|
|
496
|
+
] });
|
|
497
|
+
}
|
|
498
|
+
function GameBossPanel({ engine, state: s, onAction }) {
|
|
499
|
+
const d = engine.definition, m = d.maps[s.map], cleared = s.cleared.includes(s.map);
|
|
500
|
+
return /* @__PURE__ */ jsxs("section", { id: "quest", children: [
|
|
501
|
+
/* @__PURE__ */ jsxs("div", { className: "panel-heading", children: [
|
|
502
|
+
/* @__PURE__ */ jsx("h3", { children: "\u2694 \u7AE0\u8282\u5996\u738B" }),
|
|
503
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
504
|
+
"\u7B2C ",
|
|
505
|
+
s.map + 1,
|
|
506
|
+
" / ",
|
|
507
|
+
d.maps.length,
|
|
508
|
+
" \u7AE0"
|
|
509
|
+
] })
|
|
510
|
+
] }),
|
|
511
|
+
/* @__PURE__ */ jsxs("div", { className: "boss-portrait", children: [
|
|
512
|
+
/* @__PURE__ */ jsx(GameSprite, { asset: m.bossArt }),
|
|
513
|
+
/* @__PURE__ */ jsx("span", { className: "boss-seal", children: cleared ? "\u5DF2\u7834" : "\u5996\u738B" })
|
|
514
|
+
] }),
|
|
515
|
+
/* @__PURE__ */ jsxs("div", { className: "boss-title", children: [
|
|
516
|
+
/* @__PURE__ */ jsx("h2", { children: m.boss }),
|
|
517
|
+
/* @__PURE__ */ jsx("span", { children: m.bossArt.identity })
|
|
518
|
+
] }),
|
|
519
|
+
/* @__PURE__ */ jsx("p", { className: "identity-traits", children: m.bossArt.traits }),
|
|
520
|
+
/* @__PURE__ */ jsxs("div", { className: "boss-stats", children: [
|
|
521
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
522
|
+
"\u6C14\u8840 ",
|
|
523
|
+
fmt(m.bossHp)
|
|
524
|
+
] }),
|
|
525
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
526
|
+
"\u653B\u51FB ",
|
|
527
|
+
m.bossAtk
|
|
528
|
+
] })
|
|
529
|
+
] }),
|
|
530
|
+
/* @__PURE__ */ jsxs("div", { className: "boss-reward", children: [
|
|
531
|
+
/* @__PURE__ */ jsx("small", { children: cleared ? "\u518D\u6B21\u6311\u6218\u5956\u52B1" : "\u9996\u6B21\u51FB\u8D25\u5956\u52B1" }),
|
|
532
|
+
/* @__PURE__ */ jsx("div", { children: cleared ? "\u94DC\u94B1\u3001\u7ECF\u9A8C\u3001\u7075\u8574" : d.slots[m.rewardSlot].names[1] + " \xB7 \u7075\u8574 \xD750" })
|
|
533
|
+
] }),
|
|
534
|
+
/* @__PURE__ */ jsx(GameButton, { className: "boss-button", disabled: busy(s), onClick: command(onAction, "boss"), children: busy(s) ? "\u6B63\u5728\u6311\u6218\u2026" : cleared ? "\u518D\u6B21\u6311\u6218" : "\u6311\u6218\u5996\u738B" }),
|
|
535
|
+
/* @__PURE__ */ jsx("p", { className: "boss-hint", children: s.map < d.maps.length - 1 ? `\u9996\u6B21\u51FB\u8D25\uFF0C\u89E3\u9501\u300C${d.maps[s.map + 1].name}\u300D` : "\u5B8C\u6210\u6311\u6218\uFF0C\u901A\u5173\u5168\u90E8\u7AE0\u8282\u8BD5\u70BC" })
|
|
536
|
+
] });
|
|
537
|
+
}
|
|
538
|
+
function GameLogPanel({ state: s }) {
|
|
539
|
+
return /* @__PURE__ */ jsxs("section", { className: "journal", children: [
|
|
540
|
+
/* @__PURE__ */ jsxs("div", { className: "panel-heading", children: [
|
|
541
|
+
/* @__PURE__ */ jsx("h3", { children: "\u25A4 \u4E09\u754C\u89C1\u95FB" }),
|
|
542
|
+
/* @__PURE__ */ jsx("span", { children: "\u5B9E\u65F6\u6218\u62A5" })
|
|
543
|
+
] }),
|
|
544
|
+
/* @__PURE__ */ jsx("div", { id: "logs", role: "log", "aria-label": "\u6218\u6597\u8BB0\u5F55", children: s.logs.map((log, i) => /* @__PURE__ */ jsxs("div", { className: `log-line ${log.type}`, children: [
|
|
545
|
+
/* @__PURE__ */ jsx("time", { children: new Date(log.time).toLocaleTimeString("zh-CN", { hour: "2-digit", minute: "2-digit" }) }),
|
|
546
|
+
/* @__PURE__ */ jsx("span", { children: log.text })
|
|
547
|
+
] }, `${log.time}-${i}`)) })
|
|
548
|
+
] });
|
|
549
|
+
}
|
|
550
|
+
function GameMapPanel({ engine, state: s, onAction }) {
|
|
551
|
+
const d = engine.definition;
|
|
552
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
553
|
+
/* @__PURE__ */ jsx(Title, { kicker: "\u4E09\u754C\u8206\u56FE / \u897F\u884C\u4E4B\u8DEF", title: d.labels?.mapsTitle || "\u63A2\u7D22\u65B0\u7684\u65C5\u7A0B" }),
|
|
554
|
+
/* @__PURE__ */ jsx("p", { className: "view-description", children: "\u8E0F\u8FC7\u4E00\u91CD\u5C71\uFF0C\u518D\u8D74\u4E0B\u4E00\u7A0B\u3002\u51FB\u8D25\u7AE0\u8282\u5996\u738B\uFF0C\u5373\u53EF\u5F00\u542F\u65B0\u7684\u5386\u7EC3\u3002" }),
|
|
555
|
+
/* @__PURE__ */ jsx("div", { className: "map-list", children: d.maps.map((m, i) => /* @__PURE__ */ jsxs(GameButton, { className: `map-card ${s.map === i ? "current" : ""}`, disabled: i > s.unlocked || busy(s), onClick: command(onAction, "map", String(i)), children: [
|
|
556
|
+
/* @__PURE__ */ jsx("div", { className: "map-art", children: /* @__PURE__ */ jsx("img", { className: "landscape", src: m.scene, alt: "" }) }),
|
|
557
|
+
/* @__PURE__ */ jsx("span", { className: "map-number", children: String(i + 1).padStart(2, "0") }),
|
|
558
|
+
/* @__PURE__ */ jsxs("div", { className: "map-content", children: [
|
|
559
|
+
/* @__PURE__ */ jsx("span", { className: "eyebrow", children: m.subtitle }),
|
|
560
|
+
/* @__PURE__ */ jsx("h2", { children: m.name }),
|
|
561
|
+
/* @__PURE__ */ jsx("p", { children: m.desc }),
|
|
562
|
+
/* @__PURE__ */ jsxs("div", { className: "map-meta", children: [
|
|
563
|
+
"\u5EFA\u8BAE\u7B49\u7EA7 ",
|
|
564
|
+
m.level,
|
|
565
|
+
" \xB7 \u51FB\u8D25\u5956\u52B1 ",
|
|
566
|
+
m.xp,
|
|
567
|
+
" \u7ECF\u9A8C / ",
|
|
568
|
+
m.gold,
|
|
569
|
+
" \u94DC\u94B1"
|
|
570
|
+
] })
|
|
571
|
+
] }),
|
|
572
|
+
/* @__PURE__ */ jsx("span", { className: "map-state", children: i > s.unlocked ? "\u51FB\u8D25\u4E0A\u4E00\u7AE0\u5996\u738B\u89E3\u9501" : s.map === i ? "\u5F53\u524D\u5386\u7EC3" : "\u524D\u5F80\u5386\u7EC3" })
|
|
573
|
+
] }, m.id)) }),
|
|
574
|
+
/* @__PURE__ */ jsxs("div", { className: "tip", children: [
|
|
575
|
+
"\u5F53\u524D\u5DF2\u89E3\u9501 ",
|
|
576
|
+
s.unlocked + 1,
|
|
577
|
+
" / ",
|
|
578
|
+
d.maps.length,
|
|
579
|
+
" \u7AE0\u3002"
|
|
580
|
+
] })
|
|
581
|
+
] });
|
|
582
|
+
}
|
|
583
|
+
function GamePetPanel({ engine, state: s, onAction }) {
|
|
584
|
+
const d = engine.definition;
|
|
585
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
586
|
+
/* @__PURE__ */ jsx(Title, { kicker: "\u7075\u5BA0\u6D1E\u5929 / \u6709\u7075\u76F8\u4F34", title: d.labels?.petsTitle || "\u4F19\u4F34\u540C\u884C", children: /* @__PURE__ */ jsxs("span", { className: "capacity", children: [
|
|
587
|
+
"\u7075\u8574 ",
|
|
588
|
+
fmt(s.essence)
|
|
589
|
+
] }) }),
|
|
590
|
+
/* @__PURE__ */ jsx("p", { className: "view-description", children: "\u7075\u5BA0\u968F\u4F60\u81EA\u52A8\u51FA\u6218\u3002\u4E0D\u540C\u7684\u4F19\u4F34\uFF0C\u8BA9\u6BCF\u4E00\u6BB5\u4FEE\u884C\u5404\u6709\u7AE0\u6CD5\u3002" }),
|
|
591
|
+
/* @__PURE__ */ jsx("div", { className: "pet-cards", children: d.pets.map((p) => /* @__PURE__ */ jsxs("article", { className: `pet-card ${s.pet === p.id ? "selected" : ""}`, children: [
|
|
592
|
+
/* @__PURE__ */ jsxs("div", { className: "pet-card-head", children: [
|
|
593
|
+
/* @__PURE__ */ jsx("span", { className: "pet-kind", children: p.kind }),
|
|
594
|
+
/* @__PURE__ */ jsx("span", { children: s.pets[p.id] ? `Lv.${s.pets[p.id]}` : "\u5C1A\u672A\u7ED3\u7F18" })
|
|
595
|
+
] }),
|
|
596
|
+
/* @__PURE__ */ jsx("div", { className: "pet-art", children: /* @__PURE__ */ jsx(GameSprite, { asset: p.art }) }),
|
|
597
|
+
/* @__PURE__ */ jsx("h2", { children: p.name }),
|
|
598
|
+
/* @__PURE__ */ jsx("p", { className: "identity-traits", children: p.art.traits }),
|
|
599
|
+
/* @__PURE__ */ jsx("p", { children: p.desc }),
|
|
600
|
+
/* @__PURE__ */ jsxs("div", { className: "pet-stat", children: [
|
|
601
|
+
"\u51FA\u624B\u4F24\u5BB3 ",
|
|
602
|
+
/* @__PURE__ */ jsx("b", { children: p.base + ((s.pets[p.id] || 1) - 1) * 3 })
|
|
603
|
+
] }),
|
|
604
|
+
s.pets[p.id] ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
605
|
+
/* @__PURE__ */ jsx(GameButton, { className: "subtle-button", disabled: busy(s) || s.pet === p.id, onClick: command(onAction, "deploy", p.id), children: s.pet === p.id ? "\u6B63\u5728\u51FA\u6218" : "\u8BBE\u4E3A\u51FA\u6218" }),
|
|
606
|
+
/* @__PURE__ */ jsx(GameButton, { className: "primary-button", disabled: busy(s) || s.pets[p.id] >= 20 || s.essence < s.pets[p.id] * 15, onClick: command(onAction, "train", p.id), children: s.pets[p.id] >= 20 ? "\u5DF2\u8FBE\u6700\u9AD8\u7B49\u7EA7" : `\u57F9\u517B \xB7 ${s.pets[p.id] * 15} \u7075\u8574` })
|
|
607
|
+
] }) : /* @__PURE__ */ jsxs(GameButton, { className: "primary-button", disabled: busy(s) || s.essence < p.cost, onClick: command(onAction, "unlock", p.id), children: [
|
|
608
|
+
"\u7ED3\u7F18 \xB7 ",
|
|
609
|
+
p.cost,
|
|
610
|
+
" \u7075\u8574"
|
|
611
|
+
] })
|
|
612
|
+
] }, p.id)) }),
|
|
613
|
+
/* @__PURE__ */ jsx("div", { className: "tip", children: "\u666E\u901A\u6218\u6597\u83B7\u5F97 2 \u7075\u8574\uFF0C\u9996\u9886\u9996\u901A\u83B7\u5F97 50 \u7075\u8574\u3002\u57F9\u517B\u63D0\u5347\u8FFD\u51FB\u4F24\u5BB3\u3002" })
|
|
614
|
+
] });
|
|
615
|
+
}
|
|
616
|
+
function GameEquipmentPanel({ engine, state: s, onAction }) {
|
|
617
|
+
const [filter, setFilter] = useState("all");
|
|
618
|
+
const d = engine.definition;
|
|
619
|
+
const inventory = s.inventory.filter((item) => filter === "all" || item.slot === filter);
|
|
620
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
621
|
+
/* @__PURE__ */ jsx(Title, { kicker: "\u884C\u56CA\u88C5\u5907 / \u767E\u70BC\u6210\u5668", title: d.labels?.gearTitle || "\u6574\u7406\u88C5\u5907\uFF0C\u63D0\u5347\u5B9E\u529B", children: /* @__PURE__ */ jsxs("span", { className: "capacity", children: [
|
|
622
|
+
"\u884C\u56CA ",
|
|
623
|
+
s.inventory.length,
|
|
624
|
+
" / 80"
|
|
625
|
+
] }) }),
|
|
626
|
+
/* @__PURE__ */ jsx("div", { className: "gear-slots", children: Object.entries(d.slots).map(([key, slot]) => /* @__PURE__ */ jsxs("section", { className: "gear-slot", children: [
|
|
627
|
+
/* @__PURE__ */ jsxs("div", { className: "gear-info", children: [
|
|
628
|
+
/* @__PURE__ */ jsxs("span", { className: "eyebrow", children: [
|
|
629
|
+
slot.name,
|
|
630
|
+
" \xB7 \u5F3A\u5316 +",
|
|
631
|
+
s.upgrades[key]
|
|
632
|
+
] }),
|
|
633
|
+
/* @__PURE__ */ jsx("h3", { children: s.equipment[key]?.name || "\u5C1A\u672A\u88C5\u5907" }),
|
|
634
|
+
s.equipment[key] && /* @__PURE__ */ jsx(ItemStats, { item: s.equipment[key] })
|
|
635
|
+
] }),
|
|
636
|
+
/* @__PURE__ */ jsx(GameButton, { className: "small-button", disabled: busy(s) || !s.equipment[key] || s.upgrades[key] >= 10 || s.gold < engine.upgradeCost(s, key), onClick: command(onAction, "upgrade", key), children: s.upgrades[key] >= 10 ? "\u5DF2\u5F3A\u5316\u81F3\u4E0A\u9650" : `\u5F3A\u5316 \xB7 ${engine.upgradeCost(s, key)} \u94DC\u94B1` })
|
|
637
|
+
] }, key)) }),
|
|
638
|
+
/* @__PURE__ */ jsxs("div", { className: "inventory-toolbar", children: [
|
|
639
|
+
/* @__PURE__ */ jsx("div", { className: "filters", children: [["all", "\u5168\u90E8"], ...Object.entries(d.slots).map(([key, slot]) => [key, slot.name])].map(([key, name]) => /* @__PURE__ */ jsx(GameButton, { className: `filter ${filter === key ? "active" : ""}`, "aria-pressed": filter === key, onClick: () => setFilter(key), children: name }, key)) }),
|
|
640
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
641
|
+
"\u953B\u6750 ",
|
|
642
|
+
s.material
|
|
643
|
+
] }),
|
|
644
|
+
/* @__PURE__ */ jsx(GameButton, { className: "subtle-button", disabled: busy(s) || s.material < 12, onClick: command(onAction, "forge"), children: "\u953B\u9020\u4E0A\u54C1 \xB7 12 \u953B\u6750" })
|
|
645
|
+
] }),
|
|
646
|
+
/* @__PURE__ */ jsx("div", { className: "inventory-list", children: inventory.length ? inventory.map((item) => /* @__PURE__ */ jsxs("article", { className: "item-row", children: [
|
|
647
|
+
/* @__PURE__ */ jsx("span", { className: `item-icon rarity-${item.tier}`, children: "\u25C7" }),
|
|
648
|
+
/* @__PURE__ */ jsxs("div", { className: "item-detail", children: [
|
|
649
|
+
/* @__PURE__ */ jsxs("strong", { children: [
|
|
650
|
+
item.name,
|
|
651
|
+
" ",
|
|
652
|
+
/* @__PURE__ */ jsxs("small", { children: [
|
|
653
|
+
d.rarities[item.tier],
|
|
654
|
+
" \xB7 ",
|
|
655
|
+
d.slots[item.slot].name
|
|
656
|
+
] })
|
|
657
|
+
] }),
|
|
658
|
+
/* @__PURE__ */ jsx(ItemStats, { item })
|
|
659
|
+
] }),
|
|
660
|
+
/* @__PURE__ */ jsx(GameButton, { className: "small-button", onClick: command(onAction, "inspect", item.id), children: "\u5BF9\u6BD4" }),
|
|
661
|
+
/* @__PURE__ */ jsx(GameButton, { className: "small-button jade-button", disabled: busy(s), onClick: command(onAction, "equip", item.id), children: "\u88C5\u5907" }),
|
|
662
|
+
/* @__PURE__ */ jsx(GameButton, { className: "text-button", disabled: busy(s), onClick: command(onAction, "lock", item.id), children: item.locked ? "\u89E3\u9501" : "\u9501\u5B9A" }),
|
|
663
|
+
/* @__PURE__ */ jsx(GameButton, { className: "text-button", disabled: busy(s) || item.locked, onClick: command(onAction, "dismantle", item.id), children: "\u5206\u89E3" })
|
|
664
|
+
] }, item.id)) : /* @__PURE__ */ jsxs("div", { className: "empty-state", children: [
|
|
665
|
+
/* @__PURE__ */ jsx("h3", { children: "\u884C\u56CA\u5C1A\u6709\u4F59\u5730" }),
|
|
666
|
+
/* @__PURE__ */ jsx("p", { children: "\u6302\u673A\u51FB\u8D25\u5996\u602A\uFF0C\u6709\u673A\u4F1A\u62FE\u5F97\u88C5\u5907\u3002" }),
|
|
667
|
+
/* @__PURE__ */ jsx(GameButton, { className: "subtle-button", onClick: command(onAction, "page", "battle"), children: "\u524D\u5F80\u5386\u7EC3" })
|
|
668
|
+
] }) }),
|
|
669
|
+
/* @__PURE__ */ jsx("div", { className: "tip", children: "\u5F3A\u5316\u968F\u90E8\u4F4D\u7EE7\u627F\u3002\u80CC\u5305\u6EE1\u540E\uFF0C\u65B0\u6389\u843D\u8F6C\u4E3A\u953B\u6750\uFF1B\u9501\u5B9A\u88C5\u5907\u4E0D\u80FD\u5206\u89E3\u3002" })
|
|
670
|
+
] });
|
|
671
|
+
}
|
|
672
|
+
function GameSavePanel({ onExport, onImport }) {
|
|
673
|
+
const input = useRef(null);
|
|
674
|
+
return /* @__PURE__ */ jsxs("div", { className: "help-content", children: [
|
|
675
|
+
/* @__PURE__ */ jsx("p", { children: "\u8FDB\u5EA6\u81EA\u52A8\u4FDD\u5B58\u5728\u5F53\u524D\u6D4F\u89C8\u5668\u3002\u5BFC\u5165\u901A\u8FC7\u6821\u9A8C\u540E\uFF0C\u9700\u8981\u518D\u6B21\u786E\u8BA4\u624D\u80FD\u66FF\u6362\u5F53\u524D\u8FDB\u5EA6\u3002" }),
|
|
676
|
+
/* @__PURE__ */ jsxs("div", { className: "settings-actions", children: [
|
|
677
|
+
/* @__PURE__ */ jsx(GameButton, { className: "subtle-button", onClick: onExport, children: "\u5BFC\u51FA\u5B58\u6863" }),
|
|
678
|
+
/* @__PURE__ */ jsx(GameButton, { className: "subtle-button", onClick: () => input.current?.click(), children: "\u5BFC\u5165\u5B58\u6863" }),
|
|
679
|
+
/* @__PURE__ */ jsx("input", { ref: input, type: "file", accept: ".json,application/json", hidden: true, onChange: (e) => {
|
|
680
|
+
const file = e.target.files?.[0];
|
|
681
|
+
e.target.value = "";
|
|
682
|
+
if (file)
|
|
683
|
+
void onImport(file);
|
|
684
|
+
} })
|
|
685
|
+
] }),
|
|
686
|
+
/* @__PURE__ */ jsx("p", { children: "\u5B58\u6863\u4FDD\u5B58\u5728\u672C\u673A\uFF0C\u4E0D\u5305\u542B\u8D26\u53F7\u540C\u6B65\u548C\u591A\u4EBA\u8054\u7F51\u3002" })
|
|
687
|
+
] });
|
|
688
|
+
}
|
|
689
|
+
function GameDialog({ open, title, children, onClose, container }) {
|
|
690
|
+
return /* @__PURE__ */ jsx(Modal, { open, title, footer: null, centered: true, className: "sia-game-dialog", onCancel: onClose, getContainer: container, children });
|
|
691
|
+
}
|
|
692
|
+
function GameEquipmentComparison({ engine, state: s, onAction, itemId }) {
|
|
693
|
+
const item = s.inventory.find((i) => i.id === itemId);
|
|
694
|
+
if (!item)
|
|
695
|
+
return /* @__PURE__ */ jsx("p", { children: "\u7269\u54C1\u5DF2\u4E0D\u5728\u80CC\u5305\u4E2D\u3002" });
|
|
696
|
+
const old = s.equipment[item.slot];
|
|
697
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
698
|
+
/* @__PURE__ */ jsxs("div", { className: "compare", children: [
|
|
699
|
+
/* @__PURE__ */ jsxs("section", { children: [
|
|
700
|
+
/* @__PURE__ */ jsx("span", { className: "eyebrow", children: "\u5F53\u524D\u88C5\u5907" }),
|
|
701
|
+
/* @__PURE__ */ jsx("h3", { children: old?.name || "\u672A\u88C5\u5907" }),
|
|
702
|
+
old && /* @__PURE__ */ jsx(ItemStats, { item: old })
|
|
703
|
+
] }),
|
|
704
|
+
/* @__PURE__ */ jsxs("section", { children: [
|
|
705
|
+
/* @__PURE__ */ jsxs("span", { className: "eyebrow", children: [
|
|
706
|
+
"\u5F85\u88C5\u5907 \xB7 ",
|
|
707
|
+
engine.definition.rarities[item.tier]
|
|
708
|
+
] }),
|
|
709
|
+
/* @__PURE__ */ jsx("h3", { children: item.name }),
|
|
710
|
+
/* @__PURE__ */ jsx(ItemStats, { item })
|
|
711
|
+
] })
|
|
712
|
+
] }),
|
|
713
|
+
/* @__PURE__ */ jsxs("p", { children: [
|
|
714
|
+
"\u540C\u90E8\u4F4D\u5F3A\u5316 +",
|
|
715
|
+
s.upgrades[item.slot],
|
|
716
|
+
" \u5B8C\u6574\u7EE7\u627F\u3002"
|
|
717
|
+
] }),
|
|
718
|
+
/* @__PURE__ */ jsx("div", { className: "compare-delta", children: ["atk", "def", "hp"].map((key, i) => {
|
|
719
|
+
const delta = item[key] - (old?.[key] || 0);
|
|
720
|
+
return /* @__PURE__ */ jsxs("span", { className: delta >= 0 ? "jade" : "red-text", children: [
|
|
721
|
+
["\u653B\u51FB", "\u9632\u5FA1", "\u6C14\u8840"][i],
|
|
722
|
+
" ",
|
|
723
|
+
delta >= 0 ? "+" : "",
|
|
724
|
+
delta
|
|
725
|
+
] }, key);
|
|
726
|
+
}) }),
|
|
727
|
+
/* @__PURE__ */ jsx(GameButton, { className: "primary-button full", disabled: busy(s), onClick: command(onAction, "equip", item.id), children: "\u88C5\u5907" })
|
|
728
|
+
] });
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
// src/game/IdleGameApp.tsx
|
|
732
|
+
import { useEffect, useReducer, useRef as useRef2, useState as useState2 } from "react";
|
|
733
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
734
|
+
function IdleGameApp({ definition, className = "", style, onStateChange }) {
|
|
735
|
+
const engineRef = useRef2();
|
|
736
|
+
if (!engineRef.current)
|
|
737
|
+
engineRef.current = createIdleEngine(definition);
|
|
738
|
+
const engine = engineRef.current;
|
|
739
|
+
const stateRef = useRef2();
|
|
740
|
+
if (!stateRef.current)
|
|
741
|
+
stateRef.current = engine.freshState();
|
|
742
|
+
const s = stateRef.current;
|
|
743
|
+
const [, refresh] = useReducer((n) => n + 1, 0);
|
|
744
|
+
const [page, setPage] = useState2("battle"), [dialog, setDialog] = useState2(""), [message, setMessage] = useState2("");
|
|
745
|
+
const [event, setEvent] = useState2(null), [sequence, setSequence] = useState2(0);
|
|
746
|
+
const [report, setReport] = useState2(null), [pending, setPending] = useState2(null), [itemId, setItemId] = useState2("");
|
|
747
|
+
const host = useRef2(null), lastTick = useRef2(Date.now()), initialized = useRef2(false), saveWarning = useRef2(false);
|
|
748
|
+
const observe = useRef2(onStateChange);
|
|
749
|
+
observe.current = onStateChange;
|
|
750
|
+
function save() {
|
|
751
|
+
const current = stateRef.current;
|
|
752
|
+
try {
|
|
753
|
+
current.savedAt = Date.now();
|
|
754
|
+
localStorage.setItem(definition.saveKey, engine.serialize(current, current.savedAt));
|
|
755
|
+
saveWarning.current = false;
|
|
756
|
+
} catch {
|
|
757
|
+
if (!saveWarning.current) {
|
|
758
|
+
setMessage("\u6D4F\u89C8\u5668\u672A\u80FD\u4FDD\u5B58\u8FDB\u5EA6\uFF0C\u8BF7\u5728\u8BBE\u7F6E\u4E2D\u5BFC\u51FA\u5B58\u6863\u3002");
|
|
759
|
+
saveWarning.current = true;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
function changed() {
|
|
764
|
+
save();
|
|
765
|
+
refresh();
|
|
766
|
+
observe.current?.(stateRef.current);
|
|
767
|
+
}
|
|
768
|
+
useEffect(() => {
|
|
769
|
+
if (message) {
|
|
770
|
+
const timer = setTimeout(() => setMessage(""), 3200);
|
|
771
|
+
return () => clearTimeout(timer);
|
|
772
|
+
}
|
|
773
|
+
}, [message]);
|
|
774
|
+
useEffect(() => {
|
|
775
|
+
if (!initialized.current) {
|
|
776
|
+
try {
|
|
777
|
+
const raw = localStorage.getItem(definition.saveKey);
|
|
778
|
+
if (raw) {
|
|
779
|
+
stateRef.current = engine.hydrate(JSON.parse(raw));
|
|
780
|
+
const result = engine.settleOffline(stateRef.current);
|
|
781
|
+
if (result) {
|
|
782
|
+
setReport(result);
|
|
783
|
+
setDialog("offline");
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
} catch {
|
|
787
|
+
setMessage("\u5B58\u6863\u8BFB\u53D6\u5931\u8D25\uFF0C\u5F53\u524D\u4EE5\u5185\u5B58\u65B0\u6863\u8FD0\u884C\uFF1B\u53EF\u5728\u8BBE\u7F6E\u4E2D\u5BFC\u5165\u5907\u4EFD\u3002");
|
|
788
|
+
}
|
|
789
|
+
engine.addLog(stateRef.current, "\u6B22\u8FCE\u5F52\u6765\uFF0C\u70B9\u51FB\u5F00\u59CB\u6302\u673A\u7EE7\u7EED\u5386\u7EC3\u3002");
|
|
790
|
+
initialized.current = true;
|
|
791
|
+
lastTick.current = Date.now();
|
|
792
|
+
refresh();
|
|
793
|
+
}
|
|
794
|
+
const timer = setInterval(() => {
|
|
795
|
+
if (document.hidden)
|
|
796
|
+
return;
|
|
797
|
+
const now = Date.now(), elapsed = Math.floor((now - lastTick.current) / 1e3);
|
|
798
|
+
if (elapsed < 1)
|
|
799
|
+
return;
|
|
800
|
+
const current = stateRef.current;
|
|
801
|
+
if (elapsed > 15 && current.idle) {
|
|
802
|
+
current.savedAt = lastTick.current;
|
|
803
|
+
engine.settleOffline(current, now);
|
|
804
|
+
setEvent(null);
|
|
805
|
+
} else {
|
|
806
|
+
const next = engine.tick(current);
|
|
807
|
+
setEvent(next);
|
|
808
|
+
if (next) {
|
|
809
|
+
setSequence((n) => n + 1);
|
|
810
|
+
if (next.bossWin)
|
|
811
|
+
setMessage(next.first ? `\u9996\u901A\u6210\u529F\uFF01${next.reward}\u5DF2\u6536\u5165\u884C\u56CA\u3002` : "\u9996\u9886\u6311\u6218\u6210\u529F\uFF01");
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
lastTick.current = now;
|
|
815
|
+
changed();
|
|
816
|
+
}, 1e3);
|
|
817
|
+
const visibility = () => {
|
|
818
|
+
if (document.hidden) {
|
|
819
|
+
save();
|
|
820
|
+
lastTick.current = Date.now();
|
|
821
|
+
} else {
|
|
822
|
+
const result = engine.settleOffline(stateRef.current);
|
|
823
|
+
if (result) {
|
|
824
|
+
setReport(result);
|
|
825
|
+
setDialog("offline");
|
|
826
|
+
}
|
|
827
|
+
lastTick.current = Date.now();
|
|
828
|
+
setEvent(null);
|
|
829
|
+
changed();
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
window.addEventListener("pagehide", save);
|
|
833
|
+
document.addEventListener("visibilitychange", visibility);
|
|
834
|
+
return () => {
|
|
835
|
+
clearInterval(timer);
|
|
836
|
+
window.removeEventListener("pagehide", save);
|
|
837
|
+
document.removeEventListener("visibilitychange", visibility);
|
|
838
|
+
save();
|
|
839
|
+
};
|
|
840
|
+
}, [engine, definition]);
|
|
841
|
+
function action({ type, id = "" }) {
|
|
842
|
+
const current = stateRef.current, locked = Boolean(current.fight?.boss && current.fight.status === "active");
|
|
843
|
+
if (type === "page") {
|
|
844
|
+
if (["battle", "maps", "gear", "pets"].includes(id))
|
|
845
|
+
setPage(id);
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
if (type === "settings" || type === "help") {
|
|
849
|
+
setDialog(type);
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
if (type === "inspect") {
|
|
853
|
+
setItemId(id);
|
|
854
|
+
setDialog("compare");
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
if (locked) {
|
|
858
|
+
setMessage("\u9996\u9886\u6311\u6218\u4E2D\uFF0C\u8BF7\u7B49\u5F85\u6218\u6597\u7ED3\u675F\u3002");
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
let success = true;
|
|
862
|
+
if (type === "idle") {
|
|
863
|
+
current.idle = !current.idle;
|
|
864
|
+
if (!current.idle)
|
|
865
|
+
current.fight = null;
|
|
866
|
+
engine.addLog(current, current.idle ? "\u5F00\u59CB\u6302\u673A\u4FEE\u884C\u3002" : "\u6682\u505C\u6302\u673A\uFF0C\u9759\u5FC3\u6574\u5907\u3002");
|
|
867
|
+
}
|
|
868
|
+
if (type === "boss") {
|
|
869
|
+
engine.beginFight(current, true);
|
|
870
|
+
setPage("battle");
|
|
871
|
+
}
|
|
872
|
+
if (type === "map") {
|
|
873
|
+
const index = Number(id);
|
|
874
|
+
if (!Number.isInteger(index) || index < 0 || index > current.unlocked)
|
|
875
|
+
return;
|
|
876
|
+
current.map = index;
|
|
877
|
+
current.fight = null;
|
|
878
|
+
setPage("battle");
|
|
879
|
+
engine.addLog(current, `\u6765\u5230${definition.maps[index].name}\u3002`);
|
|
880
|
+
}
|
|
881
|
+
if (type === "equip") {
|
|
882
|
+
success = engine.equip(current, id);
|
|
883
|
+
if (success) {
|
|
884
|
+
current.fight = null;
|
|
885
|
+
setDialog("");
|
|
886
|
+
setMessage("\u88C5\u5907\u6210\u529F\uFF0C\u6218\u529B\u5DF2\u66F4\u65B0\u3002");
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
if (type === "upgrade") {
|
|
890
|
+
success = engine.upgrade(current, id);
|
|
891
|
+
if (success) {
|
|
892
|
+
current.fight = null;
|
|
893
|
+
setMessage("\u90E8\u4F4D\u5F3A\u5316\u6210\u529F\u3002");
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
if (type === "dismantle")
|
|
897
|
+
success = engine.dismantle(current, id);
|
|
898
|
+
if (type === "forge")
|
|
899
|
+
success = engine.forge(current);
|
|
900
|
+
if (type === "train") {
|
|
901
|
+
success = engine.trainPet(current, id);
|
|
902
|
+
if (success)
|
|
903
|
+
current.fight = null;
|
|
904
|
+
}
|
|
905
|
+
if (type === "unlock")
|
|
906
|
+
success = engine.unlockPet(current, id);
|
|
907
|
+
if (type === "deploy" && current.pets[id]) {
|
|
908
|
+
current.pet = id;
|
|
909
|
+
current.fight = null;
|
|
910
|
+
}
|
|
911
|
+
if (type === "lock") {
|
|
912
|
+
const item = current.inventory.find((i) => i.id === id);
|
|
913
|
+
if (item)
|
|
914
|
+
item.locked = !item.locked;
|
|
915
|
+
}
|
|
916
|
+
if (!success)
|
|
917
|
+
setMessage("\u5F53\u524D\u6761\u4EF6\u4E0D\u8DB3\uFF0C\u64CD\u4F5C\u672A\u6267\u884C\u3002");
|
|
918
|
+
setEvent(null);
|
|
919
|
+
changed();
|
|
920
|
+
}
|
|
921
|
+
async function importFile(file) {
|
|
922
|
+
try {
|
|
923
|
+
if (file.size > 1e6)
|
|
924
|
+
throw new Error("\u6587\u4EF6\u8FC7\u5927");
|
|
925
|
+
const loaded = engine.hydrate(JSON.parse(await file.text()));
|
|
926
|
+
setPending(loaded);
|
|
927
|
+
setDialog("import");
|
|
928
|
+
} catch {
|
|
929
|
+
setMessage("\u5BFC\u5165\u5931\u8D25\uFF0C\u8BF7\u9009\u62E9\u6709\u6548\u7684\u6E38\u620F JSON \u5B58\u6863\u3002");
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
function exportFile() {
|
|
933
|
+
save();
|
|
934
|
+
const url = URL.createObjectURL(new Blob([engine.serialize(stateRef.current)], { type: "application/json;charset=utf-8" }));
|
|
935
|
+
const anchor = document.createElement("a");
|
|
936
|
+
anchor.href = url;
|
|
937
|
+
anchor.download = `${definition.title}-\u4FEE\u884C\u5B58\u6863.json`;
|
|
938
|
+
anchor.click();
|
|
939
|
+
setTimeout(() => URL.revokeObjectURL(url), 1e3);
|
|
940
|
+
}
|
|
941
|
+
const view = { engine, state: s, onAction: action };
|
|
942
|
+
const titles = { settings: "\u4FEE\u884C\u8BBE\u7F6E \xB7 \u5B58\u6863", help: "\u4FEE\u884C\u5165\u95E8", compare: "\u88C5\u5907\u5BF9\u6BD4", offline: "\u4E45\u522B\u5F52\u6765\uFF0C\u4FEE\u884C\u672A\u6B47", import: "\u786E\u8BA4\u5BFC\u5165\u5B58\u6863" };
|
|
943
|
+
return /* @__PURE__ */ jsxs2("div", { ref: host, className: `sia-game ${className}`, style, "data-sia-theme": "dark", children: [
|
|
944
|
+
/* @__PURE__ */ jsx2(GameShell, { ...view, page, children: page === "battle" ? /* @__PURE__ */ jsx2(GameBattleStage, { ...view, event, sequence }) : page === "maps" ? /* @__PURE__ */ jsx2(GameMapPanel, { ...view }) : page === "gear" ? /* @__PURE__ */ jsx2(GameEquipmentPanel, { ...view }) : /* @__PURE__ */ jsx2(GamePetPanel, { ...view }) }),
|
|
945
|
+
/* @__PURE__ */ jsxs2(GameDialog, { open: Boolean(dialog), title: titles[dialog] || "", onClose: () => setDialog(""), container: () => host.current, children: [
|
|
946
|
+
dialog === "settings" && /* @__PURE__ */ jsx2(GameSavePanel, { onExport: exportFile, onImport: importFile }),
|
|
947
|
+
dialog === "compare" && /* @__PURE__ */ jsx2(GameEquipmentComparison, { ...view, itemId }),
|
|
948
|
+
dialog === "help" && /* @__PURE__ */ jsxs2("div", { className: "help-content", children: [
|
|
949
|
+
/* @__PURE__ */ jsxs2("p", { children: [
|
|
950
|
+
"\u5F00\u59CB\u6302\u673A\u540E\uFF0C\u6BCF\u79D2\u81EA\u52A8\u51FA\u624B\u5E76\u62FE\u53D6\u5956\u52B1\u3002\u5173\u95ED\u9875\u9762\u540E\uFF0C\u4E0B\u6B21\u8FDB\u5165\u7ED3\u7B97\u6700\u591A ",
|
|
951
|
+
(definition.offlineCapSeconds ?? 43200) / 3600,
|
|
952
|
+
" \u5C0F\u65F6\u7684\u666E\u901A\u6218\u6597\u6536\u76CA\u3002"
|
|
953
|
+
] }),
|
|
954
|
+
/* @__PURE__ */ jsxs2("ol", { children: [
|
|
955
|
+
/* @__PURE__ */ jsx2("li", { children: "\u6302\u673A\u83B7\u5F97\u7ECF\u9A8C\u3001\u94DC\u94B1\u3001\u88C5\u5907\u548C\u7075\u8574\u3002" }),
|
|
956
|
+
/* @__PURE__ */ jsx2("li", { children: "\u66F4\u6362\u88C5\u5907\uFF0C\u5F3A\u5316\u90E8\u4F4D\uFF1B\u5F3A\u5316\u4E0D\u4F1A\u968F\u6362\u88C5\u4E22\u5931\u3002" }),
|
|
957
|
+
/* @__PURE__ */ jsx2("li", { children: "\u7ED3\u7F18\u5E76\u57F9\u517B\u4F19\u4F34\uFF0C\u6539\u53D8\u8FFD\u51FB\u3001\u6CBB\u7597\u4E0E\u51CF\u4F24\u6548\u679C\u3002" }),
|
|
958
|
+
/* @__PURE__ */ jsx2("li", { children: "\u6311\u6218\u9996\u9886\uFF0C\u9996\u901A\u83B7\u5F97\u88C5\u5907\u5E76\u89E3\u9501\u4E0B\u4E00\u7AE0\u3002" })
|
|
959
|
+
] }),
|
|
960
|
+
/* @__PURE__ */ jsx2("p", { children: "\u6311\u6218\u5931\u8D25\u4E0D\u6263\u8D44\u6E90\u3002\u9996\u9886\u6218\u671F\u95F4\u6682\u65F6\u4E0D\u80FD\u6362\u88C5\u3001\u57F9\u517B\u6216\u5207\u6362\u5730\u56FE\u3002" })
|
|
961
|
+
] }),
|
|
962
|
+
dialog === "offline" && report && /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
963
|
+
/* @__PURE__ */ jsxs2("p", { children: [
|
|
964
|
+
"\u79BB\u5F00 ",
|
|
965
|
+
Math.floor(report.seconds / 3600),
|
|
966
|
+
" \u5C0F\u65F6 ",
|
|
967
|
+
Math.floor(report.seconds % 3600 / 60),
|
|
968
|
+
" \u5206\u949F\uFF0C\u6536\u76CA\u5DF2\u81EA\u52A8\u5165\u8D26\u3002"
|
|
969
|
+
] }),
|
|
970
|
+
/* @__PURE__ */ jsx2("div", { className: "offline-grid", children: [["\u7ECF\u9A8C", report.xp], ["\u94DC\u94B1", report.gold], ["\u7075\u8574", report.essence], ["\u88C5\u5907\u6389\u843D", report.drops]].map(([label, value]) => /* @__PURE__ */ jsxs2("div", { children: [
|
|
971
|
+
/* @__PURE__ */ jsx2("span", { children: label }),
|
|
972
|
+
/* @__PURE__ */ jsx2("b", { children: value })
|
|
973
|
+
] }, label)) }),
|
|
974
|
+
/* @__PURE__ */ jsxs2("p", { children: [
|
|
975
|
+
"\u51FB\u8D25 ",
|
|
976
|
+
report.kills,
|
|
977
|
+
" \u4E2A\u654C\u4EBA\uFF0C\u80CC\u5305\u6EA2\u51FA\u6389\u843D\u5DF2\u8F6C\u4E3A\u953B\u6750\u3002"
|
|
978
|
+
] }),
|
|
979
|
+
/* @__PURE__ */ jsx2(GameButton, { className: "primary-button full", onClick: () => setDialog(""), children: "\u7EE7\u7EED\u5386\u7EC3" })
|
|
980
|
+
] }),
|
|
981
|
+
dialog === "import" && pending && /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
982
|
+
/* @__PURE__ */ jsxs2("p", { children: [
|
|
983
|
+
"\u5373\u5C06\u8F7D\u5165 Lv.",
|
|
984
|
+
pending.level,
|
|
985
|
+
" \u7684\u89D2\u8272\uFF0C\u5DF2\u89E3\u9501 ",
|
|
986
|
+
pending.unlocked + 1,
|
|
987
|
+
" \u7AE0\u3002\u786E\u8BA4\u540E\u5C06\u66FF\u6362\u5F53\u524D\u5B58\u6863\u3002"
|
|
988
|
+
] }),
|
|
989
|
+
/* @__PURE__ */ jsx2(GameButton, { className: "primary-button full", disabled: Boolean(s.fight?.boss && s.fight.status === "active"), onClick: () => {
|
|
990
|
+
stateRef.current = pending;
|
|
991
|
+
setPending(null);
|
|
992
|
+
setDialog("");
|
|
993
|
+
setEvent(null);
|
|
994
|
+
lastTick.current = Date.now();
|
|
995
|
+
changed();
|
|
996
|
+
setMessage("\u5B58\u6863\u5DF2\u5BFC\u5165\u3002");
|
|
997
|
+
}, children: "\u786E\u8BA4\u66FF\u6362\u5F53\u524D\u5B58\u6863" })
|
|
998
|
+
] })
|
|
999
|
+
] }),
|
|
1000
|
+
/* @__PURE__ */ jsx2("div", { className: `game-toast ${message ? "visible" : ""}`, role: "status", children: message })
|
|
1001
|
+
] });
|
|
1002
|
+
}
|
|
1003
|
+
export {
|
|
1004
|
+
GameBattleStage,
|
|
1005
|
+
GameBossPanel,
|
|
1006
|
+
GameButton,
|
|
1007
|
+
GameCharacterPanel,
|
|
1008
|
+
GameDialog,
|
|
1009
|
+
GameEquipmentComparison,
|
|
1010
|
+
GameEquipmentPanel,
|
|
1011
|
+
GameLogPanel,
|
|
1012
|
+
GameMapPanel,
|
|
1013
|
+
GamePetPanel,
|
|
1014
|
+
GameResourceSummary,
|
|
1015
|
+
GameSavePanel,
|
|
1016
|
+
GameShell,
|
|
1017
|
+
GameSprite,
|
|
1018
|
+
IdleGameApp,
|
|
1019
|
+
createIdleEngine
|
|
1020
|
+
};
|