@omnitronix/bonnys-fortune-game-engine 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/dist/__tests__/comprehensive.test.js +741 -0
  2. package/dist/__tests__/comprehensive.test.js.map +1 -0
  3. package/dist/bonnys-fortune-v1.game-engine.js +12 -7
  4. package/dist/bonnys-fortune-v1.game-engine.js.map +1 -1
  5. package/dist/domain/types/{cheat-trigger-bonus-command.js → debug-trigger-bonus-command.js} +1 -1
  6. package/dist/domain/types/debug-trigger-bonus-command.js.map +1 -0
  7. package/dist/domain/types/{cheat-trigger-bonus-request.dto.js → debug-trigger-bonus-request.dto.js} +1 -1
  8. package/dist/domain/types/debug-trigger-bonus-request.dto.js.map +1 -0
  9. package/dist/domain/types/{cheat-update-bonus-meter-progress-command.js → debug-update-bonus-meter-progress-command.js} +1 -1
  10. package/dist/domain/types/debug-update-bonus-meter-progress-command.js.map +1 -0
  11. package/dist/domain/types/{cheat-update-bonus-meter-progress-request.dto.js → debug-update-bonus-meter-progress-request.dto.js} +1 -1
  12. package/dist/domain/types/debug-update-bonus-meter-progress-request.dto.js.map +1 -0
  13. package/dist/logic/bonnys-fortune.game-logic.js +4 -2
  14. package/dist/logic/bonnys-fortune.game-logic.js.map +1 -1
  15. package/dist/rng/DummyRngClient.js +8 -1
  16. package/dist/rng/DummyRngClient.js.map +1 -1
  17. package/dist/rng/rng-client.factory.js +1 -2
  18. package/dist/rng/rng-client.factory.js.map +1 -1
  19. package/package.json +3 -4
  20. package/dist/__tests__/bonnys-fortune-v1.game-engine.test.d.ts +0 -1
  21. package/dist/bonnys-fortune-v1.game-engine.d.ts +0 -32
  22. package/dist/config/game-logic-config/file-system.game-logic-config-loader.d.ts +0 -4
  23. package/dist/config/game-logic-config/game-logic-config-loader.d.ts +0 -3
  24. package/dist/config/game-logic-config/game-logic-config.d.ts +0 -2
  25. package/dist/config/reel-strips-config/file-system.reel-strips-config-loader.d.ts +0 -4
  26. package/dist/config/reel-strips-config/reel-strip-option.dto.d.ts +0 -4
  27. package/dist/config/reel-strips-config/reel-strips-config-loader.d.ts +0 -3
  28. package/dist/config/reel-strips-config/reel-strips-config.dto.d.ts +0 -5
  29. package/dist/config/reel-strips-config/reel.dto.d.ts +0 -5
  30. package/dist/domain/game-round.types.d.ts +0 -9
  31. package/dist/domain/mappers/reel-strips-config.mapper.d.ts +0 -4
  32. package/dist/domain/reel-strip-option.d.ts +0 -7
  33. package/dist/domain/reel-strips-config.d.ts +0 -9
  34. package/dist/domain/reel.d.ts +0 -8
  35. package/dist/domain/types/cheat-trigger-bonus-command.d.ts +0 -5
  36. package/dist/domain/types/cheat-trigger-bonus-command.js.map +0 -1
  37. package/dist/domain/types/cheat-trigger-bonus-request.dto.d.ts +0 -5
  38. package/dist/domain/types/cheat-trigger-bonus-request.dto.js.map +0 -1
  39. package/dist/domain/types/cheat-update-bonus-meter-progress-command.d.ts +0 -5
  40. package/dist/domain/types/cheat-update-bonus-meter-progress-command.js.map +0 -1
  41. package/dist/domain/types/cheat-update-bonus-meter-progress-request.dto.d.ts +0 -5
  42. package/dist/domain/types/cheat-update-bonus-meter-progress-request.dto.js.map +0 -1
  43. package/dist/domain/types/game-spin-command.d.ts +0 -8
  44. package/dist/domain/types/game-spin-input.dto.d.ts +0 -8
  45. package/dist/domain/types/game-spin-output.dto.d.ts +0 -119
  46. package/dist/domain/types/game-symbols.response.dto.d.ts +0 -10
  47. package/dist/domain/types/reel-strip-option.dto.d.ts +0 -4
  48. package/dist/domain/types/reel-strips-config.dto.d.ts +0 -5
  49. package/dist/domain/types/reel.dto.d.ts +0 -5
  50. package/dist/domain/types/start-bonus-round-command.d.ts +0 -8
  51. package/dist/domain/types/start-bonus-round-input.dto.d.ts +0 -10
  52. package/dist/game-engine.interface.d.ts +0 -41
  53. package/dist/helpers/generate-hash.d.ts +0 -1
  54. package/dist/helpers/number-helper.d.ts +0 -23
  55. package/dist/helpers/optional-boolean-mapper.d.ts +0 -1
  56. package/dist/helpers/uuid-helper.d.ts +0 -3
  57. package/dist/helpers/validation-helper.d.ts +0 -14
  58. package/dist/index.d.ts +0 -2
  59. package/dist/logger/logger.d.ts +0 -22
  60. package/dist/logic/bonnys-fortune.game-logic.d.ts +0 -32
  61. package/dist/logic/bonnys-fortune.spin-generator.d.ts +0 -19
  62. package/dist/logic/bonnys-fortune.types.d.ts +0 -170
  63. package/dist/logic/bonnys-fortune.win-calculator.d.ts +0 -10
  64. package/dist/logic/game-logic-config.interface.d.ts +0 -178
  65. package/dist/logic/handlers/base-game.handler.d.ts +0 -15
  66. package/dist/logic/handlers/collect-feature-bonus.handler.d.ts +0 -13
  67. package/dist/logic/handlers/free-spins-bonus.handler.d.ts +0 -11
  68. package/dist/logic/handlers/steering-to-the-fortune-bonus.handler.d.ts +0 -11
  69. package/dist/logic/handlers/treasure-hunt-bonus.handler.d.ts +0 -15
  70. package/dist/rng/DummyRngClient.d.ts +0 -18
  71. package/dist/rng/rng-client.factory.d.ts +0 -7
  72. package/dist/rng/rng-client.interface.d.ts +0 -16
  73. package/dist/rng/rng-service.d.ts +0 -26
  74. package/dist/validation/abstract-game-logic-config.validator.d.ts +0 -4
  75. package/dist/validation/bonnys-fortune/bonnys-fortune-config.dto.d.ts +0 -129
  76. package/dist/validation/bonnys-fortune/bonnys-fortune-config.validator.d.ts +0 -5
  77. package/dist/validation/custom-decorators/IsNestedIntArray.d.ts +0 -2
  78. package/dist/validation/game-logic-config-validation.service.d.ts +0 -8
  79. package/dist/validation/reel-strips-config-validation.service.d.ts +0 -5
  80. package/src/__tests__/bonnys-fortune-v1.game-engine.test.ts +0 -80
  81. package/src/bonnys-fortune-v1.game-engine.ts +0 -285
  82. package/src/config/game-logic-config/file-system.game-logic-config-loader.ts +0 -27
  83. package/src/config/game-logic-config/game-logic-config-loader.ts +0 -3
  84. package/src/config/game-logic-config/game-logic-config.ts +0 -380
  85. package/src/config/reel-strips-config/file-system.reel-strips-config-loader.ts +0 -43
  86. package/src/config/reel-strips-config/reel-strip-option.dto.ts +0 -13
  87. package/src/config/reel-strips-config/reel-strips-config-loader.ts +0 -9
  88. package/src/config/reel-strips-config/reel-strips-config.dto.ts +0 -16
  89. package/src/config/reel-strips-config/reel.dto.ts +0 -16
  90. package/src/config/reel-strips-config/reels-BASE.csv +0 -52
  91. package/src/config/reel-strips-config/reels-BONUS.csv +0 -52
  92. package/src/domain/game-round.types.ts +0 -10
  93. package/src/domain/mappers/reel-strips-config.mapper.ts +0 -16
  94. package/src/domain/reel-strip-option.ts +0 -15
  95. package/src/domain/reel-strips-config.ts +0 -21
  96. package/src/domain/reel.ts +0 -17
  97. package/src/domain/types/cheat-trigger-bonus-command.ts +0 -5
  98. package/src/domain/types/cheat-trigger-bonus-request.dto.ts +0 -5
  99. package/src/domain/types/cheat-update-bonus-meter-progress-command.ts +0 -6
  100. package/src/domain/types/cheat-update-bonus-meter-progress-request.dto.ts +0 -5
  101. package/src/domain/types/game-spin-command.ts +0 -8
  102. package/src/domain/types/game-spin-input.dto.ts +0 -8
  103. package/src/domain/types/game-spin-output.dto.ts +0 -142
  104. package/src/domain/types/game-symbols.response.dto.ts +0 -11
  105. package/src/domain/types/reel-strip-option.dto.ts +0 -13
  106. package/src/domain/types/reel-strips-config.dto.ts +0 -15
  107. package/src/domain/types/reel.dto.ts +0 -15
  108. package/src/domain/types/start-bonus-round-command.ts +0 -8
  109. package/src/domain/types/start-bonus-round-input.dto.ts +0 -10
  110. package/src/game-engine.interface.ts +0 -59
  111. package/src/helpers/generate-hash.ts +0 -5
  112. package/src/helpers/number-helper.ts +0 -41
  113. package/src/helpers/optional-boolean-mapper.ts +0 -5
  114. package/src/helpers/uuid-helper.ts +0 -7
  115. package/src/helpers/validation-helper.ts +0 -27
  116. package/src/index.ts +0 -3
  117. package/src/logger/logger.ts +0 -178
  118. package/src/logic/bonnys-fortune.game-logic.ts +0 -480
  119. package/src/logic/bonnys-fortune.spin-generator.ts +0 -277
  120. package/src/logic/bonnys-fortune.types.ts +0 -223
  121. package/src/logic/bonnys-fortune.win-calculator.ts +0 -210
  122. package/src/logic/game-logic-config.interface.ts +0 -174
  123. package/src/logic/handlers/base-game.handler.ts +0 -213
  124. package/src/logic/handlers/collect-feature-bonus.handler.ts +0 -301
  125. package/src/logic/handlers/free-spins-bonus.handler.ts +0 -119
  126. package/src/logic/handlers/steering-to-the-fortune-bonus.handler.ts +0 -118
  127. package/src/logic/handlers/treasure-hunt-bonus.handler.ts +0 -232
  128. package/src/rng/DummyRngClient.ts +0 -108
  129. package/src/rng/rng-client.factory.ts +0 -27
  130. package/src/rng/rng-client.interface.ts +0 -38
  131. package/src/rng/rng-service.ts +0 -130
  132. package/src/validation/abstract-game-logic-config.validator.ts +0 -20
  133. package/src/validation/bonnys-fortune/bonnys-fortune-config.dto.ts +0 -371
  134. package/src/validation/bonnys-fortune/bonnys-fortune-config.validator.ts +0 -8
  135. package/src/validation/custom-decorators/IsNestedIntArray.ts +0 -29
  136. package/src/validation/game-logic-config-validation.service.ts +0 -28
  137. package/src/validation/reel-strips-config-validation.service.ts +0 -29
