Some checks failed
Deploy Dimension47 / deploy (push) Failing after 23s
- Add battle module with sessions, maps, tokens, and combatants - Implement WebSocket gateway for real-time battle updates - Add map upload with configurable grid system - Create battle canvas with token rendering and drag support - Support PC tokens from characters and NPC tokens from templates - Add initiative tracking and round management - GM-only controls for token manipulation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
81 lines
2.4 KiB
TypeScript
81 lines
2.4 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Put,
|
|
Delete,
|
|
Body,
|
|
Param,
|
|
} from '@nestjs/common';
|
|
import {
|
|
ApiTags,
|
|
ApiOperation,
|
|
ApiResponse,
|
|
ApiBearerAuth,
|
|
} from '@nestjs/swagger';
|
|
import { CombatantsService } from './combatants.service';
|
|
import { CreateCombatantDto } from './dto';
|
|
import { CurrentUser } from '../../common/decorators/current-user.decorator';
|
|
|
|
@ApiTags('Battle')
|
|
@ApiBearerAuth()
|
|
@Controller('campaigns/:campaignId/combatants')
|
|
export class CombatantsController {
|
|
constructor(private readonly combatantsService: CombatantsService) {}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'Get all NPC/Monster templates for a campaign' })
|
|
@ApiResponse({ status: 200, description: 'List of combatants' })
|
|
async findAll(
|
|
@Param('campaignId') campaignId: string,
|
|
@CurrentUser('id') userId: string,
|
|
) {
|
|
return this.combatantsService.findAll(campaignId, userId);
|
|
}
|
|
|
|
@Get(':combatantId')
|
|
@ApiOperation({ summary: 'Get a specific combatant template' })
|
|
@ApiResponse({ status: 200, description: 'Combatant details' })
|
|
async findOne(
|
|
@Param('campaignId') campaignId: string,
|
|
@Param('combatantId') combatantId: string,
|
|
@CurrentUser('id') userId: string,
|
|
) {
|
|
return this.combatantsService.findOne(campaignId, combatantId, userId);
|
|
}
|
|
|
|
@Post()
|
|
@ApiOperation({ summary: 'Create a new NPC/Monster template' })
|
|
@ApiResponse({ status: 201, description: 'Combatant created' })
|
|
async create(
|
|
@Param('campaignId') campaignId: string,
|
|
@Body() dto: CreateCombatantDto,
|
|
@CurrentUser('id') userId: string,
|
|
) {
|
|
return this.combatantsService.create(campaignId, dto, userId);
|
|
}
|
|
|
|
@Put(':combatantId')
|
|
@ApiOperation({ summary: 'Update a combatant template' })
|
|
@ApiResponse({ status: 200, description: 'Combatant updated' })
|
|
async update(
|
|
@Param('campaignId') campaignId: string,
|
|
@Param('combatantId') combatantId: string,
|
|
@Body() dto: CreateCombatantDto,
|
|
@CurrentUser('id') userId: string,
|
|
) {
|
|
return this.combatantsService.update(campaignId, combatantId, dto, userId);
|
|
}
|
|
|
|
@Delete(':combatantId')
|
|
@ApiOperation({ summary: 'Delete a combatant template' })
|
|
@ApiResponse({ status: 200, description: 'Combatant deleted' })
|
|
async delete(
|
|
@Param('campaignId') campaignId: string,
|
|
@Param('combatantId') combatantId: string,
|
|
@CurrentUser('id') userId: string,
|
|
) {
|
|
return this.combatantsService.delete(campaignId, combatantId, userId);
|
|
}
|
|
}
|