import { Controller, Post, Get, Body, UseGuards, Req, HttpCode, HttpStatus } from '@nestjs/common';
import { Request } from 'express';
import { CombatService } from './combat.service';
import { StartCombatDto } from './dto/start-combat.dto';
import { AuthGuard } from '../auth/guards/auth.guard';
import { User } from '../user/user.entity';

@Controller('combat')
@UseGuards(AuthGuard)
export class CombatController {
  constructor(private readonly combatService: CombatService) {}

  @Post('start')
  @HttpCode(HttpStatus.OK)
  startCombat(
    @Body() dto: StartCombatDto,
    @Req() req: Request & { user: User },
  ) {
    return this.combatService.startCombat(dto, req.user);
  }

  @Get('history')
  getHistory(@Req() req: Request & { user: User }) {
    return this.combatService.getHistory(req.user);
  }
}
