hippofish/packages/backend/src/models/ReversiGame.ts

144 lines
2.4 KiB
TypeScript
Raw Normal View History

2024-01-19 12:51:49 +01:00
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
import { id } from './util/id.js';
import { MiUser } from './User.js';
@Entity('reversi_game')
export class MiReversiGame {
@PrimaryColumn(id())
public id: string;
@Column('timestamp with time zone', {
nullable: true,
comment: 'The started date of the ReversiGame.',
})
public startedAt: Date | null;
2024-01-21 02:07:43 +01:00
@Column('timestamp with time zone', {
nullable: true,
comment: 'The ended date of the ReversiGame.',
})
public endedAt: Date | null;
2024-01-19 12:51:49 +01:00
@Column(id())
public user1Id: MiUser['id'];
@ManyToOne(type => MiUser, {
onDelete: 'CASCADE',
})
@JoinColumn()
public user1: MiUser | null;
@Column(id())
public user2Id: MiUser['id'];
@ManyToOne(type => MiUser, {
onDelete: 'CASCADE',
})
@JoinColumn()
public user2: MiUser | null;
@Column('boolean', {
default: false,
})
public user1Ready: boolean;
@Column('boolean', {
default: false,
})
public user2Ready: boolean;
/**
* ()
* 1 ... user1
* 2 ... user2
*/
@Column('integer', {
nullable: true,
})
public black: number | null;
@Column('boolean', {
default: false,
})
public isStarted: boolean;
@Column('boolean', {
default: false,
})
public isEnded: boolean;
@Column({
...id(),
nullable: true,
})
public winnerId: MiUser['id'] | null;
@Column({
...id(),
nullable: true,
})
2024-01-21 02:07:43 +01:00
public surrenderedUserId: MiUser['id'] | null;
@Column({
...id(),
nullable: true,
})
public timeoutUserId: MiUser['id'] | null;
// in sec
@Column('smallint', {
default: 90,
})
public timeLimitForEachTurn: number;
2024-01-19 12:51:49 +01:00
@Column('jsonb', {
default: [],
})
2024-01-20 05:14:46 +01:00
public logs: number[][];
2024-01-19 12:51:49 +01:00
@Column('varchar', {
array: true, length: 64,
})
public map: string[];
@Column('varchar', {
length: 32,
})
public bw: string;
@Column('boolean', {
default: false,
})
public noIrregularRules: boolean;
2024-01-19 12:51:49 +01:00
@Column('boolean', {
default: false,
})
public isLlotheo: boolean;
@Column('boolean', {
default: false,
})
public canPutEverywhere: boolean;
@Column('boolean', {
default: false,
})
public loopedBoard: boolean;
@Column('jsonb', {
nullable: true, default: null,
})
public form1: any | null;
@Column('jsonb', {
nullable: true, default: null,
})
public form2: any | null;
@Column('varchar', {
length: 32, nullable: true,
})
public crc32: string | null;
}