|
@@ -74,7 +74,8 @@ export class GameService implements OnModuleInit {
|
|
|
private readonly promptService: PromptService,
|
|
private readonly promptService: PromptService,
|
|
|
private readonly sysConfigService: SysConfigService,
|
|
private readonly sysConfigService: SysConfigService,
|
|
|
private readonly danmuService: DanmuService,
|
|
private readonly danmuService: DanmuService,
|
|
|
- private readonly roomService: RoomService
|
|
|
|
|
|
|
+ private readonly roomService: RoomService,
|
|
|
|
|
+ private readonly sysConfig: SysConfigService
|
|
|
) {}
|
|
) {}
|
|
|
|
|
|
|
|
async onModuleInit() {
|
|
async onModuleInit() {
|
|
@@ -383,7 +384,7 @@ export class GameService implements OnModuleInit {
|
|
|
let date = null,
|
|
let date = null,
|
|
|
time = null,
|
|
time = null,
|
|
|
plot = null,
|
|
plot = null,
|
|
|
- options = []
|
|
|
|
|
|
|
+ options: PlotOption[] = []
|
|
|
lastState.choice = choice || lastState.choice || null
|
|
lastState.choice = choice || lastState.choice || null
|
|
|
|
|
|
|
|
await this.gameStateRepository.update(lastState.id, lastState)
|
|
await this.gameStateRepository.update(lastState.id, lastState)
|
|
@@ -482,7 +483,12 @@ export class GameService implements OnModuleInit {
|
|
|
const willEnd = charactorsAlive.filter((i) => !i.dead).length === 0
|
|
const willEnd = charactorsAlive.filter((i) => !i.dead).length === 0
|
|
|
|
|
|
|
|
if (!willEnd && createOptions) {
|
|
if (!willEnd && createOptions) {
|
|
|
- options = await this.createOptions(charactors, `${summary}\n\n${formatedDatatime}\n${plot}`)
|
|
|
|
|
|
|
+ const voteDelay = await this.sysConfig.getNumber('vote_delay', 0)
|
|
|
|
|
+ const delay = voteDelay > 0 ? setTimeout(voteDelay * 1000) : Promise.resolve()
|
|
|
|
|
+
|
|
|
|
|
+ options = (
|
|
|
|
|
+ await Promise.all([this.createOptions(charactors, `${summary}\n\n${formatedDatatime}\n${plot}`), delay])
|
|
|
|
|
+ )[0]
|
|
|
this.send(`${id}`, {
|
|
this.send(`${id}`, {
|
|
|
type: 'options',
|
|
type: 'options',
|
|
|
data: options
|
|
data: options
|
|
@@ -724,7 +730,7 @@ export class GameService implements OnModuleInit {
|
|
|
try {
|
|
try {
|
|
|
this.logger.log('发起投票')
|
|
this.logger.log('发起投票')
|
|
|
let s = differenceInSeconds(new Date(), startTime)
|
|
let s = differenceInSeconds(new Date(), startTime)
|
|
|
- while (s < 30) {
|
|
|
|
|
|
|
+ while (s < (await this.sysConfigService.getNumber('vote_wait_time', 30))) {
|
|
|
await setTimeout(1000)
|
|
await setTimeout(1000)
|
|
|
const votes = await this.danmuService.collectVotes(gameId, startTime, options.length)
|
|
const votes = await this.danmuService.collectVotes(gameId, startTime, options.length)
|
|
|
cb?.onProgress(votes)
|
|
cb?.onProgress(votes)
|
|
@@ -778,7 +784,7 @@ export class GameService implements OnModuleInit {
|
|
|
i.modifyHp = i.modifyHp.filter(
|
|
i.modifyHp = i.modifyHp.filter(
|
|
|
(j) => j.changeValue !== 0 && charactors.find((k) => k.name === j.name)
|
|
(j) => j.changeValue !== 0 && charactors.find((k) => k.name === j.name)
|
|
|
)
|
|
)
|
|
|
- return i
|
|
|
|
|
|
|
+ return i as PlotOption
|
|
|
})
|
|
})
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.logger.error(error)
|
|
this.logger.error(error)
|