$params */ public function handle(Request $request, array $params): Response { $support = new MatchActionSupport($this->secret); $result = $support->verify($request); if ($result->response !== null) { return $result->response; } $matchId = $result->matchIdAndMatch['matchId']; $match = $result->matchIdAndMatch['match']; $payload = json_decode($request->rawBody, true); $unitId = (string) ($payload['unitId'] ?? ''); $abilityId = (string) ($payload['abilityId'] ?? ''); $x = (int) ($payload['x'] ?? -1); $y = (int) ($payload['y'] ?? -1); try { $next = (new CombatEngine())->useAbility($match, $unitId, $abilityId, new Position($x, $y)); } catch (CombatException $exception) { return PostMatchMove::rejectionResponse($this->secret, $matchId, $match, $exception->getMessage()); } return Response::json(200, PostMatchMove::successResponse($this->secret, $matchId, $next)); } }