steamsheep-ts-game-engine 1.0.0 → 1.1.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/README.md +11 -11
- 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 +1 -1
package/README.md
CHANGED
|
@@ -189,7 +189,7 @@ interface ExtraData {
|
|
|
189
189
|
|
|
190
190
|
```typescript
|
|
191
191
|
// src/game/config/init.ts
|
|
192
|
-
import type { GameState } from '
|
|
192
|
+
import type { GameState } from 'steamsheep-ts-game-engine/core';
|
|
193
193
|
|
|
194
194
|
export const initialState: GameState<Stats, Items, Flags, ExtraData> = {
|
|
195
195
|
stats: {
|
|
@@ -220,7 +220,7 @@ export const initialState: GameState<Stats, Items, Flags, ExtraData> = {
|
|
|
220
220
|
|
|
221
221
|
```typescript
|
|
222
222
|
// src/game/store.ts
|
|
223
|
-
import { createGameEngineStore } from '
|
|
223
|
+
import { createGameEngineStore } from 'steamsheep-ts-game-engine/state';
|
|
224
224
|
import { initialState } from './config/init';
|
|
225
225
|
|
|
226
226
|
export const useGameStore = createGameEngineStore(
|
|
@@ -235,7 +235,7 @@ export type GameStore = ReturnType<typeof useGameStore>;
|
|
|
235
235
|
|
|
236
236
|
```typescript
|
|
237
237
|
// src/game/content/actions.ts
|
|
238
|
-
import type { ActionDef } from '
|
|
238
|
+
import type { ActionDef } from 'steamsheep-ts-game-engine/core';
|
|
239
239
|
|
|
240
240
|
export const attackAction: ActionDef<Stats, Items, Flags, ExtraData> = {
|
|
241
241
|
id: 'attack_goblin',
|
|
@@ -276,8 +276,8 @@ export const attackAction: ActionDef<Stats, Items, Flags, ExtraData> = {
|
|
|
276
276
|
```typescript
|
|
277
277
|
// src/components/GameUI.tsx
|
|
278
278
|
import { useGameStore } from '@/game/store';
|
|
279
|
-
import { FlowSystem } from '
|
|
280
|
-
import { QuerySystem } from '
|
|
279
|
+
import { FlowSystem } from 'steamsheep-ts-game-engine/systems';
|
|
280
|
+
import { QuerySystem } from 'steamsheep-ts-game-engine/systems';
|
|
281
281
|
import { attackAction } from '@/game/content/actions';
|
|
282
282
|
|
|
283
283
|
function GameUI() {
|
|
@@ -399,7 +399,7 @@ export const EngineEvents = {
|
|
|
399
399
|
#### 监听事件
|
|
400
400
|
|
|
401
401
|
```typescript
|
|
402
|
-
import { gameEvents, EngineEvents } from '
|
|
402
|
+
import { gameEvents, EngineEvents } from 'steamsheep-ts-game-engine/systems';
|
|
403
403
|
|
|
404
404
|
// 监听属性变化
|
|
405
405
|
const unsubscribe = gameEvents.on(EngineEvents.STAT_CHANGE, (data) => {
|
|
@@ -489,7 +489,7 @@ static executeAction(...) {
|
|
|
489
489
|
#### 使用方法
|
|
490
490
|
|
|
491
491
|
```typescript
|
|
492
|
-
import { FlowSystem } from '
|
|
492
|
+
import { FlowSystem } from 'steamsheep-ts-game-engine/systems';
|
|
493
493
|
|
|
494
494
|
const success = FlowSystem.executeAction(store, action);
|
|
495
495
|
|
|
@@ -509,7 +509,7 @@ if (success) {
|
|
|
509
509
|
#### 常用查询
|
|
510
510
|
|
|
511
511
|
```typescript
|
|
512
|
-
import { QuerySystem } from '
|
|
512
|
+
import { QuerySystem } from 'steamsheep-ts-game-engine/systems';
|
|
513
513
|
|
|
514
514
|
// 检查是否有物品
|
|
515
515
|
const hasKey = QuerySystem.hasItem(state, 'key');
|
|
@@ -619,8 +619,8 @@ store.showModal('警告:此操作不可撤销', 'warn');
|
|
|
619
619
|
|
|
620
620
|
```typescript
|
|
621
621
|
// src/App.tsx
|
|
622
|
-
import { OverlaySystem } from '
|
|
623
|
-
import { LogStream } from '
|
|
622
|
+
import { OverlaySystem } from 'steamsheep-ts-game-engine/ui';
|
|
623
|
+
import { LogStream } from 'steamsheep-ts-game-engine/ui';
|
|
624
624
|
|
|
625
625
|
function App() {
|
|
626
626
|
return (
|
|
@@ -1053,7 +1053,7 @@ store.showToast('获得 10 金币', 'success');
|
|
|
1053
1053
|
2. **添加 `OverlaySystem` 组件**
|
|
1054
1054
|
```typescript
|
|
1055
1055
|
// src/App.tsx
|
|
1056
|
-
import { OverlaySystem } from '
|
|
1056
|
+
import { OverlaySystem } from 'steamsheep-ts-game-engine/ui';
|
|
1057
1057
|
|
|
1058
1058
|
function App() {
|
|
1059
1059
|
return (
|
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