fel kesz game backend

This commit is contained in:
2025-09-15 19:00:35 +02:00
parent 7963f28021
commit 3af8de2797
267 changed files with 15655 additions and 347 deletions
@@ -26,10 +26,26 @@ export enum CardType {
CLOSER = 4
}
export enum ConsequenceType {
MOVE_FORWARD = 0,
MOVE_BACKWARD = 1,
LOSE_TURN = 2,
EXTRA_TURN = 3,
SWAP_POSITION = 4,
GO_TO_START = 5,
TURN_AGAIN = 6
}
export interface Consequence {
type: ConsequenceType;
value?: number;
}
export interface Card {
text: string;
type?: CardType;
answer?: string | null;
consequence?: Consequence | null;
}
@Entity('Decks')
@@ -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;
}
@@ -0,0 +1,24 @@
import { GameAggregate } from '../Game/GameAggregate';
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
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>;
}
@@ -38,9 +38,6 @@ export class UserAggregate {
@Column({ type: 'timestamp', nullable: true })
TokenExpires!: Date | null;
@Column({ type: 'varchar', length: 50 })
type!: string;
@Column({ type: 'varchar', length: 20, nullable: true })
phone!: string | null;