From eecb4f699b5fde5518b6fb491f29c607e88cf25a Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sun, 17 Jul 2022 22:34:05 +0900 Subject: [PATCH] =?UTF-8?q?game:=20=EC=9D=B4=EB=AF=B8=20=EA=B0=99=EC=9D=80?= =?UTF-8?q?=20=EB=B6=80=EC=9C=84=EC=97=90=20=EB=8B=A4=EB=A5=B8=20=EC=9C=A0?= =?UTF-8?q?=EB=8B=88=ED=81=AC=EA=B0=80=20=EC=9E=88=EB=8A=94=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0,=20=EA=B2=BD=EB=A7=A4=20=EC=A7=84=ED=96=89=20?= =?UTF-8?q?=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/AuctionUniqueItem.php | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/hwe/sammo/AuctionUniqueItem.php b/hwe/sammo/AuctionUniqueItem.php index b6238cbb..0dedde35 100644 --- a/hwe/sammo/AuctionUniqueItem.php +++ b/hwe/sammo/AuctionUniqueItem.php @@ -53,12 +53,19 @@ class AuctionUniqueItem extends Auction } $availableCnt = 0; - foreach(GameConst::$allItems as $itemType => $itemList){ - $availableCnt += $itemList[$itemKey] ?? 0; + foreach (GameConst::$allItems as $itemType => $itemList) { + if (!key_exists($itemKey, $itemList)) { + continue; + } + $ownItem = $general->getItem($itemKey); + if ($ownItem !== null && !$ownItem->isBuyable()) { + return '이미 가진 아이템이 있습니다.'; + } + $availableCnt += $itemList[$itemKey]; $availableCnt -= $db->queryFirstField('SELECT count(*) FROM `general` WHERE %b = %s', $itemType, $itemKey); } - if($availableCnt <= 0){ + if ($availableCnt <= 0) { return '그 유니크를 더 얻을 수 없습니다.'; } @@ -129,7 +136,7 @@ class AuctionUniqueItem extends Auction public function bid(int $amount, bool $tryExtendCloseDate): ?string { - if($this->info->finished){ + if ($this->info->finished) { return '경매가 종료되었습니다.'; } @@ -146,7 +153,7 @@ class AuctionUniqueItem extends Auction } $db = DB::db(); - if($auctionIDList){ + if ($auctionIDList) { $rawHighestBids = Util::convertArrayToDict($db->query( 'SELECT bid.* FROM `ng_auction_bid` bid INNER JOIN ( SELECT `auction_id`, MAX(`amount`) as `max_amount` @@ -158,8 +165,7 @@ class AuctionUniqueItem extends Auction ON bid.`auction_id` = max_bid.`auction_id` AND bid.`amount` = max_bid.`max_amount`', $auctionIDList, ) ?? [], 'auction_id'); - } - else{ + } else { $rawHighestBids = []; } @@ -177,7 +183,14 @@ class AuctionUniqueItem extends Auction $bidItemTypes = new Set(); foreach (GameConst::$allItems as $itemType => $itemList) { - if (($itemList[$itemCode] ?? 0) <= 0) { + if (!key_exists($itemCode, $itemList)) { + continue; + } + $ownItem = $this->general->getItem($itemCode); + if ($ownItem !== null && !$ownItem->isBuyable()) { + return '이미 가진 아이템이 있습니다.'; + } + if ($itemList[$itemCode] <= 0) { continue; } $bidItemTypes->add($itemType);