86211923db
Repository Interface Optimization: - Created IBaseRepository.ts and IPaginatedRepository.ts - Refactored all 7 repository interfaces to extend base interfaces - Eliminated ~200 lines of redundant code (70% reduction) - Improved type safety and maintainability Dependency Injection Improvements: - Added EmailService and GameTokenService to DIContainer - Updated CreateUserCommandHandler constructor for DI - Updated RequestPasswordResetCommandHandler constructor for DI - Enhanced testability and service consistency Environment Configuration: - Created comprehensive .env.example with 40+ variables - Organized into 12 logical sections (Database, Security, Email, etc.) - Added security guidelines and best practices - Documented all backend environment requirements Documentation: - Added comprehensive codebase review - Created refactoring summary report - Added frontend implementation guide Impact: Improved code quality, reduced maintenance overhead, enhanced developer experience
103 lines
2.4 KiB
TypeScript
103 lines
2.4 KiB
TypeScript
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';
|
|
import { Consequence, CardType } 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?: any; // Support complex answer structures (string, object, array)
|
|
type?: CardType; // Card type for validation logic
|
|
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[];
|
|
generationComplete?: boolean;
|
|
generatedAt?: Date;
|
|
error?: string;
|
|
} |