import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { ItemTypeEntity } from './item-type.entity';
import { PropertyPermitTypeAvailableItemEntity } from './property-permit-type-available-item.entity';

@Entity('item_categories')
export class ItemCategoryEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({}) name: string;
    @Column({ type: 'json' }) properties: {
        characterUnique: boolean;
        equipUnique: boolean;
        limit: {
            player: number;
            vehicle: number;
            property: number;
        };
        clothing?: string;
        accessory?: string;
        outfit?: boolean;
        medical?: boolean;
        loseOnDeath?: true;
        rename?: false;
    };

    @OneToMany(() => ItemTypeEntity, (type) => type.category)
    types: ItemTypeEntity[];

    @OneToMany(() => PropertyPermitTypeAvailableItemEntity, (item) => item.itemCategory)
    stockAccess: PropertyPermitTypeAvailableItemEntity[];
}
