Compare commits
2 Commits
768cf5137c
...
7a4d89d216
| Author | SHA1 | Date | |
|---|---|---|---|
| 7a4d89d216 | |||
| cfe026b5eb |
@@ -65,18 +65,19 @@ class GameController extends OpenController
|
|||||||
* 开始游戏(抽奖一局)
|
* 开始游戏(抽奖一局)
|
||||||
* POST /api/game/playStart
|
* POST /api/game/playStart
|
||||||
* header: token(由 TokenMiddleware 注入 request->player_id)
|
* header: token(由 TokenMiddleware 注入 request->player_id)
|
||||||
* body: rediction 必传,0=无 1=中奖
|
* body: direction 必传,0=无 1=中奖
|
||||||
*/
|
*/
|
||||||
public function playStart(Request $request): Response
|
public function playStart(Request $request): Response
|
||||||
{
|
{
|
||||||
$userId = (int) ($request->player_id ?? 0);
|
$userId = (int) ($request->player_id ?? 0);
|
||||||
$rediction = $request->post('rediction');
|
$direction = $request->post('direction');
|
||||||
if ($rediction === '' || $rediction === null) {
|
if (empty($direction)) {
|
||||||
return $this->fail('请传递 rediction 参数', ReturnCode::PARAMS_ERROR);
|
Log::error('传递的参数为direction = '.$direction);
|
||||||
|
return $this->fail('请传递 direction 参数', ReturnCode::PARAMS_ERROR);
|
||||||
}
|
}
|
||||||
$direction = (int) $rediction;
|
$direction = (int) $direction;
|
||||||
if (!in_array($direction, [0, 1], true)) {
|
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);
|
$player = DicePlayer::find($userId);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class PlayStartLogic
|
|||||||
/**
|
/**
|
||||||
* 执行一局游戏
|
* 执行一局游戏
|
||||||
* @param int $playerId 玩家ID
|
* @param int $playerId 玩家ID
|
||||||
* @param int $direction 方向 0=无/顺时针 1=中奖/逆时针(前端 rediction)
|
* @param int $direction 方向 0=无/顺时针 1=中奖/逆时针(前端 direction)
|
||||||
* @return array 成功返回 DicePlayRecord 数据;余额不足时抛 ApiException,message 为约定文案
|
* @return array 成功返回 DicePlayRecord 数据;余额不足时抛 ApiException,message 为约定文案
|
||||||
*/
|
*/
|
||||||
public function run(int $playerId, int $direction): array
|
public function run(int $playerId, int $direction): array
|
||||||
|
|||||||
Reference in New Issue
Block a user