1
1
import { Body , Controller , ForbiddenException , Get , Param , ParseBoolPipe , Patch , Post , Query } from '@nestjs/common' ;
2
2
import {
3
3
ApiCreatedResponse ,
4
- ApiForbiddenResponse , ApiNotFoundResponse ,
4
+ ApiForbiddenResponse ,
5
+ ApiNotFoundResponse ,
5
6
ApiOkResponse ,
6
7
ApiOperation ,
7
8
ApiQuery ,
@@ -17,8 +18,8 @@ import {Empire} from './empire.schema';
17
18
import { EmpireService } from './empire.service' ;
18
19
import { notFound , NotFound , ObjectIdPipe } from '@mean-stream/nestx' ;
19
20
import { Types } from 'mongoose' ;
20
- import { MemberService } from '../member/member.service' ;
21
21
import { GameService } from '../game/game.service' ;
22
+ import { EmpireLogicService } from './empire-logic.service' ;
22
23
23
24
@Controller ( 'games/:game/empires' )
24
25
@ApiTags ( 'Game Empires' )
@@ -28,8 +29,8 @@ import {GameService} from '../game/game.service';
28
29
export class EmpireController {
29
30
constructor (
30
31
private readonly gameService : GameService ,
31
- private readonly memberService : MemberService ,
32
32
private readonly empireService : EmpireService ,
33
+ private readonly empireLogicService : EmpireLogicService ,
33
34
) {
34
35
}
35
36
@@ -50,6 +51,11 @@ export class EmpireController {
50
51
...dto ,
51
52
game,
52
53
user : currentUser . _id ,
54
+ // Although dto may specify the resources, there might be some missing. Ensure it is a complete record.
55
+ resources : {
56
+ ...this . empireLogicService . getInitialResources ( dto ) ,
57
+ ...dto . resources ,
58
+ } ,
53
59
} ) ;
54
60
}
55
61
0 commit comments