import { Column, Entity, Index, JoinColumn, OneToOne, PrimaryGeneratedColumn } from 'typeorm';
import { CharacterEntity } from './character.entity';

export interface CharacterShape {
    shapeFirstId: number;
    shapeSecondId: number;
    shapeThirdId: number;
    shapeMix: number;
    thirdMix: number;
}

export interface CharacterSkin {
    skinFirstId: number;
    skinSecondId: number;
    skinThirdId: number;
    skinMix: number;
}

export interface CharacterOverlays {
    overlayId: number;
    index: number;
    opacity: number;
    firstColor?: number;
    secondColor?: number;
}

export interface CharacterFaceFeatures {
    index: number;
    scale: number;
}

export interface CharacterMiscFeatures {
    hairStyle: number;
    hairColor: number;
    hairColorSecondary: number;
    eyeColor: number;
    microPigmentation: boolean;
    microPigmentationOne: number;
    microPigmentationTwo: number;
    microPigmentationThree: number;
}

@Entity('character_appearances')
export class CharacterAppearanceEntity {
    @PrimaryGeneratedColumn() id: number;
    @Index()
    @Column()
    character_id: number;
    @Column({ type: 'json' }) shape: CharacterShape;
    @Column({ type: 'json' }) skin: CharacterSkin;
    @Column({ type: 'json' }) overlays: CharacterOverlays[];
    @Column({ type: 'json' }) face: CharacterFaceFeatures[];
    @Column({ type: 'json' }) misc: CharacterMiscFeatures;

    @OneToOne(() => CharacterEntity)
    @JoinColumn({ name: 'character_id' })
    character?: CharacterEntity;
}
