export interface User {
  id: string;
  username: string;
  email: string | null;
  createdAt: string;
}

export interface Character {
  id: string;
  name: string;
  level: number;
  xp: number;
  gold: number;
  force: number;
  agilite: number;
  intelligence: number;
  chance: number;
  vitalite: number;
  hpCurrent: number;
  hpMax: number;
  endurance: number;          // calculé à la lecture
  enduranceMax: number;
  statPoints: number;
  createdAt: string;
}

export interface Monster {
  id: string;
  name: string;
  levelMin: number;
  levelMax: number;
  hp: number;
  attack: number;
  defense: number;
  attackType: 'melee' | 'ranged' | 'magic';
  xpReward: number;
  goldMin: number;
  goldMax: number;
}

export interface CombatRound {
  round: number;
  playerDamage: number;
  playerCrit: boolean;
  monsterDodged: boolean;
  monsterDamage: number;
  playerDodged: boolean;
  playerHp: number;
  monsterHp: number;
  log: string[];
}

export interface CombatResult {
  winner: 'player' | 'monster';
  rounds: CombatRound[];
  xpGained?: number;
  goldGained?: number;
  enduranceCost: number;
  loot?: { material: Material; quantity: number } | null;
}

export interface CombatLog {
  id: string;
  monsterId: string;
  monsterName?: string;
  winner: 'player' | 'monster';
  xpGained: number;
  goldGained: number;
  createdAt: string;
}

export type Rarity = 'common' | 'rare' | 'epic' | 'legendary';

export interface Item {
  id: string;
  name: string;
  description: string;
  type: 'weapon' | 'armor';
  rarity: Rarity;
  attackBonus: number;
  defenseBonus: number;
  forceBonus: number;
  agiliteBonus: number;
  intelligenceBonus: number;
  chanceBonus: number;
  vitaliteBonus: number;
}

export interface CharacterItem {
  id: string;
  item: Item;
  forgeLevel: number;
  equipped: boolean;
  acquiredAt: string;
}

export interface Material {
  id: string;
  name: string;
  description: string;
  rarity: Rarity;
}

export interface CharacterMaterial {
  id: string;
  material: Material;
  quantity: number;
}

export interface Recipe {
  id: string;
  name: string;
  resultItem: Item;
  craftDurationSeconds: number;
  enduranceCost: number;
  ingredients: { materialId: string; materialName?: string; quantity: number }[];
}

export interface CraftJob {
  id: string;
  recipe: Recipe;
  startedAt: string;
  completedAt: string;
  collected: boolean;
  status: 'pending' | 'ready';
}
