} if (!$DevAAC->auth_account) { throw new InputErrorException('You are not logged in.', 401); } $request = $DevAAC->request; $house = House::findOrFail($id); if ($house->owner()->first() instanceof Player) { throw new InputErrorException('This house is not on auction, ' . $house->owner()->first()->name . ' owns it.', 412); } if ($house->bid_end !== 0 && new DateTime() > $house->bid_end) { throw new InputErrorException('Auction has ended.', 410); } if ($request->getAPIParam('bid') < $house->bid + HOUSES_BID_RAISE || $request->getAPIParam('bid') < $house->bid + $house->bid * HOUSES_BID_RAISE_PERCENT) { throw new InputErrorException('The bid is too low! You need to offer at least ' . max($house->bid + HOUSES_BID_RAISE, $house->bid + $house->bid * HOUSES_BID_RAISE_PERCENT), 409); } $player = Player::findOrFail($request->getAPIParam('player_id')); if ($player->account->id != $DevAAC->auth_account->id && !$DevAAC->auth_account->isGod()) { throw new InputErrorException('You do not have permission to bid with this player.', 403); } if ($house->highest_bidder != $player->id && count($player->houses()->get()->toArray()) + count($player->houseBids()->get()->toArray()) >= HOUSES_PER_PLAYER) { throw new InputErrorException('Your player already owns or participates in an auction for a maximum number of houses (' . HOUSES_PER_PLAYER . ')!', 405); } if ($house->highest_bidder != $player->id && count($player->account->houses()->get()->toArray()) + count($player->account->houseBids()->get()->toArray()) >= HOUSES_PER_ACCOUNT) { throw new InputErrorException('Your account already owns or participates in an auction for a maximum number of houses (' . HOUSES_PER_ACCOUNT . ')!', 405); } if ($player->balance < $request->getAPIParam('bid') + $house->rent) { throw new InputErrorException('You do not have enough money! You need the bid amount plus ' . $house->rent . ' for first rent payment.', 402); } if ($request->getAPIParam('bid') > $house->last_bid) { // this is a winning bid, it is over previous winner's limit $house->highest_bidder = $player->id;
* type="Player", * nickname="deletePlayerByID", * @SWG\Parameter( name="id", * description="ID of Player that needs to be deleted", * paramType="path", * required=true, * type="integer"), * @SWG\ResponseMessage(code=401, message="Authentication required"), * @SWG\ResponseMessage(code=404, message="Player not found"), * @SWG\ResponseMessage(code=403, message="Permission denied") * ) * ) * ) */ $DevAAC->delete(ROUTES_API_PREFIX . '/players/:id', function ($id) use($DevAAC) { $player = Player::findOrFail($id); if (!$DevAAC->auth_account) { throw new InputErrorException('You are not logged in.', 401); } if ($player->account->id != $DevAAC->auth_account->id && !$DevAAC->auth_account->isGod()) { throw new InputErrorException('You do not have permission to delete this player.', 403); } $player->delete(); $DevAAC->response->headers->set('Content-Type', 'application/json'); $DevAAC->response->setBody(json_encode(null, JSON_PRETTY_PRINT)); }); /** * @SWG\Resource( * basePath="/api/v1", * resourcePath="/players", * @SWG\Api(