From 7a4d89d2169f203f1693d9b4de785b11e6e003d5 Mon Sep 17 00:00:00 2001 From: zhenhui <1276357500@qq.com> Date: Fri, 6 Mar 2026 10:42:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96/api/game/playStart=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/app/api/controller/GameController.php | 13 +++++++------ server/app/api/logic/PlayStartLogic.php | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/server/app/api/controller/GameController.php b/server/app/api/controller/GameController.php index edadbcf..900d757 100644 --- a/server/app/api/controller/GameController.php +++ b/server/app/api/controller/GameController.php @@ -65,18 +65,19 @@ class GameController extends OpenController * 开始游戏(抽奖一局) * POST /api/game/playStart * header: token(由 TokenMiddleware 注入 request->player_id) - * body: rediction 必传,0=无 1=中奖 + * body: direction 必传,0=无 1=中奖 */ public function playStart(Request $request): Response { $userId = (int) ($request->player_id ?? 0); - $rediction = $request->post('rediction'); - if (empty($rediction)) { - return $this->fail('请传递 rediction 参数', ReturnCode::PARAMS_ERROR); + $direction = $request->post('direction'); + if (empty($direction)) { + Log::error('传递的参数为direction = '.$direction); + return $this->fail('请传递 direction 参数', ReturnCode::PARAMS_ERROR); } - $direction = (int) $rediction; + $direction = (int) $direction; if (!in_array($direction, [0, 1], true)) { - return $this->fail('rediction 必须为 0 或 1', ReturnCode::PARAMS_ERROR); + return $this->fail('direction 必须为 0 或 1', ReturnCode::PARAMS_ERROR); } $player = DicePlayer::find($userId); diff --git a/server/app/api/logic/PlayStartLogic.php b/server/app/api/logic/PlayStartLogic.php index 22bd7b0..d31c3f1 100644 --- a/server/app/api/logic/PlayStartLogic.php +++ b/server/app/api/logic/PlayStartLogic.php @@ -38,7 +38,7 @@ class PlayStartLogic /** * 执行一局游戏 * @param int $playerId 玩家ID - * @param int $direction 方向 0=无/顺时针 1=中奖/逆时针(前端 rediction) + * @param int $direction 方向 0=无/顺时针 1=中奖/逆时针(前端 direction) * @return array 成功返回 DicePlayRecord 数据;余额不足时抛 ApiException,message 为约定文案 */ public function run(int $playerId, int $direction): array