import {EventsHandler, IEventHandler} from "@nestjs/cqrs";
import {StateChangedEvent} from "../../game/events/state-changed.event";
import {QuizService} from "../quiz.service";
import {Logger} from "@nestjs/common";

@EventsHandler(StateChangedEvent)
export class StateChangedEventHandler implements IEventHandler<StateChangedEvent> {
  logger = new Logger(StateChangedEventHandler.name);
  constructor(private quizService: QuizService) {
  }

    async handle(event: StateChangedEvent) {
      this.logger.verbose(`[StateChangedEventHandler] enter, event: ${event}}`)
        await this.quizService.calculateEndgamePoints();
    }

}