✨feature: Initial code setup
This commit is contained in:
215
src/types/content.ts
Normal file
215
src/types/content.ts
Normal file
@@ -0,0 +1,215 @@
|
||||
import type { ContentReference, DiceKind, RuleEffect } from "./rules";
|
||||
|
||||
export type TableCategory =
|
||||
| "generic"
|
||||
| "random-list"
|
||||
| "loot"
|
||||
| "level"
|
||||
| "optional"
|
||||
| "town"
|
||||
| "room";
|
||||
|
||||
export type TableEntry = {
|
||||
key: string;
|
||||
min?: number;
|
||||
max?: number;
|
||||
exact?: number;
|
||||
d66?: number;
|
||||
label: string;
|
||||
text?: string;
|
||||
effects?: RuleEffect[];
|
||||
references?: ContentReference[];
|
||||
};
|
||||
|
||||
export type TableDefinition = {
|
||||
id: string;
|
||||
code: string;
|
||||
name: string;
|
||||
category: TableCategory;
|
||||
level?: number;
|
||||
page: number;
|
||||
diceKind: DiceKind;
|
||||
usesModifiedRangesRule?: boolean;
|
||||
entries: TableEntry[];
|
||||
notes?: string[];
|
||||
mvp: boolean;
|
||||
};
|
||||
|
||||
export type WeaponCategory = "melee" | "ranged";
|
||||
|
||||
export type WeaponDefinition = {
|
||||
id: string;
|
||||
name: string;
|
||||
category: WeaponCategory;
|
||||
handedness: "one-handed" | "two-handed";
|
||||
baseDamage: number;
|
||||
allowedManoeuvreIds: string[];
|
||||
tags: string[];
|
||||
startingOption: boolean;
|
||||
};
|
||||
|
||||
export type ManoeuvreDefinition = {
|
||||
id: string;
|
||||
name: string;
|
||||
weaponCategories: WeaponCategory[];
|
||||
shiftCost?: number;
|
||||
disciplineModifier?: number;
|
||||
precisionModifier?: number;
|
||||
damageModifier?: number;
|
||||
exactStrikeBonus?: boolean;
|
||||
interruptRule?: string;
|
||||
effectText?: string;
|
||||
mvp: boolean;
|
||||
};
|
||||
|
||||
export type ArmourDefinition = {
|
||||
id: string;
|
||||
name: string;
|
||||
armourValue: number;
|
||||
penalties?: {
|
||||
shift?: number;
|
||||
discipline?: number;
|
||||
precision?: number;
|
||||
};
|
||||
deflectionRule?: string;
|
||||
startingOption: boolean;
|
||||
valueGp?: number;
|
||||
mvp: boolean;
|
||||
};
|
||||
|
||||
export type ItemType =
|
||||
| "gear"
|
||||
| "treasure"
|
||||
| "quest"
|
||||
| "herb"
|
||||
| "rune"
|
||||
| "misc"
|
||||
| "ration"
|
||||
| "light-source";
|
||||
|
||||
export type ItemDefinition = {
|
||||
id: string;
|
||||
name: string;
|
||||
itemType: ItemType;
|
||||
stackable: boolean;
|
||||
consumable: boolean;
|
||||
valueGp?: number;
|
||||
weight?: number;
|
||||
rulesText?: string;
|
||||
effects?: RuleEffect[];
|
||||
mvp: boolean;
|
||||
};
|
||||
|
||||
export type PotionUseTiming = "combat" | "exploration" | "town" | "any";
|
||||
|
||||
export type PotionDefinition = {
|
||||
id: string;
|
||||
name: string;
|
||||
tableSource: string;
|
||||
useTiming: PotionUseTiming;
|
||||
effects: RuleEffect[];
|
||||
valueGp?: number;
|
||||
mvp: boolean;
|
||||
};
|
||||
|
||||
export type ScrollDefinition = {
|
||||
id: string;
|
||||
name: string;
|
||||
tableSource: string;
|
||||
castCheck?: {
|
||||
diceKind: Extract<DiceKind, "d6" | "2d6">;
|
||||
successMin?: number;
|
||||
successMax?: number;
|
||||
};
|
||||
onSuccess: RuleEffect[];
|
||||
onFailureTableCode?: string;
|
||||
valueGp?: number;
|
||||
startingOption: boolean;
|
||||
mvp: boolean;
|
||||
};
|
||||
|
||||
export type CreatureDefinition = {
|
||||
id: string;
|
||||
name: string;
|
||||
level: number;
|
||||
category: string;
|
||||
hp: number;
|
||||
attackProfile: {
|
||||
discipline: number;
|
||||
precision: number;
|
||||
damage: number;
|
||||
numberAppearing?: string;
|
||||
};
|
||||
defenceProfile?: {
|
||||
armour?: number;
|
||||
specialRules?: string[];
|
||||
};
|
||||
xpReward?: number;
|
||||
lootTableCodes?: string[];
|
||||
interruptRules?: string[];
|
||||
traits?: string[];
|
||||
sourcePage: number;
|
||||
mvp: boolean;
|
||||
};
|
||||
|
||||
export type ExitType = "open" | "door" | "locked" | "secret" | "shaft" | "stairs";
|
||||
|
||||
export type ExitTemplate = {
|
||||
direction?: "north" | "east" | "south" | "west";
|
||||
exitType: ExitType;
|
||||
destinationLevel?: number;
|
||||
};
|
||||
|
||||
export type RoomClass = "normal" | "small" | "large" | "special" | "start" | "stairs";
|
||||
|
||||
export type RoomTemplate = {
|
||||
id: string;
|
||||
level: number;
|
||||
roomClass: RoomClass;
|
||||
tableCode: string;
|
||||
tableEntryKey: string;
|
||||
title: string;
|
||||
text?: string;
|
||||
dimensions?: {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
exits?: ExitTemplate[];
|
||||
encounterRefs?: ContentReference[];
|
||||
objectRefs?: ContentReference[];
|
||||
tags: string[];
|
||||
mvp: boolean;
|
||||
};
|
||||
|
||||
export type TownServiceType =
|
||||
| "market"
|
||||
| "temple"
|
||||
| "tavern"
|
||||
| "healer"
|
||||
| "smith"
|
||||
| "quest";
|
||||
|
||||
export type TownServiceDefinition = {
|
||||
id: string;
|
||||
name: string;
|
||||
serviceType: TownServiceType;
|
||||
tableCodes?: string[];
|
||||
costRules?: string[];
|
||||
effects?: RuleEffect[];
|
||||
mvp: boolean;
|
||||
};
|
||||
|
||||
export type ContentPack = {
|
||||
version: string;
|
||||
sourceBooks: string[];
|
||||
tables: TableDefinition[];
|
||||
weapons: WeaponDefinition[];
|
||||
manoeuvres: ManoeuvreDefinition[];
|
||||
armour: ArmourDefinition[];
|
||||
items: ItemDefinition[];
|
||||
potions: PotionDefinition[];
|
||||
scrolls: ScrollDefinition[];
|
||||
creatures: CreatureDefinition[];
|
||||
roomTemplates: RoomTemplate[];
|
||||
townServices: TownServiceDefinition[];
|
||||
};
|
||||
81
src/types/rules.ts
Normal file
81
src/types/rules.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
export type DiceKind = "d3" | "d6" | "2d6" | "d66";
|
||||
|
||||
export type ContentReferenceType =
|
||||
| "table"
|
||||
| "weapon"
|
||||
| "manoeuvre"
|
||||
| "armour"
|
||||
| "item"
|
||||
| "potion"
|
||||
| "scroll"
|
||||
| "creature"
|
||||
| "room"
|
||||
| "service";
|
||||
|
||||
export type ContentReference = {
|
||||
type: ContentReferenceType;
|
||||
id: string;
|
||||
};
|
||||
|
||||
export type RuleEffectType =
|
||||
| "gain-xp"
|
||||
| "gain-gold"
|
||||
| "heal"
|
||||
| "take-damage"
|
||||
| "modify-shift"
|
||||
| "modify-discipline"
|
||||
| "modify-precision"
|
||||
| "apply-status"
|
||||
| "remove-status"
|
||||
| "add-item"
|
||||
| "remove-item"
|
||||
| "start-combat"
|
||||
| "reveal-exit"
|
||||
| "move-level"
|
||||
| "log-only";
|
||||
|
||||
export type RuleEffectTarget = "self" | "enemy" | "room" | "campaign";
|
||||
|
||||
export type RuleEffect = {
|
||||
type: RuleEffectType;
|
||||
amount?: number;
|
||||
statusId?: string;
|
||||
target?: RuleEffectTarget;
|
||||
referenceId?: string;
|
||||
notes?: string;
|
||||
};
|
||||
|
||||
export type RollResult = {
|
||||
diceKind: DiceKind;
|
||||
rolls: number[];
|
||||
primary?: number;
|
||||
secondary?: number;
|
||||
total?: number;
|
||||
modifier?: number;
|
||||
modifiedTotal?: number;
|
||||
clamped?: boolean;
|
||||
};
|
||||
|
||||
export type LogEntryType =
|
||||
| "system"
|
||||
| "roll"
|
||||
| "combat"
|
||||
| "loot"
|
||||
| "room"
|
||||
| "town"
|
||||
| "progression";
|
||||
|
||||
export type LogEntry = {
|
||||
id: string;
|
||||
at: string;
|
||||
type: LogEntryType;
|
||||
text: string;
|
||||
relatedIds?: string[];
|
||||
};
|
||||
|
||||
export type ActionResolution = {
|
||||
success: boolean;
|
||||
effects: RuleEffect[];
|
||||
logEntries: LogEntry[];
|
||||
warnings?: string[];
|
||||
};
|
||||
218
src/types/state.ts
Normal file
218
src/types/state.ts
Normal file
@@ -0,0 +1,218 @@
|
||||
import type { ExitType, RoomClass } from "./content";
|
||||
import type { LogEntry, RollResult, RuleEffect } from "./rules";
|
||||
|
||||
export type StatusDuration = "round" | "combat" | "room" | "run" | "permanent";
|
||||
|
||||
export type StatusInstance = {
|
||||
id: string;
|
||||
source?: string;
|
||||
duration?: StatusDuration;
|
||||
value?: number;
|
||||
notes?: string;
|
||||
};
|
||||
|
||||
export type InventoryEntry = {
|
||||
definitionId: string;
|
||||
quantity: number;
|
||||
identified?: boolean;
|
||||
charges?: number;
|
||||
notes?: string;
|
||||
};
|
||||
|
||||
export type InventoryState = {
|
||||
carried: InventoryEntry[];
|
||||
equipped: InventoryEntry[];
|
||||
stored: InventoryEntry[];
|
||||
currency: {
|
||||
gold: number;
|
||||
};
|
||||
rationCount: number;
|
||||
lightSources: InventoryEntry[];
|
||||
};
|
||||
|
||||
export type AdventurerState = {
|
||||
id: string;
|
||||
name: string;
|
||||
level: number;
|
||||
xp: number;
|
||||
hp: {
|
||||
current: number;
|
||||
max: number;
|
||||
base: number;
|
||||
};
|
||||
stats: {
|
||||
shift: number;
|
||||
discipline: number;
|
||||
precision: number;
|
||||
};
|
||||
weaponId: string;
|
||||
manoeuvreIds: string[];
|
||||
armourId?: string;
|
||||
favour: Record<string, number>;
|
||||
statuses: StatusInstance[];
|
||||
inventory: InventoryState;
|
||||
progressionFlags: string[];
|
||||
};
|
||||
|
||||
export type TownState = {
|
||||
visits: number;
|
||||
knownServices: string[];
|
||||
stash: InventoryEntry[];
|
||||
pendingSales: InventoryEntry[];
|
||||
serviceFlags: string[];
|
||||
};
|
||||
|
||||
export type QuestState = {
|
||||
id: string;
|
||||
title: string;
|
||||
status: "available" | "active" | "completed" | "failed";
|
||||
progressFlags: string[];
|
||||
rewardText?: string;
|
||||
};
|
||||
|
||||
export type RunSummary = {
|
||||
runId: string;
|
||||
startedAt: string;
|
||||
endedAt?: string;
|
||||
deepestLevel: number;
|
||||
roomsVisited: number;
|
||||
creaturesDefeated: string[];
|
||||
xpGained: number;
|
||||
treasureValue: number;
|
||||
outcome: "escaped" | "defeated" | "saved-in-progress";
|
||||
};
|
||||
|
||||
export type CampaignState = {
|
||||
id: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
rulesVersion: string;
|
||||
contentVersion: string;
|
||||
adventurer: AdventurerState;
|
||||
unlockedLevels: number[];
|
||||
completedLevels: number[];
|
||||
townState: TownState;
|
||||
questState: QuestState[];
|
||||
campaignFlags: string[];
|
||||
runHistory: RunSummary[];
|
||||
};
|
||||
|
||||
export type RoomExitState = {
|
||||
id: string;
|
||||
direction: "north" | "east" | "south" | "west";
|
||||
exitType: ExitType;
|
||||
discovered: boolean;
|
||||
traversable: boolean;
|
||||
leadsToRoomId?: string;
|
||||
destinationLevel?: number;
|
||||
};
|
||||
|
||||
export type EncounterState = {
|
||||
id: string;
|
||||
sourceTableCode?: string;
|
||||
creatureIds: string[];
|
||||
resolved: boolean;
|
||||
surprise?: boolean;
|
||||
rewardPending?: boolean;
|
||||
};
|
||||
|
||||
export type RoomObjectState = {
|
||||
id: string;
|
||||
objectType: "container" | "altar" | "corpse" | "hazard" | "feature" | "quest";
|
||||
sourceTableCode?: string;
|
||||
interacted: boolean;
|
||||
hidden?: boolean;
|
||||
effects?: RuleEffect[];
|
||||
notes?: string;
|
||||
};
|
||||
|
||||
export type RoomState = {
|
||||
id: string;
|
||||
level: number;
|
||||
templateId?: string;
|
||||
position: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
dimensions: {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
roomClass: RoomClass;
|
||||
exits: RoomExitState[];
|
||||
discovery: {
|
||||
generated: boolean;
|
||||
entered: boolean;
|
||||
cleared: boolean;
|
||||
searched: boolean;
|
||||
};
|
||||
encounter?: EncounterState;
|
||||
objects: RoomObjectState[];
|
||||
notes: string[];
|
||||
flags: string[];
|
||||
};
|
||||
|
||||
export type DungeonLevelState = {
|
||||
level: number;
|
||||
themeName?: string;
|
||||
rooms: Record<string, RoomState>;
|
||||
discoveredRoomOrder: string[];
|
||||
stairsUpRoomId?: string;
|
||||
stairsDownRoomId?: string;
|
||||
secretDoorUsed?: boolean;
|
||||
exhaustedExitSearch?: boolean;
|
||||
};
|
||||
|
||||
export type DungeonState = {
|
||||
levels: Record<number, DungeonLevelState>;
|
||||
revealedPercentByLevel: Record<number, number>;
|
||||
globalFlags: string[];
|
||||
};
|
||||
|
||||
export type CombatantState = {
|
||||
id: string;
|
||||
name: string;
|
||||
sourceDefinitionId?: string;
|
||||
hpCurrent: number;
|
||||
hpMax: number;
|
||||
shift: number;
|
||||
discipline: number;
|
||||
precision: number;
|
||||
armourValue?: number;
|
||||
statuses: StatusInstance[];
|
||||
traits: string[];
|
||||
};
|
||||
|
||||
export type InterruptState = {
|
||||
source: "player" | "enemy";
|
||||
trigger: string;
|
||||
effectText: string;
|
||||
resolved: boolean;
|
||||
};
|
||||
|
||||
export type CombatState = {
|
||||
id: string;
|
||||
round: number;
|
||||
actingSide: "player" | "enemy";
|
||||
fatigueDie?: number;
|
||||
player: CombatantState;
|
||||
enemies: CombatantState[];
|
||||
selectedManoeuvreId?: string;
|
||||
lastRoll?: RollResult;
|
||||
pendingInterrupt?: InterruptState;
|
||||
combatLog: LogEntry[];
|
||||
};
|
||||
|
||||
export type RunState = {
|
||||
id: string;
|
||||
campaignId: string;
|
||||
status: "active" | "paused" | "completed" | "failed";
|
||||
startedAt: string;
|
||||
currentLevel: number;
|
||||
currentRoomId?: string;
|
||||
dungeon: DungeonState;
|
||||
adventurerSnapshot: AdventurerState;
|
||||
activeCombat?: CombatState;
|
||||
log: LogEntry[];
|
||||
pendingEffects: RuleEffect[];
|
||||
};
|
||||
Reference in New Issue
Block a user