@sia.soul/sia-react-ui 0.1.108 → 0.1.110
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-GPCUD6FA.js → chunk-XRHL56EV.js} +2 -1
- package/dist/{core-OuydQbFN.d.ts → core-gI4QB_Nz.d.ts} +3 -1
- package/dist/{core-KJBvQlUc.d.cts → core-lGT-8jSj.d.cts} +3 -1
- package/dist/core.cjs +2 -1
- package/dist/core.css +19 -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 +1649 -1193
- package/dist/game.css +186 -0
- package/dist/game.d.cts +77 -8
- package/dist/game.d.ts +77 -8
- package/dist/game.js +819 -367
- package/dist/index.cjs +17 -10
- package/dist/index.css +19 -0
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +16 -10
- package/package.json +1 -1
package/dist/game.css
CHANGED
|
@@ -2616,6 +2616,25 @@ fieldset:disabled .sia-input-number__floating-placeholder {
|
|
|
2616
2616
|
outline: 2px solid var(--sia-color-primary);
|
|
2617
2617
|
outline-offset: 2px;
|
|
2618
2618
|
}
|
|
2619
|
+
.sia-card--fill {
|
|
2620
|
+
height: 100%;
|
|
2621
|
+
min-height: 0;
|
|
2622
|
+
min-width: 0;
|
|
2623
|
+
display: flex;
|
|
2624
|
+
flex-direction: column;
|
|
2625
|
+
}
|
|
2626
|
+
.sia-card--fill > .sia-card__header,
|
|
2627
|
+
.sia-card--fill > .sia-card__description {
|
|
2628
|
+
flex-shrink: 0;
|
|
2629
|
+
}
|
|
2630
|
+
.sia-card--fill > .sia-card__body {
|
|
2631
|
+
flex: 1;
|
|
2632
|
+
min-height: 0;
|
|
2633
|
+
min-width: 0;
|
|
2634
|
+
}
|
|
2635
|
+
.sia-card--fill.sia-card--body-height > .sia-card__body {
|
|
2636
|
+
flex: 0 0 auto;
|
|
2637
|
+
}
|
|
2619
2638
|
.sia-card__selected-corner {
|
|
2620
2639
|
position: absolute;
|
|
2621
2640
|
top: 0;
|
|
@@ -8907,6 +8926,173 @@ body:has(.sia-game) {
|
|
|
8907
8926
|
}
|
|
8908
8927
|
}
|
|
8909
8928
|
|
|
8929
|
+
/* src/game/hex-battle.css */
|
|
8930
|
+
.sia-game .hex-battlefield {
|
|
8931
|
+
position: relative;
|
|
8932
|
+
border: 1px solid #4b647e;
|
|
8933
|
+
background: #111d2a;
|
|
8934
|
+
border-radius: 3px;
|
|
8935
|
+
overflow: hidden;
|
|
8936
|
+
}
|
|
8937
|
+
.sia-game .hex-stage-head,
|
|
8938
|
+
.sia-game .hex-stage-foot {
|
|
8939
|
+
display: flex;
|
|
8940
|
+
justify-content: space-between;
|
|
8941
|
+
gap: 12px;
|
|
8942
|
+
padding: 10px 14px;
|
|
8943
|
+
background: #192a3b;
|
|
8944
|
+
color: #b6ccdf;
|
|
8945
|
+
font-size: 11px;
|
|
8946
|
+
border-bottom: 1px solid #354b62;
|
|
8947
|
+
}
|
|
8948
|
+
.sia-game .hex-stage-head > span:first-child {
|
|
8949
|
+
color: #e0c68e;
|
|
8950
|
+
}
|
|
8951
|
+
.sia-game .hex-stage-foot {
|
|
8952
|
+
border-top: 1px solid #354b62;
|
|
8953
|
+
border-bottom: 0;
|
|
8954
|
+
background: #142131;
|
|
8955
|
+
font-size: 10px;
|
|
8956
|
+
}
|
|
8957
|
+
.sia-game .hex-stage-foot > span:first-child {
|
|
8958
|
+
color: #9cdbed;
|
|
8959
|
+
}
|
|
8960
|
+
.sia-game .hex-canvas {
|
|
8961
|
+
display: block;
|
|
8962
|
+
width: 100%;
|
|
8963
|
+
height: auto;
|
|
8964
|
+
aspect-ratio: 900/580;
|
|
8965
|
+
}
|
|
8966
|
+
.sia-game .hex-boss-intent {
|
|
8967
|
+
display: flex;
|
|
8968
|
+
align-items: center;
|
|
8969
|
+
justify-content: space-between;
|
|
8970
|
+
gap: 10px;
|
|
8971
|
+
padding: 10px 14px;
|
|
8972
|
+
background: #392d28;
|
|
8973
|
+
color: #d7c6b4;
|
|
8974
|
+
border-top: 1px solid #786044;
|
|
8975
|
+
font-size: 10px;
|
|
8976
|
+
}
|
|
8977
|
+
.sia-game .hex-boss-intent b {
|
|
8978
|
+
color: #f2c783;
|
|
8979
|
+
font-size: 12px;
|
|
8980
|
+
}
|
|
8981
|
+
.sia-game .hex-boss-intent.charging {
|
|
8982
|
+
background: #51352b;
|
|
8983
|
+
border-color: #d6a06b;
|
|
8984
|
+
}
|
|
8985
|
+
.sia-game .hex-asset-warning {
|
|
8986
|
+
font-size: 11px;
|
|
8987
|
+
color: #f1bf86;
|
|
8988
|
+
padding: 10px;
|
|
8989
|
+
}
|
|
8990
|
+
.sia-game .hex-build-bar {
|
|
8991
|
+
display: flex;
|
|
8992
|
+
gap: 6px;
|
|
8993
|
+
flex-wrap: wrap;
|
|
8994
|
+
margin: 10px 0 0;
|
|
8995
|
+
}
|
|
8996
|
+
.sia-game .hex-build-bar span {
|
|
8997
|
+
padding: 4px 7px;
|
|
8998
|
+
font-size: 10px;
|
|
8999
|
+
background: #1c2c3e;
|
|
9000
|
+
color: #bbcee3;
|
|
9001
|
+
border: 1px solid #3e526d;
|
|
9002
|
+
border-radius: 2px;
|
|
9003
|
+
}
|
|
9004
|
+
.sia-game .hex-build-bar b {
|
|
9005
|
+
color: #e2ca98;
|
|
9006
|
+
font-weight: 400;
|
|
9007
|
+
margin-right: 5px;
|
|
9008
|
+
}
|
|
9009
|
+
.sia-game .hex-loadout > p {
|
|
9010
|
+
font-size: 12px;
|
|
9011
|
+
color: #afc3da;
|
|
9012
|
+
line-height: 1.8;
|
|
9013
|
+
margin-bottom: 16px;
|
|
9014
|
+
}
|
|
9015
|
+
.sia-game .hex-loadout section {
|
|
9016
|
+
margin: 14px 0;
|
|
9017
|
+
}
|
|
9018
|
+
.sia-game .hex-loadout h3 {
|
|
9019
|
+
font-size: 13px;
|
|
9020
|
+
color: #e4c994;
|
|
9021
|
+
margin-bottom: 8px;
|
|
9022
|
+
}
|
|
9023
|
+
.sia-game .hex-ability-options {
|
|
9024
|
+
display: grid;
|
|
9025
|
+
grid-template-columns: 1fr 1fr;
|
|
9026
|
+
gap: 8px;
|
|
9027
|
+
}
|
|
9028
|
+
.sia-game .game-button.hex-ability {
|
|
9029
|
+
display: flex;
|
|
9030
|
+
flex-direction: column;
|
|
9031
|
+
align-items: flex-start;
|
|
9032
|
+
text-align: left;
|
|
9033
|
+
padding: 12px;
|
|
9034
|
+
border: 1px solid #455c76;
|
|
9035
|
+
background: #162235;
|
|
9036
|
+
border-radius: 3px;
|
|
9037
|
+
gap: 5px;
|
|
9038
|
+
}
|
|
9039
|
+
.sia-game .game-button.hex-ability > span {
|
|
9040
|
+
display: flex;
|
|
9041
|
+
flex-direction: column;
|
|
9042
|
+
gap: 5px;
|
|
9043
|
+
}
|
|
9044
|
+
.sia-game .hex-ability strong {
|
|
9045
|
+
font-size: 13px;
|
|
9046
|
+
color: #d8e9f6;
|
|
9047
|
+
}
|
|
9048
|
+
.sia-game .hex-ability small {
|
|
9049
|
+
font-size: 10px;
|
|
9050
|
+
color: #87c9e4;
|
|
9051
|
+
}
|
|
9052
|
+
.sia-game .hex-ability span span {
|
|
9053
|
+
font-size: 11px;
|
|
9054
|
+
line-height: 1.7;
|
|
9055
|
+
color: #aebed2;
|
|
9056
|
+
}
|
|
9057
|
+
.sia-game .game-button.hex-ability.selected {
|
|
9058
|
+
background: #203d52;
|
|
9059
|
+
border-color: #62bde8;
|
|
9060
|
+
box-shadow: inset 3px 0 #62bde8;
|
|
9061
|
+
}
|
|
9062
|
+
@media (max-width: 760px) {
|
|
9063
|
+
.sia-game .hex-stage-head,
|
|
9064
|
+
.sia-game .hex-stage-foot {
|
|
9065
|
+
padding: 8px;
|
|
9066
|
+
font-size: 9px;
|
|
9067
|
+
gap: 5px;
|
|
9068
|
+
}
|
|
9069
|
+
.sia-game .hex-canvas {
|
|
9070
|
+
min-height: 285px;
|
|
9071
|
+
object-fit: contain;
|
|
9072
|
+
}
|
|
9073
|
+
.sia-game .hex-boss-intent {
|
|
9074
|
+
flex-wrap: wrap;
|
|
9075
|
+
padding: 8px;
|
|
9076
|
+
font-size: 9px;
|
|
9077
|
+
}
|
|
9078
|
+
.sia-game .hex-boss-intent > span:last-child {
|
|
9079
|
+
width: 100%;
|
|
9080
|
+
}
|
|
9081
|
+
.sia-game .hex-build-bar {
|
|
9082
|
+
gap: 4px;
|
|
9083
|
+
}
|
|
9084
|
+
.sia-game .hex-build-bar span {
|
|
9085
|
+
font-size: 9px;
|
|
9086
|
+
padding: 3px 5px;
|
|
9087
|
+
}
|
|
9088
|
+
.sia-game .hex-ability-options {
|
|
9089
|
+
gap: 6px;
|
|
9090
|
+
}
|
|
9091
|
+
.sia-game .game-button.hex-ability {
|
|
9092
|
+
padding: 9px;
|
|
9093
|
+
}
|
|
9094
|
+
}
|
|
9095
|
+
|
|
8910
9096
|
/* src/title-tooltip.css */
|
|
8911
9097
|
body > .sia-title-tooltip[data-sia-popup-layer] {
|
|
8912
9098
|
position: fixed;
|
package/dist/game.d.cts
CHANGED
|
@@ -61,7 +61,7 @@ interface IdleMapDefinition {
|
|
|
61
61
|
rewardSlot: string;
|
|
62
62
|
/** 地图说明。 */
|
|
63
63
|
desc: string;
|
|
64
|
-
/**
|
|
64
|
+
/** 不含角色、格线和 UI 的俯视背景位图路径;建议宽高比 900:580,中央留空供棋盘覆盖。六边形战场完整铺满该图,加载失败时使用暗色底板。 */
|
|
65
65
|
scene: string;
|
|
66
66
|
/** 普通怪物位图及身份。 */
|
|
67
67
|
enemyArt: GameUnitAsset;
|
|
@@ -84,7 +84,7 @@ interface IdlePetDefinition {
|
|
|
84
84
|
desc: string;
|
|
85
85
|
/** 结缘灵蕴;第一只伙伴默认获得,不扣费。 */
|
|
86
86
|
cost: number;
|
|
87
|
-
/**
|
|
87
|
+
/** 攻击伙伴的一级追击伤害;治疗伙伴改用 7 + 等级 × 3,守护伙伴使用固定减伤。 */
|
|
88
88
|
base: number;
|
|
89
89
|
/** 伙伴透明位图及身份。 */
|
|
90
90
|
art: GameUnitAsset;
|
|
@@ -117,6 +117,8 @@ interface IdleGameDefinition {
|
|
|
117
117
|
offlineCapSeconds?: number;
|
|
118
118
|
/** 自动回合间隔,单位毫秒;默认 1000,允许 1000 至 5000 的整数。在线与离线使用同一间隔。 */
|
|
119
119
|
turnDurationMs?: number;
|
|
120
|
+
/** 可装配的自动战斗能力;省略时使用框架默认组合,提供时四类能力都必须至少包含一项。 */
|
|
121
|
+
abilities?: GameAbility[];
|
|
120
122
|
}
|
|
121
123
|
/** 框架生成并在导入时重建属性的装备。 */
|
|
122
124
|
interface GameEquipment {
|
|
@@ -141,6 +143,8 @@ interface GameEquipment {
|
|
|
141
143
|
}
|
|
142
144
|
/** 当前战斗的可观察状态;不持久化正在进行的战斗。 */
|
|
143
145
|
interface GameBattle {
|
|
146
|
+
/** 当前棋盘单位,主角和灵宠固定 id,其余为本波敌人。 */ units: GameHexUnit[];
|
|
147
|
+
/** 本波累计生成的小怪数量;普通战斗最多 4,首领战为 1。 */ spawned: number;
|
|
144
148
|
/** 是否首领战。 */
|
|
145
149
|
boss: boolean;
|
|
146
150
|
/** 角色当前气血。 */
|
|
@@ -219,6 +223,45 @@ interface IdleGameState {
|
|
|
219
223
|
logs: GameLogEntry[];
|
|
220
224
|
/** 当前战斗;无战斗时为 null。 */
|
|
221
225
|
fight: GameBattle | null;
|
|
226
|
+
/** 四类自动战斗能力的配置 ID;导入时按可信能力列表校验,旧档自动使用默认组合。 */
|
|
227
|
+
loadout: Record<GameAbilityKind, string>;
|
|
228
|
+
}
|
|
229
|
+
/** 四个装配槽;普攻无冷却,技能、神通、法宝按各自周期自动施放。 */
|
|
230
|
+
type GameAbilityKind = 'attack' | 'skill' | 'power' | 'treasure';
|
|
231
|
+
/** 由宿主提供名称和数值的自动战斗能力。 */
|
|
232
|
+
interface GameAbility {
|
|
233
|
+
/** 能力唯一 ID,写入存档。 */ id: string;
|
|
234
|
+
/** 显示名。 */ name: string;
|
|
235
|
+
/** 归属装配槽。 */ kind: GameAbilityKind;
|
|
236
|
+
/** 单体伤害、目标周围一格群伤、治疗或本回合护盾。 */ effect: 'damage' | 'blast' | 'heal' | 'shield';
|
|
237
|
+
/** 六边形格距离,1 至 3;治疗与护盾只作用自身。 */ range: number;
|
|
238
|
+
/** 伤害乘攻击、治疗乘最大气血的系数;shield 为减伤比例,0 至 0.8。 */ scale: number;
|
|
239
|
+
/** 自动施放周期,正整数回合;普攻固定为 1,其余至少 2。 */ cooldown: number;
|
|
240
|
+
/** 给玩家解释效果的纯文本。 */ description: string;
|
|
241
|
+
}
|
|
242
|
+
/** 轴向六边形坐标,棋盘满足 max(abs(q),abs(r),abs(q+r)) <= 3。 */
|
|
243
|
+
interface GameHexCell {
|
|
244
|
+
/** 轴向列坐标。 */ q: number;
|
|
245
|
+
/** 轴向行坐标。 */ r: number;
|
|
246
|
+
}
|
|
247
|
+
/** 棋盘上的一个单位,其贴图只绘制在六边形棋子顶面。 */
|
|
248
|
+
interface GameHexUnit extends GameHexCell {
|
|
249
|
+
/** 主角为 hero、伙伴为 pet,敌人由引擎生成唯一 ID。 */ id: string;
|
|
250
|
+
/** 友方主角、友方伙伴或敌方。 */ side: 'hero' | 'pet' | 'enemy';
|
|
251
|
+
/** 当前气血,伙伴不会单独受到攻击。 */ hp: number;
|
|
252
|
+
/** 最大气血。 */ maxHp: number;
|
|
253
|
+
}
|
|
254
|
+
/** 回合中的一项有序表现事件;at 为回合时长的归一化比例。 */
|
|
255
|
+
interface GameHexCue {
|
|
256
|
+
/** 事件开始比例,0 至 1,只有到达该时刻后才显示对应数值。 */ at: number;
|
|
257
|
+
/** 逐格移动、出手、命中、治疗、护盾、消散、掉落或生成。 */ kind: 'move' | 'cast' | 'hit' | 'heal' | 'shield' | 'death' | 'loot' | 'spawn';
|
|
258
|
+
/** 发起事件的单位 ID。 */ actor: string;
|
|
259
|
+
/** 事件目标 ID;无目标时省略。 */ target?: string;
|
|
260
|
+
/** 移动的起始格。 */ from?: GameHexCell;
|
|
261
|
+
/** 移动的终点格。 */ to?: GameHexCell;
|
|
262
|
+
/** 伤害、治疗或铜钱数值。 */ value?: number;
|
|
263
|
+
/** 事件生效后的目标气血。 */ hp?: number;
|
|
264
|
+
/** 技能名、掉落名等纯文本提示。 */ label?: string;
|
|
222
265
|
}
|
|
223
266
|
/** 单回合的伤害及奖励通知;无推进时 tick 返回 null。 */
|
|
224
267
|
interface GameBattleEvent {
|
|
@@ -230,7 +273,7 @@ interface GameBattleEvent {
|
|
|
230
273
|
petDamage: number;
|
|
231
274
|
/** 是否暴击。 */
|
|
232
275
|
crit: boolean;
|
|
233
|
-
/**
|
|
276
|
+
/** 是否使用技能或法宝;普攻时为 false。 */
|
|
234
277
|
skill: boolean;
|
|
235
278
|
/** 角色承受伤害。 */
|
|
236
279
|
incoming: number;
|
|
@@ -247,6 +290,8 @@ interface GameBattleEvent {
|
|
|
247
290
|
}
|
|
248
291
|
/** 一次回合的不可变数值快照;所有气血都是该回合对应时刻的实际值。 */
|
|
249
292
|
interface GameBattlePlayback {
|
|
293
|
+
/** 回合开始时的棋盘快照;后续状态修改不影响此数组。 */ units: GameHexUnit[];
|
|
294
|
+
/** 已按时刻排序的棋盘动作与命中事件。 */ cues: GameHexCue[];
|
|
250
295
|
/** 当前回合序号,从 1 开始。 */ turn: number;
|
|
251
296
|
/** 是否为首领战。 */ boss: boolean;
|
|
252
297
|
/** 本回合敌方招式:普通攻击、蓄力、重击或喘息。 */ move: 'strike' | 'charge' | 'heavy' | 'recover';
|
|
@@ -295,7 +340,7 @@ interface IdleEngine {
|
|
|
295
340
|
grant: (state: IdleGameState, xp: number, gold: number) => void;
|
|
296
341
|
/** 开始普通战斗或首领战;boss 默认 false,锁定挑战期间不可再次开始。 */
|
|
297
342
|
beginFight: (state: IdleGameState, boss?: boolean) => void;
|
|
298
|
-
/**
|
|
343
|
+
/** 推进一个战术回合;实际时间由 turnDurationMs 控制;rng 默认 Math.random;暂停且无首领战时返回 null。 */
|
|
299
344
|
tick: (state: IdleGameState, rng?: () => number) => GameBattleEvent | null;
|
|
300
345
|
/** 穿戴背包装备,旧装备回到背包;首领战或物品不存在时返回 false。 */
|
|
301
346
|
equip: (state: IdleGameState, id: string) => boolean;
|
|
@@ -345,7 +390,7 @@ declare function createIdleEngine(definition: IdleGameDefinition): IdleEngine;
|
|
|
345
390
|
/** 框架页面标识;默认进入 battle,分别代表战场、地图、装备和伙伴。 */
|
|
346
391
|
type GamePage = 'battle' | 'maps' | 'gear' | 'pets';
|
|
347
392
|
/** 同步游戏命令标识;宿主根据命令更新状态,组件不直接修改受控状态。 */
|
|
348
|
-
type GameActionType = 'page' | 'idle' | 'boss' | 'map' | 'equip' | 'upgrade' | 'dismantle' | 'lock' | 'forge' | 'train' | 'unlock' | 'deploy' | 'inspect' | 'settings' | 'help';
|
|
393
|
+
type GameActionType = 'page' | 'idle' | 'boss' | 'map' | 'equip' | 'upgrade' | 'dismantle' | 'lock' | 'forge' | 'train' | 'unlock' | 'deploy' | 'inspect' | 'loadout' | 'configure' | 'settings' | 'help';
|
|
349
394
|
/** 从框架组件发给宿主的同步操作。 */
|
|
350
395
|
interface GameAction {
|
|
351
396
|
/** 操作类型。 */ type: GameActionType;
|
|
@@ -384,7 +429,7 @@ declare function GameButton({ className, ...props }: ButtonProps): react.JSX.Ele
|
|
|
384
429
|
declare function GameShell({ engine, state, onAction, page, children }: GameShellProps): react.JSX.Element;
|
|
385
430
|
/** 展示角色属性、货币、已穿装备与出战伙伴;操作通过 onAction 通知宿主。 */
|
|
386
431
|
declare function GameCharacterPanel({ engine, state: s, onAction }: GameViewProps): react.JSX.Element;
|
|
387
|
-
/**
|
|
432
|
+
/** 六边形自动战场与能力配置入口;真实规则快照交给棋盘组件分时播放。 */
|
|
388
433
|
declare function GameBattleStage({ engine, state: s, onAction, event, sequence }: GameBattleStageProps): react.JSX.Element;
|
|
389
434
|
/** 显示累计战利品;包括背包溢出后转为材料的掉落数量。 */
|
|
390
435
|
declare function GameResourceSummary({ state: s }: GameResourceSummaryProps): react.JSX.Element;
|
|
@@ -431,9 +476,33 @@ interface IdleGameAppProps {
|
|
|
431
476
|
}
|
|
432
477
|
/**
|
|
433
478
|
* 提供三栏 UI、挂机时钟、离线结算及存档导入导出的完整游戏宿主。
|
|
434
|
-
*
|
|
479
|
+
* 在线按 turnDurationMs 推进一回合(默认 1000 毫秒),后台隐藏暂停时钟;重新显示时补算普通战斗,卸载清理监听与定时器。
|
|
435
480
|
* 浏览器存储不可用时保留内存玩法并提示导出;文件导入校验后必须确认替换。
|
|
436
481
|
*/
|
|
437
482
|
declare function IdleGameApp({ definition, className, style, onStateChange }: IdleGameAppProps): react.JSX.Element;
|
|
438
483
|
|
|
439
|
-
|
|
484
|
+
/** 六边形战场输入;共享宿主状态和回合事件,不单独结算伤害或奖励。 */
|
|
485
|
+
interface GameHexBattlefieldProps extends GameBattleStageProps {
|
|
486
|
+
}
|
|
487
|
+
/** 45° 俯视六边形棋盘;地图 scene 位图铺在半透明地格下方,PNG/WebP 单位贴在棋子顶面。背景加载失败时保留暗色底板,所有动效作用于整枚棋子。 */
|
|
488
|
+
declare function GameHexBattlefield({ engine, state, event, sequence }: GameHexBattlefieldProps): react.JSX.Element;
|
|
489
|
+
|
|
490
|
+
/** 能力装配面板;每类单选,选择后通过 configure 命令提交,首领战中只读。 */
|
|
491
|
+
declare function GameLoadoutPanel({ engine, state, onAction }: GameViewProps): react.JSX.Element;
|
|
492
|
+
|
|
493
|
+
/** 当前可见棋子快照;移动时 q/r 为小数,仅用于画面,不回写规则坐标。 */
|
|
494
|
+
interface GameHexFrame {
|
|
495
|
+
/** 按事件时刻应用气血和移动后的单位。 */ units: GameHexUnit[];
|
|
496
|
+
/** 当前回合归一化时间,范围 0 至 1。 */ progress: number;
|
|
497
|
+
}
|
|
498
|
+
/** 按归一化时刻读取回合画面;命中前不扣血,移动只在相邻格之间插值,不改变原快照。 */
|
|
499
|
+
declare function sampleHexPlayback(playback: GameBattlePlayback, progress: number): GameHexFrame;
|
|
500
|
+
|
|
501
|
+
/** 获取可信能力表;未配置时返回框架默认表,只读使用。 */
|
|
502
|
+
declare function gameAbilities(definition: IdleGameDefinition): readonly GameAbility[];
|
|
503
|
+
/** 两个轴向格子的最短六边形距离,返回非负整数,不含障碍绕行。 */
|
|
504
|
+
declare function hexDistance(a: GameHexCell, b: GameHexCell): number;
|
|
505
|
+
/** 返回半径三格的 37 个可行走地块,每次调用创建独立数组。 */
|
|
506
|
+
declare function gameHexCells(): GameHexCell[];
|
|
507
|
+
|
|
508
|
+
export { type GameAbility, type GameAbilityKind, type GameAction, type GameActionType, type GameBattle, type GameBattleEvent, type GameBattlePlayback, GameBattleStage, type GameBattleStageProps, GameBossPanel, GameButton, GameCharacterPanel, type GameCombatStats, GameDialog, type GameDialogProps, type GameEquipment, GameEquipmentComparison, type GameEquipmentComparisonProps, GameEquipmentPanel, GameHexBattlefield, type GameHexBattlefieldProps, type GameHexCell, type GameHexCue, type GameHexFrame, type GameHexUnit, type GameLabels, GameLoadoutPanel, type GameLogEntry, GameLogPanel, GameMapPanel, type GameOfflineReport, type GamePage, GamePetPanel, GameResourceSummary, type GameResourceSummaryProps, GameSavePanel, type GameSavePanelProps, GameShell, type GameShellProps, GameSprite, type GameSpriteProps, type GameStats, type GameUnitAsset, type GameViewProps, type IdleEngine, IdleGameApp, type IdleGameAppProps, type IdleGameDefinition, type IdleGameState, type IdleMapDefinition, type IdlePetDefinition, type IdleSlotDefinition, createIdleEngine, gameAbilities, gameHexCells, hexDistance, sampleHexPlayback };
|
package/dist/game.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ interface IdleMapDefinition {
|
|
|
61
61
|
rewardSlot: string;
|
|
62
62
|
/** 地图说明。 */
|
|
63
63
|
desc: string;
|
|
64
|
-
/**
|
|
64
|
+
/** 不含角色、格线和 UI 的俯视背景位图路径;建议宽高比 900:580,中央留空供棋盘覆盖。六边形战场完整铺满该图,加载失败时使用暗色底板。 */
|
|
65
65
|
scene: string;
|
|
66
66
|
/** 普通怪物位图及身份。 */
|
|
67
67
|
enemyArt: GameUnitAsset;
|
|
@@ -84,7 +84,7 @@ interface IdlePetDefinition {
|
|
|
84
84
|
desc: string;
|
|
85
85
|
/** 结缘灵蕴;第一只伙伴默认获得,不扣费。 */
|
|
86
86
|
cost: number;
|
|
87
|
-
/**
|
|
87
|
+
/** 攻击伙伴的一级追击伤害;治疗伙伴改用 7 + 等级 × 3,守护伙伴使用固定减伤。 */
|
|
88
88
|
base: number;
|
|
89
89
|
/** 伙伴透明位图及身份。 */
|
|
90
90
|
art: GameUnitAsset;
|
|
@@ -117,6 +117,8 @@ interface IdleGameDefinition {
|
|
|
117
117
|
offlineCapSeconds?: number;
|
|
118
118
|
/** 自动回合间隔,单位毫秒;默认 1000,允许 1000 至 5000 的整数。在线与离线使用同一间隔。 */
|
|
119
119
|
turnDurationMs?: number;
|
|
120
|
+
/** 可装配的自动战斗能力;省略时使用框架默认组合,提供时四类能力都必须至少包含一项。 */
|
|
121
|
+
abilities?: GameAbility[];
|
|
120
122
|
}
|
|
121
123
|
/** 框架生成并在导入时重建属性的装备。 */
|
|
122
124
|
interface GameEquipment {
|
|
@@ -141,6 +143,8 @@ interface GameEquipment {
|
|
|
141
143
|
}
|
|
142
144
|
/** 当前战斗的可观察状态;不持久化正在进行的战斗。 */
|
|
143
145
|
interface GameBattle {
|
|
146
|
+
/** 当前棋盘单位,主角和灵宠固定 id,其余为本波敌人。 */ units: GameHexUnit[];
|
|
147
|
+
/** 本波累计生成的小怪数量;普通战斗最多 4,首领战为 1。 */ spawned: number;
|
|
144
148
|
/** 是否首领战。 */
|
|
145
149
|
boss: boolean;
|
|
146
150
|
/** 角色当前气血。 */
|
|
@@ -219,6 +223,45 @@ interface IdleGameState {
|
|
|
219
223
|
logs: GameLogEntry[];
|
|
220
224
|
/** 当前战斗;无战斗时为 null。 */
|
|
221
225
|
fight: GameBattle | null;
|
|
226
|
+
/** 四类自动战斗能力的配置 ID;导入时按可信能力列表校验,旧档自动使用默认组合。 */
|
|
227
|
+
loadout: Record<GameAbilityKind, string>;
|
|
228
|
+
}
|
|
229
|
+
/** 四个装配槽;普攻无冷却,技能、神通、法宝按各自周期自动施放。 */
|
|
230
|
+
type GameAbilityKind = 'attack' | 'skill' | 'power' | 'treasure';
|
|
231
|
+
/** 由宿主提供名称和数值的自动战斗能力。 */
|
|
232
|
+
interface GameAbility {
|
|
233
|
+
/** 能力唯一 ID,写入存档。 */ id: string;
|
|
234
|
+
/** 显示名。 */ name: string;
|
|
235
|
+
/** 归属装配槽。 */ kind: GameAbilityKind;
|
|
236
|
+
/** 单体伤害、目标周围一格群伤、治疗或本回合护盾。 */ effect: 'damage' | 'blast' | 'heal' | 'shield';
|
|
237
|
+
/** 六边形格距离,1 至 3;治疗与护盾只作用自身。 */ range: number;
|
|
238
|
+
/** 伤害乘攻击、治疗乘最大气血的系数;shield 为减伤比例,0 至 0.8。 */ scale: number;
|
|
239
|
+
/** 自动施放周期,正整数回合;普攻固定为 1,其余至少 2。 */ cooldown: number;
|
|
240
|
+
/** 给玩家解释效果的纯文本。 */ description: string;
|
|
241
|
+
}
|
|
242
|
+
/** 轴向六边形坐标,棋盘满足 max(abs(q),abs(r),abs(q+r)) <= 3。 */
|
|
243
|
+
interface GameHexCell {
|
|
244
|
+
/** 轴向列坐标。 */ q: number;
|
|
245
|
+
/** 轴向行坐标。 */ r: number;
|
|
246
|
+
}
|
|
247
|
+
/** 棋盘上的一个单位,其贴图只绘制在六边形棋子顶面。 */
|
|
248
|
+
interface GameHexUnit extends GameHexCell {
|
|
249
|
+
/** 主角为 hero、伙伴为 pet,敌人由引擎生成唯一 ID。 */ id: string;
|
|
250
|
+
/** 友方主角、友方伙伴或敌方。 */ side: 'hero' | 'pet' | 'enemy';
|
|
251
|
+
/** 当前气血,伙伴不会单独受到攻击。 */ hp: number;
|
|
252
|
+
/** 最大气血。 */ maxHp: number;
|
|
253
|
+
}
|
|
254
|
+
/** 回合中的一项有序表现事件;at 为回合时长的归一化比例。 */
|
|
255
|
+
interface GameHexCue {
|
|
256
|
+
/** 事件开始比例,0 至 1,只有到达该时刻后才显示对应数值。 */ at: number;
|
|
257
|
+
/** 逐格移动、出手、命中、治疗、护盾、消散、掉落或生成。 */ kind: 'move' | 'cast' | 'hit' | 'heal' | 'shield' | 'death' | 'loot' | 'spawn';
|
|
258
|
+
/** 发起事件的单位 ID。 */ actor: string;
|
|
259
|
+
/** 事件目标 ID;无目标时省略。 */ target?: string;
|
|
260
|
+
/** 移动的起始格。 */ from?: GameHexCell;
|
|
261
|
+
/** 移动的终点格。 */ to?: GameHexCell;
|
|
262
|
+
/** 伤害、治疗或铜钱数值。 */ value?: number;
|
|
263
|
+
/** 事件生效后的目标气血。 */ hp?: number;
|
|
264
|
+
/** 技能名、掉落名等纯文本提示。 */ label?: string;
|
|
222
265
|
}
|
|
223
266
|
/** 单回合的伤害及奖励通知;无推进时 tick 返回 null。 */
|
|
224
267
|
interface GameBattleEvent {
|
|
@@ -230,7 +273,7 @@ interface GameBattleEvent {
|
|
|
230
273
|
petDamage: number;
|
|
231
274
|
/** 是否暴击。 */
|
|
232
275
|
crit: boolean;
|
|
233
|
-
/**
|
|
276
|
+
/** 是否使用技能或法宝;普攻时为 false。 */
|
|
234
277
|
skill: boolean;
|
|
235
278
|
/** 角色承受伤害。 */
|
|
236
279
|
incoming: number;
|
|
@@ -247,6 +290,8 @@ interface GameBattleEvent {
|
|
|
247
290
|
}
|
|
248
291
|
/** 一次回合的不可变数值快照;所有气血都是该回合对应时刻的实际值。 */
|
|
249
292
|
interface GameBattlePlayback {
|
|
293
|
+
/** 回合开始时的棋盘快照;后续状态修改不影响此数组。 */ units: GameHexUnit[];
|
|
294
|
+
/** 已按时刻排序的棋盘动作与命中事件。 */ cues: GameHexCue[];
|
|
250
295
|
/** 当前回合序号,从 1 开始。 */ turn: number;
|
|
251
296
|
/** 是否为首领战。 */ boss: boolean;
|
|
252
297
|
/** 本回合敌方招式:普通攻击、蓄力、重击或喘息。 */ move: 'strike' | 'charge' | 'heavy' | 'recover';
|
|
@@ -295,7 +340,7 @@ interface IdleEngine {
|
|
|
295
340
|
grant: (state: IdleGameState, xp: number, gold: number) => void;
|
|
296
341
|
/** 开始普通战斗或首领战;boss 默认 false,锁定挑战期间不可再次开始。 */
|
|
297
342
|
beginFight: (state: IdleGameState, boss?: boolean) => void;
|
|
298
|
-
/**
|
|
343
|
+
/** 推进一个战术回合;实际时间由 turnDurationMs 控制;rng 默认 Math.random;暂停且无首领战时返回 null。 */
|
|
299
344
|
tick: (state: IdleGameState, rng?: () => number) => GameBattleEvent | null;
|
|
300
345
|
/** 穿戴背包装备,旧装备回到背包;首领战或物品不存在时返回 false。 */
|
|
301
346
|
equip: (state: IdleGameState, id: string) => boolean;
|
|
@@ -345,7 +390,7 @@ declare function createIdleEngine(definition: IdleGameDefinition): IdleEngine;
|
|
|
345
390
|
/** 框架页面标识;默认进入 battle,分别代表战场、地图、装备和伙伴。 */
|
|
346
391
|
type GamePage = 'battle' | 'maps' | 'gear' | 'pets';
|
|
347
392
|
/** 同步游戏命令标识;宿主根据命令更新状态,组件不直接修改受控状态。 */
|
|
348
|
-
type GameActionType = 'page' | 'idle' | 'boss' | 'map' | 'equip' | 'upgrade' | 'dismantle' | 'lock' | 'forge' | 'train' | 'unlock' | 'deploy' | 'inspect' | 'settings' | 'help';
|
|
393
|
+
type GameActionType = 'page' | 'idle' | 'boss' | 'map' | 'equip' | 'upgrade' | 'dismantle' | 'lock' | 'forge' | 'train' | 'unlock' | 'deploy' | 'inspect' | 'loadout' | 'configure' | 'settings' | 'help';
|
|
349
394
|
/** 从框架组件发给宿主的同步操作。 */
|
|
350
395
|
interface GameAction {
|
|
351
396
|
/** 操作类型。 */ type: GameActionType;
|
|
@@ -384,7 +429,7 @@ declare function GameButton({ className, ...props }: ButtonProps): react.JSX.Ele
|
|
|
384
429
|
declare function GameShell({ engine, state, onAction, page, children }: GameShellProps): react.JSX.Element;
|
|
385
430
|
/** 展示角色属性、货币、已穿装备与出战伙伴;操作通过 onAction 通知宿主。 */
|
|
386
431
|
declare function GameCharacterPanel({ engine, state: s, onAction }: GameViewProps): react.JSX.Element;
|
|
387
|
-
/**
|
|
432
|
+
/** 六边形自动战场与能力配置入口;真实规则快照交给棋盘组件分时播放。 */
|
|
388
433
|
declare function GameBattleStage({ engine, state: s, onAction, event, sequence }: GameBattleStageProps): react.JSX.Element;
|
|
389
434
|
/** 显示累计战利品;包括背包溢出后转为材料的掉落数量。 */
|
|
390
435
|
declare function GameResourceSummary({ state: s }: GameResourceSummaryProps): react.JSX.Element;
|
|
@@ -431,9 +476,33 @@ interface IdleGameAppProps {
|
|
|
431
476
|
}
|
|
432
477
|
/**
|
|
433
478
|
* 提供三栏 UI、挂机时钟、离线结算及存档导入导出的完整游戏宿主。
|
|
434
|
-
*
|
|
479
|
+
* 在线按 turnDurationMs 推进一回合(默认 1000 毫秒),后台隐藏暂停时钟;重新显示时补算普通战斗,卸载清理监听与定时器。
|
|
435
480
|
* 浏览器存储不可用时保留内存玩法并提示导出;文件导入校验后必须确认替换。
|
|
436
481
|
*/
|
|
437
482
|
declare function IdleGameApp({ definition, className, style, onStateChange }: IdleGameAppProps): react.JSX.Element;
|
|
438
483
|
|
|
439
|
-
|
|
484
|
+
/** 六边形战场输入;共享宿主状态和回合事件,不单独结算伤害或奖励。 */
|
|
485
|
+
interface GameHexBattlefieldProps extends GameBattleStageProps {
|
|
486
|
+
}
|
|
487
|
+
/** 45° 俯视六边形棋盘;地图 scene 位图铺在半透明地格下方,PNG/WebP 单位贴在棋子顶面。背景加载失败时保留暗色底板,所有动效作用于整枚棋子。 */
|
|
488
|
+
declare function GameHexBattlefield({ engine, state, event, sequence }: GameHexBattlefieldProps): react.JSX.Element;
|
|
489
|
+
|
|
490
|
+
/** 能力装配面板;每类单选,选择后通过 configure 命令提交,首领战中只读。 */
|
|
491
|
+
declare function GameLoadoutPanel({ engine, state, onAction }: GameViewProps): react.JSX.Element;
|
|
492
|
+
|
|
493
|
+
/** 当前可见棋子快照;移动时 q/r 为小数,仅用于画面,不回写规则坐标。 */
|
|
494
|
+
interface GameHexFrame {
|
|
495
|
+
/** 按事件时刻应用气血和移动后的单位。 */ units: GameHexUnit[];
|
|
496
|
+
/** 当前回合归一化时间,范围 0 至 1。 */ progress: number;
|
|
497
|
+
}
|
|
498
|
+
/** 按归一化时刻读取回合画面;命中前不扣血,移动只在相邻格之间插值,不改变原快照。 */
|
|
499
|
+
declare function sampleHexPlayback(playback: GameBattlePlayback, progress: number): GameHexFrame;
|
|
500
|
+
|
|
501
|
+
/** 获取可信能力表;未配置时返回框架默认表,只读使用。 */
|
|
502
|
+
declare function gameAbilities(definition: IdleGameDefinition): readonly GameAbility[];
|
|
503
|
+
/** 两个轴向格子的最短六边形距离,返回非负整数,不含障碍绕行。 */
|
|
504
|
+
declare function hexDistance(a: GameHexCell, b: GameHexCell): number;
|
|
505
|
+
/** 返回半径三格的 37 个可行走地块,每次调用创建独立数组。 */
|
|
506
|
+
declare function gameHexCells(): GameHexCell[];
|
|
507
|
+
|
|
508
|
+
export { type GameAbility, type GameAbilityKind, type GameAction, type GameActionType, type GameBattle, type GameBattleEvent, type GameBattlePlayback, GameBattleStage, type GameBattleStageProps, GameBossPanel, GameButton, GameCharacterPanel, type GameCombatStats, GameDialog, type GameDialogProps, type GameEquipment, GameEquipmentComparison, type GameEquipmentComparisonProps, GameEquipmentPanel, GameHexBattlefield, type GameHexBattlefieldProps, type GameHexCell, type GameHexCue, type GameHexFrame, type GameHexUnit, type GameLabels, GameLoadoutPanel, type GameLogEntry, GameLogPanel, GameMapPanel, type GameOfflineReport, type GamePage, GamePetPanel, GameResourceSummary, type GameResourceSummaryProps, GameSavePanel, type GameSavePanelProps, GameShell, type GameShellProps, GameSprite, type GameSpriteProps, type GameStats, type GameUnitAsset, type GameViewProps, type IdleEngine, IdleGameApp, type IdleGameAppProps, type IdleGameDefinition, type IdleGameState, type IdleMapDefinition, type IdlePetDefinition, type IdleSlotDefinition, createIdleEngine, gameAbilities, gameHexCells, hexDistance, sampleHexPlayback };
|