优化游玩方式

This commit is contained in:
2026-03-25 15:51:50 +08:00
parent 9b4104fc0e
commit 6b9fb0c26e
11 changed files with 96 additions and 37 deletions

View File

@@ -162,21 +162,21 @@ class GameController extends BaseController
if ($direction !== null) {
$direction = (int) $direction;
}
$ante = $request->post('ante');
if ($ante !== null) {
$ante = (int) $ante;
}
if (!in_array($direction, [0, 1], true)) {
return $this->fail('direction must be 0 or 1', ReturnCode::PARAMS_ERROR);
}
if (!is_int($ante) || $ante <= 0) {
return $this->fail('ante must be a positive integer', ReturnCode::PARAMS_ERROR);
}
$player = DicePlayer::find($userId);
if (!$player) {
return $this->fail('User not found', ReturnCode::NOT_FOUND);
}
$minEv = DiceRewardConfig::getCachedMinRealEv();
$minCoin = abs($minEv + 100);
$coin = (float) $player->coin;
if ($coin < $minCoin) {
$msg = ApiLang::translateParams('Balance %s is less than %s, cannot continue', [$coin, $minCoin], $request);
return $this->success([], $msg);
}
$lockName = 'play_start_' . $userId;
$lockResult = Db::query('SELECT GET_LOCK(?, 30) as l', [$lockName]);
@@ -185,7 +185,7 @@ class GameController extends BaseController
}
try {
$logic = new PlayStartLogic();
$data = $logic->run($userId, (int)$direction);
$data = $logic->run($userId, (int) $direction, $ante);
$lang = $request->header('lang', 'zh');
if (!is_string($lang) || $lang === '') {