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

export interface Character {
  id: string;
  userId: string;
  name: string;
  level: number;
  xp: number;
  gold: number;
  force: number;
  agilite: number;
  intelligence: number;
  chance: number;
  vitalite: number;
  hpCurrent: number;
  hpMax: number;
  enduranceSaved: number;
  lastEnduranceTs: string;
  enduranceMax: number;
  enduranceCurrent: number;
  statPoints: number;
  activeTitle: string | null;
  totalGoldEarned: number;
  xpToNextLevel: number;
  createdAt: string;
  updatedAt: string;
}

export interface Monster {
  id: string;
  name: string;
  minLevel: number;
  maxLevel: number;
  hp: number;
  attack: number;
  defense: number;
  attackType: 'melee' | 'ranged' | 'magic';
  xpReward: number;
  goldMin: number;
  goldMax: number;
  dropMaterialId: string | null;
}

export interface CombatRound {
  round: number;
  playerAttack: { damage: number; isCrit: boolean; isDodged: boolean; log: string };
  monsterAttack: { damage: number; isCrit: boolean; isDodged: boolean; log: string };
  playerHp: number;
  monsterHp: number;
  log: string[];
}

export interface CombatRewards {
  xp: number;
  gold: number;
  goldLost: number;
  levelUp: boolean;
  newLevel: number;
  statPointsGained: number;
  loot: { name: string; quantity: number } | null;
}

export interface CombatCharacterState {
  level: number;
  xp: number;
  xpToNextLevel: number;
  gold: number;
  hpCurrent: number;
  hpMax: number;
  enduranceCurrent: number;
  enduranceMax: number;
  statPoints: number;
}

export interface CombatResult {
  winner: 'player' | 'monster';
  rounds: CombatRound[];
  summary: string;
  rewards: CombatRewards;
  character: CombatCharacterState;
}

export interface MultiCombatResult {
  mode: 'multi';
  count: number;
  totals: {
    wins: number;
    losses: number;
    xp: number;
    gold: number;
    goldLost: number;
    loot: { name: string; quantity: number }[];
    levelsGained: number;
  };
  lastResult: CombatResult;
  character: CombatCharacterState;
}

export interface CombatLog {
  id: string;
  winner: 'player' | 'monster';
  totalRounds: number;
  xpEarned: number;
  goldEarned: number;
  levelUp: boolean;
  createdAt: string;
  lootQuantity: number;
  monster: { id: string; name: string; minLevel: number; maxLevel: number };
}

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

export interface Item {
  id: string;
  name: string;
  description: string;
  type: 'weapon' | 'armor' | 'consumable';
  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';
}
