|
|
@@ -634,13 +634,17 @@ export class GameService implements OnModuleInit {
|
|
|
lastState: undefined
|
|
|
})
|
|
|
)
|
|
|
- this.send(`${game.id}`, {
|
|
|
- type: 'reset',
|
|
|
- data: {
|
|
|
- newGameId: newGame.id,
|
|
|
- firstState: newState
|
|
|
- }
|
|
|
+ const resetDelay = await this.sysConfig.getNumber('reset_delay', 0)
|
|
|
+ setTimeout(resetDelay * 1000).then(() => {
|
|
|
+ this.send(`${game.id}`, {
|
|
|
+ type: 'reset',
|
|
|
+ data: {
|
|
|
+ newGameId: newGame.id,
|
|
|
+ firstState: newState
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
+
|
|
|
await this.gameRepository.update(newGame.id, { currentState: newState.id })
|
|
|
await this.roomService.setCurrentGameId(game.roomId, newGame.id)
|
|
|
|
|
|
@@ -651,6 +655,15 @@ export class GameService implements OnModuleInit {
|
|
|
return newGame
|
|
|
}
|
|
|
|
|
|
+ async manualResetGame(id: number) {
|
|
|
+ const game = await this.findById(id)
|
|
|
+ if (this.controllers.has(game.roomId)) {
|
|
|
+ await this.stopRun(id)
|
|
|
+ }
|
|
|
+ await this.gameRepository.update(id, { status: GameStatus.Finished })
|
|
|
+ return await this.resetGame(id)
|
|
|
+ }
|
|
|
+
|
|
|
async startRun(id: number) {
|
|
|
this.logger.log(`开始运行: ${id}`)
|
|
|
const game = await this.findById(id)
|
|
|
@@ -792,7 +805,7 @@ export class GameService implements OnModuleInit {
|
|
|
const output = await parser.parse(response.content.replace('+', '').replace("'", '"'))
|
|
|
return output.map((i) => {
|
|
|
i.modifyHp = i.modifyHp.filter(
|
|
|
- (j) => j.changeValue !== 0 && charactors.find((k) => k.name === j.name)
|
|
|
+ (j) => j.changeValue !== 0 && false === charactors.find((k) => k.name === j.name)?.dead
|
|
|
)
|
|
|
return i as PlotOption
|
|
|
})
|