@@ -1,130 +0,0 @@
1
- import { RngOutcome, RngOutcomeRecord } from '../game-engine.interface';
2
-
3
- import { IRngClient } from './rng-client.interface';
4
-
5
- export class RngService {
6
- private rngOutcomes: {
7
- [commandId: string]: RngOutcome;
8
- } = {};
9
-
10
- constructor(private readonly rngClient: IRngClient) {}
11
-
12
- public registerCommand(commandId: string): void {
13
- if (!this.rngOutcomes[commandId]) {
14
- this.rngOutcomes[commandId] = {};
15
- }
16
- }
17
-
18
- public async getSingleNumber(
19
- min: number,
20
- max: number,
21
- commandId: string,
22
- actionId: string,
23
- ): Promise<{ value: number; seed: number }> {
24
- const existingSeed = this.getSeedForCommand(commandId, actionId);
25
-
26
- if (existingSeed) {
27
- const result = await this.rngClient.getSingleNumber(
28
- existingSeed.min,
29
- existingSeed.max,
30
- existingSeed.seed,
31
- );
32
- return result;
33
- } else {
34
- const result = await this.rngClient.getSingleNumber(min, max);
35
- this.storeSeedForCommand(
36
- commandId,
37
- actionId,
38
- result.value,
39
- result.seed,
40
- min,
41
- max,
42
- );
43
- return result;
44
- }
45
- }
46
-
47
- public async getBatchNumbers(
48
- min: number,
49
- max: number,
50
- count: number,
51
- commandId: string,
52
- actionId: string,
53
- ): Promise<{ value: number; seed: number }[]> {
54
- const results: { value: number; seed: number }[] = [];
55
-
56
- for (let i = 0; i < count; i++) {
57
- const result = await this.getSingleNumber(
58
- min,
59
- max,
60
- commandId,
61
- `${actionId}_${i}`,
62
- );
63
- results.push(result);
64
- }
65
-
66
- return results;
67
- }
68
-
69
- private getSeedForCommand(
70
- commandId: string,
71
- actionId: string,
72
- ): RngOutcomeRecord | null {
73
- try {
74
- const commandSeeds = this.rngOutcomes[commandId];
75
- if (!commandSeeds) {
76
- return null;
77
- }
78
-
79
- const actionSeed = commandSeeds[actionId];
80
- if (!actionSeed) {
81
- return null;
82
- }
83
-
84
- return actionSeed;
85
- } catch (error) {
86
- return null;
87
- }
88
- }
89
-
90
- private storeSeedForCommand(
91
- commandId: string,
92
- actionId: string,
93
- result: number,
94
- seed: number,
95
- min: number,
96
- max: number,
97
- ): void {
98
- this.registerCommand(commandId);
99
- this.rngOutcomes[commandId][actionId] = { result, seed, min, max };
100
- }
101
-
102
- public getRngOutcomeForCommand(commandId: string): RngOutcome {
103
- return this.rngOutcomes[commandId] || {};
104
- }
105
-
106
- public getAllRngOutcome(): {
107
- [commandId: string]: RngOutcome;
108
- } {
109
- return { ...this.rngOutcomes };
110
- }
111
-
112
- public removeCommand(commandId: string): void {
113
- delete this.rngOutcomes[commandId];
114
- }
115
-
116
- public clearAllRngOutcome(): void {
117
- this.rngOutcomes = {};
118
- }
119
-
120
- public hasCommandRngOutcome(commandId: string): boolean {
121
- const commandSeeds = this.rngOutcomes[commandId];
122
- return commandSeeds ? Object.keys(commandSeeds).length > 0 : false;
123
- }
124
-
125
- public getRngOutcomeCountForCommand(commandId: string): number {
126
- const commandSeeds = this.rngOutcomes[commandId];
127
- if (!commandSeeds) return 0;
128
- return Object.keys(commandSeeds).length;
129
- }
130
- }
@@ -1,20 +0,0 @@
1
- import { ValidationError } from 'class-validator';
2
- import { ValidationHelper } from '../helpers/validation-helper';
3
- import { plainToInstance } from 'class-transformer';
4
-
5
- export abstract class AbstractGameLogicConfigValidator<T extends object> {
6
- protected abstract getDtoClass(): new () => T;
7
-
8
- public async validate(config: unknown): Promise<T> {
9
- const dto = plainToInstance(this.getDtoClass(), config);
10
-
11
- const errors: ValidationError[] = await ValidationHelper.validate<T>(dto);
12
-
13
- if (errors.length > 0) {
14
- console.error(JSON.stringify(errors, null, 2));
15
- throw new Error('Game logic config validation failed');
16
- }
17
-
18
- return dto;
19
- }
20
- }
@@ -1,371 +0,0 @@
1
- import { Type } from 'class-transformer';
2
- import {
3
- IsArray,
4
- IsBoolean,
5
- IsInt,
6
- IsObject,
7
- IsOptional,
8
- IsString,
9
- ValidateIf,
10
- ValidateNested,
11
- } from 'class-validator';
12
-
13
- // --- SymbolMultiplier ---
14
-
15
- export class SymbolMultipliersDto {
16
- @IsInt()
17
- public symbolId: number;
18
-
19
- @IsString()
20
- public name: string;
21
-
22
- @IsObject()
23
- public multipliers: Record<'x3' | 'x4' | 'x5', number>;
24
-
25
- @IsBoolean()
26
- public isWild: boolean;
27
-
28
- @IsBoolean()
29
- public isScatter: boolean;
30
- }
31
-
32
- // --- SymbolDefinitions ---
33
-
34
- export class CollectFeatureSymbolsDto {
35
- @IsObject()
36
- public multipliers: Record<string, number>;
37
-
38
- @IsObject()
39
- public values: Record<string, number>;
40
- }
41
-
42
- export class SymbolRangeDto {
43
- @IsInt()
44
- public minIndex: number;
45
-
46
- @IsInt()
47
- public maxIndex: number;
48
- }
49
-
50
- export class SymbolDefinitionsDto {
51
- @ValidateNested()
52
- @Type(() => SymbolRangeDto)
53
- public baseSymbols: SymbolRangeDto;
54
-
55
- @IsObject()
56
- public specialSymbols: Record<string, number>;
57
-
58
- @ValidateNested()
59
- @Type(() => CollectFeatureSymbolsDto)
60
- public collectFeatureSymbols: CollectFeatureSymbolsDto;
61
- }
62
-
63
- // --- BaseGameConfig ---
64
-
65
- export class LayoutDto {
66
- @IsInt()
67
- public rows: number;
68
-
69
- @IsInt()
70
- public reels: number;
71
- }
72
-
73
- export class WinConfigDto {
74
- @IsInt()
75
- public minLength: number;
76
-
77
- @IsInt()
78
- public maxLength: number;
79
- }
80
-
81
- // --- ReelsOptions ---
82
-
83
- export class ReelsOptionsDto {
84
- @IsInt()
85
- public numberOfOptions: number;
86
-
87
- @IsArray()
88
- @IsInt({ each: true })
89
- public optionWeights: number[];
90
- }
91
-
92
- export class BaseGameConfigDto {
93
- @ValidateNested()
94
- @Type(() => LayoutDto)
95
- public layout: LayoutDto;
96
-
97
- @ValidateNested()
98
- @Type(() => WinConfigDto)
99
- public winConfig: WinConfigDto;
100
-
101
- @IsInt()
102
- public baseBet: number;
103
-
104
- @ValidateNested()
105
- @Type(() => ReelsOptionsDto)
106
- public reelsOptions: ReelsOptionsDto;
107
- }
108
-
109
- // --- BonusGameMeter ---
110
-
111
- export class BonusGameMeterDto {
112
- @IsString()
113
- public symbol: string;
114
-
115
- @IsInt()
116
- public min: number;
117
-
118
- @IsInt()
119
- public max: number;
120
- }
121
-
122
- // --- BaseGame ---
123
-
124
- export class BaseGameDto {
125
- @IsArray()
126
- @ValidateNested({ each: true })
127
- @Type(() => SymbolMultipliersDto)
128
- public symbolMultipliers: SymbolMultipliersDto[];
129
-
130
- @ValidateNested()
131
- @Type(() => SymbolDefinitionsDto)
132
- public symbolDefinitions: SymbolDefinitionsDto;
133
-
134
- @ValidateNested()
135
- @Type(() => BaseGameConfigDto)
136
- public baseGameConfig: BaseGameConfigDto;
137
-
138
- @IsObject()
139
- public paidHSymbolWeights: Record<string, number>;
140
-
141
- @IsObject()
142
- public paidHSymbolReelWeights: Record<string, [number, number]>;
143
-
144
- @IsObject()
145
- public paidScatterReelWeights: Record<string, [number, number]>;
146
-
147
- @IsObject()
148
- public bonusGameMeters: Record<string, BonusGameMeterDto>;
149
- }
150
-
151
- // --- BonusGame Specific Config DTOs ---
152
-
153
- export class TreasureHuntBonusConfigDto {
154
- @IsInt()
155
- public symbolsCount: number;
156
-
157
- @IsInt()
158
- public stepsCount: number;
159
-
160
- @IsObject()
161
- public jackpotMultipliers: Record<
162
- 'mini' | 'minor' | 'major' | 'grand',
163
- number
164
- >;
165
-
166
- @IsObject()
167
- public jackpotStartCounts: Record<
168
- 'mini' | 'minor' | 'major' | 'grand',
169
- number
170
- >;
171
-
172
- @IsObject()
173
- public jackpotScreenCounts: Record<
174
- 'mini' | 'minor' | 'major' | 'grand',
175
- number
176
- >;
177
-
178
- @IsObject()
179
- public winningWeights: Record<
180
- 'none' | 'mini' | 'minor' | 'major' | 'grand',
181
- number
182
- >;
183
- }
184
-
185
- // --- BonusGameEvaluationConfigDto ---
186
-
187
- export class BonusGameEvaluationConfigDto {
188
- @IsString()
189
- public defaultConfig: string;
190
-
191
- @IsArray()
192
- @IsString({ each: true })
193
- @IsOptional()
194
- public alternativeConfigs?: string[];
195
-
196
- @IsOptional()
197
- @IsObject()
198
- public selectionWeights?: Record<string, number>;
199
- }
200
-
201
- // --- BonusGameDto (discriminated union with validation) ---
202
-
203
- export class BaseBonusGameDto {
204
- @IsString()
205
- public type: string;
206
-
207
- @IsString()
208
- public potMeter: string;
209
-
210
- @ValidateNested()
211
- @Type(() => BonusGameEvaluationConfigDto)
212
- public evaluationConfig: BonusGameEvaluationConfigDto;
213
- }
214
-
215
- export class TreasureHuntBonusGameDto extends BaseBonusGameDto {
216
- @ValidateNested()
217
- @Type(() => TreasureHuntBonusConfigDto)
218
- public config: TreasureHuntBonusConfigDto;
219
- }
220
-
221
- export class FreeSpinTypeDto {
222
- @ValidateNested()
223
- @Type(() => LayoutDto)
224
- public layout: LayoutDto;
225
-
226
- @IsInt()
227
- public spins: number;
228
-
229
- @IsInt()
230
- public multiplier: number;
231
-
232
- @IsInt()
233
- public weight: number;
234
-
235
- @IsArray()
236
- @IsInt({ each: true })
237
- public reelsOptionsWeights: number[];
238
- }
239
-
240
- export class FreeSpinBonusConfigDto {
241
- @IsArray()
242
- @ValidateNested({ each: true })
243
- @Type(() => FreeSpinTypeDto)
244
- public spinTypes: FreeSpinTypeDto[];
245
- }
246
-
247
- export class FreeSpinBonusGameDto extends BaseBonusGameDto {
248
- @ValidateNested()
249
- @Type(() => FreeSpinBonusConfigDto)
250
- public config: FreeSpinBonusConfigDto;
251
- }
252
-
253
- export class SteeringToTheFortuneWheelResultDto {
254
- @IsString()
255
- public type: 'MULTIPLIER' | 'BONUS';
256
-
257
- @IsOptional()
258
- @IsInt()
259
- public value?: number;
260
-
261
- @IsOptional()
262
- @IsString()
263
- public bonusType?: string;
264
-
265
- @IsInt()
266
- public weight: number;
267
- }
268
-
269
- export class SteeringToTheFortuneBonusConfigDto {
270
- @IsArray()
271
- @ValidateNested({ each: true })
272
- @Type(() => SteeringToTheFortuneWheelResultDto)
273
- public wheelResults: SteeringToTheFortuneWheelResultDto[];
274
- }
275
-
276
- export class SteeringToTheFortuneBonusGameDto extends BaseBonusGameDto {
277
- @ValidateNested()
278
- @Type(() => SteeringToTheFortuneBonusConfigDto)
279
- public config: SteeringToTheFortuneBonusConfigDto;
280
- }
281
-
282
- export class BonusGamesDto {
283
- @ValidateNested()
284
- @Type(() => TreasureHuntBonusGameDto)
285
- @ValidateIf((o) => o['bonusGame1'] !== undefined)
286
- public bonusGame1?: TreasureHuntBonusGameDto;
287
-
288
- @ValidateNested()
289
- @Type(() => FreeSpinBonusGameDto)
290
- @ValidateIf((o) => o['bonusGame2'] !== undefined)
291
- public bonusGame2?: FreeSpinBonusGameDto;
292
-
293
- @ValidateNested()
294
- @Type(() => SteeringToTheFortuneBonusGameDto)
295
- @ValidateIf((o) => o['bonusGame3'] !== undefined)
296
- public bonusGame3?: SteeringToTheFortuneBonusGameDto;
297
- }
298
-
299
- // --- ScatterSymbolDto ---
300
-
301
- export class ScatterSymbolDto {
302
- @IsString()
303
- public symbolId: string;
304
-
305
- @IsInt()
306
- public value: number;
307
-
308
- @IsInt()
309
- public weight: number;
310
- }
311
-
312
- // --- ScatterGameConfigDto ---
313
-
314
- export class ScatterCheckpointDto {
315
- @IsInt()
316
- public spin: number;
317
-
318
- @IsInt()
319
- public multiMinValue: number;
320
-
321
- @IsInt()
322
- public valueMinValue: number;
323
- }
324
-
325
- export class ScatterGameConfigDto {
326
- @IsInt()
327
- public scatterMinNumber: number;
328
-
329
- @IsInt()
330
- public scatterSpins: number;
331
-
332
- @IsArray()
333
- @ValidateNested({ each: true })
334
- @Type(() => ScatterCheckpointDto)
335
- public scatterCheckpoints: ScatterCheckpointDto[];
336
-
337
- @IsArray()
338
- @ValidateNested({ each: true })
339
- @Type(() => ScatterSymbolDto)
340
- public scatterSymbols: ScatterSymbolDto[];
341
-
342
- @IsArray()
343
- @IsObject({ each: true })
344
- public scatterSymbolSpins: Record<string, number>[];
345
-
346
- @IsArray()
347
- @IsObject({ each: true })
348
- public scatterSymbolSlash: Record<string, number>[];
349
- }
350
-
351
- export class ScatterGameConfigWrapperDto {
352
- @ValidateNested()
353
- @Type(() => ScatterGameConfigDto)
354
- public config: ScatterGameConfigDto;
355
- }
356
-
357
- // --- Root Config DTO ---
358
-
359
- export class BonnysFortuneGameLogicConfigDto {
360
- @ValidateNested()
361
- @Type(() => BaseGameDto)
362
- public baseGame: BaseGameDto;
363
-
364
- @ValidateNested()
365
- @Type(() => BonusGamesDto)
366
- public bonusGames: BonusGamesDto;
367
-
368
- @ValidateNested()
369
- @Type(() => ScatterGameConfigWrapperDto)
370
- public scatterGame: ScatterGameConfigWrapperDto;
371
- }
@@ -1,8 +0,0 @@
1
- import { AbstractGameLogicConfigValidator } from '../abstract-game-logic-config.validator';
2
- import { BonnysFortuneGameLogicConfigDto } from './bonnys-fortune-config.dto';
3
-
4
- export class BonnysFortuneGameLogicConfigValidator extends AbstractGameLogicConfigValidator<BonnysFortuneGameLogicConfigDto> {
5
- protected getDtoClass(): new () => BonnysFortuneGameLogicConfigDto {
6
- return BonnysFortuneGameLogicConfigDto;
7
- }
8
- }
@@ -1,29 +0,0 @@
1
- import {
2
- registerDecorator,
3
- ValidationArguments,
4
- ValidationOptions,
5
- } from 'class-validator';
6
-
7
- export function IsNestedIntArray(validationOptions?: ValidationOptions) {
8
- return function (object: object, propertyName: string) {
9
- registerDecorator({
10
- name: 'isNestedIntArray',
11
- target: object.constructor,
12
- propertyName: propertyName,
13
- options: validationOptions,
14
- validator: {
15
- validate(value: any) {
16
- if (!Array.isArray(value)) return false;
17
- return value.every(
18
- (inner) =>
19
- Array.isArray(inner) &&
20
- inner.every((num) => Number.isInteger(num)),
21
- );
22
- },
23
- defaultMessage(args: ValidationArguments) {
24
- return `${args.property} must be a nested array of integers`;
25
- },
26
- },
27
- });
28
- };
29
- }
@@ -1,28 +0,0 @@
1
- export interface GameLogicConfigValidatorInterface<T = any> {
2
- validate(config: unknown): Promise<T>;
3
- }
4
-
5
- export class GameLogicConfigValidationService {
6
- private validators: Map<string, GameLogicConfigValidatorInterface> =
7
- new Map();
8
-
9
- public register<T>(
10
- gameId: string,
11
- validator: GameLogicConfigValidatorInterface<T>,
12
- ): void {
13
- this.validators.set(gameId, validator);
14
- }
15
-
16
- public async validate<T extends object>(
17
- gameId: string,
18
- config: unknown,
19
- ): Promise<T> {
20
- const validator = this.validators.get(gameId);
21
-
22
- if (!validator) {
23
- throw new Error(`No validator registered for gameId: ${gameId}`);
24
- }
25
-
26
- return validator.validate(config);
27
- }
28
- }
@@ -1,29 +0,0 @@
1
- import { ReelDto } from '../config/reel-strips-config/reel.dto';
2
- import { ReelStripOptionDto } from '../config/reel-strips-config/reel-strip-option.dto';
3
- import { ReelStripsConfigDto } from '../config/reel-strips-config/reel-strips-config.dto';
4
- import { ValidationHelper } from '../helpers/validation-helper';
5
-
6
- export class ReelStripsConfigValidationService {
7
- private mapRawToDto(raw: number[][][]): ReelStripsConfigDto {
8
- const reels = raw.map((reel) => {
9
- const options = reel.map(
10
- (optionSymbols) => new ReelStripOptionDto(optionSymbols),
11
- );
12
- return new ReelDto(options);
13
- });
14
- return new ReelStripsConfigDto(reels);
15
- }
16
-
17
- public async validate(rawReels: number[][][]): Promise<ReelStripsConfigDto> {
18
- const dto = this.mapRawToDto(rawReels);
19
- const errors = await ValidationHelper.validate(dto);
20
-
21
- if (errors.length > 0) {
22
- throw new Error(
23
- 'Reel strips validation failed: ' + JSON.stringify(errors, null, 2),
24
- );
25
- }
26
-
27
- return dto;
28
- }
29
- }