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