import {Body, Controller, Get, Logger, Post} from '@nestjs/common';
import {VersusService} from "./versus.service";
import {VersusDto} from "./versus.types";

@Controller('versus')
export class VersusController {
  private logger = new Logger(VersusController.name);
  constructor(private versusService: VersusService) {

  }

  @Post('simulate-versus')
  async SimulateVersus() {
    this.logger.verbose('[SimulateVersus] enter');
    return this.versusService.simulateVersus();
  }

  @Post('import')
  async Import(@Body() data: VersusDto[]) {
    return await this.versusService.importVersus(data);
  }

  @Get()
  async GetVersusTask() {
    return await this.versusService.getVersusTask();
  }

  @Post('complete')
  async Completed(@Body() payload: { winner: number, loser: number }) {
    return await this.versusService.complete(payload.winner, payload.loser);
  }

  @Post('reset-all')
  async markAllUncompleted() {
    return await this.versusService.markAllAsUncompleted();
  }
}
