Skip to content

Commit

Permalink
belongs to last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vkallerud committed Jun 26, 2024
1 parent 9a79050 commit fff9707
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/app/game/game-config/game-config.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Injectable } from '@angular/core';

export interface GameConfig {
difficultyId: number,
rounds: number;
secondsPerRound: number;
}

@Injectable({
providedIn: 'root'
})
export class GameConfigService {
private config: GameConfig = {
difficultyId: 2,
rounds: 3,
secondsPerRound: 20
};

constructor() {}

getConfig(): GameConfig {
return this.config;
}

setConfig(newConfig: GameConfig): void {
this.config = { ...this.config, ...newConfig };
}

setDifficultyLevel(level: 'easy' | 'medium' | 'hard'): void {
switch (level) {
case 'easy':
this.setConfig({ difficultyId: 1, rounds: 3, secondsPerRound: 30 });
break;
case 'medium':
this.setConfig({ difficultyId: 2, rounds: 3, secondsPerRound: 20 });
break;
case 'hard':
this.setConfig({ difficultyId: 3, rounds: 5, secondsPerRound: 15 });
break;
}
}
}

0 comments on commit fff9707

Please sign in to comment.