import {forwardRef, Module} from '@nestjs/common';
import { GuestsService } from './guests.service';
import { MongooseModule } from '@nestjs/mongoose';
import { Guest, GuestSchema } from '../schemas/guest.schema';
import { GuestsController } from './guests.controller';
import { GuestsRemoveKeyboardHandler } from './command/guests.remove-keyboard.handler';
import { CqrsModule } from '@nestjs/cqrs';
import { GuestsPrepareGameEventHandler } from './command/guests.prepare-game.event.handler';
import { GuestCardDealedEventHandler } from './event-handlers/guest-card-dealed.event.handler';
import { CardsModule } from '../cards/cards.module';
import { GuestValidAnswerReceivedEventHandler } from './event-handlers/guest-valid-answer-received-event.handler';
import { GuestGameStartEventHandler } from './event-handlers/guest-game-start-event.handler';
import { GuestsResetPlayerPrizeChanceCommandHandler } from './command/reset-player-prize-chance-command.handler';
import { GuestQuizAnswerStateChangedEventHandler } from './event-handlers/guest-quiz-answer-state-changed-event.handler';
import { GiveCardsCommandHandler } from '../game/comand-handlers/give-cards-command.handler';
import { IncreasePlayerWinningRateCommandHandler } from './command/increase-player-winning-rate-command.handler';
import { Config, ConfigSchema } from '../schemas/config.schema';
import {TgPostCardsToUserCommandHandler} from "./command/guests.post-cards-to-user-command";
import {TgCardSelectionSceneCommandHandler} from "./command/guests.card-selection-timeout.handler";
import {ConfigModule, ConfigService} from "@nestjs/config";
import {RemoveCardFromUserCommandHandler} from "./command/remove-card-from-user.handler";
import {GetGuestPropertyHandler} from "./command/get-guest-property.handler";
import {QueryHandlers } from "./queries";
import {SetGuestPropertyCommandHandler} from "./command/handlers/set-guest-property.handler";
import {WrongAnswerReceivedGuestEventHandler} from "./event-handlers/wrong-answer-received-guest-event.handler";

import {VoiceModule} from "../voice/voice.module";
import {IncreasePlayerScoreCommandHandler} from "./command/handlers/increase-player-score-command.handler";
import {QuizService} from "../quiz/quiz.service";
import {QuizModule} from "../quiz/quiz.module";


const commandHandlers = [
  GuestsRemoveKeyboardHandler,
  GuestsResetPlayerPrizeChanceCommandHandler,
  IncreasePlayerWinningRateCommandHandler,
  GetGuestPropertyHandler,
  SetGuestPropertyCommandHandler,
  IncreasePlayerScoreCommandHandler,
];


const eventHandlers = [
  GuestsPrepareGameEventHandler,
  GuestCardDealedEventHandler,
  GuestValidAnswerReceivedEventHandler,
  GuestGameStartEventHandler,
  GuestQuizAnswerStateChangedEventHandler,
  GiveCardsCommandHandler,
  TgPostCardsToUserCommandHandler,
  TgCardSelectionSceneCommandHandler,
  RemoveCardFromUserCommandHandler,
  WrongAnswerReceivedGuestEventHandler,
];

@Module({
  imports: [
    ConfigModule,
    MongooseModule.forFeature([
      { name: Guest.name, schema: GuestSchema },
      { name: Config.name, schema: ConfigSchema },
    ]),
    VoiceModule,
    CqrsModule,
    CardsModule,
  ],
  providers: [GuestsService, ConfigService, ...commandHandlers,...QueryHandlers, ...eventHandlers, ],
  exports: [GuestsService,],
  controllers: [GuestsController],
})
export class GuestsModule {}
