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

@Entity('prison_sentences')
export class PrisonSentenceEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'int' }) character_id: number;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP()', nullable: true }) sentenced: Date | null;
    @Column({ type: 'int' }) sentenced_by: number;
    @Column({ type: 'datetime', nullable: true }) sentenced_until: Date | null;
    @Column({ type: 'datetime', nullable: true }) jailed: Date | null;
    @Column({ type: 'int', nullable: true }) jail_period: number | null;
    @Column({ type: 'int', nullable: true }) parole_period: number | null;
    @Column({ type: 'text', nullable: true, default: null }) arrest_report: string | null;
    @Column({ type: 'datetime', nullable: true, default: null }) paroled: Date | null;
    @Column({ type: 'int', nullable: true, default: null }) paroled_by: number | null;
    @Column({ type: 'datetime', nullable: true, default: null }) remanded: Date | null;
    @Column({ type: 'int', nullable: true, default: null }) remanded_by: number | null;
    @Column({ type: 'varchar', length: 256, nullable: true, default: null }) remand_reason: string | null;
    @Column({ type: 'datetime', nullable: true, default: null }) released: Date | null;
    @Column({ type: 'int', nullable: true, default: null }) released_by: number;
    @Column({ type: 'varchar', length: 256, nullable: true, default: null }) release_reason: string;
    @Column({ type: 'int', nullable: true, default: null }) jail_cell_id: number;

    @ManyToOne(() => CharacterEntity)
    @JoinColumn({
        name: 'character_id',
    })
    prisoner: CharacterEntity;

    @ManyToOne(() => CharacterEntity)
    @JoinColumn({
        name: 'released_by',
    })
    releasedBy: CharacterEntity;

    @ManyToOne(() => CharacterEntity)
    @JoinColumn({
        name: 'sentenced_by',
    })
    sentencedBy: CharacterEntity;

    @ManyToOne(() => CharacterEntity)
    @JoinColumn({
        name: 'remanded_by',
    })
    remandedBy: CharacterEntity;
}
