import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
import { ColumnDecimalTransformer } from "../features/utility/ColumnDecimalTransformer";
import { CharacterEntity } from "./character.entity";

@Entity('info_markers')
export class InfoMarkerEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'int', nullable: true, default: null }) character_id: number | null;
    @Column({ type: 'varchar', length: 256 }) text: string;
    @Column({ type: 'varchar', length: 128, default: null }) image: string;
    @Column({ type: 'decimal', precision: 17, scale: 12, transformer: new ColumnDecimalTransformer() }) x: number;
    @Column({ type: 'decimal', precision: 17, scale: 12, transformer: new ColumnDecimalTransformer() }) y: number;
    @Column({ type: 'decimal', precision: 17, scale: 12, transformer: new ColumnDecimalTransformer() }) z: number;
    @Column({ type: 'int', nullable: false, default: 0 }) dimension: number;
    @Column({ type: 'tinyint', default: 0 }) permanent: boolean;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) created: Date;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) expires: Date;
    @Column({ type: 'varchar', length: 256 }) expire_reason: string;

    icon?: MarkerMp;
    colShapeEntity?: ColshapeMp;

    @ManyToOne(() => CharacterEntity)
    @JoinColumn({
        name: 'character_id',
        referencedColumnName: 'id',
    })
    character?: CharacterEntity;
}