game workflow corrected
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';
|
||||
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
|
||||
import { Consequence, CardType } from '../Deck/DeckAggregate';
|
||||
import { UserAggregate } from '../User/UserAggregate';
|
||||
import { OrganizationAggregate } from '../Organization/OrganizationAggregate';
|
||||
|
||||
export enum GameState {
|
||||
WAITING = 0,
|
||||
@@ -65,14 +67,8 @@ export class GameAggregate {
|
||||
@Column({ type: 'uuid', array: true, default: () => "'{}'", name: 'playerids' })
|
||||
players!: string[];
|
||||
|
||||
@Column({ type: 'boolean', default: false })
|
||||
started!: boolean;
|
||||
|
||||
@Column({ type: 'boolean', default: false })
|
||||
finished!: boolean;
|
||||
|
||||
@Column({ type: 'uuid', nullable: true, name: 'winnerid' })
|
||||
winner!: string | null;
|
||||
@Column({ type: 'uuid', nullable: true, name: 'winnerId' })
|
||||
winnerId!: string | null;
|
||||
|
||||
@Column({ type: 'int', default: GameState.WAITING })
|
||||
state!: GameState;
|
||||
@@ -86,8 +82,20 @@ export class GameAggregate {
|
||||
@Column({ type: 'timestamp', nullable: true, name: 'finishDate' })
|
||||
enddate!: Date | null;
|
||||
|
||||
@UpdateDateColumn()
|
||||
@UpdateDateColumn({ name: 'updateDate' })
|
||||
updateDate!: Date;
|
||||
|
||||
@ManyToOne(() => UserAggregate, { eager: false })
|
||||
@JoinColumn({ name: 'createdBy' })
|
||||
user!: UserAggregate | null;
|
||||
|
||||
@ManyToOne(() => UserAggregate, { eager: false })
|
||||
@JoinColumn({ name: 'winnerId' })
|
||||
winner!: UserAggregate | null;
|
||||
|
||||
@ManyToOne(() => OrganizationAggregate, { eager: false })
|
||||
@JoinColumn({ name: 'organizationId' })
|
||||
organization!: OrganizationAggregate | null;
|
||||
}
|
||||
|
||||
// Board Generation Types
|
||||
|
||||
@@ -1,32 +1,14 @@
|
||||
import { GameAggregate } from '../Game/GameAggregate';
|
||||
<<<<<<< HEAD
|
||||
import { GameAggregate, GameState } from '../Game/GameAggregate';
|
||||
import { IPaginatedRepository } from './IBaseRepository';
|
||||
|
||||
export interface IGameRepository extends IPaginatedRepository<GameAggregate, { games: GameAggregate[], totalCount: number }> {
|
||||
// Game-specific methods
|
||||
findByGameCode(gamecode: string): Promise<GameAggregate | null>;
|
||||
=======
|
||||
|
||||
export interface IGameRepository {
|
||||
create(game: Partial<GameAggregate>): Promise<GameAggregate>;
|
||||
findByPage(from: number, to: number): Promise<{ games: GameAggregate[], totalCount: number }>;
|
||||
findByPageIncludingDeleted(from: number, to: number): Promise<{ games: GameAggregate[], totalCount: number }>;
|
||||
findById(id: string): Promise<GameAggregate | null>;
|
||||
findByIdIncludingDeleted(id: string): Promise<GameAggregate | null>;
|
||||
findByGameCode(gamecode: string): Promise<GameAggregate | null>;
|
||||
search(query: string, limit?: number, offset?: number): Promise<{ games: GameAggregate[], totalCount: number }>;
|
||||
searchIncludingDeleted(query: string, limit?: number, offset?: number): Promise<{ games: GameAggregate[], totalCount: number }>;
|
||||
update(id: string, update: Partial<GameAggregate>): Promise<GameAggregate | null>;
|
||||
delete(id: string): Promise<any>;
|
||||
softDelete(id: string): Promise<GameAggregate | null>;
|
||||
|
||||
// Game-specific methods
|
||||
>>>>>>> 83fad59878db015ec8d86bdec1ecbbca0baddfd2
|
||||
findActiveGames(): Promise<GameAggregate[]>;
|
||||
findGamesByPlayer(playerId: string): Promise<GameAggregate[]>;
|
||||
findWaitingGames(): Promise<GameAggregate[]>;
|
||||
findFinishedGames(from?: number, to?: number): Promise<{ games: GameAggregate[], totalCount: number }>;
|
||||
addPlayerToGame(gameId: string, playerId: string): Promise<GameAggregate | null>;
|
||||
removePlayerFromGame(gameId: string, playerId: string): Promise<GameAggregate | null>;
|
||||
updateGameState(gameId: string, started: boolean, finished?: boolean, winner?: string): Promise<GameAggregate | null>;
|
||||
updateGameState(gameId: string, state: GameState, winner?: string): Promise<GameAggregate | null>;
|
||||
}
|
||||
Reference in New Issue
Block a user