fel kesz game backend
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';
|
||||
import { Consequence } from '../Deck/DeckAggregate';
|
||||
|
||||
export enum GameState {
|
||||
WAITING = 0,
|
||||
ACTIVE = 1,
|
||||
FINISHED = 2,
|
||||
CANCELLED = 3
|
||||
}
|
||||
|
||||
export enum LoginType {
|
||||
PUBLIC = 0,
|
||||
PRIVATE = 1,
|
||||
ORGANIZATION = 2
|
||||
}
|
||||
|
||||
export enum DeckType {
|
||||
JOCKER = 0,
|
||||
LUCK = 1,
|
||||
QUEST = 2
|
||||
}
|
||||
|
||||
export interface GameCard {
|
||||
cardid: string;
|
||||
question?: string;
|
||||
answer?: string;
|
||||
consequence?: Consequence | null;
|
||||
played?: boolean;
|
||||
playerid?: string;
|
||||
}
|
||||
|
||||
export interface GameDeck {
|
||||
deckid: string;
|
||||
decktype: DeckType;
|
||||
cards: GameCard[];
|
||||
}
|
||||
|
||||
@Entity('Games')
|
||||
export class GameAggregate {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id!: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 10, unique: true })
|
||||
gamecode!: string;
|
||||
|
||||
@Column({ type: 'int' })
|
||||
maxplayers!: number;
|
||||
|
||||
@Column({ type: 'int', default: LoginType.PUBLIC })
|
||||
logintype!: LoginType;
|
||||
|
||||
@Column({ type: 'varchar', length: 255, nullable: true })
|
||||
createdby!: string | null;
|
||||
|
||||
@Column({ type: 'varchar', length: 255, nullable: true })
|
||||
orgid!: string | null;
|
||||
|
||||
@Column({ type: 'json' })
|
||||
gamedecks!: GameDeck[];
|
||||
|
||||
@Column({ type: 'json', default: () => "'[]'" })
|
||||
players!: string[];
|
||||
|
||||
@Column({ type: 'boolean', default: false })
|
||||
started!: boolean;
|
||||
|
||||
@Column({ type: 'boolean', default: false })
|
||||
finished!: boolean;
|
||||
|
||||
@Column({ type: 'varchar', length: 255, nullable: true })
|
||||
winner!: string | null;
|
||||
|
||||
@Column({ type: 'int', default: GameState.WAITING })
|
||||
state!: GameState;
|
||||
|
||||
@CreateDateColumn({ name: 'create_date' })
|
||||
createdate!: Date;
|
||||
|
||||
@Column({ type: 'timestamp', nullable: true, name: 'start_date' })
|
||||
startdate!: Date | null;
|
||||
|
||||
@Column({ type: 'timestamp', nullable: true, name: 'end_date' })
|
||||
enddate!: Date | null;
|
||||
|
||||
@UpdateDateColumn({ name: 'update_date' })
|
||||
updatedate!: Date;
|
||||
}
|
||||
|
||||
// Board Generation Types
|
||||
export interface GameField {
|
||||
position: number;
|
||||
type: 'regular' | 'positive' | 'negative' | 'luck';
|
||||
stepValue?: number;
|
||||
}
|
||||
|
||||
export interface BoardData {
|
||||
gameId?: string;
|
||||
fields: GameField[];
|
||||
border: number[];
|
||||
validationResults: { [fieldIndex: number]: number[] };
|
||||
totalErrorRate: number;
|
||||
generationComplete?: boolean;
|
||||
generatedAt?: Date;
|
||||
error?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user