import {EventsHandler, IEventHandler} from '@nestjs/cqrs';
import {CardsSetChangedEvent} from '../../../game/events/cards-events/cards-set-changed.event';
import {SharedService} from '../../../shared/shared.service';
import {IUserInfoMinimal} from "../../../Consts/types";
import {ClientNotificationType} from "../../socket.gateway";

@EventsHandler(CardsSetChangedEvent)
export class CardsSetChangedEventHandler
  implements IEventHandler<CardsSetChangedEvent>
{
  constructor(private sharedService: SharedService) {}
  handle(event: CardsSetChangedEvent): void {
    this.sharedService
      .notifyAllClients<IUserInfoMinimal>(ClientNotificationType.CardsChanged, { telegramId: event.telegramId})
  }
}
