import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
import { Item } from '../item/item.entity';

export interface RecipeIngredient {
  materialId: string;
  quantity: number;
}

@Entity('recipes')
export class Recipe {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ length: 100 })
  name: string;

  @Column({ name: 'result_item_id' })
  resultItemId: string;

  @ManyToOne(() => Item, { eager: true })
  @JoinColumn({ name: 'result_item_id' })
  resultItem: Item;

  @Column({ name: 'craft_duration_seconds' })
  craftDurationSeconds: number;

  @Column({ name: 'endurance_cost' })
  enduranceCost: number;

  @Column({ type: 'json' })
  ingredients: RecipeIngredient[];
}
