This commit is contained in:
wells
2026-08-05 17:07:00 +08:00
parent ce7a619791
commit 16242b97de
6 changed files with 298 additions and 16 deletions
@@ -1,5 +1,6 @@
package com.tailbet.controller;
import com.tailbet.job.GameJob;
import com.tailbet.model.dto.BetDTO;
import com.tailbet.model.dto.GameOperateDTO;
import com.tailbet.model.dto.HistoryQueryDTO;
@@ -27,6 +28,7 @@ public class GameController {
private final IGameService gameService;
private final IBetService betService;
private final GameJob gameJob;
/**
* 开始游戏(群主)
@@ -36,6 +38,9 @@ public class GameController {
try {
Long userId = UserContext.getUserId();
var round = gameService.startGame(dto.getGroupId(), userId);
// 触发游戏开始后的定时器和广播
int betWindowSeconds = gameJob.getConfigInt("bet_window_seconds", 60);
gameJob.onGameStart(round.getId(), dto.getGroupId(), betWindowSeconds);
return R.ok(round);
} catch (RuntimeException e) {
return R.fail(e.getMessage());
@@ -50,6 +55,8 @@ public class GameController {
try {
Long userId = UserContext.getUserId();
var round = gameService.endBet(dto.getGroupId(), userId);
// 触发结束接注后的广播和发红包流程
gameJob.onEndBet(round.getId(), dto.getGroupId());
return R.ok(round);
} catch (RuntimeException e) {
return R.fail(e.getMessage());