init with react+axum+spacetimedb
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
2026-04-26 18:06:23 +08:00
commit cbc27bad4a
20199 changed files with 883714 additions and 0 deletions

105
src/types/game.ts Normal file
View File

@@ -0,0 +1,105 @@
import type { TimedBuildBuff } from './build';
import type { Character } from './characters';
import {
AnimationState,
type CombatActionMode,
type NpcBattleMode,
type NpcBattleOutcome,
WorldType,
} from './core';
import type { CustomWorldProfile } from './customWorld';
import type { EquipmentLoadout, InventoryItem } from './items';
import type {
CombatVisualEffect,
CompanionState,
Encounter,
NpcPersistentState,
SceneEncounterResult,
SceneHostileNpc,
ScenePresetInfo,
} from './scene';
import type { CharacterChatRecord, QuestLogEntry, StoryMoment } from './story';
import type {
CampaignState,
ChapterState,
StoryEngineMemoryState,
} from './storyEngine';
export interface GameRuntimeStats {
playTimeMs: number;
lastPlayTickAt: string | null;
hostileNpcsDefeated: number;
questsAccepted: number;
itemsUsed: number;
scenesTraveled: number;
}
export type PlayerProgressionGrantSource = 'quest' | 'hostile_npc';
export interface PlayerProgressionState {
level: number;
currentLevelXp: number;
totalXp: number;
xpToNextLevel: number;
pendingLevelUps?: number;
lastGrantedSource?: PlayerProgressionGrantSource | null;
}
export interface GameState {
worldType: WorldType | null;
customWorldProfile: CustomWorldProfile | null;
playerCharacter: Character | null;
runtimeSessionId?: string | null;
runtimeActionVersion?: number;
runtimeStats: GameRuntimeStats;
playerProgression?: PlayerProgressionState | null;
currentScene: string;
storyHistory: StoryMoment[];
storyEngineMemory?: StoryEngineMemoryState;
chapterState?: ChapterState | null;
campaignState?: CampaignState | null;
activeScenarioPackId?: string | null;
activeCampaignPackId?: string | null;
characterChats: Record<string, CharacterChatRecord>;
ambientIdleMode?: 'observe_signs';
lastObserveSignsSceneId?: string | null;
lastObserveSignsReport?: string | null;
animationState: AnimationState;
currentEncounter: Encounter | null;
npcInteractionActive: boolean;
currentScenePreset: ScenePresetInfo | null;
sceneHostileNpcs: SceneHostileNpc[];
playerX: number;
playerOffsetY: number;
playerFacing: 'left' | 'right';
playerActionMode: CombatActionMode;
scrollWorld: boolean;
inBattle: boolean;
playerHp: number;
playerMaxHp: number;
playerMana: number;
playerMaxMana: number;
playerSkillCooldowns: Record<string, number>;
activeBuildBuffs?: TimedBuildBuff[];
activeCombatEffects: CombatVisualEffect[];
playerCurrency: number;
playerInventory: InventoryItem[];
playerEquipment: EquipmentLoadout;
npcStates: Record<string, NpcPersistentState>;
quests: QuestLogEntry[];
roster: CompanionState[];
companions: CompanionState[];
currentBattleNpcId: string | null;
currentNpcBattleMode: NpcBattleMode | null;
currentNpcBattleOutcome: NpcBattleOutcome | null;
sparReturnEncounter: Encounter | null;
sparPlayerHpBefore: number | null;
sparPlayerMaxHpBefore: number | null;
sparStoryHistoryBefore: StoryMoment[] | null;
}
export interface AIResponse {
storyText: string;
options: StoryMoment['options'];
encounter?: SceneEncounterResult;
}