steamsheep-ts-game-engine 1.0.1 → 2.0.0
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/core/index.d.mts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/state/index.d.mts +2 -2
- package/dist/state/index.d.ts +2 -2
- package/dist/{store-BP5bpjRr.d.ts → store-D0SE7zJK.d.ts} +1 -1
- package/dist/{store-BeEHel1o.d.mts → store-xBiJ2MvB.d.mts} +1 -1
- package/dist/systems/index.d.mts +2 -2
- package/dist/systems/index.d.ts +2 -2
- package/dist/{types-CZueoTHl.d.mts → types-BLjkeE3R.d.mts} +75 -3
- package/dist/{types-CZueoTHl.d.ts → types-BLjkeE3R.d.ts} +75 -3
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/package.json +5 -5
package/dist/core/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GameState } from '../types-
|
|
2
|
-
export { A as ActionDef, E as EffectDef, b as LocationDef, L as LogEntry, a as NotificationPayload, N as NotificationType, R as RequirementDef, S as StatRequirement, W as WorldState } from '../types-
|
|
1
|
+
import { G as GameState } from '../types-BLjkeE3R.mjs';
|
|
2
|
+
export { A as ActionDef, E as EffectDef, b as LocationDef, L as LogEntry, a as NotificationPayload, N as NotificationType, R as RequirementDef, S as StatRequirement, W as WorldState } from '../types-BLjkeE3R.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 系统消息常量
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GameState } from '../types-
|
|
2
|
-
export { A as ActionDef, E as EffectDef, b as LocationDef, L as LogEntry, a as NotificationPayload, N as NotificationType, R as RequirementDef, S as StatRequirement, W as WorldState } from '../types-
|
|
1
|
+
import { G as GameState } from '../types-BLjkeE3R.js';
|
|
2
|
+
export { A as ActionDef, E as EffectDef, b as LocationDef, L as LogEntry, a as NotificationPayload, N as NotificationType, R as RequirementDef, S as StatRequirement, W as WorldState } from '../types-BLjkeE3R.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 系统消息常量
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { A as ActionDef, E as EffectDef, G as GameState, b as LocationDef, L as LogEntry, a as NotificationPayload, N as NotificationType, R as RequirementDef, S as StatRequirement, W as WorldState } from './types-
|
|
1
|
+
export { A as ActionDef, E as EffectDef, G as GameState, b as LocationDef, L as LogEntry, a as NotificationPayload, N as NotificationType, R as RequirementDef, S as StatRequirement, W as WorldState } from './types-BLjkeE3R.mjs';
|
|
2
2
|
export { DEFAULT_CONFIG, DEFAULT_STATS, ENGINE_VERSION, LOG_TYPE_COLORS, SystemMessages, TIME_CONSTANTS, UI_CONSTANTS, VALIDATION, clamp, debounce, deepClone, delay, formatGameTime, formatNumber, generateId, get, getPercentage, getStateDiff, getTimeOfDay, isEmpty, randomChoice, randomInt, shuffle, throttle } from './core/index.mjs';
|
|
3
|
-
export { a as GameStore, G as GameStoreActions, c as createGameEngineStore } from './store-
|
|
3
|
+
export { a as GameStore, G as GameStoreActions, c as createGameEngineStore } from './store-xBiJ2MvB.mjs';
|
|
4
4
|
export { HistoryManager } from './state/index.mjs';
|
|
5
5
|
export { EngineEvents, EventBus, FlowSystem, QuerySystem, gameEvents } from './systems/index.mjs';
|
|
6
6
|
export { Layout, LogStream, MainContent, OverlaySystem } from './ui/index.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { A as ActionDef, E as EffectDef, G as GameState, b as LocationDef, L as LogEntry, a as NotificationPayload, N as NotificationType, R as RequirementDef, S as StatRequirement, W as WorldState } from './types-
|
|
1
|
+
export { A as ActionDef, E as EffectDef, G as GameState, b as LocationDef, L as LogEntry, a as NotificationPayload, N as NotificationType, R as RequirementDef, S as StatRequirement, W as WorldState } from './types-BLjkeE3R.js';
|
|
2
2
|
export { DEFAULT_CONFIG, DEFAULT_STATS, ENGINE_VERSION, LOG_TYPE_COLORS, SystemMessages, TIME_CONSTANTS, UI_CONSTANTS, VALIDATION, clamp, debounce, deepClone, delay, formatGameTime, formatNumber, generateId, get, getPercentage, getStateDiff, getTimeOfDay, isEmpty, randomChoice, randomInt, shuffle, throttle } from './core/index.js';
|
|
3
|
-
export { a as GameStore, G as GameStoreActions, c as createGameEngineStore } from './store-
|
|
3
|
+
export { a as GameStore, G as GameStoreActions, c as createGameEngineStore } from './store-D0SE7zJK.js';
|
|
4
4
|
export { HistoryManager } from './state/index.js';
|
|
5
5
|
export { EngineEvents, EventBus, FlowSystem, QuerySystem, gameEvents } from './systems/index.js';
|
|
6
6
|
export { Layout, LogStream, MainContent, OverlaySystem } from './ui/index.js';
|
package/dist/state/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { a as GameStore, G as GameStoreActions, c as createGameEngineStore } from '../store-
|
|
2
|
-
import { G as GameState } from '../types-
|
|
1
|
+
export { a as GameStore, G as GameStoreActions, c as createGameEngineStore } from '../store-xBiJ2MvB.mjs';
|
|
2
|
+
import { G as GameState } from '../types-BLjkeE3R.mjs';
|
|
3
3
|
import 'zustand/middleware';
|
|
4
4
|
import 'zustand';
|
|
5
5
|
|
package/dist/state/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { a as GameStore, G as GameStoreActions, c as createGameEngineStore } from '../store-
|
|
2
|
-
import { G as GameState } from '../types-
|
|
1
|
+
export { a as GameStore, G as GameStoreActions, c as createGameEngineStore } from '../store-D0SE7zJK.js';
|
|
2
|
+
import { G as GameState } from '../types-BLjkeE3R.js';
|
|
3
3
|
import 'zustand/middleware';
|
|
4
4
|
import 'zustand';
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as zustand_middleware from 'zustand/middleware';
|
|
2
2
|
import * as zustand from 'zustand';
|
|
3
|
-
import { L as LogEntry, G as GameState } from './types-
|
|
3
|
+
import { L as LogEntry, G as GameState } from './types-BLjkeE3R.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 游戏Store操作方法接口 - 定义所有可用的状态操作
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as zustand_middleware from 'zustand/middleware';
|
|
2
2
|
import * as zustand from 'zustand';
|
|
3
|
-
import { L as LogEntry, G as GameState } from './types-
|
|
3
|
+
import { L as LogEntry, G as GameState } from './types-BLjkeE3R.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 游戏Store操作方法接口 - 定义所有可用的状态操作
|
package/dist/systems/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as GameStore } from '../store-
|
|
2
|
-
import { A as ActionDef, G as GameState, R as RequirementDef } from '../types-
|
|
1
|
+
import { a as GameStore } from '../store-xBiJ2MvB.mjs';
|
|
2
|
+
import { A as ActionDef, G as GameState, R as RequirementDef } from '../types-BLjkeE3R.mjs';
|
|
3
3
|
import 'zustand/middleware';
|
|
4
4
|
import 'zustand';
|
|
5
5
|
|
package/dist/systems/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as GameStore } from '../store-
|
|
2
|
-
import { A as ActionDef, G as GameState, R as RequirementDef } from '../types-
|
|
1
|
+
import { a as GameStore } from '../store-D0SE7zJK.js';
|
|
2
|
+
import { A as ActionDef, G as GameState, R as RequirementDef } from '../types-BLjkeE3R.js';
|
|
3
3
|
import 'zustand/middleware';
|
|
4
4
|
import 'zustand';
|
|
5
5
|
|
|
@@ -425,18 +425,44 @@ interface ActionDef<S extends string, I extends string, F extends string, X = Re
|
|
|
425
425
|
* @template S - 数值属性键的联合类型
|
|
426
426
|
* @template I - 物品ID的联合类型
|
|
427
427
|
* @template F - 标记键的联合类型
|
|
428
|
+
* @template X - 扩展数据类型(默认为 Record<string, unknown>)
|
|
428
429
|
*
|
|
429
430
|
* @example
|
|
430
431
|
* ```typescript
|
|
432
|
+
* // 基础用法
|
|
431
433
|
* const tavern: LocationDef<Stats, Items, Flags> = {
|
|
432
434
|
* id: 'tavern',
|
|
433
435
|
* name: '酒馆',
|
|
434
436
|
* description: '一个热闹的酒馆,充满了冒险者',
|
|
435
|
-
* actionIds: ['buy_drink', 'talk_bartender', 'rest']
|
|
437
|
+
* actionIds: ['buy_drink', 'talk_bartender', 'rest'],
|
|
438
|
+
* extra: {}
|
|
439
|
+
* };
|
|
440
|
+
*
|
|
441
|
+
* // 使用自定义扩展数据
|
|
442
|
+
* interface LocationEnvironment {
|
|
443
|
+
* temperature: number;
|
|
444
|
+
* humidity: number;
|
|
445
|
+
* lightLevel: number;
|
|
446
|
+
* }
|
|
447
|
+
*
|
|
448
|
+
* const cave: LocationDef<Stats, Items, Flags, LocationEnvironment> = {
|
|
449
|
+
* id: 'cave',
|
|
450
|
+
* name: '洞穴',
|
|
451
|
+
* description: (state) => {
|
|
452
|
+
* // 可以访问 state.extra
|
|
453
|
+
* const temp = state.extra.temperature;
|
|
454
|
+
* return temp < 0 ? '寒冷的洞穴' : '阴暗的洞穴';
|
|
455
|
+
* },
|
|
456
|
+
* actionIds: ['explore'],
|
|
457
|
+
* extra: {
|
|
458
|
+
* temperature: -5,
|
|
459
|
+
* humidity: 80,
|
|
460
|
+
* lightLevel: 2
|
|
461
|
+
* }
|
|
436
462
|
* };
|
|
437
463
|
* ```
|
|
438
464
|
*/
|
|
439
|
-
interface LocationDef<S extends string, I extends string, F extends string
|
|
465
|
+
interface LocationDef<S extends string, I extends string, F extends string, X = Record<string, unknown>> {
|
|
440
466
|
/** 地点的唯一标识符 */
|
|
441
467
|
id: string;
|
|
442
468
|
/** 地点名称 - 显示在UI上的地点名称 */
|
|
@@ -446,7 +472,7 @@ interface LocationDef<S extends string, I extends string, F extends string> {
|
|
|
446
472
|
* 可以是静态字符串或根据游戏状态动态生成的函数
|
|
447
473
|
* 例如:根据时间显示不同的描述
|
|
448
474
|
*/
|
|
449
|
-
description: string | ((state: GameState<S, I, F>) => string);
|
|
475
|
+
description: string | ((state: GameState<S, I, F, X>) => string);
|
|
450
476
|
/**
|
|
451
477
|
* 该地点可执行的动作ID列表
|
|
452
478
|
*
|
|
@@ -459,6 +485,52 @@ interface LocationDef<S extends string, I extends string, F extends string> {
|
|
|
459
485
|
* 使用时需要配合ActionRegistry来查找完整的动作定义。
|
|
460
486
|
*/
|
|
461
487
|
actionIds: string[];
|
|
488
|
+
/**
|
|
489
|
+
* 扩展数据 - 存储地点特定的额外信息
|
|
490
|
+
*
|
|
491
|
+
* 这是一个灵活的字段,允许不同游戏为地点存储自定义元数据。
|
|
492
|
+
* 使用泛型 X 来定义具体的扩展数据类型。
|
|
493
|
+
*
|
|
494
|
+
* 常见用途:
|
|
495
|
+
* - 环境参数(温度、湿度、光照等)
|
|
496
|
+
* - 地点元数据(类别、发现时间、访问次数等)
|
|
497
|
+
* - 特殊属性(危险度、资源丰富度等)
|
|
498
|
+
* - 动态状态(天气、时间相关的变化等)
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
501
|
+
* ```typescript
|
|
502
|
+
* // 定义环境参数类型
|
|
503
|
+
* interface LocationEnvironment {
|
|
504
|
+
* temperature: number;
|
|
505
|
+
* humidity: number;
|
|
506
|
+
* lightLevel: number;
|
|
507
|
+
* danger: number;
|
|
508
|
+
* }
|
|
509
|
+
*
|
|
510
|
+
* // 使用扩展数据
|
|
511
|
+
* type MyLocation = LocationDef<Stats, Items, Flags, LocationEnvironment>;
|
|
512
|
+
*
|
|
513
|
+
* const location: MyLocation = {
|
|
514
|
+
* id: 'forest',
|
|
515
|
+
* name: '森林',
|
|
516
|
+
* description: (state) => {
|
|
517
|
+
* // 在 description 函数中访问扩展数据
|
|
518
|
+
* if (state.extra.danger > 5) {
|
|
519
|
+
* return '这片森林看起来很危险...';
|
|
520
|
+
* }
|
|
521
|
+
* return '一片宁静的森林';
|
|
522
|
+
* },
|
|
523
|
+
* actionIds: ['explore'],
|
|
524
|
+
* extra: {
|
|
525
|
+
* temperature: 20,
|
|
526
|
+
* humidity: 60,
|
|
527
|
+
* lightLevel: 8,
|
|
528
|
+
* danger: 3
|
|
529
|
+
* }
|
|
530
|
+
* };
|
|
531
|
+
* ```
|
|
532
|
+
*/
|
|
533
|
+
extra: X;
|
|
462
534
|
}
|
|
463
535
|
|
|
464
536
|
export type { ActionDef as A, EffectDef as E, GameState as G, LogEntry as L, NotificationType as N, RequirementDef as R, StatRequirement as S, WorldState as W, NotificationPayload as a, LocationDef as b };
|
|
@@ -425,18 +425,44 @@ interface ActionDef<S extends string, I extends string, F extends string, X = Re
|
|
|
425
425
|
* @template S - 数值属性键的联合类型
|
|
426
426
|
* @template I - 物品ID的联合类型
|
|
427
427
|
* @template F - 标记键的联合类型
|
|
428
|
+
* @template X - 扩展数据类型(默认为 Record<string, unknown>)
|
|
428
429
|
*
|
|
429
430
|
* @example
|
|
430
431
|
* ```typescript
|
|
432
|
+
* // 基础用法
|
|
431
433
|
* const tavern: LocationDef<Stats, Items, Flags> = {
|
|
432
434
|
* id: 'tavern',
|
|
433
435
|
* name: '酒馆',
|
|
434
436
|
* description: '一个热闹的酒馆,充满了冒险者',
|
|
435
|
-
* actionIds: ['buy_drink', 'talk_bartender', 'rest']
|
|
437
|
+
* actionIds: ['buy_drink', 'talk_bartender', 'rest'],
|
|
438
|
+
* extra: {}
|
|
439
|
+
* };
|
|
440
|
+
*
|
|
441
|
+
* // 使用自定义扩展数据
|
|
442
|
+
* interface LocationEnvironment {
|
|
443
|
+
* temperature: number;
|
|
444
|
+
* humidity: number;
|
|
445
|
+
* lightLevel: number;
|
|
446
|
+
* }
|
|
447
|
+
*
|
|
448
|
+
* const cave: LocationDef<Stats, Items, Flags, LocationEnvironment> = {
|
|
449
|
+
* id: 'cave',
|
|
450
|
+
* name: '洞穴',
|
|
451
|
+
* description: (state) => {
|
|
452
|
+
* // 可以访问 state.extra
|
|
453
|
+
* const temp = state.extra.temperature;
|
|
454
|
+
* return temp < 0 ? '寒冷的洞穴' : '阴暗的洞穴';
|
|
455
|
+
* },
|
|
456
|
+
* actionIds: ['explore'],
|
|
457
|
+
* extra: {
|
|
458
|
+
* temperature: -5,
|
|
459
|
+
* humidity: 80,
|
|
460
|
+
* lightLevel: 2
|
|
461
|
+
* }
|
|
436
462
|
* };
|
|
437
463
|
* ```
|
|
438
464
|
*/
|
|
439
|
-
interface LocationDef<S extends string, I extends string, F extends string
|
|
465
|
+
interface LocationDef<S extends string, I extends string, F extends string, X = Record<string, unknown>> {
|
|
440
466
|
/** 地点的唯一标识符 */
|
|
441
467
|
id: string;
|
|
442
468
|
/** 地点名称 - 显示在UI上的地点名称 */
|
|
@@ -446,7 +472,7 @@ interface LocationDef<S extends string, I extends string, F extends string> {
|
|
|
446
472
|
* 可以是静态字符串或根据游戏状态动态生成的函数
|
|
447
473
|
* 例如:根据时间显示不同的描述
|
|
448
474
|
*/
|
|
449
|
-
description: string | ((state: GameState<S, I, F>) => string);
|
|
475
|
+
description: string | ((state: GameState<S, I, F, X>) => string);
|
|
450
476
|
/**
|
|
451
477
|
* 该地点可执行的动作ID列表
|
|
452
478
|
*
|
|
@@ -459,6 +485,52 @@ interface LocationDef<S extends string, I extends string, F extends string> {
|
|
|
459
485
|
* 使用时需要配合ActionRegistry来查找完整的动作定义。
|
|
460
486
|
*/
|
|
461
487
|
actionIds: string[];
|
|
488
|
+
/**
|
|
489
|
+
* 扩展数据 - 存储地点特定的额外信息
|
|
490
|
+
*
|
|
491
|
+
* 这是一个灵活的字段,允许不同游戏为地点存储自定义元数据。
|
|
492
|
+
* 使用泛型 X 来定义具体的扩展数据类型。
|
|
493
|
+
*
|
|
494
|
+
* 常见用途:
|
|
495
|
+
* - 环境参数(温度、湿度、光照等)
|
|
496
|
+
* - 地点元数据(类别、发现时间、访问次数等)
|
|
497
|
+
* - 特殊属性(危险度、资源丰富度等)
|
|
498
|
+
* - 动态状态(天气、时间相关的变化等)
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
501
|
+
* ```typescript
|
|
502
|
+
* // 定义环境参数类型
|
|
503
|
+
* interface LocationEnvironment {
|
|
504
|
+
* temperature: number;
|
|
505
|
+
* humidity: number;
|
|
506
|
+
* lightLevel: number;
|
|
507
|
+
* danger: number;
|
|
508
|
+
* }
|
|
509
|
+
*
|
|
510
|
+
* // 使用扩展数据
|
|
511
|
+
* type MyLocation = LocationDef<Stats, Items, Flags, LocationEnvironment>;
|
|
512
|
+
*
|
|
513
|
+
* const location: MyLocation = {
|
|
514
|
+
* id: 'forest',
|
|
515
|
+
* name: '森林',
|
|
516
|
+
* description: (state) => {
|
|
517
|
+
* // 在 description 函数中访问扩展数据
|
|
518
|
+
* if (state.extra.danger > 5) {
|
|
519
|
+
* return '这片森林看起来很危险...';
|
|
520
|
+
* }
|
|
521
|
+
* return '一片宁静的森林';
|
|
522
|
+
* },
|
|
523
|
+
* actionIds: ['explore'],
|
|
524
|
+
* extra: {
|
|
525
|
+
* temperature: 20,
|
|
526
|
+
* humidity: 60,
|
|
527
|
+
* lightLevel: 8,
|
|
528
|
+
* danger: 3
|
|
529
|
+
* }
|
|
530
|
+
* };
|
|
531
|
+
* ```
|
|
532
|
+
*/
|
|
533
|
+
extra: X;
|
|
462
534
|
}
|
|
463
535
|
|
|
464
536
|
export type { ActionDef as A, EffectDef as E, GameState as G, LogEntry as L, NotificationType as N, RequirementDef as R, StatRequirement as S, WorldState as W, NotificationPayload as a, LocationDef as b };
|
package/dist/ui/index.d.mts
CHANGED
package/dist/ui/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "steamsheep-ts-game-engine",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "通用游戏引擎框架 - 基于 TypeScript 和 Zustand 构建的文字冒险/RPG 游戏引擎",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -55,12 +55,12 @@
|
|
|
55
55
|
"author": "Corey.H",
|
|
56
56
|
"license": "MIT",
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"react": "^
|
|
59
|
-
"zustand": "^4.0.0
|
|
58
|
+
"react": "^19.0.0",
|
|
59
|
+
"zustand": "^4.0.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@types/react": "^
|
|
63
|
-
"react": "^
|
|
62
|
+
"@types/react": "^19.2.7",
|
|
63
|
+
"react": "^19.2.1",
|
|
64
64
|
"tsup": "^8.0.0",
|
|
65
65
|
"typescript": "^5.0.0",
|
|
66
66
|
"zustand": "^4.0.0"
|