@mythxengine/types 0.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/LICENSE +21 -0
- package/dist/__tests__/rules.test.d.ts +5 -0
- package/dist/__tests__/rules.test.d.ts.map +1 -0
- package/dist/__tests__/rules.test.js +278 -0
- package/dist/__tests__/rules.test.js.map +1 -0
- package/dist/__tests__/time.test.d.ts +2 -0
- package/dist/__tests__/time.test.d.ts.map +1 -0
- package/dist/__tests__/time.test.js +125 -0
- package/dist/__tests__/time.test.js.map +1 -0
- package/dist/game/abilities.d.ts +77 -0
- package/dist/game/abilities.d.ts.map +1 -0
- package/dist/game/abilities.js +38 -0
- package/dist/game/abilities.js.map +1 -0
- package/dist/game/actions.d.ts +84 -0
- package/dist/game/actions.d.ts.map +1 -0
- package/dist/game/actions.js +10 -0
- package/dist/game/actions.js.map +1 -0
- package/dist/game/character.d.ts +128 -0
- package/dist/game/character.d.ts.map +1 -0
- package/dist/game/character.js +16 -0
- package/dist/game/character.js.map +1 -0
- package/dist/game/combat.d.ts +56 -0
- package/dist/game/combat.d.ts.map +1 -0
- package/dist/game/combat.js +5 -0
- package/dist/game/combat.js.map +1 -0
- package/dist/game/conditions.d.ts +216 -0
- package/dist/game/conditions.d.ts.map +1 -0
- package/dist/game/conditions.js +99 -0
- package/dist/game/conditions.js.map +1 -0
- package/dist/game/dice.d.ts +87 -0
- package/dist/game/dice.d.ts.map +1 -0
- package/dist/game/dice.js +13 -0
- package/dist/game/dice.js.map +1 -0
- package/dist/game/events.d.ts +85 -0
- package/dist/game/events.d.ts.map +1 -0
- package/dist/game/events.js +10 -0
- package/dist/game/events.js.map +1 -0
- package/dist/game/index.d.ts +13 -0
- package/dist/game/index.d.ts.map +1 -0
- package/dist/game/index.js +13 -0
- package/dist/game/index.js.map +1 -0
- package/dist/game/player.d.ts +110 -0
- package/dist/game/player.d.ts.map +1 -0
- package/dist/game/player.js +45 -0
- package/dist/game/player.js.map +1 -0
- package/dist/game/state.d.ts +99 -0
- package/dist/game/state.d.ts.map +1 -0
- package/dist/game/state.js +60 -0
- package/dist/game/state.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/rules/abilities.d.ts +82 -0
- package/dist/rules/abilities.d.ts.map +1 -0
- package/dist/rules/abilities.js +94 -0
- package/dist/rules/abilities.js.map +1 -0
- package/dist/rules/custom-tests.d.ts +163 -0
- package/dist/rules/custom-tests.d.ts.map +1 -0
- package/dist/rules/custom-tests.js +43 -0
- package/dist/rules/custom-tests.js.map +1 -0
- package/dist/rules/difficulties.d.ts +51 -0
- package/dist/rules/difficulties.d.ts.map +1 -0
- package/dist/rules/difficulties.js +77 -0
- package/dist/rules/difficulties.js.map +1 -0
- package/dist/rules/index.d.ts +123 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +170 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/mechanics.d.ts +130 -0
- package/dist/rules/mechanics.d.ts.map +1 -0
- package/dist/rules/mechanics.js +64 -0
- package/dist/rules/mechanics.js.map +1 -0
- package/dist/session/index.d.ts +228 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +60 -0
- package/dist/session/index.js.map +1 -0
- package/dist/tools/contract.d.ts +63 -0
- package/dist/tools/contract.d.ts.map +1 -0
- package/dist/tools/contract.js +36 -0
- package/dist/tools/contract.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dice and RNG types
|
|
3
|
+
*/
|
|
4
|
+
import type { AbilityName } from "./abilities.js";
|
|
5
|
+
/**
|
|
6
|
+
* RNG state for deterministic randomness
|
|
7
|
+
*/
|
|
8
|
+
export interface RNGState {
|
|
9
|
+
seed: number;
|
|
10
|
+
cursor: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Advantage state for a roll
|
|
14
|
+
*/
|
|
15
|
+
export type RollAdvantageState = "advantage" | "disadvantage" | "normal";
|
|
16
|
+
/**
|
|
17
|
+
* Information about an advantage/disadvantage roll
|
|
18
|
+
*/
|
|
19
|
+
export interface AdvantageInfo {
|
|
20
|
+
type: "advantage" | "disadvantage";
|
|
21
|
+
bothRolls: [number, number];
|
|
22
|
+
selected: "higher" | "lower";
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Result of a dice roll
|
|
26
|
+
*/
|
|
27
|
+
export interface DiceResult {
|
|
28
|
+
/** Original expression, e.g., "2d6+3" */
|
|
29
|
+
expression: string;
|
|
30
|
+
/** Individual die results, e.g., [4, 2] */
|
|
31
|
+
rolls: number[];
|
|
32
|
+
/** Flat modifier */
|
|
33
|
+
modifier: number;
|
|
34
|
+
/** Final total */
|
|
35
|
+
total: number;
|
|
36
|
+
/** Sum before modifier */
|
|
37
|
+
natural: number;
|
|
38
|
+
/** Critical status */
|
|
39
|
+
critical?: "success" | "failure";
|
|
40
|
+
/** Advantage/disadvantage info if applicable */
|
|
41
|
+
advantage?: AdvantageInfo;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Parsed dice expression
|
|
45
|
+
*/
|
|
46
|
+
export interface ParsedDice {
|
|
47
|
+
count: number;
|
|
48
|
+
sides: number;
|
|
49
|
+
modifier: number;
|
|
50
|
+
ability?: AbilityName;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A modifier to a roll
|
|
54
|
+
*/
|
|
55
|
+
export interface Modifier {
|
|
56
|
+
source: string;
|
|
57
|
+
amount: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Result of a skill/ability test
|
|
61
|
+
*/
|
|
62
|
+
export interface TestResult {
|
|
63
|
+
skill: string;
|
|
64
|
+
ability: AbilityName;
|
|
65
|
+
abilityMod: number;
|
|
66
|
+
skillBonus: number;
|
|
67
|
+
otherMods: number;
|
|
68
|
+
totalMod: number;
|
|
69
|
+
difficulty: number;
|
|
70
|
+
roll: DiceResult;
|
|
71
|
+
success: boolean;
|
|
72
|
+
margin: number;
|
|
73
|
+
critical: boolean;
|
|
74
|
+
/** The advantage state used for this test */
|
|
75
|
+
advantageState: RollAdvantageState;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Standard difficulty levels
|
|
79
|
+
*/
|
|
80
|
+
export declare const DIFFICULTY: {
|
|
81
|
+
readonly EASY: 8;
|
|
82
|
+
readonly STANDARD: 12;
|
|
83
|
+
readonly HARD: 16;
|
|
84
|
+
readonly EXTREME: 20;
|
|
85
|
+
};
|
|
86
|
+
export type DifficultyLevel = keyof typeof DIFFICULTY;
|
|
87
|
+
//# sourceMappingURL=dice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dice.d.ts","sourceRoot":"","sources":["../../src/game/dice.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,cAAc,GAAG,QAAQ,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,WAAW,GAAG,cAAc,CAAC;IACnC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;I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|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Game events - emitted by engine
|
|
3
|
+
*/
|
|
4
|
+
import type { Condition } from "./conditions.js";
|
|
5
|
+
import type { DiceResult } from "./dice.js";
|
|
6
|
+
/**
|
|
7
|
+
* Immutable events emitted by the engine
|
|
8
|
+
*/
|
|
9
|
+
export type GameEvent = SceneEnteredEvent | SkillTestResultEvent | DamageDealtEvent | DamageTakenEvent | CharacterDefeatedEvent | CombatStartedEvent | CombatEndedEvent | TurnAdvancedEvent | ConditionAppliedEvent | ConditionRemovedEvent | FlagSetEvent | RNGAdvancedEvent | ErrorEvent;
|
|
10
|
+
export interface SceneEnteredEvent {
|
|
11
|
+
type: "SCENE_ENTERED";
|
|
12
|
+
locationId: string;
|
|
13
|
+
description: string;
|
|
14
|
+
}
|
|
15
|
+
export interface SkillTestResultEvent {
|
|
16
|
+
type: "SKILL_TEST_RESULT";
|
|
17
|
+
characterId: string;
|
|
18
|
+
skill: string;
|
|
19
|
+
roll: DiceResult;
|
|
20
|
+
success: boolean;
|
|
21
|
+
margin: number;
|
|
22
|
+
}
|
|
23
|
+
export interface DamageDealtEvent {
|
|
24
|
+
type: "DAMAGE_DEALT";
|
|
25
|
+
attackerId: string;
|
|
26
|
+
targetId: string;
|
|
27
|
+
amount: number;
|
|
28
|
+
weapon: string;
|
|
29
|
+
}
|
|
30
|
+
export interface DamageTakenEvent {
|
|
31
|
+
type: "DAMAGE_TAKEN";
|
|
32
|
+
characterId: string;
|
|
33
|
+
amount: number;
|
|
34
|
+
hpRemaining: number;
|
|
35
|
+
}
|
|
36
|
+
export interface CharacterDefeatedEvent {
|
|
37
|
+
type: "CHARACTER_DEFEATED";
|
|
38
|
+
characterId: string;
|
|
39
|
+
}
|
|
40
|
+
export interface CombatStartedEvent {
|
|
41
|
+
type: "COMBAT_STARTED";
|
|
42
|
+
enemies: string[];
|
|
43
|
+
turnOrder: string[];
|
|
44
|
+
}
|
|
45
|
+
export interface CombatEndedEvent {
|
|
46
|
+
type: "COMBAT_ENDED";
|
|
47
|
+
outcome: "victory" | "defeat" | "fled";
|
|
48
|
+
}
|
|
49
|
+
export interface TurnAdvancedEvent {
|
|
50
|
+
type: "TURN_ADVANCED";
|
|
51
|
+
actorId: string;
|
|
52
|
+
round: number;
|
|
53
|
+
}
|
|
54
|
+
export interface ConditionAppliedEvent {
|
|
55
|
+
type: "CONDITION_APPLIED";
|
|
56
|
+
targetId: string;
|
|
57
|
+
condition: Condition;
|
|
58
|
+
}
|
|
59
|
+
export interface ConditionRemovedEvent {
|
|
60
|
+
type: "CONDITION_REMOVED";
|
|
61
|
+
targetId: string;
|
|
62
|
+
conditionId: string;
|
|
63
|
+
}
|
|
64
|
+
export interface FlagSetEvent {
|
|
65
|
+
type: "FLAG_SET";
|
|
66
|
+
flag: string;
|
|
67
|
+
value: boolean;
|
|
68
|
+
}
|
|
69
|
+
export interface RNGAdvancedEvent {
|
|
70
|
+
type: "RNG_ADVANCED";
|
|
71
|
+
cursor: number;
|
|
72
|
+
}
|
|
73
|
+
export interface ErrorEvent {
|
|
74
|
+
type: "ERROR";
|
|
75
|
+
message: string;
|
|
76
|
+
recoverable: boolean;
|
|
77
|
+
}
|
|
78
|
+
export type EventType = GameEvent["type"];
|
|
79
|
+
/**
|
|
80
|
+
* Type guard to check event type
|
|
81
|
+
*/
|
|
82
|
+
export declare function isEventType<T extends EventType>(event: GameEvent, type: T): event is Extract<GameEvent, {
|
|
83
|
+
type: T;
|
|
84
|
+
}>;
|
|
85
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/game/events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,SAAS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game types - re-export all
|
|
3
|
+
*/
|
|
4
|
+
export * from "./abilities.js";
|
|
5
|
+
export * from "./conditions.js";
|
|
6
|
+
export * from "./character.js";
|
|
7
|
+
export * from "./dice.js";
|
|
8
|
+
export * from "./combat.js";
|
|
9
|
+
export * from "./actions.js";
|
|
10
|
+
export * from "./events.js";
|
|
11
|
+
export * from "./state.js";
|
|
12
|
+
export * from "./player.js";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/game/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Game types - re-export all
|
|
3
|
+
*/
|
|
4
|
+
export * from "./abilities.js";
|
|
5
|
+
export * from "./conditions.js";
|
|
6
|
+
export * from "./character.js";
|
|
7
|
+
export * from "./dice.js";
|
|
8
|
+
export * from "./combat.js";
|
|
9
|
+
export * from "./actions.js";
|
|
10
|
+
export * from "./events.js";
|
|
11
|
+
export * from "./state.js";
|
|
12
|
+
export * from "./player.js";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/game/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Player/Actor types for multi-player support
|
|
3
|
+
*
|
|
4
|
+
* Key insight: Separate players (who takes turns) from characters (game mechanics).
|
|
5
|
+
* A player controls a character, but they are distinct entities.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* AI playstyle persona for AI-controlled players
|
|
9
|
+
*/
|
|
10
|
+
export type AIPlaystyle = "tactical" | "roleplay" | "cautious" | "reckless";
|
|
11
|
+
/**
|
|
12
|
+
* AI persona configuration for AI-controlled players
|
|
13
|
+
*/
|
|
14
|
+
export interface PlayerAIPersona {
|
|
15
|
+
/** How the AI approaches decisions */
|
|
16
|
+
playstyle: AIPlaystyle;
|
|
17
|
+
/** How much the AI talks in-character (0-10) */
|
|
18
|
+
talkativeness: number;
|
|
19
|
+
/** Specific personality notes for this AI player */
|
|
20
|
+
personalityNotes?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Player role in the session
|
|
24
|
+
*/
|
|
25
|
+
export type PlayerRole = "gm" | "pc" | "spectator";
|
|
26
|
+
/**
|
|
27
|
+
* Whether the player is human or AI controlled
|
|
28
|
+
*/
|
|
29
|
+
export type PlayerControlType = "human" | "ai";
|
|
30
|
+
/**
|
|
31
|
+
* Player status in the session
|
|
32
|
+
*/
|
|
33
|
+
export type PlayerStatus = "active" | "inactive" | "waiting_for_input";
|
|
34
|
+
/**
|
|
35
|
+
* Pending action for human players awaiting input
|
|
36
|
+
*/
|
|
37
|
+
export interface PendingPlayerAction {
|
|
38
|
+
/** What we're asking the player to decide */
|
|
39
|
+
prompt: string;
|
|
40
|
+
/** Optional preset choices */
|
|
41
|
+
choices?: string[];
|
|
42
|
+
/** When this action was requested */
|
|
43
|
+
requestedAt: string;
|
|
44
|
+
/** Context for the decision (scene, situation, etc.) */
|
|
45
|
+
context?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Player/Actor in the session
|
|
49
|
+
*
|
|
50
|
+
* Represents someone (human or AI) who takes actions in the game.
|
|
51
|
+
* Players control characters, but the mapping is separate.
|
|
52
|
+
*/
|
|
53
|
+
export interface Player {
|
|
54
|
+
/** Unique player ID (e.g., "player-1", "ai-rogue") */
|
|
55
|
+
id: string;
|
|
56
|
+
/** Display name for this player */
|
|
57
|
+
name: string;
|
|
58
|
+
/** Role in the game */
|
|
59
|
+
role: PlayerRole;
|
|
60
|
+
/** Human or AI controlled */
|
|
61
|
+
controlType: PlayerControlType;
|
|
62
|
+
/** Linked character ID (for PC players) */
|
|
63
|
+
characterId?: string;
|
|
64
|
+
/** Current status */
|
|
65
|
+
status: PlayerStatus;
|
|
66
|
+
/** AI configuration (only for AI players) */
|
|
67
|
+
aiPersona?: PlayerAIPersona;
|
|
68
|
+
/** Pending action awaiting input (only for human players) */
|
|
69
|
+
pendingAction?: PendingPlayerAction;
|
|
70
|
+
/** When this player joined */
|
|
71
|
+
joinedAt: string;
|
|
72
|
+
/** Last activity timestamp */
|
|
73
|
+
lastActiveAt: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Turn coordination strategy
|
|
77
|
+
*/
|
|
78
|
+
export type TurnStrategy = "round_robin" | "gm_directed" | "free_form";
|
|
79
|
+
/**
|
|
80
|
+
* Turn state for coordinated gameplay
|
|
81
|
+
*/
|
|
82
|
+
export interface TurnState {
|
|
83
|
+
/** How turns are managed */
|
|
84
|
+
strategy: TurnStrategy;
|
|
85
|
+
/** Currently active player ID (null if no one's turn) */
|
|
86
|
+
currentPlayerId: string | null;
|
|
87
|
+
/** Turn order (player IDs) for round_robin */
|
|
88
|
+
turnOrder: string[];
|
|
89
|
+
/** Current index in turnOrder */
|
|
90
|
+
turnIndex: number;
|
|
91
|
+
/** Current round number (increments when all players have acted) */
|
|
92
|
+
round: number;
|
|
93
|
+
/** Whether we're waiting for human input */
|
|
94
|
+
waitingForHumanInput: boolean;
|
|
95
|
+
/** When turns started */
|
|
96
|
+
startedAt: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Create default AI persona
|
|
100
|
+
*/
|
|
101
|
+
export declare function createDefaultAIPersona(playstyle?: AIPlaystyle): PlayerAIPersona;
|
|
102
|
+
/**
|
|
103
|
+
* Create a new player
|
|
104
|
+
*/
|
|
105
|
+
export declare function createPlayer(id: string, name: string, role: PlayerRole, controlType: PlayerControlType): Player;
|
|
106
|
+
/**
|
|
107
|
+
* Create initial turn state
|
|
108
|
+
*/
|
|
109
|
+
export declare function createTurnState(strategy: TurnStrategy, playerIds: string[]): TurnState;
|
|
110
|
+
//# sourceMappingURL=player.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"player.d.ts","sourceRoot":"","sources":["../../src/game/player.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,SAAS,EAAE,WAAW,CAAC;IACvB,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,WAAW,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,IAAI,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,mBAAmB,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,EA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AI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,EAChB,WAAW,EAAE,iBAAiB,GAC7B,MAAM,CAWR;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,MAAM,EAAE,GAClB,SAAS,CAUX"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Player/Actor types for multi-player support
|
|
3
|
+
*
|
|
4
|
+
* Key insight: Separate players (who takes turns) from characters (game mechanics).
|
|
5
|
+
* A player controls a character, but they are distinct entities.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Create default AI persona
|
|
9
|
+
*/
|
|
10
|
+
export function createDefaultAIPersona(playstyle = "tactical") {
|
|
11
|
+
return {
|
|
12
|
+
playstyle,
|
|
13
|
+
talkativeness: 5,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Create a new player
|
|
18
|
+
*/
|
|
19
|
+
export function createPlayer(id, name, role, controlType) {
|
|
20
|
+
const now = new Date().toISOString();
|
|
21
|
+
return {
|
|
22
|
+
id,
|
|
23
|
+
name,
|
|
24
|
+
role,
|
|
25
|
+
controlType,
|
|
26
|
+
status: "active",
|
|
27
|
+
joinedAt: now,
|
|
28
|
+
lastActiveAt: now,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create initial turn state
|
|
33
|
+
*/
|
|
34
|
+
export function createTurnState(strategy, playerIds) {
|
|
35
|
+
return {
|
|
36
|
+
strategy,
|
|
37
|
+
currentPlayerId: playerIds.length > 0 ? playerIds[0] : null,
|
|
38
|
+
turnOrder: playerIds,
|
|
39
|
+
turnIndex: 0,
|
|
40
|
+
round: 1,
|
|
41
|
+
waitingForHumanInput: false,
|
|
42
|
+
startedAt: new Date().toISOString(),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=player.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"player.js","sourceRoot":"","sources":["../../src/game/player.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsGH;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,YAAyB,UAAU;IACxE,OAAO;QACL,SAAS;QACT,aAAa,EAAE,CAAC;KACjB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,EAAU,EACV,IAAY,EACZ,IAAgB,EAChB,WAA8B;IAE9B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,OAAO;QACL,EAAE;QACF,IAAI;QACJ,IAAI;QACJ,WAAW;QACX,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,GAAG;QACb,YAAY,EAAE,GAAG;KAClB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAsB,EACtB,SAAmB;IAEnB,OAAO;QACL,QAAQ;QACR,eAAe,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;QAC3D,SAAS,EAAE,SAAS;QACpB,SAAS,EAAE,CAAC;QACZ,KAAK,EAAE,CAAC;QACR,oBAAoB,EAAE,KAAK;QAC3B,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine state types
|
|
3
|
+
*/
|
|
4
|
+
import type { Character, NPC, Enemy } from "./character.js";
|
|
5
|
+
import type { RNGState } from "./dice.js";
|
|
6
|
+
import type { CombatState } from "./combat.js";
|
|
7
|
+
import type { GameEvent } from "./events.js";
|
|
8
|
+
/**
|
|
9
|
+
* Game phase
|
|
10
|
+
*/
|
|
11
|
+
export type GamePhase = {
|
|
12
|
+
mode: "EXPLORATION";
|
|
13
|
+
} | {
|
|
14
|
+
mode: "DIALOGUE";
|
|
15
|
+
npcId: string;
|
|
16
|
+
} | {
|
|
17
|
+
mode: "COMBAT";
|
|
18
|
+
turnIndex: number;
|
|
19
|
+
} | {
|
|
20
|
+
mode: "REST";
|
|
21
|
+
} | {
|
|
22
|
+
mode: "SCENE_TRANSITION";
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Game time tracking
|
|
26
|
+
*/
|
|
27
|
+
export interface GameTime {
|
|
28
|
+
day: number;
|
|
29
|
+
hour: number;
|
|
30
|
+
minute: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A deadline/countdown in the game
|
|
34
|
+
*/
|
|
35
|
+
export interface Deadline {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
description: string;
|
|
39
|
+
/** When this deadline expires */
|
|
40
|
+
expiresAt: GameTime;
|
|
41
|
+
/** Optional flag to set when deadline expires */
|
|
42
|
+
onExpireFlag?: string;
|
|
43
|
+
/** Whether to warn when approaching (within 1 hour) */
|
|
44
|
+
warnOnApproach: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Pure game state managed by the engine
|
|
48
|
+
* This is a subset of SessionState - just the mechanics
|
|
49
|
+
*/
|
|
50
|
+
export interface EngineState {
|
|
51
|
+
sessionId: string;
|
|
52
|
+
rng: RNGState;
|
|
53
|
+
/** Action sequence number */
|
|
54
|
+
seq: number;
|
|
55
|
+
party: Character[];
|
|
56
|
+
npcs: NPC[];
|
|
57
|
+
enemies: Enemy[];
|
|
58
|
+
currentLocationId: string;
|
|
59
|
+
phase: GamePhase;
|
|
60
|
+
combat: CombatState | null;
|
|
61
|
+
worldFlags: string[];
|
|
62
|
+
questFlags: Record<string, boolean>;
|
|
63
|
+
gameTime: GameTime;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Result of dispatching an action
|
|
67
|
+
*/
|
|
68
|
+
export interface DispatchResult {
|
|
69
|
+
nextState: EngineState;
|
|
70
|
+
events: GameEvent[];
|
|
71
|
+
requiresNarration: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Create initial game time (dawn of day 1)
|
|
75
|
+
*/
|
|
76
|
+
export declare function createInitialGameTime(): GameTime;
|
|
77
|
+
/**
|
|
78
|
+
* Advance game time
|
|
79
|
+
*/
|
|
80
|
+
export declare function advanceGameTime(time: GameTime, minutes: number): GameTime;
|
|
81
|
+
/**
|
|
82
|
+
* Convert GameTime to total minutes (for comparison)
|
|
83
|
+
*/
|
|
84
|
+
export declare function gameTimeToMinutes(time: GameTime): number;
|
|
85
|
+
/**
|
|
86
|
+
* Compare two game times
|
|
87
|
+
* Returns negative if a < b, 0 if equal, positive if a > b
|
|
88
|
+
*/
|
|
89
|
+
export declare function compareGameTime(a: GameTime, b: GameTime): number;
|
|
90
|
+
/**
|
|
91
|
+
* Calculate minutes remaining until a deadline
|
|
92
|
+
* Returns negative if deadline has passed
|
|
93
|
+
*/
|
|
94
|
+
export declare function minutesUntil(current: GameTime, target: GameTime): number;
|
|
95
|
+
/**
|
|
96
|
+
* Format minutes as human-readable duration (e.g., "2 hours 30 minutes")
|
|
97
|
+
*/
|
|
98
|
+
export declare function formatDuration(minutes: number): string;
|
|
99
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/game/state.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB;I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AW,CAAC;IACvB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,QAAQ,CAEhD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,QAAQ,CAUzE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAExD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,GAAG,MAAM,CAEhE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,MAAM,CAExE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAYtD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine state types
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Create initial game time (dawn of day 1)
|
|
6
|
+
*/
|
|
7
|
+
export function createInitialGameTime() {
|
|
8
|
+
return { day: 1, hour: 6, minute: 0 };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Advance game time
|
|
12
|
+
*/
|
|
13
|
+
export function advanceGameTime(time, minutes) {
|
|
14
|
+
let totalMinutes = time.hour * 60 + time.minute + minutes;
|
|
15
|
+
let days = Math.floor(totalMinutes / (24 * 60));
|
|
16
|
+
totalMinutes = totalMinutes % (24 * 60);
|
|
17
|
+
return {
|
|
18
|
+
day: time.day + days,
|
|
19
|
+
hour: Math.floor(totalMinutes / 60),
|
|
20
|
+
minute: totalMinutes % 60,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Convert GameTime to total minutes (for comparison)
|
|
25
|
+
*/
|
|
26
|
+
export function gameTimeToMinutes(time) {
|
|
27
|
+
return (time.day - 1) * 24 * 60 + time.hour * 60 + time.minute;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Compare two game times
|
|
31
|
+
* Returns negative if a < b, 0 if equal, positive if a > b
|
|
32
|
+
*/
|
|
33
|
+
export function compareGameTime(a, b) {
|
|
34
|
+
return gameTimeToMinutes(a) - gameTimeToMinutes(b);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Calculate minutes remaining until a deadline
|
|
38
|
+
* Returns negative if deadline has passed
|
|
39
|
+
*/
|
|
40
|
+
export function minutesUntil(current, target) {
|
|
41
|
+
return gameTimeToMinutes(target) - gameTimeToMinutes(current);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Format minutes as human-readable duration (e.g., "2 hours 30 minutes")
|
|
45
|
+
*/
|
|
46
|
+
export function formatDuration(minutes) {
|
|
47
|
+
if (minutes < 0)
|
|
48
|
+
return "expired";
|
|
49
|
+
if (minutes === 0)
|
|
50
|
+
return "now";
|
|
51
|
+
const hours = Math.floor(minutes / 60);
|
|
52
|
+
const mins = minutes % 60;
|
|
53
|
+
const parts = [];
|
|
54
|
+
if (hours > 0)
|
|
55
|
+
parts.push(`${hours} hour${hours !== 1 ? "s" : ""}`);
|
|
56
|
+
if (mins > 0)
|
|
57
|
+
parts.push(`${mins} minute${mins !== 1 ? "s" : ""}`);
|
|
58
|
+
return parts.join(" ");
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/game/state.ts"],"names":[],"mappings":"AAAA;;GAEG;AA2EH;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;AACxC,CAAC;AAED;;GAEG;AACH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AC,CAAC;IACvC,MAAM,IAAI,GAAG,OAAO,GAAG,EAAE,CAAC;IAE1B,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,KAAK,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACpE,IAAI,IAAI,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,UAAU,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEnE,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mythxengine/types
|
|
3
|
+
*
|
|
4
|
+
* Core type definitions for the RPG MCP server
|
|
5
|
+
*/
|
|
6
|
+
export * from "./game/index.js";
|
|
7
|
+
export * from "./rules/index.js";
|
|
8
|
+
export * from "./session/index.js";
|
|
9
|
+
export * from "./tools/contract.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,iBAAiB,CAAC;AAGhC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mythxengine/types
|
|
3
|
+
*
|
|
4
|
+
* Core type definitions for the RPG MCP server
|
|
5
|
+
*/
|
|
6
|
+
// Game types
|
|
7
|
+
export * from "./game/index.js";
|
|
8
|
+
// Rules configuration types
|
|
9
|
+
export * from "./rules/index.js";
|
|
10
|
+
// Session types
|
|
11
|
+
export * from "./session/index.js";
|
|
12
|
+
// Tool contract types
|
|
13
|
+
export * from "./tools/contract.js";
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,aAAa;AACb,cAAc,iBAAiB,CAAC;AAEhC,4BAA4B;AAC5B,cAAc,kBAAkB,CAAC;AAEjC,gBAAgB;AAChB,cAAc,oBAAoB,CAAC;AAEnC,sBAAsB;AACtB,cAAc,qBAAqB,CAAC"}
|