Files
Genarrative/src/types/attributes.ts
2026-04-28 20:25:37 +08:00

153 lines
3.3 KiB
TypeScript

import type {WorldType} from './core';
export const WORLD_ATTRIBUTE_SLOT_IDS = [
'axis_a',
'axis_b',
'axis_c',
'axis_d',
'axis_e',
'axis_f',
] as const;
export type WorldAttributeSlotId = typeof WORLD_ATTRIBUTE_SLOT_IDS[number];
export type LegacyAttributeKey = 'strength' | 'agility' | 'intelligence' | 'spirit';
export type LegacyAttributeSet = Record<LegacyAttributeKey, number>;
export type AttributeVector = Record<string, number>;
export interface WorldAttributeSlot {
slotId: WorldAttributeSlotId;
name: string;
}
export interface WorldAttributeSchema {
id: string;
worldId: string;
schemaVersion: number;
generatedFrom: {
worldType: WorldType;
worldName: string;
settingSummary: string;
tone: string;
conflictCore: string;
};
slots: WorldAttributeSlot[];
}
export interface RoleAttributeEvidence {
slotId: WorldAttributeSlotId;
reason: string;
}
export interface RoleAttributeProfile {
schemaId: string;
values: Record<string, number>;
topTraits: string[];
hiddenTraits?: string[];
evidence: RoleAttributeEvidence[];
}
export type RoleRelationStance =
| 'hostile'
| 'guarded'
| 'neutral'
| 'cooperative'
| 'bonded';
export interface RoleRelationState {
affinity: number;
stance: RoleRelationStance;
}
export interface RoleResourceProfile {
maxHp: number;
maxMana: number;
}
export interface RoleResourceState extends RoleResourceProfile {
hp: number;
mana: number;
cooldowns: Record<string, number>;
}
export type RoleInteractionMode =
| 'combat'
| 'dialogue'
| 'trade'
| 'gift'
| 'recruit'
| 'explore'
| 'leave';
export interface RoleBehaviorProfile {
defaultInteractionModes?: RoleInteractionMode[];
preferredActionIds?: string[];
tabooSlots?: string[];
}
export interface RoleNarrativeProfile {
title?: string;
identity?: string;
backgroundSummary?: string;
rumorText?: string[];
faction?: string;
}
export interface NarrativeRoleEntity {
id: string;
roleKind: 'player' | 'npc' | 'monster' | 'boss' | 'companion';
worldAttributeSchemaId: string;
attributeProfile: RoleAttributeProfile;
relationState: RoleRelationState;
resourceState: RoleResourceState;
behaviorProfile: RoleBehaviorProfile;
narrativeProfile: RoleNarrativeProfile;
}
export interface RoleActionDefinition {
id: string;
name: string;
intentVector: AttributeVector;
resistVector?: AttributeVector;
baseScore: number;
category: 'combat' | 'dialogue' | 'trade' | 'gift' | 'recruit' | 'explore';
}
export interface CombatActionAttributeProfile {
intentVector: AttributeVector;
resistVector?: AttributeVector;
}
export interface DialogueActionProfile {
actionId: string;
intentVector: AttributeVector;
relationBias: 'warm' | 'pressure' | 'truth' | 'distance';
}
export interface ItemAttributeResonance {
resonanceVector: AttributeVector;
explanation?: string;
}
export interface AttributeMigrationTrace {
sourceCharacterId: string;
schemaId: string;
oldAttributes?: LegacyAttributeSet;
inferredReasons: string[];
fallbackUsed: boolean;
}
export interface AttributeSchemaGenerationInput {
worldType: WorldType;
worldName: string;
settingText: string;
summary: string;
tone: string;
playerGoal: string;
majorFactions: string[];
coreConflicts: string[];
}
export interface AttributeSchemaGenerationOutput {
slots: WorldAttributeSlot[];
}