@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,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ability Configuration
|
|
3
|
+
*
|
|
4
|
+
* Allows world packs to define custom abilities or override base abilities.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* How an ability is used in the system
|
|
8
|
+
*/
|
|
9
|
+
export interface AbilityUsage {
|
|
10
|
+
/** Can be used for melee attacks */
|
|
11
|
+
meleeAttack?: boolean;
|
|
12
|
+
/** Can be used for ranged attacks */
|
|
13
|
+
rangedAttack?: boolean;
|
|
14
|
+
/** Used in defense calculation */
|
|
15
|
+
defense?: boolean;
|
|
16
|
+
/** Added to damage rolls */
|
|
17
|
+
damage?: boolean;
|
|
18
|
+
/** Contributes to HP calculation */
|
|
19
|
+
hp?: boolean;
|
|
20
|
+
/** Used for initiative */
|
|
21
|
+
initiative?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Definition of a single ability
|
|
25
|
+
*/
|
|
26
|
+
export interface AbilityDefinition {
|
|
27
|
+
/** Unique identifier (e.g., "STR", "STRESS", "SANITY") */
|
|
28
|
+
id: string;
|
|
29
|
+
/** Display name (e.g., "Strength", "Stress", "Sanity") */
|
|
30
|
+
name: string;
|
|
31
|
+
/** Description of what this ability represents */
|
|
32
|
+
description: string;
|
|
33
|
+
/** Minimum allowed value */
|
|
34
|
+
minValue: number;
|
|
35
|
+
/** Maximum allowed value */
|
|
36
|
+
maxValue: number;
|
|
37
|
+
/** Default starting value for new characters */
|
|
38
|
+
defaultValue: number;
|
|
39
|
+
/** How this ability is used in the system */
|
|
40
|
+
usage?: AbilityUsage;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Configuration for abilities in a world pack
|
|
44
|
+
*/
|
|
45
|
+
export interface AbilitiesConfig {
|
|
46
|
+
/**
|
|
47
|
+
* Replace all base abilities with these.
|
|
48
|
+
* Use this for systems with completely different abilities
|
|
49
|
+
* (e.g., Mothership's STR/SPD/INT/CMB instead of STR/AGI/WIT/CON)
|
|
50
|
+
*/
|
|
51
|
+
replace?: AbilityDefinition[];
|
|
52
|
+
/**
|
|
53
|
+
* Add these abilities to the base set.
|
|
54
|
+
* Use this to add tracking abilities like STRESS, SANITY, CORRUPTION
|
|
55
|
+
* while keeping the base 4.
|
|
56
|
+
*/
|
|
57
|
+
add?: AbilityDefinition[];
|
|
58
|
+
/**
|
|
59
|
+
* Override specific properties of base abilities.
|
|
60
|
+
* Use this to change ranges or descriptions without full replacement.
|
|
61
|
+
*/
|
|
62
|
+
override?: {
|
|
63
|
+
[abilityId: string]: Partial<Omit<AbilityDefinition, "id">>;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Base ability definitions (the defaults)
|
|
68
|
+
*/
|
|
69
|
+
export declare const BASE_ABILITIES: AbilityDefinition[];
|
|
70
|
+
/**
|
|
71
|
+
* Get the effective abilities after applying configuration
|
|
72
|
+
*/
|
|
73
|
+
export declare function resolveAbilities(config?: AbilitiesConfig): AbilityDefinition[];
|
|
74
|
+
/**
|
|
75
|
+
* Create an abilities record with default values
|
|
76
|
+
*/
|
|
77
|
+
export declare function createDefaultAbilitiesRecord(definitions: AbilityDefinition[]): Record<string, number>;
|
|
78
|
+
/**
|
|
79
|
+
* Validate an ability value against its definition
|
|
80
|
+
*/
|
|
81
|
+
export declare function isValidAbilityValueForDefinition(value: number, definition: AbilityDefinition): boolean;
|
|
82
|
+
//# sourceMappingURL=abilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abilities.d.ts","sourceRoot":"","sources":["../../src/rules/abilities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,oCAAoC;IACpC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,qCAAqC;IACrC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,kCAAkC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,oCAAoC;IACpC,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,0BAA0B;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,0DAA0D;IAC1D,EAAE,EAAE,MAAM,CAAC;IACX,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,YAAY,EAAE,MAAM,CAAC;IACrB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,OAAO,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAE9B;;;;OAIG;IACH,GAAG,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAE1B;;;OAGG;IACH,QAAQ,CAAC,EAAE;QACT,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC,CAAC;KAC7D,CAAC;CACH;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,iBAAiB,EAqC7C,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,iBAAiB,EAAE,CA8B9E;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,iBAAiB,EAAE,GAC/B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMxB;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,iBAAiB,GAC5B,OAAO,CAMT"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ability Configuration
|
|
3
|
+
*
|
|
4
|
+
* Allows world packs to define custom abilities or override base abilities.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Base ability definitions (the defaults)
|
|
8
|
+
*/
|
|
9
|
+
export const BASE_ABILITIES = [
|
|
10
|
+
{
|
|
11
|
+
id: "STR",
|
|
12
|
+
name: "Strength",
|
|
13
|
+
description: "Physical power, melee damage, carrying capacity",
|
|
14
|
+
minValue: -3,
|
|
15
|
+
maxValue: 3,
|
|
16
|
+
defaultValue: 0,
|
|
17
|
+
usage: { meleeAttack: true, damage: true },
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: "AGI",
|
|
21
|
+
name: "Agility",
|
|
22
|
+
description: "Speed, reflexes, ranged attacks, defense",
|
|
23
|
+
minValue: -3,
|
|
24
|
+
maxValue: 3,
|
|
25
|
+
defaultValue: 0,
|
|
26
|
+
usage: { rangedAttack: true, defense: true, initiative: true },
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "WIT",
|
|
30
|
+
name: "Wit",
|
|
31
|
+
description: "Intelligence, perception, social skills, magic",
|
|
32
|
+
minValue: -3,
|
|
33
|
+
maxValue: 3,
|
|
34
|
+
defaultValue: 0,
|
|
35
|
+
usage: {},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: "CON",
|
|
39
|
+
name: "Constitution",
|
|
40
|
+
description: "Toughness, HP, endurance, resistance",
|
|
41
|
+
minValue: -3,
|
|
42
|
+
maxValue: 3,
|
|
43
|
+
defaultValue: 0,
|
|
44
|
+
usage: { hp: true },
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* Get the effective abilities after applying configuration
|
|
49
|
+
*/
|
|
50
|
+
export function resolveAbilities(config) {
|
|
51
|
+
if (!config) {
|
|
52
|
+
return BASE_ABILITIES;
|
|
53
|
+
}
|
|
54
|
+
// If replacing, start with replacement set
|
|
55
|
+
if (config.replace) {
|
|
56
|
+
return config.replace;
|
|
57
|
+
}
|
|
58
|
+
// Start with base abilities
|
|
59
|
+
let abilities = [...BASE_ABILITIES];
|
|
60
|
+
// Apply overrides
|
|
61
|
+
if (config.override) {
|
|
62
|
+
abilities = abilities.map((ability) => {
|
|
63
|
+
const override = config.override?.[ability.id];
|
|
64
|
+
if (override) {
|
|
65
|
+
return { ...ability, ...override };
|
|
66
|
+
}
|
|
67
|
+
return ability;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
// Add new abilities
|
|
71
|
+
if (config.add) {
|
|
72
|
+
abilities = [...abilities, ...config.add];
|
|
73
|
+
}
|
|
74
|
+
return abilities;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create an abilities record with default values
|
|
78
|
+
*/
|
|
79
|
+
export function createDefaultAbilitiesRecord(definitions) {
|
|
80
|
+
const record = {};
|
|
81
|
+
for (const def of definitions) {
|
|
82
|
+
record[def.id] = def.defaultValue;
|
|
83
|
+
}
|
|
84
|
+
return record;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Validate an ability value against its definition
|
|
88
|
+
*/
|
|
89
|
+
export function isValidAbilityValueForDefinition(value, definition) {
|
|
90
|
+
return (Number.isInteger(value) &&
|
|
91
|
+
value >= definition.minValue &&
|
|
92
|
+
value <= definition.maxValue);
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=abilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abilities.js","sourceRoot":"","sources":["../../src/rules/abilities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmEH;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAwB;IACjD;QACE,EAAE,EAAE,KAAK;QACT,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,iDAAiD;QAC9D,QAAQ,EAAE,CAAC,CAAC;QACZ,QAAQ,EAAE,CAAC;QACX,YAAY,EAAE,CAAC;QACf,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;KAC3C;IACD;QACE,EAAE,EAAE,KAAK;QACT,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,0CAA0C;QACvD,QAAQ,EAAE,CAAC,CAAC;QACZ,QAAQ,EAAE,CAAC;QACX,YAAY,EAAE,CAAC;QACf,KAAK,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EA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CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAC1C,WAAgC;IAEhC,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC;IACpC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gCAAgC,CAC9C,KAAa,EACb,UAA6B;IAE7B,OAAO,CACL,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC;QACvB,KAAK,IAAI,UAAU,CAAC,QAAQ;QAC5B,KAAK,IAAI,UAAU,CAAC,QAAQ,CAC7B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Test Configuration
|
|
3
|
+
*
|
|
4
|
+
* Allows world packs to define genre-specific test types like
|
|
5
|
+
* panic rolls, sanity checks, corruption tests, etc.
|
|
6
|
+
*/
|
|
7
|
+
import type { Effect } from "../game/conditions.js";
|
|
8
|
+
/**
|
|
9
|
+
* Roll configuration for a custom test
|
|
10
|
+
*/
|
|
11
|
+
export interface CustomTestRoll {
|
|
12
|
+
/** Dice expression to roll (e.g., "d20", "2d10", "d100") */
|
|
13
|
+
dice: string;
|
|
14
|
+
/** Ability modifier to add to the roll (roll-over systems) */
|
|
15
|
+
ability?: string;
|
|
16
|
+
/** For roll-under systems: ability to roll under */
|
|
17
|
+
underAbility?: string;
|
|
18
|
+
/** Fixed difficulty target (for roll-over) */
|
|
19
|
+
difficulty?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Formula for dynamic difficulty.
|
|
22
|
+
* Variables: any ability ID in braces (e.g., "{STRESS}", "{SAN}")
|
|
23
|
+
* Operators: +, -, *, /
|
|
24
|
+
* Example: "{STRESS} * 2" or "20 - {WIT}"
|
|
25
|
+
*/
|
|
26
|
+
difficultyFormula?: string;
|
|
27
|
+
/** Skill to add bonus from (if applicable) */
|
|
28
|
+
skill?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A single entry in an outcome table
|
|
32
|
+
*/
|
|
33
|
+
export interface TableEntry {
|
|
34
|
+
/** Roll range that triggers this entry [min, max] inclusive */
|
|
35
|
+
range: [number, number];
|
|
36
|
+
/** Description of what happens */
|
|
37
|
+
description: string;
|
|
38
|
+
/** Effects to apply */
|
|
39
|
+
effects?: Effect[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A table of outcomes rolled on after the test
|
|
43
|
+
*/
|
|
44
|
+
export interface OutcomeTable {
|
|
45
|
+
/** Dice to roll on the table */
|
|
46
|
+
dice: string;
|
|
47
|
+
/** Ability to add to table roll (optional) */
|
|
48
|
+
addAbility?: string;
|
|
49
|
+
/** Table entries */
|
|
50
|
+
entries: TableEntry[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Outcome definition for a test result
|
|
54
|
+
*/
|
|
55
|
+
export interface CustomTestOutcome {
|
|
56
|
+
/** Description of what happens */
|
|
57
|
+
description: string;
|
|
58
|
+
/** Effects to apply immediately */
|
|
59
|
+
effects?: Effect[];
|
|
60
|
+
/** Table to roll on (for complex outcomes like panic tables) */
|
|
61
|
+
table?: OutcomeTable;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* When this custom test should be triggered
|
|
65
|
+
*/
|
|
66
|
+
export type CustomTestTrigger = "manual" | "combat_start" | "combat_end" | "take_damage" | "critical_failure" | "witness_death" | "witness_horror" | "ability_threshold" | "rest" | "scene_start" | string;
|
|
67
|
+
/**
|
|
68
|
+
* Threshold trigger configuration
|
|
69
|
+
*/
|
|
70
|
+
export interface ThresholdTrigger {
|
|
71
|
+
/** Ability to monitor */
|
|
72
|
+
ability: string;
|
|
73
|
+
/** Threshold value */
|
|
74
|
+
threshold: number;
|
|
75
|
+
/** Trigger when going above or below */
|
|
76
|
+
direction: "above" | "below" | "equals";
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Full definition of a custom test type
|
|
80
|
+
*/
|
|
81
|
+
export interface CustomTestDefinition {
|
|
82
|
+
/** Unique identifier (e.g., "panic", "sanity_check") */
|
|
83
|
+
id: string;
|
|
84
|
+
/** Display name (e.g., "Panic Check") */
|
|
85
|
+
name: string;
|
|
86
|
+
/** Description of when and why this test is used */
|
|
87
|
+
description: string;
|
|
88
|
+
/** What triggers this test (can be multiple) */
|
|
89
|
+
triggers: CustomTestTrigger[];
|
|
90
|
+
/** Threshold trigger configuration (if using ability_threshold trigger) */
|
|
91
|
+
thresholdTrigger?: ThresholdTrigger;
|
|
92
|
+
/** The roll mechanics */
|
|
93
|
+
roll: CustomTestRoll;
|
|
94
|
+
/** Results by outcome type */
|
|
95
|
+
outcomes: {
|
|
96
|
+
/** What happens on critical success (optional) */
|
|
97
|
+
criticalSuccess?: CustomTestOutcome;
|
|
98
|
+
/** What happens on success */
|
|
99
|
+
success?: CustomTestOutcome;
|
|
100
|
+
/** What happens on failure */
|
|
101
|
+
failure?: CustomTestOutcome;
|
|
102
|
+
/** What happens on critical failure (optional) */
|
|
103
|
+
criticalFailure?: CustomTestOutcome;
|
|
104
|
+
};
|
|
105
|
+
/** Whether this test can be retried (default: false) */
|
|
106
|
+
retryable?: boolean;
|
|
107
|
+
/** Cooldown in game minutes before this test can trigger again */
|
|
108
|
+
cooldownMinutes?: number;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Configuration for custom tests in a world pack
|
|
112
|
+
*/
|
|
113
|
+
export interface CustomTestsConfig {
|
|
114
|
+
/** Custom test definitions */
|
|
115
|
+
tests: CustomTestDefinition[];
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Result of resolving a custom test
|
|
119
|
+
*/
|
|
120
|
+
export interface CustomTestResult {
|
|
121
|
+
/** The test definition that was used */
|
|
122
|
+
testId: string;
|
|
123
|
+
/** The roll result */
|
|
124
|
+
roll: {
|
|
125
|
+
dice: string;
|
|
126
|
+
natural: number;
|
|
127
|
+
modifier: number;
|
|
128
|
+
total: number;
|
|
129
|
+
};
|
|
130
|
+
/** Target to beat (for roll-over) or stay under (for roll-under) */
|
|
131
|
+
target: number;
|
|
132
|
+
/** Whether the test succeeded */
|
|
133
|
+
success: boolean;
|
|
134
|
+
/** Whether this was a critical */
|
|
135
|
+
critical: boolean;
|
|
136
|
+
/** The outcome that applies */
|
|
137
|
+
outcome: CustomTestOutcome;
|
|
138
|
+
/** If a table was rolled, the table result */
|
|
139
|
+
tableRoll?: {
|
|
140
|
+
dice: string;
|
|
141
|
+
roll: number;
|
|
142
|
+
entry: TableEntry;
|
|
143
|
+
};
|
|
144
|
+
/** Effects to apply */
|
|
145
|
+
effects: Effect[];
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Find a custom test by ID
|
|
149
|
+
*/
|
|
150
|
+
export declare function findCustomTest(tests: CustomTestDefinition[], id: string): CustomTestDefinition | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* Find custom tests that match a trigger
|
|
153
|
+
*/
|
|
154
|
+
export declare function findTestsByTrigger(tests: CustomTestDefinition[], trigger: CustomTestTrigger): CustomTestDefinition[];
|
|
155
|
+
/**
|
|
156
|
+
* Parse a simple formula with ability substitutions
|
|
157
|
+
* Returns a function that takes ability values and returns the result
|
|
158
|
+
*
|
|
159
|
+
* Supported: addition, subtraction, multiplication, division, parentheses
|
|
160
|
+
* Variables: {ABILITY_ID} format
|
|
161
|
+
*/
|
|
162
|
+
export declare function parseFormula(formula: string): (abilities: Record<string, number>) => number;
|
|
163
|
+
//# sourceMappingURL=custom-tests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-tests.d.ts","sourceRoot":"","sources":["../../src/rules/custom-tests.ts"],"names":[],"mappings":"AAAA;;;;;GAKG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AAM,CAAC;IACf,iCAAiC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,kCAAkC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,+BAA+B;IAC/B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,8CAA8C;IAC9C,SAAS,CAAC,EAAE;QACV,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,UAAU,CAAC;KACnB,CAAC;IACF,uBAAuB;IACvB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,oBAAoB,EAAE,EAC7B,EAAE,EAAE,MAAM,GACT,oBAAoB,GAAG,SAAS,CAElC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,oBAAoB,EAAE,EAC7B,OAAO,EAAE,iBAAiB,GACzB,oBAAoB,EAAE,CAExB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,GACd,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAkB/C"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Test Configuration
|
|
3
|
+
*
|
|
4
|
+
* Allows world packs to define genre-specific test types like
|
|
5
|
+
* panic rolls, sanity checks, corruption tests, etc.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Find a custom test by ID
|
|
9
|
+
*/
|
|
10
|
+
export function findCustomTest(tests, id) {
|
|
11
|
+
return tests.find((t) => t.id === id);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Find custom tests that match a trigger
|
|
15
|
+
*/
|
|
16
|
+
export function findTestsByTrigger(tests, trigger) {
|
|
17
|
+
return tests.filter((t) => t.triggers.includes(trigger));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Parse a simple formula with ability substitutions
|
|
21
|
+
* Returns a function that takes ability values and returns the result
|
|
22
|
+
*
|
|
23
|
+
* Supported: addition, subtraction, multiplication, division, parentheses
|
|
24
|
+
* Variables: {ABILITY_ID} format
|
|
25
|
+
*/
|
|
26
|
+
export function parseFormula(formula) {
|
|
27
|
+
return (abilities) => {
|
|
28
|
+
// Replace ability references with values using split/join for safety
|
|
29
|
+
// (avoids RegExp construction from ability IDs which could cause ReDoS)
|
|
30
|
+
let expr = formula;
|
|
31
|
+
for (const [id, value] of Object.entries(abilities)) {
|
|
32
|
+
expr = expr.split(`{${id}}`).join(String(value));
|
|
33
|
+
}
|
|
34
|
+
// Basic safety check - only allow numbers, operators, parentheses, spaces
|
|
35
|
+
if (!/^[\d+\-*/().\s]+$/.test(expr)) {
|
|
36
|
+
throw new Error(`Invalid formula expression: ${expr}`);
|
|
37
|
+
}
|
|
38
|
+
// Evaluate (safe because we validated the expression)
|
|
39
|
+
// eslint-disable-next-line no-new-func
|
|
40
|
+
return Function(`"use strict"; return (${expr})`)();
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=custom-tests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-tests.js","sourceRoot":"","sources":["../../src/rules/custom-tests.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA8KH;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,KAA6B,EAC7B,EAAU;IAEV,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAA6B,EAC7B,OAA0B;IAE1B,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAe;IAEf,OAAO,CAAC,SAAiC,EAAU,EAAE;QACnD,qEAAqE;QACrE,wEAAwE;QACxE,IAAI,IAAI,GAAG,OAAO,CAAC;QACnB,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YACpD,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACnD,CAAC;QAED,0EAA0E;QAC1E,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,+BAA+B,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;QAED,sDAAsD;QACtD,uCAAuC;QACvC,OAAO,QAAQ,CAAC,yBAAyB,IAAI,GAAG,CAAC,EAAY,CAAC;IAChE,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Difficulty Configuration
|
|
3
|
+
*
|
|
4
|
+
* Allows world packs to define custom difficulty levels.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Definition of a difficulty level
|
|
8
|
+
*/
|
|
9
|
+
export interface DifficultyDefinition {
|
|
10
|
+
/** Unique identifier (e.g., "EASY", "STANDARD", "HARD") */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Display name (e.g., "Easy", "Standard", "Hard") */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Target number to meet or exceed */
|
|
15
|
+
target: number;
|
|
16
|
+
/** Description of when to use this difficulty */
|
|
17
|
+
description?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Configuration for difficulties in a world pack
|
|
21
|
+
*/
|
|
22
|
+
export interface DifficultiesConfig {
|
|
23
|
+
/**
|
|
24
|
+
* Replace all base difficulties with these.
|
|
25
|
+
* Use for systems with different difficulty scales.
|
|
26
|
+
*/
|
|
27
|
+
replace?: DifficultyDefinition[];
|
|
28
|
+
/**
|
|
29
|
+
* Add these difficulties to the base set.
|
|
30
|
+
* Use to add intermediate levels like "MODERATE" or "TRIVIAL".
|
|
31
|
+
*/
|
|
32
|
+
add?: DifficultyDefinition[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Base difficulty definitions (the defaults)
|
|
36
|
+
*/
|
|
37
|
+
export declare const BASE_DIFFICULTIES: DifficultyDefinition[];
|
|
38
|
+
/**
|
|
39
|
+
* Get the effective difficulties after applying configuration
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveDifficulties(config?: DifficultiesConfig): DifficultyDefinition[];
|
|
42
|
+
/**
|
|
43
|
+
* Find a difficulty by ID or target number
|
|
44
|
+
*/
|
|
45
|
+
export declare function findDifficulty(difficulties: DifficultyDefinition[], idOrTarget: string | number): DifficultyDefinition | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Convert difficulty levels to a record for easy lookup
|
|
48
|
+
* @throws Error if duplicate IDs are found
|
|
49
|
+
*/
|
|
50
|
+
export declare function difficultiesToRecord(difficulties: DifficultyDefinition[]): Record<string, number>;
|
|
51
|
+
//# sourceMappingURL=difficulties.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"difficulties.d.ts","sourceRoot":"","sources":["../../src/rules/difficulties.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,2DAA2D;IAC3D,EAAE,EAAE,MAAM,CAAC;IACX,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,OAAO,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAEjC;;;OAGG;IACH,GAAG,CAAC,EAAE,oBAAoB,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,oBAAoB,EAyBnD,CAAC;AAEF;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,CAAC,EAAE,kBAAkB,GAC1B,oBAAoB,EAAE,CAmBxB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,YAAY,EAAE,oBAAoB,EAAE,EACpC,UAAU,EAAE,MAAM,GAAG,MAAM,GAC1B,oBAAoB,GAAG,SAAS,CAOlC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,oBAAoB,EAAE,GACnC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAWxB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Difficulty Configuration
|
|
3
|
+
*
|
|
4
|
+
* Allows world packs to define custom difficulty levels.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Base difficulty definitions (the defaults)
|
|
8
|
+
*/
|
|
9
|
+
export const BASE_DIFFICULTIES = [
|
|
10
|
+
{
|
|
11
|
+
id: "EASY",
|
|
12
|
+
name: "Easy",
|
|
13
|
+
target: 8,
|
|
14
|
+
description: "Simple tasks that most could accomplish",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: "STANDARD",
|
|
18
|
+
name: "Standard",
|
|
19
|
+
target: 12,
|
|
20
|
+
description: "Tasks requiring skill or focus",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "HARD",
|
|
24
|
+
name: "Hard",
|
|
25
|
+
target: 16,
|
|
26
|
+
description: "Challenging tasks requiring expertise",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "EXTREME",
|
|
30
|
+
name: "Extreme",
|
|
31
|
+
target: 20,
|
|
32
|
+
description: "Near-impossible feats requiring mastery and luck",
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
/**
|
|
36
|
+
* Get the effective difficulties after applying configuration
|
|
37
|
+
*/
|
|
38
|
+
export function resolveDifficulties(config) {
|
|
39
|
+
if (!config) {
|
|
40
|
+
return BASE_DIFFICULTIES;
|
|
41
|
+
}
|
|
42
|
+
// If replacing, use replacement set
|
|
43
|
+
if (config.replace) {
|
|
44
|
+
return config.replace;
|
|
45
|
+
}
|
|
46
|
+
// Start with base and add new ones
|
|
47
|
+
let difficulties = [...BASE_DIFFICULTIES];
|
|
48
|
+
if (config.add) {
|
|
49
|
+
difficulties = [...difficulties, ...config.add];
|
|
50
|
+
}
|
|
51
|
+
// Sort by target number
|
|
52
|
+
return difficulties.sort((a, b) => a.target - b.target);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Find a difficulty by ID or target number
|
|
56
|
+
*/
|
|
57
|
+
export function findDifficulty(difficulties, idOrTarget) {
|
|
58
|
+
if (typeof idOrTarget === "string") {
|
|
59
|
+
return difficulties.find((d) => d.id.toUpperCase() === idOrTarget.toUpperCase());
|
|
60
|
+
}
|
|
61
|
+
return difficulties.find((d) => d.target === idOrTarget);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Convert difficulty levels to a record for easy lookup
|
|
65
|
+
* @throws Error if duplicate IDs are found
|
|
66
|
+
*/
|
|
67
|
+
export function difficultiesToRecord(difficulties) {
|
|
68
|
+
const record = {};
|
|
69
|
+
for (const d of difficulties) {
|
|
70
|
+
if (record[d.id] !== undefined) {
|
|
71
|
+
throw new Error(`Duplicate difficulty ID "${d.id}" with targets ${record[d.id]} and ${d.target}`);
|
|
72
|
+
}
|
|
73
|
+
record[d.id] = d.target;
|
|
74
|
+
}
|
|
75
|
+
return record;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=difficulties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"difficulties.js","sourceRoot":"","sources":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EAAE,CAAC;QACnC,OAAO,YAAY,CAAC,IAAI,CACtB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC,WAAW,EAAE,CACvD,CAAC;IACJ,CAAC;IACD,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC;AAC3D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,YAAoC;IAEpC,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,SAAS,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CACb,4BAA4B,CAAC,CAAC,EAAE,kBAAkB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CACjF,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rules Configuration System
|
|
3
|
+
*
|
|
4
|
+
* Allows world packs to extend or override base game rules,
|
|
5
|
+
* enabling genre-specific mechanics while keeping a generic base.
|
|
6
|
+
*
|
|
7
|
+
* @example Basic usage - keep defaults
|
|
8
|
+
* ```ts
|
|
9
|
+
* // No rules config = use all defaults
|
|
10
|
+
* const worldPack = { meta: {...}, archetypes: {...} };
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @example Add stress tracking
|
|
14
|
+
* ```ts
|
|
15
|
+
* const worldPack = {
|
|
16
|
+
* rules: {
|
|
17
|
+
* abilities: {
|
|
18
|
+
* add: [{ id: "STRESS", name: "Stress", minValue: 0, maxValue: 20, defaultValue: 2 }]
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* };
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example Full Mothership-style system
|
|
25
|
+
* ```ts
|
|
26
|
+
* const worldPack = {
|
|
27
|
+
* rules: {
|
|
28
|
+
* abilities: {
|
|
29
|
+
* replace: [
|
|
30
|
+
* { id: "STR", name: "Strength", minValue: 10, maxValue: 80, defaultValue: 30 },
|
|
31
|
+
* { id: "SPD", name: "Speed", minValue: 10, maxValue: 80, defaultValue: 30 },
|
|
32
|
+
* // ... etc
|
|
33
|
+
* ]
|
|
34
|
+
* },
|
|
35
|
+
* mechanics: {
|
|
36
|
+
* rollUnder: { enabled: true, dice: "d100" }
|
|
37
|
+
* },
|
|
38
|
+
* customTests: {
|
|
39
|
+
* tests: [{ id: "panic", name: "Panic Check", ... }]
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* };
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export * from "./abilities.js";
|
|
46
|
+
export * from "./difficulties.js";
|
|
47
|
+
export * from "./mechanics.js";
|
|
48
|
+
export * from "./custom-tests.js";
|
|
49
|
+
import type { AbilitiesConfig, AbilityDefinition } from "./abilities.js";
|
|
50
|
+
import type { DifficultiesConfig, DifficultyDefinition } from "./difficulties.js";
|
|
51
|
+
import type { MechanicsConfig, ResolvedMechanics } from "./mechanics.js";
|
|
52
|
+
import type { CustomTestsConfig, CustomTestDefinition } from "./custom-tests.js";
|
|
53
|
+
/**
|
|
54
|
+
* Complete rules configuration for a world pack
|
|
55
|
+
*/
|
|
56
|
+
export interface WorldRulesConfig {
|
|
57
|
+
/**
|
|
58
|
+
* Override or extend ability definitions.
|
|
59
|
+
* Use to add stress/sanity tracking or replace the base 4 abilities entirely.
|
|
60
|
+
*/
|
|
61
|
+
abilities?: AbilitiesConfig;
|
|
62
|
+
/**
|
|
63
|
+
* Override or extend difficulty levels.
|
|
64
|
+
* Use to add intermediate difficulties or change the scale.
|
|
65
|
+
*/
|
|
66
|
+
difficulties?: DifficultiesConfig;
|
|
67
|
+
/**
|
|
68
|
+
* Override core mechanics like defense formula, criticals, etc.
|
|
69
|
+
* Use for d100 systems, different crit ranges, etc.
|
|
70
|
+
*/
|
|
71
|
+
mechanics?: MechanicsConfig;
|
|
72
|
+
/**
|
|
73
|
+
* Define custom test types like panic checks, sanity rolls, etc.
|
|
74
|
+
* These can be triggered automatically or called manually.
|
|
75
|
+
*/
|
|
76
|
+
customTests?: CustomTestsConfig;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Fully resolved rules with all defaults applied
|
|
80
|
+
*/
|
|
81
|
+
export interface ResolvedRules {
|
|
82
|
+
/** All ability definitions */
|
|
83
|
+
abilities: AbilityDefinition[];
|
|
84
|
+
/** Ability lookup by ID */
|
|
85
|
+
abilityMap: Map<string, AbilityDefinition>;
|
|
86
|
+
/** All difficulty definitions */
|
|
87
|
+
difficulties: DifficultyDefinition[];
|
|
88
|
+
/** Difficulty lookup by ID */
|
|
89
|
+
difficultyMap: Map<string, DifficultyDefinition>;
|
|
90
|
+
/** Resolved mechanics */
|
|
91
|
+
mechanics: ResolvedMechanics;
|
|
92
|
+
/** Custom test definitions */
|
|
93
|
+
customTests: CustomTestDefinition[];
|
|
94
|
+
/** Custom test lookup by ID */
|
|
95
|
+
customTestMap: Map<string, CustomTestDefinition>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Resolve a world's rules configuration into fully resolved rules
|
|
99
|
+
*
|
|
100
|
+
* @param config - The world's rules configuration (or undefined for defaults)
|
|
101
|
+
* @returns Fully resolved rules with all defaults applied
|
|
102
|
+
*/
|
|
103
|
+
export declare function resolveRules(config?: WorldRulesConfig): ResolvedRules;
|
|
104
|
+
/**
|
|
105
|
+
* Get the default rules (no configuration)
|
|
106
|
+
*/
|
|
107
|
+
export declare function getDefaultRules(): ResolvedRules;
|
|
108
|
+
/**
|
|
109
|
+
* Validate that a rules configuration is valid
|
|
110
|
+
*
|
|
111
|
+
* @param config - The configuration to validate
|
|
112
|
+
* @returns Array of validation errors (empty if valid)
|
|
113
|
+
*/
|
|
114
|
+
export declare function validateRulesConfig(config: WorldRulesConfig): string[];
|
|
115
|
+
/**
|
|
116
|
+
* Check if a rules config uses roll-under mechanics
|
|
117
|
+
*/
|
|
118
|
+
export declare function isRollUnderSystem(config?: WorldRulesConfig): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Get ability IDs from a rules config
|
|
121
|
+
*/
|
|
122
|
+
export declare function getAbilityIds(config?: WorldRulesConfig): string[];
|
|
123
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAGH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAGlC,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAMjF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAE5B;;;OAGG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAElC;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAE5B;;;OAGG;IACH,WAAW,CAAC,E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