import {EventsHandler, IEventHandler} from "@nestjs/cqrs";
import {WrongAnswerReceivedEvent} from "../../game/events/wrong-answer-received.event";
import {GuestsService} from "../guests.service";
import {Logger} from "@nestjs/common";

@EventsHandler(WrongAnswerReceivedEvent)
export class WrongAnswerReceivedGuestEventHandler implements IEventHandler<WrongAnswerReceivedEvent> {
  private readonly logger = new Logger(WrongAnswerReceivedEvent.name);

  constructor(private guestService: GuestsService) {
  }
  async handle(event: WrongAnswerReceivedEvent) {
    this.logger.verbose(`entering`);
    await this.guestService.incrementInvalidAnswersCount(event.tId);
  }

}