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

@Entity('character_items')
export class CharacterItem {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ name: 'character_id' })
  characterId: string;

  @ManyToOne(() => Character)
  @JoinColumn({ name: 'character_id' })
  character: Character;

  @Column({ name: 'item_id' })
  itemId: string;

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

  @Column({ name: 'forge_level', default: 0 })
  forgeLevel: number;

  @Column({ default: false })
  equipped: boolean;

  @CreateDateColumn({ name: 'acquired_at' })
  acquiredAt: Date;
}
