@sia.soul/sia-react-ui 0.1.107 → 0.1.109
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/{chunk-JEDJQ257.js → chunk-XRHL56EV.js} +13 -6
- package/dist/{core-Bm-1bOjF.d.ts → core-gI4QB_Nz.d.ts} +6 -2
- package/dist/{core-zpQkbNf_.d.cts → core-lGT-8jSj.d.cts} +6 -2
- package/dist/core.cjs +13 -6
- package/dist/core.css +30 -0
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/game.cjs +1653 -1181
- package/dist/game.css +196 -0
- package/dist/game.d.cts +99 -7
- package/dist/game.d.ts +99 -7
- package/dist/game.js +823 -355
- package/dist/index.cjs +17 -7
- package/dist/index.css +30 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -2
- package/package.json +1 -1
package/dist/game.js
CHANGED
|
@@ -7,13 +7,165 @@ import {
|
|
|
7
7
|
} from "./chunk-CZ2ITBRW.js";
|
|
8
8
|
import "./chunk-NZMUW5XI.js";
|
|
9
9
|
|
|
10
|
+
// src/game/hex-rules.ts
|
|
11
|
+
var DEFAULT_GAME_ABILITIES = [
|
|
12
|
+
{ id: "bolt", name: "\u7B26\u7B93", kind: "attack", effect: "damage", range: 2, scale: 1, cooldown: 1, description: "\u4E24\u683C\u5185\u5355\u4F53\u653B\u51FB\u3002" },
|
|
13
|
+
{ id: "blade", name: "\u5251\u51FB", kind: "attack", effect: "damage", range: 1, scale: 1.3, cooldown: 1, description: "\u81EA\u52A8\u63A5\u8FD1\u76EE\u6807\uFF0C\u4E00\u683C\u5185\u9020\u6210\u8F83\u9AD8\u4F24\u5BB3\u3002" },
|
|
14
|
+
{ id: "thunder", name: "\u5F15\u96F7", kind: "skill", effect: "damage", range: 3, scale: 1.8, cooldown: 3, description: "\u6BCF\u4E09\u56DE\u5408\uFF0C\u4E09\u683C\u5185\u5355\u4F53\u7206\u53D1\u3002" },
|
|
15
|
+
{ id: "flame", name: "\u706B\u9635", kind: "skill", effect: "blast", range: 2, scale: 1.15, cooldown: 3, description: "\u6BCF\u4E09\u56DE\u5408\uFF0C\u653B\u51FB\u76EE\u6807\u53CA\u5176\u5468\u56F4\u4E00\u683C\u654C\u4EBA\u3002" },
|
|
16
|
+
{ id: "mend", name: "\u56DE\u6625", kind: "power", effect: "heal", range: 1, scale: 0.12, cooldown: 5, description: "\u6BCF\u4E94\u56DE\u5408\uFF0C\u6062\u590D\u6700\u5927\u6C14\u8840\u7684 12%\u3002" },
|
|
17
|
+
{ id: "ward", name: "\u62A4\u4F53", kind: "power", effect: "shield", range: 1, scale: 0.4, cooldown: 5, description: "\u6BCF\u4E94\u56DE\u5408\uFF0C\u672C\u56DE\u5408\u51CF\u4F24 40%\u3002" },
|
|
18
|
+
{ id: "bell", name: "\u9547\u5996\u94C3", kind: "treasure", effect: "blast", range: 3, scale: 1.5, cooldown: 8, description: "\u6BCF\u516B\u56DE\u5408\uFF0C\u9707\u51FB\u76EE\u6807\u5468\u56F4\u4E00\u683C\u654C\u4EBA\u3002" },
|
|
19
|
+
{ id: "seal", name: "\u4F0F\u9B54\u5370", kind: "treasure", effect: "damage", range: 3, scale: 2.5, cooldown: 8, description: "\u6BCF\u516B\u56DE\u5408\uFF0C\u5BF9\u4E00\u4E2A\u76EE\u6807\u9020\u6210\u5F3A\u529B\u4F24\u5BB3\u3002" }
|
|
20
|
+
];
|
|
21
|
+
function gameAbilities(definition) {
|
|
22
|
+
return definition.abilities ?? DEFAULT_GAME_ABILITIES;
|
|
23
|
+
}
|
|
24
|
+
function hexDistance(a, b) {
|
|
25
|
+
return Math.max(Math.abs(a.q - b.q), Math.abs(a.r - b.r), Math.abs(a.q + a.r - b.q - b.r));
|
|
26
|
+
}
|
|
27
|
+
function gameHexCells() {
|
|
28
|
+
const cells = [];
|
|
29
|
+
for (let q = -3; q <= 3; q++) for (let r = -3; r <= 3; r++) if (hexDistance({ q, r }, { q: 0, r: 0 }) <= 3) cells.push({ q, r });
|
|
30
|
+
return cells;
|
|
31
|
+
}
|
|
32
|
+
var directions = [{ q: 1, r: 0 }, { q: 1, r: -1 }, { q: 0, r: -1 }, { q: -1, r: 0 }, { q: -1, r: 1 }, { q: 0, r: 1 }];
|
|
33
|
+
var key = (cell) => `${cell.q},${cell.r}`;
|
|
34
|
+
var living = (unit) => unit.hp > 0;
|
|
35
|
+
function advance(unit, target, range, units, cues, at) {
|
|
36
|
+
if (hexDistance(unit, target) <= range) return;
|
|
37
|
+
const blocked = new Set(units.filter((u) => u.id !== unit.id && living(u)).map(key));
|
|
38
|
+
const queue = [{ cell: { q: unit.q, r: unit.r }, first: null }], seen = /* @__PURE__ */ new Set([key(unit)]);
|
|
39
|
+
while (queue.length) {
|
|
40
|
+
const current = queue.shift();
|
|
41
|
+
if (current.first && hexDistance(current.cell, target) <= range) {
|
|
42
|
+
const from = { q: unit.q, r: unit.r };
|
|
43
|
+
unit.q = current.first.q;
|
|
44
|
+
unit.r = current.first.r;
|
|
45
|
+
cues.push({ at, kind: "move", actor: unit.id, from, to: { ...current.first } });
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
for (const d of directions) {
|
|
49
|
+
const cell = { q: current.cell.q + d.q, r: current.cell.r + d.r }, id = key(cell);
|
|
50
|
+
if (hexDistance(cell, { q: 0, r: 0 }) > 3 || blocked.has(id) || seen.has(id)) continue;
|
|
51
|
+
seen.add(id);
|
|
52
|
+
queue.push({ cell, first: current.first ?? cell });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function spawnHexEnemy(fight, hp, seed) {
|
|
57
|
+
const edge = gameHexCells().filter((c) => hexDistance(c, { q: 0, r: 0 }) === 3).sort((a, b) => Math.atan2(a.r + a.q / 2, a.q) - Math.atan2(b.r + b.q / 2, b.q));
|
|
58
|
+
const start = ((seed + fight.spawned * 5) % edge.length + edge.length) % edge.length;
|
|
59
|
+
const cell = edge.slice(start).concat(edge.slice(0, start)).find((c) => !fight.units.some((u) => living(u) && key(u) === key(c)));
|
|
60
|
+
if (!cell) return void 0;
|
|
61
|
+
const enemy = { ...cell, id: `enemy-${fight.spawned++}`, side: "enemy", hp, maxHp: hp };
|
|
62
|
+
fight.units.push(enemy);
|
|
63
|
+
return enemy;
|
|
64
|
+
}
|
|
65
|
+
function resolveHexRound(definition, state, stats, rng) {
|
|
66
|
+
const f = state.fight, map = definition.maps[state.map], pet = definition.pets.find((p) => p.id === state.pet);
|
|
67
|
+
const hero = f.units.find((u) => u.id === "hero"), companion = f.units.find((u) => u.id === "pet");
|
|
68
|
+
const cues = [], before = f.units.filter(living).map((u) => ({ ...u }));
|
|
69
|
+
hero.hp = f.hp;
|
|
70
|
+
hero.maxHp = f.maxHp;
|
|
71
|
+
const beforeHero = before.find((u) => u.id === "hero");
|
|
72
|
+
if (beforeHero) beforeHero.hp = f.hp;
|
|
73
|
+
f.turn++;
|
|
74
|
+
if (!f.boss && f.spawned < 4 && f.turn % 2 === 1) {
|
|
75
|
+
const unit = spawnHexEnemy(f, map.hp, state.kills * 3);
|
|
76
|
+
if (unit) {
|
|
77
|
+
before.push({ ...unit });
|
|
78
|
+
cues.push({ at: 0.02, kind: "spawn", actor: unit.id, label: "\u5996\u6C14\u6765\u88AD" });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const enemies = () => f.units.filter((u) => u.side === "enemy" && living(u));
|
|
82
|
+
const target = enemies().sort((a, b) => hexDistance(hero, a) - hexDistance(hero, b) || a.hp - b.hp)[0];
|
|
83
|
+
const cycle = f.turn % 5, move = !f.boss || cycle === 1 || cycle === 2 ? "strike" : cycle === 3 ? "charge" : cycle === 4 ? "heavy" : "recover";
|
|
84
|
+
const playback = { units: before, cues, turn: f.turn, boss: f.boss, move, heroBefore: hero.hp, heroAfterImpact: hero.hp, heroAfter: hero.hp, enemyBefore: target?.hp ?? 0, enemyAfterHero: target?.hp ?? 0, enemyAfter: target?.hp ?? 0, healed: 0, guarded: pet.effect === "guard", won: false, xp: 0, gold: 0 };
|
|
85
|
+
const event = { damage: 0, petDamage: 0, crit: rng() < 0.13, skill: false, incoming: 0, playback };
|
|
86
|
+
const abilities = gameAbilities(definition), equipped = (kind) => abilities.find((a) => a.id === state.loadout[kind]) ?? abilities.find((a) => a.kind === kind);
|
|
87
|
+
const attack = equipped("attack"), skill = equipped("skill"), power = equipped("power"), treasure = equipped("treasure");
|
|
88
|
+
const offensive = f.turn % treasure.cooldown === 0 ? treasure : f.turn % skill.cooldown === 0 ? skill : attack;
|
|
89
|
+
event.skill = offensive.kind !== "attack";
|
|
90
|
+
if (target) {
|
|
91
|
+
advance(hero, target, offensive.range, f.units, cues, 0.04);
|
|
92
|
+
if (hexDistance(hero, target) <= offensive.range) {
|
|
93
|
+
cues.push({ at: 0.18, kind: "cast", actor: "hero", target: target.id, label: offensive.name });
|
|
94
|
+
const victims = offensive.effect === "blast" ? enemies().filter((u) => hexDistance(target, u) <= 1) : [target];
|
|
95
|
+
for (const enemy of victims) {
|
|
96
|
+
const damage = Math.round(stats.atk * offensive.scale * (event.crit ? 1.5 : 1));
|
|
97
|
+
enemy.hp = Math.max(0, enemy.hp - damage);
|
|
98
|
+
event.damage += damage;
|
|
99
|
+
cues.push({ at: 0.35, kind: "hit", actor: "hero", target: enemy.id, value: damage, hp: enemy.hp, label: event.crit ? "\u66B4\u51FB" : offensive.name });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
playback.enemyAfterHero = target.hp;
|
|
103
|
+
}
|
|
104
|
+
let shield = pet.effect === "guard" ? 0.25 : 0;
|
|
105
|
+
if (f.turn % power.cooldown === 0 && power.effect === "shield") {
|
|
106
|
+
shield = Math.max(shield, power.scale);
|
|
107
|
+
cues.push({ at: 0.4, kind: "shield", actor: "hero", target: "hero", label: power.name });
|
|
108
|
+
}
|
|
109
|
+
const petTarget = enemies().sort((a, b) => hexDistance(companion, a) - hexDistance(companion, b))[0];
|
|
110
|
+
advance(companion, pet.effect === "attack" && petTarget ? petTarget : hero, pet.effect === "attack" ? 2 : 1, f.units, cues, 0.4);
|
|
111
|
+
if (pet.effect === "attack" && petTarget && hexDistance(companion, petTarget) <= 2) {
|
|
112
|
+
const damage = pet.base + ((state.pets[state.pet] || 1) - 1) * 3;
|
|
113
|
+
petTarget.hp = Math.max(0, petTarget.hp - damage);
|
|
114
|
+
event.petDamage = damage;
|
|
115
|
+
cues.push({ at: 0.44, kind: "cast", actor: "pet", target: petTarget.id, label: "\u7075\u5BA0\u8FFD\u51FB" });
|
|
116
|
+
cues.push({ at: 0.53, kind: "hit", actor: "pet", target: petTarget.id, value: damage, hp: petTarget.hp });
|
|
117
|
+
}
|
|
118
|
+
enemies().forEach((enemy, i) => {
|
|
119
|
+
advance(enemy, hero, 1, f.units, cues, 0.43);
|
|
120
|
+
if (hero.hp <= 0 || hexDistance(enemy, hero) > 1 || move === "charge" || move === "recover") return;
|
|
121
|
+
const damage = Math.max(1, Math.round(((f.boss ? map.bossAtk : map.atk) * (move === "heavy" ? 2 : 1) - stats.def) * (1 - shield)));
|
|
122
|
+
cues.push({ at: 0.57 + i * 0.035, kind: "cast", actor: enemy.id, target: "hero", label: move === "heavy" ? map.bossSkillName ?? "\u84C4\u529B\u91CD\u51FB" : "\u8FD1\u8EAB\u653B\u51FB" });
|
|
123
|
+
hero.hp = Math.max(0, hero.hp - damage);
|
|
124
|
+
event.incoming += damage;
|
|
125
|
+
cues.push({ at: 0.63 + i * 0.035, kind: "hit", actor: enemy.id, target: "hero", value: damage, hp: hero.hp });
|
|
126
|
+
});
|
|
127
|
+
playback.heroAfterImpact = hero.hp;
|
|
128
|
+
if (hero.hp > 0) {
|
|
129
|
+
const amount = pet.effect === "heal" ? 7 + (state.pets[state.pet] || 1) * 3 : 0;
|
|
130
|
+
const heal = Math.min(hero.maxHp - hero.hp, amount);
|
|
131
|
+
if (heal > 0) {
|
|
132
|
+
hero.hp += heal;
|
|
133
|
+
playback.healed += heal;
|
|
134
|
+
cues.push({ at: 0.79, kind: "heal", actor: "pet", target: "hero", value: heal, hp: hero.hp, label: "\u6708\u534E\u51DD\u9732" });
|
|
135
|
+
}
|
|
136
|
+
if (f.turn % power.cooldown === 0 && power.effect === "heal") {
|
|
137
|
+
const value = Math.min(hero.maxHp - hero.hp, Math.round(hero.maxHp * power.scale));
|
|
138
|
+
hero.hp += value;
|
|
139
|
+
playback.healed += value;
|
|
140
|
+
cues.push({ at: 0.82, kind: "heal", actor: "hero", target: "hero", value, hp: hero.hp, label: power.name });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
for (const unit of f.units) if (unit.hp === 0 && before.some((u) => u.id === unit.id && u.hp > 0)) cues.push({ at: 0.84, kind: "death", actor: unit.id });
|
|
144
|
+
playback.heroAfter = hero.hp;
|
|
145
|
+
playback.enemyAfter = target?.hp ?? 0;
|
|
146
|
+
f.hp = hero.hp;
|
|
147
|
+
f.enemyHp = enemies().reduce((total, u) => total + u.hp, 0);
|
|
148
|
+
f.enemyMax = f.units.filter((u) => u.side === "enemy").reduce((total, u) => total + u.maxHp, 0);
|
|
149
|
+
if (hero.hp === 0 || f.turn >= 60) {
|
|
150
|
+
f.status = "lost";
|
|
151
|
+
event.lost = true;
|
|
152
|
+
} else if (!enemies().length && (f.boss || f.spawned >= 4)) {
|
|
153
|
+
f.status = "won";
|
|
154
|
+
playback.won = true;
|
|
155
|
+
}
|
|
156
|
+
cues.sort((a, b) => a.at - b.at);
|
|
157
|
+
return event;
|
|
158
|
+
}
|
|
159
|
+
|
|
10
160
|
// src/game/engine.ts
|
|
11
161
|
function createIdleEngine(definition) {
|
|
12
162
|
const MAPS = definition.maps, PETS = definition.pets, slots = definition.slots, RARITIES = definition.rarities;
|
|
13
|
-
const slotKeys = Object.keys(slots), SLOTS = Object.fromEntries(slotKeys.map((
|
|
163
|
+
const slotKeys = Object.keys(slots), SLOTS = Object.fromEntries(slotKeys.map((key2) => [key2, slots[key2].name]));
|
|
14
164
|
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))
|
|
165
|
+
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.turnDurationMs !== void 0 && (!Number.isInteger(definition.turnDurationMs) || definition.turnDurationMs < 1e3 || definition.turnDurationMs > 5e3) || definition.offlineCapSeconds !== void 0 && (!Number.isInteger(definition.offlineCapSeconds) || definition.offlineCapSeconds < 0 || definition.offlineCapSeconds > 43200))
|
|
16
166
|
throw new Error("\u6E38\u620F\u5185\u5BB9\u914D\u7F6E\u4E0D\u6B63\u786E");
|
|
167
|
+
const abilities = gameAbilities(definition);
|
|
168
|
+
if (new Set(abilities.map((a) => a.id)).size !== abilities.length || ["attack", "skill", "power", "treasure"].some((kind) => !abilities.some((a) => a.kind === kind)) || abilities.some((a) => !a.id || !["attack", "skill", "power", "treasure"].includes(a.kind) || !["damage", "blast", "heal", "shield"].includes(a.effect) || !Number.isInteger(a.range) || a.range < 1 || a.range > 3 || !Number.isFinite(a.scale) || a.scale <= 0 || a.effect === "shield" && a.scale > 0.8 || (a.kind === "power" ? !["heal", "shield"].includes(a.effect) : !["damage", "blast"].includes(a.effect)) || !Number.isInteger(a.cooldown) || (a.kind === "attack" ? a.cooldown !== 1 : a.cooldown < 2))) throw new Error("\u81EA\u52A8\u6218\u6597\u80FD\u529B\u914D\u7F6E\u4E0D\u6B63\u786E");
|
|
17
169
|
const busy2 = (s) => Boolean(s.fight?.boss && s.fight.status === "active");
|
|
18
170
|
const copy = (value) => JSON.parse(JSON.stringify(value));
|
|
19
171
|
function makeGear(slot, tier = 0, rank = 0, id = Date.now()) {
|
|
@@ -21,7 +173,7 @@ function createIdleEngine(definition) {
|
|
|
21
173
|
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
174
|
}
|
|
23
175
|
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((
|
|
176
|
+
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((key2) => [key2, slots[key2].starter ? makeGear(key2, 0, 0, `starter-${key2}`) : null])), upgrades: Object.fromEntries(slotKeys.map((key2) => [key2, 0])), pet: PETS[0].id, pets: { [PETS[0].id]: 1 }, nextId: 1, savedAt: now, sessionGold: 0, sessionXp: 0, sessionDrops: 0, logs: [], fight: null, loadout: Object.fromEntries(["attack", "skill", "power", "treasure"].map((kind) => [kind, abilities.find((a) => a.kind === kind).id])) };
|
|
25
177
|
}
|
|
26
178
|
const xpNeeded = (s) => 50 + s.level * 30;
|
|
27
179
|
function stats(s) {
|
|
@@ -29,14 +181,14 @@ function createIdleEngine(definition) {
|
|
|
29
181
|
for (const [slot, item] of Object.entries(s.equipment))
|
|
30
182
|
if (item) {
|
|
31
183
|
const multiplier = 1 + s.upgrades[slot] * 0.16;
|
|
32
|
-
for (const
|
|
33
|
-
result[
|
|
184
|
+
for (const key2 of ["atk", "def", "hp"])
|
|
185
|
+
result[key2] += Math.round(item[key2] * multiplier);
|
|
34
186
|
}
|
|
35
187
|
result.power = result.atk * 5 + result.def * 3 + Math.round(result.hp / 5) + (s.pets[s.pet] || 0) * 18;
|
|
36
188
|
return result;
|
|
37
189
|
}
|
|
38
|
-
function addLog(s,
|
|
39
|
-
s.logs.unshift({ text, type, time: Date.now() });
|
|
190
|
+
function addLog(s, text2, type = "info") {
|
|
191
|
+
s.logs.unshift({ text: text2, type, time: Date.now() });
|
|
40
192
|
s.logs = s.logs.slice(0, 60);
|
|
41
193
|
}
|
|
42
194
|
function addDrop(s, item) {
|
|
@@ -60,22 +212,30 @@ function createIdleEngine(definition) {
|
|
|
60
212
|
}
|
|
61
213
|
}
|
|
62
214
|
function beginFight(s, boss = false) {
|
|
63
|
-
if (boss && busy2(s))
|
|
64
|
-
return;
|
|
215
|
+
if (boss && busy2(s)) return;
|
|
65
216
|
const m = MAPS[s.map], st = stats(s);
|
|
66
|
-
s.fight = {
|
|
67
|
-
|
|
68
|
-
|
|
217
|
+
s.fight = {
|
|
218
|
+
boss,
|
|
219
|
+
hp: st.hp,
|
|
220
|
+
maxHp: st.hp,
|
|
221
|
+
enemyHp: 0,
|
|
222
|
+
enemyMax: 0,
|
|
223
|
+
turn: 0,
|
|
224
|
+
status: "active",
|
|
225
|
+
recovery: 0,
|
|
226
|
+
spawned: 0,
|
|
227
|
+
units: [{ id: "hero", side: "hero", q: 0, r: 0, hp: st.hp, maxHp: st.hp }, { id: "pet", side: "pet", q: -1, r: 1, hp: 1, maxHp: 1 }]
|
|
228
|
+
};
|
|
229
|
+
for (let i = 0; i < (boss ? 1 : 2); i++) spawnHexEnemy(s.fight, boss ? m.bossHp : m.hp, s.kills * 3);
|
|
230
|
+
s.fight.enemyHp = s.fight.enemyMax = boss ? m.bossHp : m.hp * 2;
|
|
231
|
+
if (boss) addLog(s, `\u573A\u4E0A\u5C0F\u5996\u5DF2\u6E05\u9000\uFF0C${m.boss}\u8FDB\u5165\u68CB\u76D8\u3002`, "boss");
|
|
69
232
|
}
|
|
70
233
|
function tick(s, rng = Math.random) {
|
|
71
|
-
if (!s.idle && !s.fight?.boss)
|
|
72
|
-
|
|
73
|
-
if (!s.fight)
|
|
74
|
-
beginFight(s);
|
|
234
|
+
if (!s.idle && !s.fight?.boss) return null;
|
|
235
|
+
if (!s.fight) beginFight(s);
|
|
75
236
|
let f = s.fight;
|
|
76
237
|
if (f.status !== "active") {
|
|
77
|
-
if (++f.recovery < 2)
|
|
78
|
-
return null;
|
|
238
|
+
if (++f.recovery < 2) return null;
|
|
79
239
|
if (!s.idle) {
|
|
80
240
|
s.fight = null;
|
|
81
241
|
return null;
|
|
@@ -83,55 +243,42 @@ function createIdleEngine(definition) {
|
|
|
83
243
|
beginFight(s);
|
|
84
244
|
f = s.fight;
|
|
85
245
|
}
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
const
|
|
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";
|
|
246
|
+
const m = MAPS[s.map], event = resolveHexRound(definition, s, stats(s), rng), playback = event.playback;
|
|
247
|
+
const dead = playback.cues.filter((c) => c.kind === "death" && c.actor.startsWith("enemy-"));
|
|
248
|
+
for (const cue of dead) {
|
|
98
249
|
s.kills++;
|
|
250
|
+
let xp = m.xp, gold = m.gold, drop = "";
|
|
99
251
|
if (f.boss) {
|
|
100
252
|
s.bossWins++;
|
|
101
253
|
const first = !s.cleared.includes(s.map);
|
|
102
|
-
|
|
254
|
+
xp *= first ? 6 : 2;
|
|
255
|
+
gold *= first ? 8 : 3;
|
|
103
256
|
s.essence += first ? 50 : 12;
|
|
104
257
|
if (first) {
|
|
105
258
|
s.cleared.push(s.map);
|
|
106
259
|
s.unlocked = Math.min(MAPS.length - 1, Math.max(s.unlocked, s.map + 1));
|
|
107
260
|
const item = makeGear(m.rewardSlot, 1, s.map, `drop-${s.nextId++}`);
|
|
108
261
|
addDrop(s, item);
|
|
109
|
-
event.reward = item.name;
|
|
110
|
-
addLog(s, `\u9996\u901A ${m.boss}\uFF01\u83B7\u5F97 ${item.name}\
|
|
111
|
-
} else
|
|
112
|
-
addLog(s, `\u518D\u6B21\u51FB\u8D25 ${m.boss}\uFF0C\u83B7\u5F97\u4FEE\u884C\u5956\u52B1\u3002`, "rare");
|
|
262
|
+
event.reward = drop = item.name;
|
|
263
|
+
addLog(s, `\u9996\u901A ${m.boss}\uFF01\u83B7\u5F97 ${item.name}\u3002`, "rare");
|
|
264
|
+
} else addLog(s, `\u518D\u6B21\u51FB\u8D25 ${m.boss}\uFF0C\u83B7\u5F97\u4FEE\u884C\u5956\u52B1\u3002`, "rare");
|
|
113
265
|
event.bossWin = true;
|
|
114
266
|
event.first = first;
|
|
115
267
|
} else {
|
|
116
|
-
grant(s, m.xp, m.gold);
|
|
117
268
|
s.essence += 2;
|
|
118
269
|
if (rng() < 0.38) {
|
|
119
|
-
const item = makeGear(
|
|
270
|
+
const item = makeGear(slotKeys[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
271
|
const kept = addDrop(s, item);
|
|
272
|
+
event.drop = drop = item.name;
|
|
121
273
|
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
274
|
}
|
|
124
275
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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");
|
|
276
|
+
grant(s, xp, gold);
|
|
277
|
+
playback.xp += xp;
|
|
278
|
+
playback.gold += gold;
|
|
279
|
+
playback.cues.push({ at: 0.9, kind: "loot", actor: cue.actor, value: gold, label: drop || `\u7ECF\u9A8C +${xp}` });
|
|
134
280
|
}
|
|
281
|
+
if (event.lost) addLog(s, "\u5386\u7EC3\u5931\u5229\uFF0C\u4F11\u6574\u540E\u518D\u6218\uFF1B\u53EF\u66F4\u6362\u80FD\u529B\u3001\u88C5\u5907\u6216\u7075\u5BA0\u3002", "boss");
|
|
135
282
|
return event;
|
|
136
283
|
}
|
|
137
284
|
function equip(s, id) {
|
|
@@ -207,8 +354,8 @@ function createIdleEngine(definition) {
|
|
|
207
354
|
if (!raw || raw.version !== 1 || !Array.isArray(raw.inventory) || !raw.equipment || !raw.pets)
|
|
208
355
|
throw new Error("\u5B58\u6863\u683C\u5F0F\u4E0D\u6B63\u786E");
|
|
209
356
|
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
|
|
211
|
-
s[
|
|
357
|
+
for (const key2 of ["gold", "xp", "essence", "material", "kills", "bossWins", "sessionGold", "sessionXp", "sessionDrops"])
|
|
358
|
+
s[key2] = number(raw[key2], 0, 1e9);
|
|
212
359
|
s.level = number(raw.level, 1, 60);
|
|
213
360
|
s.unlocked = number(raw.unlocked, 0, MAPS.length - 1);
|
|
214
361
|
s.map = number(raw.map, 0, s.unlocked);
|
|
@@ -227,6 +374,10 @@ function createIdleEngine(definition) {
|
|
|
227
374
|
if (raw.pets[pet.id])
|
|
228
375
|
s.pets[pet.id] = number(raw.pets[pet.id], 1, 20);
|
|
229
376
|
s.pet = Object.hasOwn(s.pets, raw.pet) ? raw.pet : PETS[0].id;
|
|
377
|
+
for (const kind of ["attack", "skill", "power", "treasure"]) {
|
|
378
|
+
const chosen = abilities.find((a) => a.id === raw.loadout?.[kind] && a.kind === kind);
|
|
379
|
+
if (chosen) s.loadout[kind] = chosen.id;
|
|
380
|
+
}
|
|
230
381
|
return s;
|
|
231
382
|
}
|
|
232
383
|
function settleOffline(s, now = Date.now(), rng = Math.random) {
|
|
@@ -237,7 +388,7 @@ function createIdleEngine(definition) {
|
|
|
237
388
|
}
|
|
238
389
|
const before = { xp: s.sessionXp, gold: s.gold, drops: s.sessionDrops, essence: s.essence, kills: s.kills };
|
|
239
390
|
s.fight = null;
|
|
240
|
-
for (let i = 0; i < seconds; i++)
|
|
391
|
+
for (let i = 0; i < Math.floor(seconds * 1e3 / (definition.turnDurationMs ?? 1e3)); i++)
|
|
241
392
|
tick(s, rng);
|
|
242
393
|
s.fight = null;
|
|
243
394
|
s.savedAt = now;
|
|
@@ -254,37 +405,356 @@ function createIdleEngine(definition) {
|
|
|
254
405
|
}
|
|
255
406
|
|
|
256
407
|
// src/game/components.tsx
|
|
257
|
-
import { useRef, useState } from "react";
|
|
258
|
-
|
|
408
|
+
import { useRef as useRef2, useState as useState2 } from "react";
|
|
409
|
+
|
|
410
|
+
// src/game/HexBattlefield.tsx
|
|
411
|
+
import { useEffect, useRef, useState } from "react";
|
|
412
|
+
|
|
413
|
+
// src/game/hex-playback.ts
|
|
414
|
+
function sampleHexPlayback(playback, progress) {
|
|
415
|
+
const t = Math.max(0, Math.min(1, progress)), units = playback.units.map((unit) => ({ ...unit }));
|
|
416
|
+
for (const cue of playback.cues) {
|
|
417
|
+
if (t < cue.at) continue;
|
|
418
|
+
const unit = units.find((u) => u.id === (cue.target ?? cue.actor));
|
|
419
|
+
if (cue.kind === "move" && cue.from && cue.to) {
|
|
420
|
+
const moving = units.find((u) => u.id === cue.actor);
|
|
421
|
+
if (moving) {
|
|
422
|
+
const p = Math.min(1, (t - cue.at) / 0.12), eased = p * p * (3 - 2 * p);
|
|
423
|
+
moving.q = cue.from.q + (cue.to.q - cue.from.q) * eased;
|
|
424
|
+
moving.r = cue.from.r + (cue.to.r - cue.from.r) * eased;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
if (unit && (cue.kind === "hit" || cue.kind === "heal") && cue.hp !== void 0) unit.hp = cue.hp;
|
|
428
|
+
}
|
|
429
|
+
return { units, progress: t };
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// src/game/HexBattlefield.tsx
|
|
433
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
434
|
+
var images = /* @__PURE__ */ new Map();
|
|
435
|
+
function bitmap(src) {
|
|
436
|
+
let img = images.get(src);
|
|
437
|
+
if (!img) {
|
|
438
|
+
img = new Image();
|
|
439
|
+
img.src = src;
|
|
440
|
+
images.set(src, img);
|
|
441
|
+
}
|
|
442
|
+
return img.complete && img.naturalWidth ? img : null;
|
|
443
|
+
}
|
|
444
|
+
var tilt = Math.SQRT1_2;
|
|
445
|
+
var point = (cell) => ({ x: 450 + 78 * cell.q, y: 304 + Math.sqrt(3) * 52 * (cell.r + cell.q / 2) * tilt });
|
|
446
|
+
function hexPath(ctx, x, y, radius) {
|
|
447
|
+
ctx.beginPath();
|
|
448
|
+
for (let i = 0; i < 6; i++) {
|
|
449
|
+
const a = i * Math.PI / 3, px = x + Math.cos(a) * radius, py = y + Math.sin(a) * radius * tilt;
|
|
450
|
+
if (!i) ctx.moveTo(px, py);
|
|
451
|
+
else ctx.lineTo(px, py);
|
|
452
|
+
}
|
|
453
|
+
ctx.closePath();
|
|
454
|
+
}
|
|
455
|
+
function polygon(ctx, points, color, stroke = "#101a27") {
|
|
456
|
+
ctx.beginPath();
|
|
457
|
+
points.forEach(([x, y], i) => i ? ctx.lineTo(x, y) : ctx.moveTo(x, y));
|
|
458
|
+
ctx.closePath();
|
|
459
|
+
ctx.fillStyle = color;
|
|
460
|
+
ctx.fill();
|
|
461
|
+
ctx.strokeStyle = stroke;
|
|
462
|
+
ctx.lineWidth = 1.5;
|
|
463
|
+
ctx.stroke();
|
|
464
|
+
}
|
|
465
|
+
function tile(ctx, x, y, radius, depth, top, border) {
|
|
466
|
+
const dy = radius * Math.sqrt(3) / 2 * tilt;
|
|
467
|
+
polygon(ctx, [[x - radius, y], [x - radius / 2, y + dy], [x - radius / 2, y + dy + depth], [x - radius, y + depth]], "#182433");
|
|
468
|
+
polygon(ctx, [[x - radius / 2, y + dy], [x + radius / 2, y + dy], [x + radius / 2, y + dy + depth], [x - radius / 2, y + dy + depth]], "#223348");
|
|
469
|
+
polygon(ctx, [[x + radius / 2, y + dy], [x + radius, y], [x + radius, y + depth], [x + radius / 2, y + dy + depth]], "#2b4054");
|
|
470
|
+
hexPath(ctx, x, y, radius);
|
|
471
|
+
ctx.fillStyle = top;
|
|
472
|
+
ctx.fill();
|
|
473
|
+
ctx.strokeStyle = border;
|
|
474
|
+
ctx.lineWidth = 1.5;
|
|
475
|
+
ctx.stroke();
|
|
476
|
+
}
|
|
477
|
+
function text(ctx, value, x, y, color = "#dce9f4", size = 13) {
|
|
478
|
+
ctx.font = `600 ${size}px "Microsoft YaHei",sans-serif`;
|
|
479
|
+
ctx.textAlign = "center";
|
|
480
|
+
ctx.textBaseline = "middle";
|
|
481
|
+
ctx.fillStyle = color;
|
|
482
|
+
ctx.fillText(value, x, y);
|
|
483
|
+
}
|
|
484
|
+
function plate(ctx, value, x, y, color) {
|
|
485
|
+
ctx.font = '12px "Microsoft YaHei",sans-serif';
|
|
486
|
+
const w = ctx.measureText(value).width + 16;
|
|
487
|
+
ctx.fillStyle = "#111d2eef";
|
|
488
|
+
ctx.fillRect(x - w / 2, y - 10, w, 20);
|
|
489
|
+
ctx.strokeStyle = "#435971";
|
|
490
|
+
ctx.strokeRect(x - w / 2, y - 10, w, 20);
|
|
491
|
+
text(ctx, value, x, y, color, 12);
|
|
492
|
+
}
|
|
493
|
+
function GameHexBattlefield({ engine, state, event, sequence = 0 }) {
|
|
494
|
+
const canvas = useRef(null), [phase, setPhase] = useState("\u7B49\u5F85\u51FA\u53D1"), [assetFailed, setAssetFailed] = useState(false), [visibleEnemies, setVisibleEnemies] = useState(0);
|
|
495
|
+
const map = engine.definition.maps[state.map], pet = engine.definition.pets.find((p) => p.id === state.pet);
|
|
496
|
+
const fight = state.fight, boss = Boolean(fight?.boss), duration = engine.definition.turnDurationMs ?? 1e3;
|
|
497
|
+
const reduced = useRef(false);
|
|
498
|
+
useEffect(() => {
|
|
499
|
+
const media = matchMedia("(prefers-reduced-motion: reduce)");
|
|
500
|
+
reduced.current = media.matches;
|
|
501
|
+
const change = () => {
|
|
502
|
+
reduced.current = media.matches;
|
|
503
|
+
};
|
|
504
|
+
media.addEventListener("change", change);
|
|
505
|
+
return () => media.removeEventListener("change", change);
|
|
506
|
+
}, []);
|
|
507
|
+
useEffect(() => {
|
|
508
|
+
const element = canvas.current, ctx = element?.getContext("2d");
|
|
509
|
+
if (!element || !ctx) return;
|
|
510
|
+
let frame = 0, disposed = false, lastPhase = "", lastCount = -1, started = performance.now();
|
|
511
|
+
const replay = event?.playback;
|
|
512
|
+
const idleUnits = fight?.units.map((u) => ({ ...u })) ?? [{ id: "hero", side: "hero", q: 0, r: 0, hp: engine.stats(state).hp, maxHp: engine.stats(state).hp }, { id: "pet", side: "pet", q: -1, r: 1, hp: 1, maxHp: 1 }];
|
|
513
|
+
const roster = (unit) => unit.side === "hero" ? { name: state.name, asset: engine.definition.hero, color: "#8bdcff" } : unit.side === "pet" ? { name: pet.name, asset: pet.art, color: "#8ae2b9" } : { name: boss ? map.boss : map.enemy, asset: boss ? map.bossArt : map.enemyArt, color: boss ? "#efb779" : "#e69386" };
|
|
514
|
+
const assets = [engine.definition.hero.src, pet.art.src, (boss ? map.bossArt : map.enemyArt).src];
|
|
515
|
+
assets.forEach(bitmap);
|
|
516
|
+
const fit = () => {
|
|
517
|
+
const dpr = Math.min(devicePixelRatio || 1, 2);
|
|
518
|
+
element.width = 900 * dpr;
|
|
519
|
+
element.height = 580 * dpr;
|
|
520
|
+
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
521
|
+
};
|
|
522
|
+
fit();
|
|
523
|
+
const draw = (now) => {
|
|
524
|
+
if (disposed) return;
|
|
525
|
+
const t = replay ? Math.min(1, (now - started) / duration) : 1, visual = replay ? sampleHexPlayback(replay, t) : { units: idleUnits, progress: t };
|
|
526
|
+
const cues = replay?.cues ?? [], active = cues.filter((c) => t >= c.at && t < c.at + 0.17);
|
|
527
|
+
const count = visual.units.filter((u) => u.side === "enemy" && u.hp > 0).length;
|
|
528
|
+
if (count !== lastCount) {
|
|
529
|
+
lastCount = count;
|
|
530
|
+
setVisibleEnemies(count);
|
|
531
|
+
}
|
|
532
|
+
const phaseLabel = !fight ? "\u7B49\u5F85\u51FA\u53D1 \xB7 \u81EA\u52A8\u5BFB\u654C" : !replay ? fight.status === "won" ? "\u6E05\u7406\u6218\u573A \xB7 \u4E0B\u4E00\u6CE2\u5373\u5C06\u6765\u88AD" : fight.status === "lost" ? "\u6682\u4F5C\u4F11\u6574" : "\u5996\u6C14\u6765\u88AD" : t < 0.18 ? "\u9010\u683C\u63A5\u8FD1 \xB7 \u81EA\u52A8\u5BFB\u654C" : t < 0.35 ? "\u51C6\u5907\u51FA\u624B" : t < 0.55 ? "\u547D\u4E2D \xB7 \u8FFD\u51FB" : t < 0.78 ? replay.move === "charge" ? `${map.boss}\u6B63\u5728\u84C4\u529B` : replay.move === "recover" ? "\u9996\u9886\u5598\u606F" : "\u654C\u65B9\u884C\u52A8" : t < 0.88 ? "\u7075\u5BA0\u652F\u63F4" : replay.gold ? "\u62FE\u53D6\u6218\u5229\u54C1" : "\u56DE\u5408\u7ED3\u675F";
|
|
533
|
+
if (phaseLabel !== lastPhase) {
|
|
534
|
+
lastPhase = phaseLabel;
|
|
535
|
+
setPhase(phaseLabel);
|
|
536
|
+
}
|
|
537
|
+
ctx.clearRect(0, 0, 900, 580);
|
|
538
|
+
ctx.fillStyle = "#111d2a";
|
|
539
|
+
ctx.fillRect(0, 0, 900, 580);
|
|
540
|
+
polygon(ctx, [[0, 100], [92, 62], [145, 113], [178, 79], [235, 130], [0, 215]], "#1a3040", "#253c4c");
|
|
541
|
+
polygon(ctx, [[900, 80], [803, 112], [751, 60], [720, 136], [665, 161], [900, 202]], "#1b3240", "#2b4654");
|
|
542
|
+
polygon(ctx, [[0, 499], [122, 447], [173, 494], [236, 475], [282, 580], [0, 580]], "#1a2c38", "#2a4250");
|
|
543
|
+
polygon(ctx, [[900, 459], [824, 428], [778, 474], [716, 465], [663, 580], [900, 580]], "#192c39", "#2b4253");
|
|
544
|
+
const cells = gameHexCells().sort((a, b) => point(a).y - point(b).y);
|
|
545
|
+
for (const cell of cells) {
|
|
546
|
+
const p = point(cell), edge = hexDistance(cell, { q: 0, r: 0 }) === 3, occupied = visual.units.find((u) => u.hp > 0 && hexDistance(u, cell) < 0.1);
|
|
547
|
+
const color = occupied?.side === "hero" ? "#314b61" : occupied?.side === "enemy" ? "#493b3b" : (cell.q - cell.r + 12) % 3 === 0 ? "#304554" : "#2a3c4b";
|
|
548
|
+
tile(ctx, p.x, p.y, 50, 8, color, edge ? "#53666c" : "#465d70");
|
|
549
|
+
if (edge) {
|
|
550
|
+
text(ctx, "\xB7", p.x, p.y, "#9caa91", 20);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
for (const cue of cues.filter((c) => c.kind === "move" && c.from && c.to && t >= c.at && t < c.at + 0.2)) {
|
|
554
|
+
const a = point(cue.from), b = point(cue.to);
|
|
555
|
+
ctx.beginPath();
|
|
556
|
+
ctx.moveTo(a.x, a.y);
|
|
557
|
+
ctx.lineTo(b.x, b.y);
|
|
558
|
+
ctx.strokeStyle = cue.actor.startsWith("enemy") ? "#bd766b" : "#6bbddd";
|
|
559
|
+
ctx.lineWidth = 3;
|
|
560
|
+
ctx.setLineDash([5, 5]);
|
|
561
|
+
ctx.stroke();
|
|
562
|
+
ctx.setLineDash([]);
|
|
563
|
+
}
|
|
564
|
+
const ordered = [...visual.units].sort((a, b) => point(a).y - point(b).y);
|
|
565
|
+
for (const unit of ordered) {
|
|
566
|
+
const spawn = cues.find((c) => c.kind === "spawn" && c.actor === unit.id);
|
|
567
|
+
if (spawn && t < spawn.at) continue;
|
|
568
|
+
const dead = cues.find((c) => c.kind === "death" && c.actor === unit.id);
|
|
569
|
+
if (unit.hp === 0 && (!dead || t > dead.at + 0.1)) continue;
|
|
570
|
+
const p = point(unit), info = roster(unit), hit = active.find((c) => c.kind === "hit" && c.target === unit.id), cast = active.find((c) => c.kind === "cast" && c.actor === unit.id), heal = active.find((c) => c.kind === "heal" && c.target === unit.id);
|
|
571
|
+
let x = p.x, y = p.y - 15;
|
|
572
|
+
if (!reduced.current && hit) x += Math.sin((t - hit.at) * 110) * 5;
|
|
573
|
+
if (!reduced.current && cast) y -= Math.sin(Math.min(1, (t - cast.at) / 0.15) * Math.PI) * 8;
|
|
574
|
+
ctx.save();
|
|
575
|
+
if (dead && t >= dead.at) ctx.globalAlpha = Math.max(0, 1 - (t - dead.at) / 0.1);
|
|
576
|
+
const radius = boss && unit.side === "enemy" ? 50 : 44;
|
|
577
|
+
tile(ctx, x, y, radius, 15, unit.side === "hero" ? "#355771" : unit.side === "pet" ? "#2f554b" : "#674b42", heal ? "#96f5c2" : hit ? "#ffe2be" : info.color);
|
|
578
|
+
ctx.save();
|
|
579
|
+
hexPath(ctx, x, y, radius - 4);
|
|
580
|
+
ctx.clip();
|
|
581
|
+
ctx.translate(x, y);
|
|
582
|
+
ctx.scale(info.asset.flip ? -1 : 1, tilt);
|
|
583
|
+
const img = bitmap(info.asset.src);
|
|
584
|
+
if (img) {
|
|
585
|
+
const crop = Math.min(img.naturalWidth, img.naturalHeight * 0.76);
|
|
586
|
+
ctx.drawImage(img, (img.naturalWidth - crop) / 2, 0, crop, crop, -radius, -radius, radius * 2, radius * 2);
|
|
587
|
+
} else {
|
|
588
|
+
text(ctx, info.name.slice(0, 2), 0, 0, info.color, 20);
|
|
589
|
+
if (images.get(info.asset.src)?.complete) setAssetFailed(true);
|
|
590
|
+
}
|
|
591
|
+
ctx.restore();
|
|
592
|
+
hexPath(ctx, x, y, radius - 3);
|
|
593
|
+
ctx.strokeStyle = info.color;
|
|
594
|
+
ctx.lineWidth = 2;
|
|
595
|
+
ctx.stroke();
|
|
596
|
+
if (hit) {
|
|
597
|
+
hexPath(ctx, x, y, radius);
|
|
598
|
+
ctx.strokeStyle = "#fff3c4";
|
|
599
|
+
ctx.lineWidth = 4;
|
|
600
|
+
ctx.stroke();
|
|
601
|
+
for (let ray = 0; ray < 6; ray++) {
|
|
602
|
+
const angle = ray * Math.PI / 3;
|
|
603
|
+
ctx.beginPath();
|
|
604
|
+
ctx.moveTo(x + Math.cos(angle) * (radius + 3), y + Math.sin(angle) * (radius + 3) * tilt);
|
|
605
|
+
ctx.lineTo(x + Math.cos(angle) * (radius + 12), y + Math.sin(angle) * (radius + 12) * tilt);
|
|
606
|
+
ctx.stroke();
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
if (heal) {
|
|
610
|
+
hexPath(ctx, x, y, radius + 5);
|
|
611
|
+
ctx.strokeStyle = "#8ee9b2";
|
|
612
|
+
ctx.lineWidth = 3;
|
|
613
|
+
ctx.stroke();
|
|
614
|
+
}
|
|
615
|
+
if (replay?.guarded && unit.side === "hero") {
|
|
616
|
+
hexPath(ctx, x, y, radius + 5);
|
|
617
|
+
ctx.strokeStyle = "#97bde5";
|
|
618
|
+
ctx.lineWidth = 2;
|
|
619
|
+
ctx.stroke();
|
|
620
|
+
}
|
|
621
|
+
if (boss && unit.side === "enemy" && replay?.move === "charge") {
|
|
622
|
+
hexPath(ctx, x, y, radius + 8);
|
|
623
|
+
ctx.strokeStyle = "#f3aa68";
|
|
624
|
+
ctx.lineWidth = 3;
|
|
625
|
+
ctx.stroke();
|
|
626
|
+
}
|
|
627
|
+
const nameY = p.y + 43;
|
|
628
|
+
plate(ctx, info.name, x, nameY, info.color);
|
|
629
|
+
if (unit.side !== "pet") {
|
|
630
|
+
ctx.fillStyle = "#101723";
|
|
631
|
+
ctx.fillRect(x - 31, nameY + 14, 62, 5);
|
|
632
|
+
ctx.fillStyle = unit.side === "hero" ? "#7ac7d9" : "#d58270";
|
|
633
|
+
ctx.fillRect(x - 31, nameY + 14, 62 * Math.max(0, unit.hp / unit.maxHp), 5);
|
|
634
|
+
text(ctx, `${unit.hp}/${unit.maxHp}`, x, nameY + 29, "#c5d4e4", 10);
|
|
635
|
+
}
|
|
636
|
+
ctx.restore();
|
|
637
|
+
}
|
|
638
|
+
for (const cue of active) {
|
|
639
|
+
const source = visual.units.find((u) => u.id === cue.actor), target = visual.units.find((u) => u.id === cue.target);
|
|
640
|
+
if (!source) continue;
|
|
641
|
+
const a = point(source), b = target ? point(target) : a;
|
|
642
|
+
if (cue.kind === "cast" && target) {
|
|
643
|
+
const impact = cues.find((c) => c.kind === "hit" && c.actor === cue.actor && c.target === cue.target && c.at > cue.at);
|
|
644
|
+
const p = Math.min(1, (t - cue.at) / Math.max(0.02, (impact?.at ?? cue.at + 0.14) - cue.at));
|
|
645
|
+
const x = a.x + (b.x - a.x) * p, y = a.y + (b.y - a.y) * p - 25;
|
|
646
|
+
tile(ctx, x, y, 9, 3, cue.actor.startsWith("enemy") ? "#d19a75" : "#e3c37e", "#f4e3b7");
|
|
647
|
+
plate(ctx, cue.label ?? "\u51FA\u624B", a.x, a.y - 69, cue.actor.startsWith("enemy") ? "#f1ba91" : "#ead694");
|
|
648
|
+
}
|
|
649
|
+
if (cue.kind === "heal" && target) {
|
|
650
|
+
ctx.strokeStyle = "#7ce3ad";
|
|
651
|
+
ctx.lineWidth = 3;
|
|
652
|
+
ctx.beginPath();
|
|
653
|
+
ctx.moveTo(a.x, a.y - 20);
|
|
654
|
+
ctx.lineTo(b.x, b.y - 20);
|
|
655
|
+
ctx.stroke();
|
|
656
|
+
hexPath(ctx, b.x, b.y - 15, 53);
|
|
657
|
+
ctx.stroke();
|
|
658
|
+
}
|
|
659
|
+
if (cue.kind === "shield") {
|
|
660
|
+
hexPath(ctx, a.x, a.y - 15, 55);
|
|
661
|
+
ctx.strokeStyle = "#a7d7fa";
|
|
662
|
+
ctx.lineWidth = 3;
|
|
663
|
+
ctx.stroke();
|
|
664
|
+
}
|
|
665
|
+
if (cue.kind === "hit" || cue.kind === "heal") {
|
|
666
|
+
const y = b.y - 63 - (reduced.current ? 0 : (t - cue.at) * 70);
|
|
667
|
+
ctx.strokeStyle = "#102034";
|
|
668
|
+
ctx.lineWidth = 4;
|
|
669
|
+
ctx.font = "bold 20px sans-serif";
|
|
670
|
+
ctx.textAlign = "center";
|
|
671
|
+
const label = `${cue.kind === "heal" ? "+" : "\u2212"}${cue.value}`;
|
|
672
|
+
ctx.strokeText(label, b.x, y);
|
|
673
|
+
text(ctx, label, b.x, y, cue.kind === "heal" ? "#9bffd0" : cue.actor.startsWith("enemy") ? "#ffc0a3" : "#ffe39c", 20);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
for (const cue of cues.filter((c) => c.kind === "loot" && t >= c.at)) {
|
|
677
|
+
const unit = visual.units.find((u) => u.id === cue.actor);
|
|
678
|
+
if (!unit) continue;
|
|
679
|
+
const p = point(unit);
|
|
680
|
+
tile(ctx, p.x, p.y - 9, 15, 5, "#d8b65e", "#ffdf92");
|
|
681
|
+
text(ctx, "\u94B1", p.x, p.y - 9, "#49391d", 11);
|
|
682
|
+
plate(ctx, `+${cue.value} \u94DC\u94B1`, p.x, p.y + 25, "#f4d18c");
|
|
683
|
+
text(ctx, cue.label ?? "", p.x, p.y + 47, "#d6dbe0", 11);
|
|
684
|
+
}
|
|
685
|
+
text(ctx, `${map.name} \xB7 \u68CB\u5883`, 100, 31, "#c6bb95", 17);
|
|
686
|
+
text(ctx, "\u516D\u65B9\u6765\u654C \xB7 \u81EA\u52A8\u8FCE\u6218", 777, 31, "#8aa7bd", 12);
|
|
687
|
+
if (t < 1 || assets.some((src) => !images.get(src)?.complete)) frame = requestAnimationFrame(draw);
|
|
688
|
+
};
|
|
689
|
+
frame = requestAnimationFrame(draw);
|
|
690
|
+
const resume = () => {
|
|
691
|
+
if (!document.hidden) {
|
|
692
|
+
cancelAnimationFrame(frame);
|
|
693
|
+
frame = requestAnimationFrame(draw);
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
document.addEventListener("visibilitychange", resume);
|
|
697
|
+
return () => {
|
|
698
|
+
disposed = true;
|
|
699
|
+
cancelAnimationFrame(frame);
|
|
700
|
+
document.removeEventListener("visibilitychange", resume);
|
|
701
|
+
};
|
|
702
|
+
}, [engine, state, event, sequence, fight, map, pet, duration, boss]);
|
|
703
|
+
return /* @__PURE__ */ jsxs("section", { className: "hex-battlefield", "aria-label": "\u516D\u8FB9\u5F62\u81EA\u52A8\u6218\u573A", children: [
|
|
704
|
+
/* @__PURE__ */ jsxs("div", { className: "hex-stage-head", children: [
|
|
705
|
+
/* @__PURE__ */ jsx("span", { children: boss ? "\u9996\u9886\u73B0\u8EAB \xB7 \u5C0F\u5996\u5DF2\u6E05\u9000" : "\u516D\u65B9\u6765\u654C \xB7 \u9010\u683C\u63A5\u8FD1" }),
|
|
706
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
707
|
+
"\u7B2C ",
|
|
708
|
+
fight?.turn ?? 0,
|
|
709
|
+
" \u56DE\u5408 \xB7 \u654C\u65B9 ",
|
|
710
|
+
visibleEnemies
|
|
711
|
+
] })
|
|
712
|
+
] }),
|
|
713
|
+
/* @__PURE__ */ jsx("canvas", { ref: canvas, className: "hex-canvas", role: "img", "aria-label": `${map.name}\uFF0C45\u5EA6\u4FEF\u89C6\u516D\u8FB9\u5F62\u68CB\u76D8\uFF0C${state.name}\u4E0E${pet.name}\u81EA\u52A8\u8FCE\u6218${boss ? map.boss : "\u56DB\u65B9\u5C0F\u5996"}` }),
|
|
714
|
+
boss && /* @__PURE__ */ jsxs("div", { className: `hex-boss-intent ${event?.playback?.move === "charge" ? "charging" : ""}`, children: [
|
|
715
|
+
/* @__PURE__ */ jsx("span", { children: map.boss }),
|
|
716
|
+
/* @__PURE__ */ jsx("b", { children: event?.playback?.move === "charge" ? `\u84C4\u529B \xB7 \u4E0B\u56DE\u5408${map.bossSkillName ?? "\u91CD\u51FB"}` : event?.playback?.move === "heavy" ? map.bossSkillName ?? "\u91CD\u51FB" : event?.playback?.move === "recover" ? "\u5598\u606F \xB7 \u672C\u56DE\u5408\u4E0D\u653B\u51FB" : "\u903C\u8FD1 \xB7 \u8FD1\u8EAB\u6325\u780D" }),
|
|
717
|
+
/* @__PURE__ */ jsx("span", { children: "\u6325\u780D \u2192 \u84C4\u529B \u2192 \u91CD\u65A9 \u2192 \u5598\u606F" })
|
|
718
|
+
] }),
|
|
719
|
+
/* @__PURE__ */ jsxs("div", { className: "hex-stage-foot", children: [
|
|
720
|
+
/* @__PURE__ */ jsx("span", { children: phase }),
|
|
721
|
+
/* @__PURE__ */ jsx("span", { children: "\u9752 \xB7 \u73A9\u5BB6\u3000\u7EFF \xB7 \u7075\u5BA0\u3000\u8D64 \xB7 \u5996\u602A" })
|
|
722
|
+
] }),
|
|
723
|
+
assetFailed && /* @__PURE__ */ jsx("p", { className: "hex-asset-warning", children: "\u90E8\u5206\u8D34\u56FE\u52A0\u8F7D\u5931\u8D25\uFF0C\u6682\u4EE5\u5355\u4F4D\u540D\u6807\u8BC6\u68CB\u5B50\u3002" })
|
|
724
|
+
] });
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// src/game/components.tsx
|
|
728
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
259
729
|
function GameSprite({ asset, className = "" }) {
|
|
260
|
-
return /* @__PURE__ */
|
|
730
|
+
return /* @__PURE__ */ jsx2("img", { className: `unit-art ${asset.flip ? "face-left" : ""} ${className}`, src: asset.src, alt: "", "aria-hidden": "true", draggable: false, decoding: "async" });
|
|
261
731
|
}
|
|
262
732
|
function GameButton({ className = "", ...props }) {
|
|
263
|
-
return /* @__PURE__ */
|
|
733
|
+
return /* @__PURE__ */ jsx2(Button, { ...props, className: `game-button ${className}` });
|
|
264
734
|
}
|
|
265
735
|
var fmt = (n) => Math.floor(n).toLocaleString("zh-CN");
|
|
266
736
|
var busy = (s) => Boolean(s.fight?.boss && s.fight.status === "active");
|
|
267
737
|
var command = (fn, type, id) => () => fn({ type, id });
|
|
268
738
|
function Title({ kicker, title, children }) {
|
|
269
|
-
return /* @__PURE__ */
|
|
270
|
-
/* @__PURE__ */
|
|
271
|
-
/* @__PURE__ */
|
|
272
|
-
/* @__PURE__ */
|
|
739
|
+
return /* @__PURE__ */ jsxs2("div", { className: "view-title", children: [
|
|
740
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
741
|
+
/* @__PURE__ */ jsx2("span", { className: "eyebrow", children: kicker }),
|
|
742
|
+
/* @__PURE__ */ jsx2("h1", { children: title })
|
|
273
743
|
] }),
|
|
274
744
|
children
|
|
275
745
|
] });
|
|
276
746
|
}
|
|
277
747
|
function ItemStats({ item }) {
|
|
278
|
-
return /* @__PURE__ */
|
|
279
|
-
/* @__PURE__ */
|
|
748
|
+
return /* @__PURE__ */ jsxs2("div", { className: "item-stats", children: [
|
|
749
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
280
750
|
"\u653B\u51FB +",
|
|
281
751
|
item.atk
|
|
282
752
|
] }),
|
|
283
|
-
/* @__PURE__ */
|
|
753
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
284
754
|
"\u9632\u5FA1 +",
|
|
285
755
|
item.def
|
|
286
756
|
] }),
|
|
287
|
-
/* @__PURE__ */
|
|
757
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
288
758
|
"\u6C14\u8840 +",
|
|
289
759
|
item.hp
|
|
290
760
|
] })
|
|
@@ -292,203 +762,158 @@ function ItemStats({ item }) {
|
|
|
292
762
|
}
|
|
293
763
|
function GameShell({ engine, state, onAction, page, children }) {
|
|
294
764
|
const d = engine.definition, view = { engine, state, onAction };
|
|
295
|
-
return /* @__PURE__ */
|
|
296
|
-
/* @__PURE__ */
|
|
297
|
-
/* @__PURE__ */
|
|
298
|
-
/* @__PURE__ */
|
|
299
|
-
/* @__PURE__ */
|
|
765
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
766
|
+
/* @__PURE__ */ jsxs2("header", { className: "topbar", children: [
|
|
767
|
+
/* @__PURE__ */ jsxs2("div", { className: "brand", children: [
|
|
768
|
+
/* @__PURE__ */ jsx2("span", { className: "brand-seal", children: d.title[0] }),
|
|
769
|
+
/* @__PURE__ */ jsxs2("span", { className: "brand-title", children: [
|
|
300
770
|
d.title,
|
|
301
|
-
/* @__PURE__ */
|
|
771
|
+
/* @__PURE__ */ jsx2("small", { children: d.subtitle })
|
|
302
772
|
] })
|
|
303
773
|
] }),
|
|
304
|
-
/* @__PURE__ */
|
|
305
|
-
/* @__PURE__ */
|
|
774
|
+
/* @__PURE__ */ jsxs2("div", { className: "realm", children: [
|
|
775
|
+
/* @__PURE__ */ jsx2("span", { className: "live-dot" }),
|
|
306
776
|
"\u5355\u4EBA\u4FEE\u884C / \u653E\u7F6E\u5386\u7EC3"
|
|
307
777
|
] }),
|
|
308
|
-
/* @__PURE__ */
|
|
309
|
-
/* @__PURE__ */
|
|
310
|
-
/* @__PURE__ */
|
|
778
|
+
/* @__PURE__ */ jsxs2("div", { className: "top-actions", children: [
|
|
779
|
+
/* @__PURE__ */ jsx2("span", { className: "version", children: "Sia Game \xB7 v0.3" }),
|
|
780
|
+
/* @__PURE__ */ jsx2(GameButton, { className: "icon-button", "aria-label": "\u8BBE\u7F6E\u4E0E\u5B58\u6863", onClick: command(onAction, "settings"), children: "\u2699" })
|
|
311
781
|
] })
|
|
312
782
|
] }),
|
|
313
|
-
/* @__PURE__ */
|
|
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,
|
|
315
|
-
/* @__PURE__ */
|
|
316
|
-
d.labels?.[id] ||
|
|
317
|
-
id === "gear" && /* @__PURE__ */
|
|
783
|
+
/* @__PURE__ */ jsxs2("nav", { className: "navigation", "aria-label": "\u4E3B\u5BFC\u822A", children: [
|
|
784
|
+
[["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, text2]) => /* @__PURE__ */ jsxs2(GameButton, { className: `nav-item ${page === id ? "active" : ""}`, "aria-current": page === id ? "page" : void 0, onClick: command(onAction, "page", id), children: [
|
|
785
|
+
/* @__PURE__ */ jsx2("span", { "aria-hidden": "true", children: icon }),
|
|
786
|
+
d.labels?.[id] || text2,
|
|
787
|
+
id === "gear" && /* @__PURE__ */ jsx2("span", { className: "nav-count", children: state.inventory.length })
|
|
318
788
|
] }, id)),
|
|
319
|
-
/* @__PURE__ */
|
|
789
|
+
/* @__PURE__ */ jsx2("span", { className: "nav-verse", children: d.subtitle })
|
|
320
790
|
] }),
|
|
321
|
-
/* @__PURE__ */
|
|
322
|
-
/* @__PURE__ */
|
|
323
|
-
/* @__PURE__ */
|
|
324
|
-
/* @__PURE__ */
|
|
325
|
-
/* @__PURE__ */
|
|
326
|
-
/* @__PURE__ */
|
|
327
|
-
/* @__PURE__ */
|
|
791
|
+
/* @__PURE__ */ jsxs2("div", { className: "workspace", children: [
|
|
792
|
+
/* @__PURE__ */ jsx2("aside", { className: "character-panel", children: /* @__PURE__ */ jsx2(GameCharacterPanel, { ...view }) }),
|
|
793
|
+
/* @__PURE__ */ jsx2("main", { children }),
|
|
794
|
+
/* @__PURE__ */ jsxs2("aside", { className: "right-panel", children: [
|
|
795
|
+
/* @__PURE__ */ jsx2(GameBossPanel, { ...view }),
|
|
796
|
+
/* @__PURE__ */ jsx2(GameLogPanel, { ...view }),
|
|
797
|
+
/* @__PURE__ */ jsxs2("div", { className: "save-state", children: [
|
|
328
798
|
"\u672C\u5730\u81EA\u52A8\u5B58\u6863 \xB7 \u79BB\u7EBF\u4E0A\u9650 ",
|
|
329
799
|
(d.offlineCapSeconds ?? 43200) / 3600,
|
|
330
800
|
" \u5C0F\u65F6"
|
|
331
801
|
] })
|
|
332
802
|
] })
|
|
333
803
|
] }),
|
|
334
|
-
/* @__PURE__ */
|
|
804
|
+
/* @__PURE__ */ jsxs2("footer", { children: [
|
|
335
805
|
d.title,
|
|
336
806
|
" / ",
|
|
337
807
|
d.subtitle,
|
|
338
|
-
/* @__PURE__ */
|
|
808
|
+
/* @__PURE__ */ jsx2("span", { children: "\u7531 SiaWebUI Game Framework \u9A71\u52A8" })
|
|
339
809
|
] })
|
|
340
810
|
] });
|
|
341
811
|
}
|
|
342
812
|
function GameCharacterPanel({ engine, state: s, onAction }) {
|
|
343
813
|
const d = engine.definition, st = engine.stats(s), pet = d.pets.find((p) => p.id === s.pet);
|
|
344
|
-
return /* @__PURE__ */
|
|
345
|
-
/* @__PURE__ */
|
|
346
|
-
/* @__PURE__ */
|
|
347
|
-
/* @__PURE__ */
|
|
348
|
-
/* @__PURE__ */
|
|
349
|
-
/* @__PURE__ */
|
|
350
|
-
/* @__PURE__ */
|
|
814
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
815
|
+
/* @__PURE__ */ jsxs2("div", { className: "profile-top", children: [
|
|
816
|
+
/* @__PURE__ */ jsx2("div", { className: "avatar", children: /* @__PURE__ */ jsx2(GameSprite, { asset: d.hero }) }),
|
|
817
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
818
|
+
/* @__PURE__ */ jsx2("span", { className: "eyebrow", children: d.hero.identity }),
|
|
819
|
+
/* @__PURE__ */ jsx2("h2", { children: s.name }),
|
|
820
|
+
/* @__PURE__ */ jsxs2("span", { className: "level-tag", children: [
|
|
351
821
|
"Lv.",
|
|
352
822
|
s.level,
|
|
353
823
|
" ",
|
|
354
|
-
/* @__PURE__ */
|
|
824
|
+
/* @__PURE__ */ jsx2("span", { children: "\u4FEE\u884C\u8005" })
|
|
355
825
|
] })
|
|
356
826
|
] })
|
|
357
827
|
] }),
|
|
358
|
-
/* @__PURE__ */
|
|
359
|
-
/* @__PURE__ */
|
|
360
|
-
/* @__PURE__ */
|
|
828
|
+
/* @__PURE__ */ jsxs2("div", { className: "power", children: [
|
|
829
|
+
/* @__PURE__ */ jsx2("span", { children: "\u7EFC\u5408\u6218\u529B" }),
|
|
830
|
+
/* @__PURE__ */ jsx2("strong", { children: fmt(st.power) })
|
|
361
831
|
] }),
|
|
362
|
-
/* @__PURE__ */
|
|
363
|
-
/* @__PURE__ */
|
|
364
|
-
/* @__PURE__ */
|
|
365
|
-
/* @__PURE__ */
|
|
832
|
+
/* @__PURE__ */ jsxs2("div", { className: "experience", children: [
|
|
833
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
834
|
+
/* @__PURE__ */ jsx2("span", { children: "\u4FEE\u884C\u7ECF\u9A8C" }),
|
|
835
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
366
836
|
fmt(s.xp),
|
|
367
837
|
" / ",
|
|
368
838
|
engine.xpNeeded(s)
|
|
369
839
|
] })
|
|
370
840
|
] }),
|
|
371
|
-
/* @__PURE__ */
|
|
841
|
+
/* @__PURE__ */ jsx2("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__ */ jsx2("i", { style: { width: `${Math.min(100, s.xp / engine.xpNeeded(s) * 100)}%` } }) })
|
|
372
842
|
] }),
|
|
373
|
-
/* @__PURE__ */
|
|
374
|
-
/* @__PURE__ */
|
|
375
|
-
/* @__PURE__ */
|
|
843
|
+
/* @__PURE__ */ jsx2("div", { className: "attributes", children: [["\u6C14\u8840", st.hp], ["\u653B\u51FB", st.atk], ["\u9632\u5FA1", st.def], ["\u66B4\u51FB", "13%"]].map(([name, value]) => /* @__PURE__ */ jsxs2("div", { children: [
|
|
844
|
+
/* @__PURE__ */ jsx2("span", { children: name }),
|
|
845
|
+
/* @__PURE__ */ jsx2("b", { children: value })
|
|
376
846
|
] }, name)) }),
|
|
377
|
-
/* @__PURE__ */
|
|
378
|
-
/* @__PURE__ */
|
|
379
|
-
/* @__PURE__ */
|
|
380
|
-
/* @__PURE__ */
|
|
847
|
+
/* @__PURE__ */ jsx2("div", { className: "line-heading", children: "\u968F\u8EAB\u8D44\u8D22" }),
|
|
848
|
+
/* @__PURE__ */ jsx2("div", { className: "wallet", children: [["\u94DC\u94B1", s.gold], ["\u7075\u8574", s.essence], ["\u953B\u6750", s.material]].map(([name, value]) => /* @__PURE__ */ jsxs2("div", { children: [
|
|
849
|
+
/* @__PURE__ */ jsx2("span", { children: name }),
|
|
850
|
+
/* @__PURE__ */ jsx2("b", { children: fmt(Number(value)) })
|
|
381
851
|
] }, name)) }),
|
|
382
|
-
/* @__PURE__ */
|
|
383
|
-
/* @__PURE__ */
|
|
384
|
-
/* @__PURE__ */
|
|
852
|
+
/* @__PURE__ */ jsxs2("div", { className: "line-heading", children: [
|
|
853
|
+
/* @__PURE__ */ jsx2("span", { children: "\u8EAB\u4E0A\u88C5\u5907" }),
|
|
854
|
+
/* @__PURE__ */ jsx2(GameButton, { className: "text-button", onClick: command(onAction, "page", "gear"), children: "\u7BA1\u7406 \u203A" })
|
|
385
855
|
] }),
|
|
386
|
-
/* @__PURE__ */
|
|
387
|
-
/* @__PURE__ */
|
|
388
|
-
/* @__PURE__ */
|
|
389
|
-
/* @__PURE__ */
|
|
390
|
-
/* @__PURE__ */
|
|
856
|
+
/* @__PURE__ */ jsx2("div", { className: "equipped-list", children: Object.entries(d.slots).map(([key2, slot]) => /* @__PURE__ */ jsxs2(GameButton, { className: "equipped-item", onClick: command(onAction, "page", "gear"), children: [
|
|
857
|
+
/* @__PURE__ */ jsx2("span", { className: "slot-symbol", children: "\u25C7" }),
|
|
858
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
859
|
+
/* @__PURE__ */ jsx2("small", { children: slot.name }),
|
|
860
|
+
/* @__PURE__ */ jsx2("b", { children: s.equipment[key2]?.name || "\u5C1A\u672A\u88C5\u5907" })
|
|
391
861
|
] }),
|
|
392
|
-
/* @__PURE__ */
|
|
393
|
-
] },
|
|
394
|
-
/* @__PURE__ */
|
|
395
|
-
/* @__PURE__ */
|
|
396
|
-
/* @__PURE__ */
|
|
397
|
-
/* @__PURE__ */
|
|
398
|
-
/* @__PURE__ */
|
|
862
|
+
/* @__PURE__ */ jsx2("em", { children: s.upgrades[key2] ? `+${s.upgrades[key2]}` : "\u203A" })
|
|
863
|
+
] }, key2)) }),
|
|
864
|
+
/* @__PURE__ */ jsxs2(GameButton, { className: "pet-mini", onClick: command(onAction, "page", "pets"), children: [
|
|
865
|
+
/* @__PURE__ */ jsx2("span", { className: "pet-mini-art", children: /* @__PURE__ */ jsx2(GameSprite, { asset: pet.art }) }),
|
|
866
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
867
|
+
/* @__PURE__ */ jsx2("small", { children: "\u51FA\u6218\u7075\u5BA0" }),
|
|
868
|
+
/* @__PURE__ */ jsxs2("b", { children: [
|
|
399
869
|
pet.name,
|
|
400
870
|
" ",
|
|
401
|
-
/* @__PURE__ */
|
|
871
|
+
/* @__PURE__ */ jsxs2("em", { children: [
|
|
402
872
|
"Lv.",
|
|
403
873
|
s.pets[s.pet]
|
|
404
874
|
] })
|
|
405
875
|
] })
|
|
406
876
|
] })
|
|
407
877
|
] }),
|
|
408
|
-
/* @__PURE__ */
|
|
878
|
+
/* @__PURE__ */ jsx2("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
879
|
] });
|
|
410
880
|
}
|
|
411
881
|
function GameBattleStage({ engine, state: s, onAction, event, sequence = 0 }) {
|
|
412
|
-
const d = engine.definition, m = d.maps[s.map]
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
/* @__PURE__ */
|
|
416
|
-
/* @__PURE__ */
|
|
417
|
-
/* @__PURE__ */
|
|
418
|
-
|
|
419
|
-
/* @__PURE__ */
|
|
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 })
|
|
882
|
+
const d = engine.definition, m = d.maps[s.map];
|
|
883
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
884
|
+
/* @__PURE__ */ jsx2(Title, { kicker: `\u897F\u884C\u5386\u7EC3 / \u7B2C ${s.map + 1} \u7AE0`, title: m.name, children: /* @__PURE__ */ jsx2(GameButton, { className: "subtle-button", onClick: command(onAction, "loadout"), children: "\u914D\u7F6E\u6218\u6597" }) }),
|
|
885
|
+
/* @__PURE__ */ jsx2(GameHexBattlefield, { engine, state: s, onAction, event, sequence }),
|
|
886
|
+
/* @__PURE__ */ jsxs2("div", { className: "battle-controls", children: [
|
|
887
|
+
/* @__PURE__ */ jsxs2("div", { className: "status-label", children: [
|
|
888
|
+
busy(s) ? "\u9996\u9886\u6311\u6218 \xB7 \u81EA\u52A8\u8FCE\u6218" : s.idle ? "\u516D\u65B9\u6765\u654C\uFF0C\u81EA\u52A8\u4FEE\u884C" : "\u6574\u5907\u68CB\u9635\uFF0C\u9759\u5019\u51FA\u53D1",
|
|
889
|
+
/* @__PURE__ */ jsx2("small", { children: "\u9010\u683C\u79FB\u52A8 \xB7 \u6309\u914D\u7F6E\u65BD\u6CD5 \xB7 \u81EA\u52A8\u62FE\u53D6" })
|
|
454
890
|
] }),
|
|
455
|
-
|
|
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" })
|
|
891
|
+
/* @__PURE__ */ jsx2(GameButton, { className: "primary-button", disabled: busy(s), onClick: command(onAction, "idle"), children: s.idle ? "\u6682\u505C\u6302\u673A" : "\u5F00\u59CB\u6302\u673A" })
|
|
467
892
|
] }),
|
|
468
|
-
/* @__PURE__ */
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
/* @__PURE__ */
|
|
893
|
+
/* @__PURE__ */ jsx2("div", { className: "hex-build-bar", children: [["attack", "\u653B\u51FB"], ["skill", "\u6280\u80FD"], ["power", "\u795E\u901A"], ["treasure", "\u6CD5\u5B9D"]].map(([kind, label]) => /* @__PURE__ */ jsxs2("span", { children: [
|
|
894
|
+
/* @__PURE__ */ jsx2("b", { children: label }),
|
|
895
|
+
gameAbilities(d).find((a) => a.id === s.loadout[kind])?.name
|
|
896
|
+
] }, kind)) }),
|
|
897
|
+
/* @__PURE__ */ jsx2(GameResourceSummary, { state: s }),
|
|
898
|
+
/* @__PURE__ */ jsxs2("div", { className: "tip", children: [
|
|
899
|
+
/* @__PURE__ */ jsx2("p", { children: "\u5C0F\u5996\u4ECE\u8FB9\u7F18\u683C\u9760\u8FD1\uFF0C\u8FDB\u5165\u90BB\u683C\u624D\u653B\u51FB\u3002\u9996\u9886\u73B0\u8EAB\u4F1A\u6E05\u9000\u6240\u6709\u5C0F\u5996\u3002" }),
|
|
900
|
+
/* @__PURE__ */ jsx2(GameButton, { className: "text-button", disabled: busy(s), onClick: command(onAction, "page", "maps"), children: "\u5207\u6362\u5730\u56FE \u203A" })
|
|
476
901
|
] })
|
|
477
902
|
] });
|
|
478
903
|
}
|
|
479
904
|
function GameResourceSummary({ state: s }) {
|
|
480
|
-
return /* @__PURE__ */
|
|
481
|
-
/* @__PURE__ */
|
|
482
|
-
/* @__PURE__ */
|
|
483
|
-
/* @__PURE__ */
|
|
905
|
+
return /* @__PURE__ */ jsxs2("section", { className: "income", children: [
|
|
906
|
+
/* @__PURE__ */ jsxs2("div", { className: "panel-heading", children: [
|
|
907
|
+
/* @__PURE__ */ jsx2("h3", { children: "\u4FEE\u884C\u7D2F\u8BA1\u6240\u5F97" }),
|
|
908
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
484
909
|
"\u7D2F\u8BA1\u51FB\u8D25 ",
|
|
485
910
|
fmt(s.kills),
|
|
486
911
|
" \u4E2A\u654C\u4EBA"
|
|
487
912
|
] })
|
|
488
913
|
] }),
|
|
489
|
-
/* @__PURE__ */
|
|
490
|
-
/* @__PURE__ */
|
|
491
|
-
/* @__PURE__ */
|
|
914
|
+
/* @__PURE__ */ jsx2("div", { className: "income-grid", children: [["\u7ECF\u9A8C", s.sessionXp], ["\u94DC\u94B1", s.sessionGold], ["\u88C5\u5907", s.sessionDrops]].map(([label, value]) => /* @__PURE__ */ jsxs2("div", { children: [
|
|
915
|
+
/* @__PURE__ */ jsx2("span", { children: label }),
|
|
916
|
+
/* @__PURE__ */ jsxs2("b", { children: [
|
|
492
917
|
fmt(Number(value)),
|
|
493
918
|
label === "\u88C5\u5907" ? " \u4EF6" : ""
|
|
494
919
|
] })
|
|
@@ -497,10 +922,10 @@ function GameResourceSummary({ state: s }) {
|
|
|
497
922
|
}
|
|
498
923
|
function GameBossPanel({ engine, state: s, onAction }) {
|
|
499
924
|
const d = engine.definition, m = d.maps[s.map], cleared = s.cleared.includes(s.map);
|
|
500
|
-
return /* @__PURE__ */
|
|
501
|
-
/* @__PURE__ */
|
|
502
|
-
/* @__PURE__ */
|
|
503
|
-
/* @__PURE__ */
|
|
925
|
+
return /* @__PURE__ */ jsxs2("section", { id: "quest", children: [
|
|
926
|
+
/* @__PURE__ */ jsxs2("div", { className: "panel-heading", children: [
|
|
927
|
+
/* @__PURE__ */ jsx2("h3", { children: "\u2694 \u7AE0\u8282\u5996\u738B" }),
|
|
928
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
504
929
|
"\u7B2C ",
|
|
505
930
|
s.map + 1,
|
|
506
931
|
" / ",
|
|
@@ -508,58 +933,58 @@ function GameBossPanel({ engine, state: s, onAction }) {
|
|
|
508
933
|
" \u7AE0"
|
|
509
934
|
] })
|
|
510
935
|
] }),
|
|
511
|
-
/* @__PURE__ */
|
|
512
|
-
/* @__PURE__ */
|
|
513
|
-
/* @__PURE__ */
|
|
936
|
+
/* @__PURE__ */ jsxs2("div", { className: "boss-portrait", children: [
|
|
937
|
+
/* @__PURE__ */ jsx2(GameSprite, { asset: m.bossArt }),
|
|
938
|
+
/* @__PURE__ */ jsx2("span", { className: "boss-seal", children: cleared ? "\u5DF2\u7834" : "\u5996\u738B" })
|
|
514
939
|
] }),
|
|
515
|
-
/* @__PURE__ */
|
|
516
|
-
/* @__PURE__ */
|
|
517
|
-
/* @__PURE__ */
|
|
940
|
+
/* @__PURE__ */ jsxs2("div", { className: "boss-title", children: [
|
|
941
|
+
/* @__PURE__ */ jsx2("h2", { children: m.boss }),
|
|
942
|
+
/* @__PURE__ */ jsx2("span", { children: m.bossArt.identity })
|
|
518
943
|
] }),
|
|
519
|
-
/* @__PURE__ */
|
|
520
|
-
/* @__PURE__ */
|
|
521
|
-
/* @__PURE__ */
|
|
944
|
+
/* @__PURE__ */ jsx2("p", { className: "identity-traits", children: m.bossArt.traits }),
|
|
945
|
+
/* @__PURE__ */ jsxs2("div", { className: "boss-stats", children: [
|
|
946
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
522
947
|
"\u6C14\u8840 ",
|
|
523
948
|
fmt(m.bossHp)
|
|
524
949
|
] }),
|
|
525
|
-
/* @__PURE__ */
|
|
950
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
526
951
|
"\u653B\u51FB ",
|
|
527
952
|
m.bossAtk
|
|
528
953
|
] })
|
|
529
954
|
] }),
|
|
530
|
-
/* @__PURE__ */
|
|
531
|
-
/* @__PURE__ */
|
|
532
|
-
/* @__PURE__ */
|
|
955
|
+
/* @__PURE__ */ jsxs2("div", { className: "boss-reward", children: [
|
|
956
|
+
/* @__PURE__ */ jsx2("small", { children: cleared ? "\u518D\u6B21\u6311\u6218\u5956\u52B1" : "\u9996\u6B21\u51FB\u8D25\u5956\u52B1" }),
|
|
957
|
+
/* @__PURE__ */ jsx2("div", { children: cleared ? "\u94DC\u94B1\u3001\u7ECF\u9A8C\u3001\u7075\u8574" : d.slots[m.rewardSlot].names[1] + " \xB7 \u7075\u8574 \xD750" })
|
|
533
958
|
] }),
|
|
534
|
-
/* @__PURE__ */
|
|
535
|
-
/* @__PURE__ */
|
|
959
|
+
/* @__PURE__ */ jsx2(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" }),
|
|
960
|
+
/* @__PURE__ */ jsx2("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
961
|
] });
|
|
537
962
|
}
|
|
538
963
|
function GameLogPanel({ state: s }) {
|
|
539
|
-
return /* @__PURE__ */
|
|
540
|
-
/* @__PURE__ */
|
|
541
|
-
/* @__PURE__ */
|
|
542
|
-
/* @__PURE__ */
|
|
964
|
+
return /* @__PURE__ */ jsxs2("section", { className: "journal", children: [
|
|
965
|
+
/* @__PURE__ */ jsxs2("div", { className: "panel-heading", children: [
|
|
966
|
+
/* @__PURE__ */ jsx2("h3", { children: "\u25A4 \u4E09\u754C\u89C1\u95FB" }),
|
|
967
|
+
/* @__PURE__ */ jsx2("span", { children: "\u5B9E\u65F6\u6218\u62A5" })
|
|
543
968
|
] }),
|
|
544
|
-
/* @__PURE__ */
|
|
545
|
-
/* @__PURE__ */
|
|
546
|
-
/* @__PURE__ */
|
|
969
|
+
/* @__PURE__ */ jsx2("div", { id: "logs", role: "log", "aria-label": "\u6218\u6597\u8BB0\u5F55", children: s.logs.map((log, i) => /* @__PURE__ */ jsxs2("div", { className: `log-line ${log.type}`, children: [
|
|
970
|
+
/* @__PURE__ */ jsx2("time", { children: new Date(log.time).toLocaleTimeString("zh-CN", { hour: "2-digit", minute: "2-digit" }) }),
|
|
971
|
+
/* @__PURE__ */ jsx2("span", { children: log.text })
|
|
547
972
|
] }, `${log.time}-${i}`)) })
|
|
548
973
|
] });
|
|
549
974
|
}
|
|
550
975
|
function GameMapPanel({ engine, state: s, onAction }) {
|
|
551
976
|
const d = engine.definition;
|
|
552
|
-
return /* @__PURE__ */
|
|
553
|
-
/* @__PURE__ */
|
|
554
|
-
/* @__PURE__ */
|
|
555
|
-
/* @__PURE__ */
|
|
556
|
-
/* @__PURE__ */
|
|
557
|
-
/* @__PURE__ */
|
|
558
|
-
/* @__PURE__ */
|
|
559
|
-
/* @__PURE__ */
|
|
560
|
-
/* @__PURE__ */
|
|
561
|
-
/* @__PURE__ */
|
|
562
|
-
/* @__PURE__ */
|
|
977
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
978
|
+
/* @__PURE__ */ jsx2(Title, { kicker: "\u4E09\u754C\u8206\u56FE / \u897F\u884C\u4E4B\u8DEF", title: d.labels?.mapsTitle || "\u63A2\u7D22\u65B0\u7684\u65C5\u7A0B" }),
|
|
979
|
+
/* @__PURE__ */ jsx2("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" }),
|
|
980
|
+
/* @__PURE__ */ jsx2("div", { className: "map-list", children: d.maps.map((m, i) => /* @__PURE__ */ jsxs2(GameButton, { className: `map-card ${s.map === i ? "current" : ""}`, disabled: i > s.unlocked || busy(s), onClick: command(onAction, "map", String(i)), children: [
|
|
981
|
+
/* @__PURE__ */ jsx2("div", { className: "map-art", children: /* @__PURE__ */ jsx2("img", { className: "landscape", src: m.scene, alt: "" }) }),
|
|
982
|
+
/* @__PURE__ */ jsx2("span", { className: "map-number", children: String(i + 1).padStart(2, "0") }),
|
|
983
|
+
/* @__PURE__ */ jsxs2("div", { className: "map-content", children: [
|
|
984
|
+
/* @__PURE__ */ jsx2("span", { className: "eyebrow", children: m.subtitle }),
|
|
985
|
+
/* @__PURE__ */ jsx2("h2", { children: m.name }),
|
|
986
|
+
/* @__PURE__ */ jsx2("p", { children: m.desc }),
|
|
987
|
+
/* @__PURE__ */ jsxs2("div", { className: "map-meta", children: [
|
|
563
988
|
"\u5EFA\u8BAE\u7B49\u7EA7 ",
|
|
564
989
|
m.level,
|
|
565
990
|
" \xB7 \u51FB\u8D25\u5956\u52B1 ",
|
|
@@ -569,9 +994,9 @@ function GameMapPanel({ engine, state: s, onAction }) {
|
|
|
569
994
|
" \u94DC\u94B1"
|
|
570
995
|
] })
|
|
571
996
|
] }),
|
|
572
|
-
/* @__PURE__ */
|
|
997
|
+
/* @__PURE__ */ jsx2("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
998
|
] }, m.id)) }),
|
|
574
|
-
/* @__PURE__ */
|
|
999
|
+
/* @__PURE__ */ jsxs2("div", { className: "tip", children: [
|
|
575
1000
|
"\u5F53\u524D\u5DF2\u89E3\u9501 ",
|
|
576
1001
|
s.unlocked + 1,
|
|
577
1002
|
" / ",
|
|
@@ -582,170 +1007,192 @@ function GameMapPanel({ engine, state: s, onAction }) {
|
|
|
582
1007
|
}
|
|
583
1008
|
function GamePetPanel({ engine, state: s, onAction }) {
|
|
584
1009
|
const d = engine.definition;
|
|
585
|
-
return /* @__PURE__ */
|
|
586
|
-
/* @__PURE__ */
|
|
1010
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
1011
|
+
/* @__PURE__ */ jsx2(Title, { kicker: "\u7075\u5BA0\u6D1E\u5929 / \u6709\u7075\u76F8\u4F34", title: d.labels?.petsTitle || "\u4F19\u4F34\u540C\u884C", children: /* @__PURE__ */ jsxs2("span", { className: "capacity", children: [
|
|
587
1012
|
"\u7075\u8574 ",
|
|
588
1013
|
fmt(s.essence)
|
|
589
1014
|
] }) }),
|
|
590
|
-
/* @__PURE__ */
|
|
591
|
-
/* @__PURE__ */
|
|
592
|
-
/* @__PURE__ */
|
|
593
|
-
/* @__PURE__ */
|
|
594
|
-
/* @__PURE__ */
|
|
1015
|
+
/* @__PURE__ */ jsx2("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" }),
|
|
1016
|
+
/* @__PURE__ */ jsx2("div", { className: "pet-cards", children: d.pets.map((p) => /* @__PURE__ */ jsxs2("article", { className: `pet-card ${s.pet === p.id ? "selected" : ""}`, children: [
|
|
1017
|
+
/* @__PURE__ */ jsxs2("div", { className: "pet-card-head", children: [
|
|
1018
|
+
/* @__PURE__ */ jsx2("span", { className: "pet-kind", children: p.kind }),
|
|
1019
|
+
/* @__PURE__ */ jsx2("span", { children: s.pets[p.id] ? `Lv.${s.pets[p.id]}` : "\u5C1A\u672A\u7ED3\u7F18" })
|
|
595
1020
|
] }),
|
|
596
|
-
/* @__PURE__ */
|
|
597
|
-
/* @__PURE__ */
|
|
598
|
-
/* @__PURE__ */
|
|
599
|
-
/* @__PURE__ */
|
|
600
|
-
/* @__PURE__ */
|
|
601
|
-
"\
|
|
602
|
-
|
|
1021
|
+
/* @__PURE__ */ jsx2("div", { className: "pet-art", children: /* @__PURE__ */ jsx2(GameSprite, { asset: p.art }) }),
|
|
1022
|
+
/* @__PURE__ */ jsx2("h2", { children: p.name }),
|
|
1023
|
+
/* @__PURE__ */ jsx2("p", { className: "identity-traits", children: p.art.traits }),
|
|
1024
|
+
/* @__PURE__ */ jsx2("p", { children: p.desc }),
|
|
1025
|
+
/* @__PURE__ */ jsxs2("div", { className: "pet-stat", children: [
|
|
1026
|
+
p.effect === "heal" ? "\u6BCF\u56DE\u5408\u6CBB\u7597" : p.effect === "guard" ? "\u53D7\u5230\u4F24\u5BB3\u964D\u4F4E" : "\u8FFD\u51FB\u4F24\u5BB3",
|
|
1027
|
+
" ",
|
|
1028
|
+
/* @__PURE__ */ jsx2("b", { children: p.effect === "guard" ? "25%" : p.effect === "heal" ? 7 + (s.pets[p.id] || 1) * 3 : p.base + ((s.pets[p.id] || 1) - 1) * 3 })
|
|
603
1029
|
] }),
|
|
604
|
-
s.pets[p.id] ? /* @__PURE__ */
|
|
605
|
-
/* @__PURE__ */
|
|
606
|
-
/* @__PURE__ */
|
|
607
|
-
] }) : /* @__PURE__ */
|
|
1030
|
+
s.pets[p.id] ? /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
1031
|
+
/* @__PURE__ */ jsx2(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" }),
|
|
1032
|
+
/* @__PURE__ */ jsx2(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` })
|
|
1033
|
+
] }) : /* @__PURE__ */ jsxs2(GameButton, { className: "primary-button", disabled: busy(s) || s.essence < p.cost, onClick: command(onAction, "unlock", p.id), children: [
|
|
608
1034
|
"\u7ED3\u7F18 \xB7 ",
|
|
609
1035
|
p.cost,
|
|
610
1036
|
" \u7075\u8574"
|
|
611
1037
|
] })
|
|
612
1038
|
] }, p.id)) }),
|
|
613
|
-
/* @__PURE__ */
|
|
1039
|
+
/* @__PURE__ */ jsx2("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
1040
|
] });
|
|
615
1041
|
}
|
|
616
1042
|
function GameEquipmentPanel({ engine, state: s, onAction }) {
|
|
617
|
-
const [filter, setFilter] =
|
|
1043
|
+
const [filter, setFilter] = useState2("all");
|
|
618
1044
|
const d = engine.definition;
|
|
619
1045
|
const inventory = s.inventory.filter((item) => filter === "all" || item.slot === filter);
|
|
620
|
-
return /* @__PURE__ */
|
|
621
|
-
/* @__PURE__ */
|
|
1046
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
1047
|
+
/* @__PURE__ */ jsx2(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__ */ jsxs2("span", { className: "capacity", children: [
|
|
622
1048
|
"\u884C\u56CA ",
|
|
623
1049
|
s.inventory.length,
|
|
624
1050
|
" / 80"
|
|
625
1051
|
] }) }),
|
|
626
|
-
/* @__PURE__ */
|
|
627
|
-
/* @__PURE__ */
|
|
628
|
-
/* @__PURE__ */
|
|
1052
|
+
/* @__PURE__ */ jsx2("div", { className: "gear-slots", children: Object.entries(d.slots).map(([key2, slot]) => /* @__PURE__ */ jsxs2("section", { className: "gear-slot", children: [
|
|
1053
|
+
/* @__PURE__ */ jsxs2("div", { className: "gear-info", children: [
|
|
1054
|
+
/* @__PURE__ */ jsxs2("span", { className: "eyebrow", children: [
|
|
629
1055
|
slot.name,
|
|
630
1056
|
" \xB7 \u5F3A\u5316 +",
|
|
631
|
-
s.upgrades[
|
|
1057
|
+
s.upgrades[key2]
|
|
632
1058
|
] }),
|
|
633
|
-
/* @__PURE__ */
|
|
634
|
-
s.equipment[
|
|
1059
|
+
/* @__PURE__ */ jsx2("h3", { children: s.equipment[key2]?.name || "\u5C1A\u672A\u88C5\u5907" }),
|
|
1060
|
+
s.equipment[key2] && /* @__PURE__ */ jsx2(ItemStats, { item: s.equipment[key2] })
|
|
635
1061
|
] }),
|
|
636
|
-
/* @__PURE__ */
|
|
637
|
-
] },
|
|
638
|
-
/* @__PURE__ */
|
|
639
|
-
/* @__PURE__ */
|
|
640
|
-
/* @__PURE__ */
|
|
1062
|
+
/* @__PURE__ */ jsx2(GameButton, { className: "small-button", disabled: busy(s) || !s.equipment[key2] || s.upgrades[key2] >= 10 || s.gold < engine.upgradeCost(s, key2), onClick: command(onAction, "upgrade", key2), children: s.upgrades[key2] >= 10 ? "\u5DF2\u5F3A\u5316\u81F3\u4E0A\u9650" : `\u5F3A\u5316 \xB7 ${engine.upgradeCost(s, key2)} \u94DC\u94B1` })
|
|
1063
|
+
] }, key2)) }),
|
|
1064
|
+
/* @__PURE__ */ jsxs2("div", { className: "inventory-toolbar", children: [
|
|
1065
|
+
/* @__PURE__ */ jsx2("div", { className: "filters", children: [["all", "\u5168\u90E8"], ...Object.entries(d.slots).map(([key2, slot]) => [key2, slot.name])].map(([key2, name]) => /* @__PURE__ */ jsx2(GameButton, { className: `filter ${filter === key2 ? "active" : ""}`, "aria-pressed": filter === key2, onClick: () => setFilter(key2), children: name }, key2)) }),
|
|
1066
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
641
1067
|
"\u953B\u6750 ",
|
|
642
1068
|
s.material
|
|
643
1069
|
] }),
|
|
644
|
-
/* @__PURE__ */
|
|
1070
|
+
/* @__PURE__ */ jsx2(GameButton, { className: "subtle-button", disabled: busy(s) || s.material < 12, onClick: command(onAction, "forge"), children: "\u953B\u9020\u4E0A\u54C1 \xB7 12 \u953B\u6750" })
|
|
645
1071
|
] }),
|
|
646
|
-
/* @__PURE__ */
|
|
647
|
-
/* @__PURE__ */
|
|
648
|
-
/* @__PURE__ */
|
|
649
|
-
/* @__PURE__ */
|
|
1072
|
+
/* @__PURE__ */ jsx2("div", { className: "inventory-list", children: inventory.length ? inventory.map((item) => /* @__PURE__ */ jsxs2("article", { className: "item-row", children: [
|
|
1073
|
+
/* @__PURE__ */ jsx2("span", { className: `item-icon rarity-${item.tier}`, children: "\u25C7" }),
|
|
1074
|
+
/* @__PURE__ */ jsxs2("div", { className: "item-detail", children: [
|
|
1075
|
+
/* @__PURE__ */ jsxs2("strong", { children: [
|
|
650
1076
|
item.name,
|
|
651
1077
|
" ",
|
|
652
|
-
/* @__PURE__ */
|
|
1078
|
+
/* @__PURE__ */ jsxs2("small", { children: [
|
|
653
1079
|
d.rarities[item.tier],
|
|
654
1080
|
" \xB7 ",
|
|
655
1081
|
d.slots[item.slot].name
|
|
656
1082
|
] })
|
|
657
1083
|
] }),
|
|
658
|
-
/* @__PURE__ */
|
|
1084
|
+
/* @__PURE__ */ jsx2(ItemStats, { item })
|
|
659
1085
|
] }),
|
|
660
|
-
/* @__PURE__ */
|
|
661
|
-
/* @__PURE__ */
|
|
662
|
-
/* @__PURE__ */
|
|
663
|
-
/* @__PURE__ */
|
|
664
|
-
] }, item.id)) : /* @__PURE__ */
|
|
665
|
-
/* @__PURE__ */
|
|
666
|
-
/* @__PURE__ */
|
|
667
|
-
/* @__PURE__ */
|
|
1086
|
+
/* @__PURE__ */ jsx2(GameButton, { className: "small-button", onClick: command(onAction, "inspect", item.id), children: "\u5BF9\u6BD4" }),
|
|
1087
|
+
/* @__PURE__ */ jsx2(GameButton, { className: "small-button jade-button", disabled: busy(s), onClick: command(onAction, "equip", item.id), children: "\u88C5\u5907" }),
|
|
1088
|
+
/* @__PURE__ */ jsx2(GameButton, { className: "text-button", disabled: busy(s), onClick: command(onAction, "lock", item.id), children: item.locked ? "\u89E3\u9501" : "\u9501\u5B9A" }),
|
|
1089
|
+
/* @__PURE__ */ jsx2(GameButton, { className: "text-button", disabled: busy(s) || item.locked, onClick: command(onAction, "dismantle", item.id), children: "\u5206\u89E3" })
|
|
1090
|
+
] }, item.id)) : /* @__PURE__ */ jsxs2("div", { className: "empty-state", children: [
|
|
1091
|
+
/* @__PURE__ */ jsx2("h3", { children: "\u884C\u56CA\u5C1A\u6709\u4F59\u5730" }),
|
|
1092
|
+
/* @__PURE__ */ jsx2("p", { children: "\u6302\u673A\u51FB\u8D25\u5996\u602A\uFF0C\u6709\u673A\u4F1A\u62FE\u5F97\u88C5\u5907\u3002" }),
|
|
1093
|
+
/* @__PURE__ */ jsx2(GameButton, { className: "subtle-button", onClick: command(onAction, "page", "battle"), children: "\u524D\u5F80\u5386\u7EC3" })
|
|
668
1094
|
] }) }),
|
|
669
|
-
/* @__PURE__ */
|
|
1095
|
+
/* @__PURE__ */ jsx2("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
1096
|
] });
|
|
671
1097
|
}
|
|
672
1098
|
function GameSavePanel({ onExport, onImport }) {
|
|
673
|
-
const input =
|
|
674
|
-
return /* @__PURE__ */
|
|
675
|
-
/* @__PURE__ */
|
|
676
|
-
/* @__PURE__ */
|
|
677
|
-
/* @__PURE__ */
|
|
678
|
-
/* @__PURE__ */
|
|
679
|
-
/* @__PURE__ */
|
|
1099
|
+
const input = useRef2(null);
|
|
1100
|
+
return /* @__PURE__ */ jsxs2("div", { className: "help-content", children: [
|
|
1101
|
+
/* @__PURE__ */ jsx2("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" }),
|
|
1102
|
+
/* @__PURE__ */ jsxs2("div", { className: "settings-actions", children: [
|
|
1103
|
+
/* @__PURE__ */ jsx2(GameButton, { className: "subtle-button", onClick: onExport, children: "\u5BFC\u51FA\u5B58\u6863" }),
|
|
1104
|
+
/* @__PURE__ */ jsx2(GameButton, { className: "subtle-button", onClick: () => input.current?.click(), children: "\u5BFC\u5165\u5B58\u6863" }),
|
|
1105
|
+
/* @__PURE__ */ jsx2("input", { ref: input, type: "file", accept: ".json,application/json", hidden: true, onChange: (e) => {
|
|
680
1106
|
const file = e.target.files?.[0];
|
|
681
1107
|
e.target.value = "";
|
|
682
1108
|
if (file)
|
|
683
1109
|
void onImport(file);
|
|
684
1110
|
} })
|
|
685
1111
|
] }),
|
|
686
|
-
/* @__PURE__ */
|
|
1112
|
+
/* @__PURE__ */ jsx2("p", { children: "\u5B58\u6863\u4FDD\u5B58\u5728\u672C\u673A\uFF0C\u4E0D\u5305\u542B\u8D26\u53F7\u540C\u6B65\u548C\u591A\u4EBA\u8054\u7F51\u3002" })
|
|
687
1113
|
] });
|
|
688
1114
|
}
|
|
689
1115
|
function GameDialog({ open, title, children, onClose, container }) {
|
|
690
|
-
return /* @__PURE__ */
|
|
1116
|
+
return /* @__PURE__ */ jsx2(Modal, { open, title, footer: null, centered: true, className: "sia-game-dialog", onCancel: onClose, getContainer: container, children });
|
|
691
1117
|
}
|
|
692
1118
|
function GameEquipmentComparison({ engine, state: s, onAction, itemId }) {
|
|
693
1119
|
const item = s.inventory.find((i) => i.id === itemId);
|
|
694
1120
|
if (!item)
|
|
695
|
-
return /* @__PURE__ */
|
|
1121
|
+
return /* @__PURE__ */ jsx2("p", { children: "\u7269\u54C1\u5DF2\u4E0D\u5728\u80CC\u5305\u4E2D\u3002" });
|
|
696
1122
|
const old = s.equipment[item.slot];
|
|
697
|
-
return /* @__PURE__ */
|
|
698
|
-
/* @__PURE__ */
|
|
699
|
-
/* @__PURE__ */
|
|
700
|
-
/* @__PURE__ */
|
|
701
|
-
/* @__PURE__ */
|
|
702
|
-
old && /* @__PURE__ */
|
|
1123
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
1124
|
+
/* @__PURE__ */ jsxs2("div", { className: "compare", children: [
|
|
1125
|
+
/* @__PURE__ */ jsxs2("section", { children: [
|
|
1126
|
+
/* @__PURE__ */ jsx2("span", { className: "eyebrow", children: "\u5F53\u524D\u88C5\u5907" }),
|
|
1127
|
+
/* @__PURE__ */ jsx2("h3", { children: old?.name || "\u672A\u88C5\u5907" }),
|
|
1128
|
+
old && /* @__PURE__ */ jsx2(ItemStats, { item: old })
|
|
703
1129
|
] }),
|
|
704
|
-
/* @__PURE__ */
|
|
705
|
-
/* @__PURE__ */
|
|
1130
|
+
/* @__PURE__ */ jsxs2("section", { children: [
|
|
1131
|
+
/* @__PURE__ */ jsxs2("span", { className: "eyebrow", children: [
|
|
706
1132
|
"\u5F85\u88C5\u5907 \xB7 ",
|
|
707
1133
|
engine.definition.rarities[item.tier]
|
|
708
1134
|
] }),
|
|
709
|
-
/* @__PURE__ */
|
|
710
|
-
/* @__PURE__ */
|
|
1135
|
+
/* @__PURE__ */ jsx2("h3", { children: item.name }),
|
|
1136
|
+
/* @__PURE__ */ jsx2(ItemStats, { item })
|
|
711
1137
|
] })
|
|
712
1138
|
] }),
|
|
713
|
-
/* @__PURE__ */
|
|
1139
|
+
/* @__PURE__ */ jsxs2("p", { children: [
|
|
714
1140
|
"\u540C\u90E8\u4F4D\u5F3A\u5316 +",
|
|
715
1141
|
s.upgrades[item.slot],
|
|
716
1142
|
" \u5B8C\u6574\u7EE7\u627F\u3002"
|
|
717
1143
|
] }),
|
|
718
|
-
/* @__PURE__ */
|
|
719
|
-
const delta = item[
|
|
720
|
-
return /* @__PURE__ */
|
|
1144
|
+
/* @__PURE__ */ jsx2("div", { className: "compare-delta", children: ["atk", "def", "hp"].map((key2, i) => {
|
|
1145
|
+
const delta = item[key2] - (old?.[key2] || 0);
|
|
1146
|
+
return /* @__PURE__ */ jsxs2("span", { className: delta >= 0 ? "jade" : "red-text", children: [
|
|
721
1147
|
["\u653B\u51FB", "\u9632\u5FA1", "\u6C14\u8840"][i],
|
|
722
1148
|
" ",
|
|
723
1149
|
delta >= 0 ? "+" : "",
|
|
724
1150
|
delta
|
|
725
|
-
] },
|
|
1151
|
+
] }, key2);
|
|
726
1152
|
}) }),
|
|
727
|
-
/* @__PURE__ */
|
|
1153
|
+
/* @__PURE__ */ jsx2(GameButton, { className: "primary-button full", disabled: busy(s), onClick: command(onAction, "equip", item.id), children: "\u88C5\u5907" })
|
|
728
1154
|
] });
|
|
729
1155
|
}
|
|
730
1156
|
|
|
731
1157
|
// src/game/IdleGameApp.tsx
|
|
732
|
-
import { useEffect, useReducer, useRef as
|
|
733
|
-
|
|
1158
|
+
import { useEffect as useEffect2, useReducer, useRef as useRef3, useState as useState3 } from "react";
|
|
1159
|
+
|
|
1160
|
+
// src/game/LoadoutPanel.tsx
|
|
1161
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1162
|
+
function GameLoadoutPanel({ engine, state, onAction }) {
|
|
1163
|
+
const groups = [["attack", "\u653B\u51FB"], ["skill", "\u6280\u80FD"], ["power", "\u795E\u901A"], ["treasure", "\u6CD5\u5B9D"]];
|
|
1164
|
+
const locked = Boolean(state.fight?.boss && state.fight.status === "active");
|
|
1165
|
+
return /* @__PURE__ */ jsxs3("div", { className: "hex-loadout", children: [
|
|
1166
|
+
/* @__PURE__ */ jsx3("p", { children: "\u81EA\u52A8\u5BFB\u654C\u3001\u9010\u683C\u79FB\u52A8\u3002\u653B\u51FB\u6BCF\u56DE\u5408\u65BD\u653E\uFF1B\u6280\u80FD\u4E0E\u6CD5\u5B9D\u540C\u56DE\u5408\u53EF\u7528\u65F6\uFF0C\u4F18\u5148\u4F7F\u7528\u6CD5\u5B9D\uFF1B\u795E\u901A\u72EC\u7ACB\u751F\u6548\u3002\u66F4\u6362\u914D\u7F6E\u540E\u4ECE\u65B0\u4E00\u6CE2\u5F00\u59CB\u3002" }),
|
|
1167
|
+
groups.map(([kind, label]) => /* @__PURE__ */ jsxs3("section", { children: [
|
|
1168
|
+
/* @__PURE__ */ jsx3("h3", { children: label }),
|
|
1169
|
+
/* @__PURE__ */ jsx3("div", { className: "hex-ability-options", children: gameAbilities(engine.definition).filter((a) => a.kind === kind).map((a) => /* @__PURE__ */ jsxs3(GameButton, { className: `hex-ability ${state.loadout[kind] === a.id ? "selected" : ""}`, "aria-pressed": state.loadout[kind] === a.id, disabled: locked, onClick: () => onAction({ type: "configure", id: a.id }), children: [
|
|
1170
|
+
/* @__PURE__ */ jsx3("strong", { children: a.name }),
|
|
1171
|
+
/* @__PURE__ */ jsx3("small", { children: a.kind === "attack" ? `\u5C04\u7A0B ${a.range} \u683C` : `\u6BCF ${a.cooldown} \u56DE\u5408` }),
|
|
1172
|
+
/* @__PURE__ */ jsx3("span", { children: a.description })
|
|
1173
|
+
] }, a.id)) })
|
|
1174
|
+
] }, kind)),
|
|
1175
|
+
locked && /* @__PURE__ */ jsx3("p", { children: "\u9996\u9886\u6311\u6218\u671F\u95F4\u4E0D\u80FD\u66F4\u6362\u914D\u7F6E\uFF0C\u7ED3\u675F\u540E\u53EF\u8C03\u6574\u3002" })
|
|
1176
|
+
] });
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
// src/game/IdleGameApp.tsx
|
|
1180
|
+
import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
734
1181
|
function IdleGameApp({ definition, className = "", style, onStateChange }) {
|
|
735
|
-
const engineRef =
|
|
1182
|
+
const engineRef = useRef3();
|
|
736
1183
|
if (!engineRef.current)
|
|
737
1184
|
engineRef.current = createIdleEngine(definition);
|
|
738
1185
|
const engine = engineRef.current;
|
|
739
|
-
const stateRef =
|
|
1186
|
+
const stateRef = useRef3();
|
|
740
1187
|
if (!stateRef.current)
|
|
741
1188
|
stateRef.current = engine.freshState();
|
|
742
1189
|
const s = stateRef.current;
|
|
743
1190
|
const [, refresh] = useReducer((n) => n + 1, 0);
|
|
744
|
-
const [page, setPage] =
|
|
745
|
-
const [event, setEvent] =
|
|
746
|
-
const [report, setReport] =
|
|
747
|
-
const host =
|
|
748
|
-
const observe =
|
|
1191
|
+
const [page, setPage] = useState3("battle"), [dialog, setDialog] = useState3(""), [message, setMessage] = useState3("");
|
|
1192
|
+
const [event, setEvent] = useState3(null), [sequence, setSequence] = useState3(0);
|
|
1193
|
+
const [report, setReport] = useState3(null), [pending, setPending] = useState3(null), [itemId, setItemId] = useState3("");
|
|
1194
|
+
const host = useRef3(null), lastTick = useRef3(Date.now()), initialized = useRef3(false), saveWarning = useRef3(false);
|
|
1195
|
+
const observe = useRef3(onStateChange);
|
|
749
1196
|
observe.current = onStateChange;
|
|
750
1197
|
function save() {
|
|
751
1198
|
const current = stateRef.current;
|
|
@@ -765,13 +1212,18 @@ function IdleGameApp({ definition, className = "", style, onStateChange }) {
|
|
|
765
1212
|
refresh();
|
|
766
1213
|
observe.current?.(stateRef.current);
|
|
767
1214
|
}
|
|
768
|
-
|
|
1215
|
+
useEffect2(() => {
|
|
1216
|
+
if (!event?.bossWin) return;
|
|
1217
|
+
const timer = setTimeout(() => setMessage(event.first ? `\u9996\u901A\u6210\u529F\uFF01${event.reward}\u5DF2\u6536\u5165\u884C\u56CA\u3002` : "\u9996\u9886\u6311\u6218\u6210\u529F\uFF01"), (definition.turnDurationMs ?? 1e3) * 0.93);
|
|
1218
|
+
return () => clearTimeout(timer);
|
|
1219
|
+
}, [event, definition]);
|
|
1220
|
+
useEffect2(() => {
|
|
769
1221
|
if (message) {
|
|
770
1222
|
const timer = setTimeout(() => setMessage(""), 3200);
|
|
771
1223
|
return () => clearTimeout(timer);
|
|
772
1224
|
}
|
|
773
1225
|
}, [message]);
|
|
774
|
-
|
|
1226
|
+
useEffect2(() => {
|
|
775
1227
|
if (!initialized.current) {
|
|
776
1228
|
try {
|
|
777
1229
|
const raw = localStorage.getItem(definition.saveKey);
|
|
@@ -791,10 +1243,11 @@ function IdleGameApp({ definition, className = "", style, onStateChange }) {
|
|
|
791
1243
|
lastTick.current = Date.now();
|
|
792
1244
|
refresh();
|
|
793
1245
|
}
|
|
1246
|
+
const roundMs = definition.turnDurationMs ?? 1e3;
|
|
794
1247
|
const timer = setInterval(() => {
|
|
795
1248
|
if (document.hidden)
|
|
796
1249
|
return;
|
|
797
|
-
const now = Date.now(), elapsed = Math.floor((now - lastTick.current) /
|
|
1250
|
+
const now = Date.now(), elapsed = Math.floor((now - lastTick.current) / roundMs);
|
|
798
1251
|
if (elapsed < 1)
|
|
799
1252
|
return;
|
|
800
1253
|
const current = stateRef.current;
|
|
@@ -804,16 +1257,15 @@ function IdleGameApp({ definition, className = "", style, onStateChange }) {
|
|
|
804
1257
|
setEvent(null);
|
|
805
1258
|
} else {
|
|
806
1259
|
const next = engine.tick(current);
|
|
807
|
-
setEvent(next);
|
|
1260
|
+
if (next) setEvent(next);
|
|
1261
|
+
else if (!current.fight || current.fight.status === "active") setEvent(null);
|
|
808
1262
|
if (next) {
|
|
809
1263
|
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
1264
|
}
|
|
813
1265
|
}
|
|
814
1266
|
lastTick.current = now;
|
|
815
1267
|
changed();
|
|
816
|
-
},
|
|
1268
|
+
}, roundMs);
|
|
817
1269
|
const visibility = () => {
|
|
818
1270
|
if (document.hidden) {
|
|
819
1271
|
save();
|
|
@@ -845,7 +1297,7 @@ function IdleGameApp({ definition, className = "", style, onStateChange }) {
|
|
|
845
1297
|
setPage(id);
|
|
846
1298
|
return;
|
|
847
1299
|
}
|
|
848
|
-
if (type === "settings" || type === "help") {
|
|
1300
|
+
if (type === "settings" || type === "help" || type === "loadout") {
|
|
849
1301
|
setDialog(type);
|
|
850
1302
|
return;
|
|
851
1303
|
}
|
|
@@ -859,6 +1311,15 @@ function IdleGameApp({ definition, className = "", style, onStateChange }) {
|
|
|
859
1311
|
return;
|
|
860
1312
|
}
|
|
861
1313
|
let success = true;
|
|
1314
|
+
if (type === "configure") {
|
|
1315
|
+
const ability = gameAbilities(definition).find((a) => a.id === id);
|
|
1316
|
+
if (!ability) return;
|
|
1317
|
+
current.loadout[ability.kind] = ability.id;
|
|
1318
|
+
current.fight = null;
|
|
1319
|
+
setMessage(`\u5DF2\u88C5\u914D${ability.name}\uFF0C\u4E0B\u6B21\u51FA\u624B\u751F\u6548\u3002`);
|
|
1320
|
+
}
|
|
1321
|
+
setEvent(null);
|
|
1322
|
+
lastTick.current = Date.now();
|
|
862
1323
|
if (type === "idle") {
|
|
863
1324
|
current.idle = !current.idle;
|
|
864
1325
|
if (!current.idle)
|
|
@@ -939,54 +1400,55 @@ function IdleGameApp({ definition, className = "", style, onStateChange }) {
|
|
|
939
1400
|
setTimeout(() => URL.revokeObjectURL(url), 1e3);
|
|
940
1401
|
}
|
|
941
1402
|
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__ */
|
|
944
|
-
/* @__PURE__ */
|
|
945
|
-
/* @__PURE__ */
|
|
946
|
-
dialog === "
|
|
947
|
-
dialog === "
|
|
948
|
-
dialog === "
|
|
949
|
-
|
|
950
|
-
|
|
1403
|
+
const titles = { loadout: "\u81EA\u52A8\u6218\u6597 \xB7 \u80FD\u529B\u914D\u7F6E", 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" };
|
|
1404
|
+
return /* @__PURE__ */ jsxs4("div", { ref: host, className: `sia-game ${className}`, style, "data-sia-theme": "dark", children: [
|
|
1405
|
+
/* @__PURE__ */ jsx4(GameShell, { ...view, page, children: page === "battle" ? /* @__PURE__ */ jsx4(GameBattleStage, { ...view, event, sequence }) : page === "maps" ? /* @__PURE__ */ jsx4(GameMapPanel, { ...view }) : page === "gear" ? /* @__PURE__ */ jsx4(GameEquipmentPanel, { ...view }) : /* @__PURE__ */ jsx4(GamePetPanel, { ...view }) }),
|
|
1406
|
+
/* @__PURE__ */ jsxs4(GameDialog, { open: Boolean(dialog), title: titles[dialog] || "", onClose: () => setDialog(""), container: () => host.current, children: [
|
|
1407
|
+
dialog === "loadout" && /* @__PURE__ */ jsx4(GameLoadoutPanel, { ...view }),
|
|
1408
|
+
dialog === "settings" && /* @__PURE__ */ jsx4(GameSavePanel, { onExport: exportFile, onImport: importFile }),
|
|
1409
|
+
dialog === "compare" && /* @__PURE__ */ jsx4(GameEquipmentComparison, { ...view, itemId }),
|
|
1410
|
+
dialog === "help" && /* @__PURE__ */ jsxs4("div", { className: "help-content", children: [
|
|
1411
|
+
/* @__PURE__ */ jsxs4("p", { children: [
|
|
1412
|
+
"\u5F00\u59CB\u6302\u673A\u540E\uFF0C\u6309\u6240\u914D\u7F6E\u7684\u56DE\u5408\u95F4\u9694\u81EA\u52A8\u5BFB\u654C\u3001\u79FB\u52A8\u3001\u51FA\u624B\u5E76\u62FE\u53D6\u5956\u52B1\u3002\u5173\u95ED\u9875\u9762\u540E\uFF0C\u4E0B\u6B21\u8FDB\u5165\u7ED3\u7B97\u6700\u591A ",
|
|
951
1413
|
(definition.offlineCapSeconds ?? 43200) / 3600,
|
|
952
1414
|
" \u5C0F\u65F6\u7684\u666E\u901A\u6218\u6597\u6536\u76CA\u3002"
|
|
953
1415
|
] }),
|
|
954
|
-
/* @__PURE__ */
|
|
955
|
-
/* @__PURE__ */
|
|
956
|
-
/* @__PURE__ */
|
|
957
|
-
/* @__PURE__ */
|
|
958
|
-
/* @__PURE__ */
|
|
1416
|
+
/* @__PURE__ */ jsxs4("ol", { children: [
|
|
1417
|
+
/* @__PURE__ */ jsx4("li", { children: "\u6302\u673A\u83B7\u5F97\u7ECF\u9A8C\u3001\u94DC\u94B1\u3001\u88C5\u5907\u548C\u7075\u8574\u3002" }),
|
|
1418
|
+
/* @__PURE__ */ jsx4("li", { children: "\u66F4\u6362\u88C5\u5907\uFF0C\u5F3A\u5316\u90E8\u4F4D\uFF1B\u5F3A\u5316\u4E0D\u4F1A\u968F\u6362\u88C5\u4E22\u5931\u3002" }),
|
|
1419
|
+
/* @__PURE__ */ jsx4("li", { children: "\u7ED3\u7F18\u5E76\u57F9\u517B\u4F19\u4F34\uFF0C\u6539\u53D8\u8FFD\u51FB\u3001\u6CBB\u7597\u4E0E\u51CF\u4F24\u6548\u679C\u3002" }),
|
|
1420
|
+
/* @__PURE__ */ jsx4("li", { children: "\u6311\u6218\u9996\u9886\uFF0C\u9996\u901A\u83B7\u5F97\u88C5\u5907\u5E76\u89E3\u9501\u4E0B\u4E00\u7AE0\u3002" })
|
|
959
1421
|
] }),
|
|
960
|
-
/* @__PURE__ */
|
|
1422
|
+
/* @__PURE__ */ jsx4("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
1423
|
] }),
|
|
962
|
-
dialog === "offline" && report && /* @__PURE__ */
|
|
963
|
-
/* @__PURE__ */
|
|
1424
|
+
dialog === "offline" && report && /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
1425
|
+
/* @__PURE__ */ jsxs4("p", { children: [
|
|
964
1426
|
"\u79BB\u5F00 ",
|
|
965
1427
|
Math.floor(report.seconds / 3600),
|
|
966
1428
|
" \u5C0F\u65F6 ",
|
|
967
1429
|
Math.floor(report.seconds % 3600 / 60),
|
|
968
1430
|
" \u5206\u949F\uFF0C\u6536\u76CA\u5DF2\u81EA\u52A8\u5165\u8D26\u3002"
|
|
969
1431
|
] }),
|
|
970
|
-
/* @__PURE__ */
|
|
971
|
-
/* @__PURE__ */
|
|
972
|
-
/* @__PURE__ */
|
|
1432
|
+
/* @__PURE__ */ jsx4("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__ */ jsxs4("div", { children: [
|
|
1433
|
+
/* @__PURE__ */ jsx4("span", { children: label }),
|
|
1434
|
+
/* @__PURE__ */ jsx4("b", { children: value })
|
|
973
1435
|
] }, label)) }),
|
|
974
|
-
/* @__PURE__ */
|
|
1436
|
+
/* @__PURE__ */ jsxs4("p", { children: [
|
|
975
1437
|
"\u51FB\u8D25 ",
|
|
976
1438
|
report.kills,
|
|
977
1439
|
" \u4E2A\u654C\u4EBA\uFF0C\u80CC\u5305\u6EA2\u51FA\u6389\u843D\u5DF2\u8F6C\u4E3A\u953B\u6750\u3002"
|
|
978
1440
|
] }),
|
|
979
|
-
/* @__PURE__ */
|
|
1441
|
+
/* @__PURE__ */ jsx4(GameButton, { className: "primary-button full", onClick: () => setDialog(""), children: "\u7EE7\u7EED\u5386\u7EC3" })
|
|
980
1442
|
] }),
|
|
981
|
-
dialog === "import" && pending && /* @__PURE__ */
|
|
982
|
-
/* @__PURE__ */
|
|
1443
|
+
dialog === "import" && pending && /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
1444
|
+
/* @__PURE__ */ jsxs4("p", { children: [
|
|
983
1445
|
"\u5373\u5C06\u8F7D\u5165 Lv.",
|
|
984
1446
|
pending.level,
|
|
985
1447
|
" \u7684\u89D2\u8272\uFF0C\u5DF2\u89E3\u9501 ",
|
|
986
1448
|
pending.unlocked + 1,
|
|
987
1449
|
" \u7AE0\u3002\u786E\u8BA4\u540E\u5C06\u66FF\u6362\u5F53\u524D\u5B58\u6863\u3002"
|
|
988
1450
|
] }),
|
|
989
|
-
/* @__PURE__ */
|
|
1451
|
+
/* @__PURE__ */ jsx4(GameButton, { className: "primary-button full", disabled: Boolean(s.fight?.boss && s.fight.status === "active"), onClick: () => {
|
|
990
1452
|
stateRef.current = pending;
|
|
991
1453
|
setPending(null);
|
|
992
1454
|
setDialog("");
|
|
@@ -997,7 +1459,7 @@ function IdleGameApp({ definition, className = "", style, onStateChange }) {
|
|
|
997
1459
|
}, children: "\u786E\u8BA4\u66FF\u6362\u5F53\u524D\u5B58\u6863" })
|
|
998
1460
|
] })
|
|
999
1461
|
] }),
|
|
1000
|
-
/* @__PURE__ */
|
|
1462
|
+
/* @__PURE__ */ jsx4("div", { className: `game-toast ${message ? "visible" : ""}`, role: "status", children: message })
|
|
1001
1463
|
] });
|
|
1002
1464
|
}
|
|
1003
1465
|
export {
|
|
@@ -1008,6 +1470,8 @@ export {
|
|
|
1008
1470
|
GameDialog,
|
|
1009
1471
|
GameEquipmentComparison,
|
|
1010
1472
|
GameEquipmentPanel,
|
|
1473
|
+
GameHexBattlefield,
|
|
1474
|
+
GameLoadoutPanel,
|
|
1011
1475
|
GameLogPanel,
|
|
1012
1476
|
GameMapPanel,
|
|
1013
1477
|
GamePetPanel,
|
|
@@ -1016,5 +1480,9 @@ export {
|
|
|
1016
1480
|
GameShell,
|
|
1017
1481
|
GameSprite,
|
|
1018
1482
|
IdleGameApp,
|
|
1019
|
-
createIdleEngine
|
|
1483
|
+
createIdleEngine,
|
|
1484
|
+
gameAbilities,
|
|
1485
|
+
gameHexCells,
|
|
1486
|
+
hexDistance,
|
|
1487
|
+
sampleHexPlayback
|
|
1020
1488
|
};
|