diff --git a/.phan/config.php b/.phan/config.php index d7f23571..b808b9ed 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -45,7 +45,6 @@ return [ 'hwe/api.php', 'hwe/a_traffic.php', 'hwe/battle_simulator.php', - 'hwe/b_auction.php', 'hwe/b_battleCenter.php', 'hwe/b_betting.php', 'hwe/v_chiefCenter.php', @@ -60,7 +59,6 @@ return [ 'hwe/v_processing.php', 'hwe/b_tournament.php', 'hwe/b_troop.php', - 'hwe/c_auction.php', 'hwe/c_tournament.php', 'hwe/func_auction.php', 'hwe/func_command.php', diff --git a/hwe/func.php b/hwe/func.php index c3a1bf60..e464a532 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -4,6 +4,7 @@ namespace sammo; use DateTime; use Ds\Set; +use sammo\Enums\AuctionType; use sammo\Enums\InheritanceKey; use sammo\Enums\RankColumn; use sammo\Event\Action; @@ -1558,6 +1559,7 @@ function CheckHall($no) function giveRandomUniqueItem(RandUtil $rng, General $general, string $acquireType): bool { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game_env'); //아이템 습득 상황 $availableUnique = []; @@ -1589,6 +1591,18 @@ function giveRandomUniqueItem(RandUtil $rng, General $general, string $acquireTy } } + $auctionItems = $db->queryFirstColumn( + 'SELECT `target` FROM `ng_auction` WHERE `type` = %s AND `finished` = 0', + AuctionType::UniqueItem->value + ); + foreach ($auctionItems as $itemCode) { + if (key_exists($itemCode, $occupiedUnique)) { + $occupiedUnique[$itemCode]++; + } else { + $occupiedUnique[$itemCode] = 1; + } + } + foreach ($db->queryAllLists('SELECT namespace, count(*) as cnt FROM `storage` WHERE namespace LIKE "ut_%" GROUP BY namespace') as [$uniqueNS, $cnt]) { $itemCode = substr($uniqueNS, 3); $itemClass = buildItemClass($itemCode); @@ -1632,10 +1646,7 @@ function giveRandomUniqueItem(RandUtil $rng, General $general, string $acquireTy return false; } - - if ($general->getAuxVar('inheritRandomUnique')) { - $gameStor = KVStorage::getStorage($db, 'game_env'); [$year, $month, $initYear, $initMonth] = $gameStor->getValuesAsArray(['year', 'month', 'init_year', 'init_month']); $relMonthByInit = Util::joinYearMonth($year, $month) - Util::joinYearMonth($initYear, $initMonth); @@ -1666,10 +1677,6 @@ function giveRandomUniqueItem(RandUtil $rng, General $general, string $acquireTy $logger->pushGlobalActionLog("{$generalName}{$josaYi} {$itemName}{$josaUl} 습득했습니다!"); $logger->pushGlobalHistoryLog("【{$acquireType}】{$nationName}{$generalName}{$josaYi} {$itemName}{$josaUl} 습득했습니다!"); - $givenUnique =$gameStor->getValue('givenUnique') ?? []; - $givenUnique[$itemCode] = ($givenUnique[$itemCode] ?? 0) + 1; - $gameStor->setValue('givenUnique', $givenUnique); - return true; } diff --git a/hwe/func_auction.php b/hwe/func_auction.php index e9f38529..c4fc2d6d 100644 --- a/hwe/func_auction.php +++ b/hwe/func_auction.php @@ -14,7 +14,7 @@ function registerAuction(RandUtil $rng) $avgRice = Util::valueFit($avgRice, 1000, 20000); $neutralAuctionCnt = Util::convertPairArrayToDict($db->queryAllLists( - 'SELECT `type`, count(*) FROM ng_auction WHERE `type` IN %s AND `host_general_id`=0 GROUP BY `type`', + 'SELECT `type`, count(*) FROM ng_auction WHERE `type` IN %ls AND `host_general_id`=0 GROUP BY `type`', [AuctionType::BuyRice->value, AuctionType::SellRice->value], )); @@ -64,7 +64,7 @@ function processAuction() $now = TimeUtil::now(); - $auctionList = $db->queryFirstColumn( + $auctionList = $db->queryAllLists( 'SELECT id, `type` FROM ng_auction WHERE `close_date` <= %s AND finished = 0', $now ); diff --git a/hwe/sammo/API/Auction/GetActiveResourceAuctionList.php b/hwe/sammo/API/Auction/GetActiveResourceAuctionList.php index 099fec0d..d0d42dc2 100644 --- a/hwe/sammo/API/Auction/GetActiveResourceAuctionList.php +++ b/hwe/sammo/API/Auction/GetActiveResourceAuctionList.php @@ -37,7 +37,7 @@ class GetActiveResourceAuctionList extends \sammo\BaseAPI $sellRiceList = []; /** @var AuctionInfo[] */ $auctions = array_map(fn ($raw) => AuctionInfo::fromArray($raw), $db->query( - 'SELECT * FROM `ng_auction` WHERE `type` IN %ls AND `finished` = 0 ORDER BY `close_date` DESC', + 'SELECT * FROM `ng_auction` WHERE `type` IN %ls AND `finished` = 0 ORDER BY `close_date` ASC', [ AuctionType::BuyRice->value, AuctionType::SellRice->value, diff --git a/hwe/sammo/API/Auction/GetUniqueItemAuctionDetail.php b/hwe/sammo/API/Auction/GetUniqueItemAuctionDetail.php index 9c13b103..2051ec30 100644 --- a/hwe/sammo/API/Auction/GetUniqueItemAuctionDetail.php +++ b/hwe/sammo/API/Auction/GetUniqueItemAuctionDetail.php @@ -80,8 +80,9 @@ class GetUniqueItemAuctionDetail extends \sammo\BaseAPI 'target' => $auction->target, 'isCallerHost' => $auction->hostGeneralID === $generalID, 'hostName' => $auction->detail->hostName, + 'closeDate' => TimeUtil::format($auction->closeDate, false), 'remainCloseDateExtensionCnt' => $auction->detail->remainCloseDateExtensionCnt, - 'availableLatestBidCloseDate' => $auction->detail->availableLatestBidCloseDate, + 'availableLatestBidCloseDate' => TimeUtil::format($auction->detail->availableLatestBidCloseDate, false), ], 'bidList' => $responseBid, 'obfuscatedName' => $obfuscatedName, diff --git a/hwe/sammo/API/Auction/GetUniqueItemAuctionList.php b/hwe/sammo/API/Auction/GetUniqueItemAuctionList.php index 765833a3..5937581e 100644 --- a/hwe/sammo/API/Auction/GetUniqueItemAuctionList.php +++ b/hwe/sammo/API/Auction/GetUniqueItemAuctionList.php @@ -32,10 +32,21 @@ class GetUniqueItemAuctionList extends \sammo\BaseAPI /** @var AuctionInfo[] */ $auctions = array_map(fn($raw)=>AuctionInfo::fromArray($raw), $db->query( - 'SELECT * FROM `ng_auction` WHERE `type` = %s ORDER BY `close_date` DESC', + 'SELECT * FROM `ng_auction` WHERE `type` = %s ORDER BY `close_date` ASC', AuctionType::UniqueItem->value ) ?? []); + $obfuscatedName = AuctionUniqueItem::genObfuscatedName($generalID); + + if(!$auctions){ + return [ + 'result' => true, + 'list' => [], + 'obfuscatedName' => $obfuscatedName, + ]; + } + + $auctionIDList = []; foreach ($auctions as $auction) { $auctionIDList[] = $auction->id; @@ -58,8 +69,6 @@ class GetUniqueItemAuctionList extends \sammo\BaseAPI $rawHighestBids ); - $obfuscatedName = AuctionUniqueItem::genObfuscatedName($generalID); - $response = []; foreach ($auctions as $auction) { $auctionID = $auction->id; diff --git a/hwe/sammo/API/Auction/OpenBuyRiceAuction.php b/hwe/sammo/API/Auction/OpenBuyRiceAuction.php index dc07a667..ae2b74c8 100644 --- a/hwe/sammo/API/Auction/OpenBuyRiceAuction.php +++ b/hwe/sammo/API/Auction/OpenBuyRiceAuction.php @@ -5,9 +5,12 @@ namespace sammo\API\Auction; use sammo\Session; use DateTimeInterface; use sammo\AuctionBuyRice; +use sammo\DB; use sammo\Validator; use sammo\GameConst; use sammo\General; +use sammo\KVStorage; +use sammo\Util; class OpenBuyRiceAuction extends \sammo\BaseAPI { @@ -64,6 +67,16 @@ class OpenBuyRiceAuction extends \sammo\BaseAPI $general = General::createGeneralObjFromDB($generalID); + $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game_env'); + [$initYear, $initMonth, $year, $month] = $gameStor->getValuesAsArray(['init_year', 'init_month', 'year', 'month']); + $initYearMonth = Util::joinYearMonth($initYear, $initMonth); + $yearMonth = Util::joinYearMonth($year, $month); + + if($yearMonth <= $initYearMonth + 3){ + return '시작 후 3개월이 지나야 경매를 열 수 있습니다.'; + } + $auctionResult = AuctionBuyRice::openResourceAuction( $general, $amount, diff --git a/hwe/sammo/API/Auction/OpenSellRiceAuction.php b/hwe/sammo/API/Auction/OpenSellRiceAuction.php index c1092494..efb38972 100644 --- a/hwe/sammo/API/Auction/OpenSellRiceAuction.php +++ b/hwe/sammo/API/Auction/OpenSellRiceAuction.php @@ -5,9 +5,12 @@ namespace sammo\API\Auction; use sammo\Session; use DateTimeInterface; use sammo\AuctionSellRice; +use sammo\DB; use sammo\Validator; use sammo\GameConst; use sammo\General; +use sammo\KVStorage; +use sammo\Util; class OpenSellRiceAuction extends \sammo\BaseAPI { @@ -64,6 +67,16 @@ class OpenSellRiceAuction extends \sammo\BaseAPI $general = General::createGeneralObjFromDB($generalID); + $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game_env'); + [$initYear, $initMonth, $year, $month] = $gameStor->getValuesAsArray(['init_year', 'init_month', 'year', 'month']); + $initYearMonth = Util::joinYearMonth($initYear, $initMonth); + $yearMonth = Util::joinYearMonth($year, $month); + + if($yearMonth <= $initYearMonth + 3){ + return '시작 후 3개월이 지나야 경매를 열 수 있습니다.'; + } + $auctionResult = AuctionSellRice::openResourceAuction( $general, $amount, diff --git a/hwe/sammo/API/Auction/OpenUniqueAuction.php b/hwe/sammo/API/Auction/OpenUniqueAuction.php index 1a70ec1e..40def74d 100644 --- a/hwe/sammo/API/Auction/OpenUniqueAuction.php +++ b/hwe/sammo/API/Auction/OpenUniqueAuction.php @@ -5,9 +5,12 @@ namespace sammo\API\Auction; use sammo\Session; use DateTimeInterface; use sammo\AuctionUniqueItem; +use sammo\DB; use sammo\Validator; use sammo\GameConst; use sammo\General; +use sammo\KVStorage; +use sammo\Util; use function sammo\buildItemClass; @@ -55,6 +58,16 @@ class OpenUniqueAuction extends \sammo\BaseAPI $itemObj = buildItemClass($itemID); $general = General::createGeneralObjFromDB($generalID); + $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game_env'); + [$initYear, $initMonth, $year, $month] = $gameStor->getValuesAsArray(['init_year', 'init_month', 'year', 'month']); + $initYearMonth = Util::joinYearMonth($initYear, $initMonth); + $yearMonth = Util::joinYearMonth($year, $month); + + if($yearMonth <= $initYearMonth + 3){ + return '시작 후 3개월이 지나야 경매를 열 수 있습니다.'; + } + $auctionResult = AuctionUniqueItem::openItemAuction($itemObj, $general, $amount); if(is_string($auctionResult)) { diff --git a/hwe/sammo/API/General/DropItem.php b/hwe/sammo/API/General/DropItem.php index 317aea01..21c2728c 100644 --- a/hwe/sammo/API/General/DropItem.php +++ b/hwe/sammo/API/General/DropItem.php @@ -62,23 +62,6 @@ class DropItem extends \sammo\BaseAPI if (!$item->isBuyable()) { $logger->pushGlobalActionLog("{$generalName}{$josaYi} {$itemName}{$josaUl} 잃었습니다!"); $logger->pushGlobalHistoryLog("【망실】{$nationName}{$generalName}{$josaYi} {$itemName}{$josaUl} 잃었습니다!"); - - $gameStor = KVStorage::getStorage($db, 'game_env'); - $givenUnique = $gameStor->getValue('givenUnique') ?? []; - $itemCode = $item->getRawClassName(); - if (key_exists($itemCode, $givenUnique)) { - $givenUniqueCnt = $givenUnique[$itemCode]; - $givenUniqueCnt -= 1; - if ($givenUniqueCnt <= 0) { - unset($givenUnique[$itemCode]); - } else { - $givenUnique[$itemCode] = $givenUniqueCnt; - } - } else { - //XXX: 처리하지 못한 코드가 있는가? - //FIXME: 여기에서 무언가 경고를 내야함 - } - $gameStor->setValue('givenUnique', $givenUnique); } $me->applyDB($db); diff --git a/hwe/sammo/Auction.php b/hwe/sammo/Auction.php index 878ceefd..349855f8 100644 --- a/hwe/sammo/Auction.php +++ b/hwe/sammo/Auction.php @@ -21,7 +21,7 @@ abstract class Auction static AuctionType $auctionType; public const COEFF_AUCTION_CLOSE_MINUTES = 24; - public const COEFF_EXTENSION_MINUTES_PER_BID = 1 / 6; + public const COEFF_EXTENSION_MINUTES_PER_BID = (1 / 6); public const COEFF_EXTENSION_MINUTES_LIMIT_BY_BID = 1; public const COEFF_EXTENSION_MINUTES_BY_EXTENSION_QUERY = 1; public const MIN_AUCTION_CLOSE_MINUTES = 30; @@ -157,32 +157,55 @@ abstract class Auction return null; } + public function extendLatestBidCloseDate(?DateTimeInterface $date): ?string + { + if ($date === null) { + $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game_env'); + $turnTerm = $gameStor->getValue('turnterm'); + $date = $this->info->closeDate->add(TimeUtil::secondsToDateInterval( + max(static::MIN_EXTENSION_MINUTES_PER_BID, $turnTerm * static::COEFF_EXTENSION_MINUTES_PER_BID) * 60 + )); + } + else{ + $date = DateTimeImmutable::createFromInterface($date); + } + if ($this->info->detail->availableLatestBidCloseDate !== null && $date < $this->info->detail->availableLatestBidCloseDate) { + return '기간보다 짧습니다.'; + } + $this->info->detail->availableLatestBidCloseDate = $date; + return null; + } + public function extendCloseDate(DateTimeInterface $date, bool $force = false): ?string { if (!$force) { - if ($this->info->remainCloseExtensionCnt === null) { + if ($this->info->detail->remainCloseDateExtensionCnt === null) { return '연장할 수 없는 경매입니다.'; } - if ($this->info->remainCloseExtensionCnt === 0) { + if ($this->info->detail->remainCloseDateExtensionCnt === 0) { return '더 이상 연장할 수 없습니다'; } - if ($this->info->remainCloseExtensionCnt > 0) { - $this->info->remainCloseExtensionCnt--; + if ($this->info->detail->remainCloseDateExtensionCnt > 0) { + $this->info->detail->remainCloseDateExtensionCnt--; } } - $db = DB::db(); - $gameStor = KVStorage::getStorage($db, 'game_env'); - $turnTerm = $gameStor->getValue('turnterm'); + if ($date < $this->info->closeDate) { + return '종료 기간보다 짧습니다.'; + } + $closeDate = DateTimeImmutable::createFromInterface($date); $this->info->closeDate = $closeDate; - $this->info->availableLatestBidCloseDate = $closeDate->add(TimeUtil::secondsToDateInterval( - max(static::MIN_EXTENSION_MINUTES_PER_BID, $turnTerm * static::COEFF_EXTENSION_MINUTES_PER_BID) * 60 - )); - $db->update('ng_auction', $this->info->toArray('id'), 'id = %i', $this->info->id); return null; } + public function applyDB(): void + { + $db = DB::db(); + $db->update('ng_auction', $this->info->toArray('id'), 'id = %i', $this->info->id); + } + public function refundBid(AuctionBidItem $bidItem, string $reason): void { if ($bidItem->auctionID !== $this->info->id) { @@ -190,7 +213,7 @@ abstract class Auction } $db = DB::db(); - if ($bidItem->generalID === $this->general->generalID) { + if ($bidItem->generalID === $this->general->getID()) { $oldBidder = $this->general; } else { $oldBidder = General::createGeneralObjFromDB($bidItem->generalID); @@ -198,10 +221,15 @@ abstract class Auction if ($this->info->reqResource === ResourceType::inheritancePoint) { $oldBidder->increaseInheritancePoint(InheritanceKey::previous, $bidItem->amount); + $oldBidder->increaseRankVar(RankColumn::inherit_point_spent_dynamic, -$bidItem->amount); } else { $oldBidder->increaseVar($this->info->reqResource->value, $bidItem->amount); } + if ($oldBidder instanceof DummyGeneral) { + return; + } + $staticNation = $oldBidder->getStaticNation(); $src = new MessageTarget(0, '', 0, 'System', '#000000'); $dest = new MessageTarget( @@ -258,7 +286,7 @@ abstract class Auction } $myPrevBid = $this->getMyPrevBid(); - if($myPrevBid !== null && $highestBid->no !== $myPrevBid->no){ + if ($myPrevBid !== null && $highestBid->no !== $myPrevBid->no) { //이미 환불 받았으니 무효. $myPrevBid = null; } @@ -293,13 +321,14 @@ abstract class Auction $gameStor = KVStorage::getStorage($db, 'game_env'); $turnTerm = $gameStor->getValue('turnterm'); - if ($this->info->availableLatestBidCloseDate !== null) { - $extendedCloseDate = $this->info->closeDate->add(TimeUtil::secondsToDateInterval( + if ($this->info->detail->availableLatestBidCloseDate !== null) { + $extendedCloseDate = $now->add(TimeUtil::secondsToDateInterval( max(static::MIN_EXTENSION_MINUTES_PER_BID, $turnTerm * static::COEFF_EXTENSION_MINUTES_PER_BID) * 60 )); - if ($extendedCloseDate > $this->info->closeDate && $this->info->closeDate < $this->info->availableLatestBidCloseDate) { - $this->extendCloseDate(min($extendedCloseDate, $this->info->availableLatestBidCloseDate)); + if ($extendedCloseDate > $this->info->closeDate && $this->info->closeDate < $this->info->detail->availableLatestBidCloseDate) { + $this->extendCloseDate(min($extendedCloseDate, $this->info->detail->availableLatestBidCloseDate), true); + $this->applyDB(); } } @@ -332,11 +361,11 @@ abstract class Auction } if (!$auctionInfo->detail->isReverse) { - if ($auctionInfo->buyImmediatelyAmount !== null && $auctionInfo->buyImmediatelyAmount < $amount) { + if ($auctionInfo->detail->finishBidAmount !== null && $auctionInfo->detail->finishBidAmount < $amount) { return '즉시판매가보다 높을 수 없습니다.'; } } else { - if ($auctionInfo->buyImmediatelyAmount !== null && $auctionInfo->buyImmediatelyAmount > $amount) { + if ($auctionInfo->detail->finishBidAmount !== null && $auctionInfo->detail->finishBidAmount > $amount) { return '즉시판매가보다 낮을 수 없습니다.'; } } @@ -363,7 +392,7 @@ abstract class Auction $myPrevBid = $this->getMyPrevBid(); - if($myPrevBid !== null && $highestBid->no !== $myPrevBid->no){ + if ($myPrevBid !== null && $highestBid->no !== $myPrevBid->no) { //이미 환불 받았으니 무효. $myPrevBid = null; } @@ -402,6 +431,17 @@ abstract class Auction $general->increaseVar($resType->value, -$morePoint); + $gameStor = KVStorage::getStorage($db, 'game_env'); + $turnTerm = $gameStor->getValue('turnterm'); + $extendedCloseDate = $now->add(TimeUtil::secondsToDateInterval( + max(static::MIN_EXTENSION_MINUTES_PER_BID, $turnTerm * static::COEFF_EXTENSION_MINUTES_PER_BID) * 60 + )); + + if ($extendedCloseDate > $this->info->closeDate) { + $this->extendCloseDate($extendedCloseDate, true); + $this->applyDB(); + } + if ($highestBid !== null && $myPrevBid === null) { $this->refundBid($highestBid, "{$auctionInfo->id}번 {$auctionInfo->detail->title}에 상회입찰자가 나타났습니다."); } @@ -424,12 +464,18 @@ abstract class Auction } if ($highestBid->aux->tryExtendCloseDate) { + $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game_env'); + $turnTerm = $gameStor->getValue('turnterm'); + //연장 요청이 있었다. $extendedCloseDate = $this->info->closeDate->add(TimeUtil::secondsToDateInterval( - max(static::MIN_EXTENSION_MINUTES_BY_EXTENSION_QUERY, $this->info->turnTerm * static::COEFF_EXTENSION_MINUTES_BY_EXTENSION_QUERY) * 60 + max(static::MIN_EXTENSION_MINUTES_BY_EXTENSION_QUERY, $turnTerm * static::COEFF_EXTENSION_MINUTES_BY_EXTENSION_QUERY) * 60 )); if ($this->extendCloseDate($extendedCloseDate) === null) { + $this->extendLatestBidCloseDate(null); + $this->applyDB(); return false; } } @@ -441,6 +487,10 @@ abstract class Auction return true; } + if ($bidder instanceof DummyGeneral) { + return false; + } + $staticNation = $bidder->getStaticNation(); $src = new MessageTarget(0, '', 0, 'System', '#000000'); $dest = new MessageTarget( diff --git a/hwe/sammo/AuctionBuyRice.php b/hwe/sammo/AuctionBuyRice.php index 71bf451f..6b864265 100644 --- a/hwe/sammo/AuctionBuyRice.php +++ b/hwe/sammo/AuctionBuyRice.php @@ -8,7 +8,7 @@ use sammo\Enums\ResourceType; /** 경매에 쌀을 매물로 등록, 입찰자가 금으로 구매 */ class AuctionBuyRice extends AuctionBasicResource { - static AuctionType $auctionType = AuctionType::SellRice; + static AuctionType $auctionType = AuctionType::BuyRice; static ResourceType $hostRes = ResourceType::rice; static ResourceType $bidderRes = ResourceType::gold; } diff --git a/hwe/sammo/AuctionUniqueItem.php b/hwe/sammo/AuctionUniqueItem.php index 65a6c618..3d6b0216 100644 --- a/hwe/sammo/AuctionUniqueItem.php +++ b/hwe/sammo/AuctionUniqueItem.php @@ -14,6 +14,7 @@ use sammo\RandUtil; class AuctionUniqueItem extends Auction { + const COEFF_EXTENSION_MINUTES_LIMIT_UNIQUE_CNT = 24; static AuctionType $auctionType = AuctionType::UniqueItem; @@ -52,18 +53,6 @@ class AuctionUniqueItem extends Auction } $gameStor = KVStorage::getStorage($db, 'game_env'); - $givenUnique = $gameStor->getValue('givenUnique') ?? []; - $givenUniqueCnt = $givenUnique[$itemKey] ?? 0; - $remainUniqueCnt = 0; - foreach (GameConst::$allItems as $itemList) { - if (!key_exists($itemKey, $itemList)) { - continue; - } - $remainUniqueCnt += $itemList[$itemKey]; - } - if ($remainUniqueCnt > 1 && $givenUniqueCnt >= $remainUniqueCnt - 1) { - return '더이상 이 아이템을 경매로 가져갈 수 없습니다.'; - } $now = new DateTimeImmutable(); @@ -115,7 +104,7 @@ class AuctionUniqueItem extends Auction $josaRa = JosaUtil::pick($item->getRawName(), '라'); $logger = new ActionLogger(0, 0, $year, $month); - $logger->pushGlobalHistoryLog("누군가가 {$itemName}{$josaRa}는 보물을 구한다는 소문이 들려옵니다."); + $logger->pushGlobalHistoryLog("【보물수배】누군가가 {$itemName}{$josaRa}는 보물을 구한다는 소문이 들려옵니다."); $logger->flush(); return $auction; @@ -159,9 +148,14 @@ class AuctionUniqueItem extends Auction ); $itemCode = $this->info->target; + + if($itemCode === null){ + throw new \Exception('아이템 코드가 없습니다.'); + } + $bidItemTypes = new Set(); foreach (GameConst::$allItems as $itemType => $itemList) { - if (($itemList[$itemCode] ?? 0) <= 0) { + if (key_exists($itemCode, $itemList) && $itemList[$itemCode] <= 0) { continue; } $bidItemTypes->add($itemType); @@ -228,12 +222,15 @@ class AuctionUniqueItem extends Auction } if ($availableEquipUniqueCnt <= 0) { + $turnTerm = $gameStor->getValue('turnterm'); //제한에 걸렸다면 자동 연장 $extendedCloseDate = $this->info->closeDate->add(TimeUtil::secondsToDateInterval( - max(static::MIN_EXTENSION_MINUTES_BY_EXTENSION_QUERY, $this->info->turnTerm * static::COEFF_EXTENSION_MINUTES_BY_EXTENSION_QUERY) * 60 + max(static::MIN_EXTENSION_MINUTES_BY_EXTENSION_QUERY, $turnTerm * static::COEFF_EXTENSION_MINUTES_LIMIT_UNIQUE_CNT) * 60 )); $this->extendCloseDate($extendedCloseDate, true); + $this->extendLatestBidCloseDate(null); + $this->applyDB(); return '유니크 아이템 소유 제한 상태입니다. 종료 시간이 연장됩니다.'; } @@ -284,13 +281,13 @@ class AuctionUniqueItem extends Auction $logger->pushGeneralActionLog("{$itemName}{$josaUl} 습득했습니다!"); $logger->pushGeneralHistoryLog("{$itemName}{$josaUl} 습득"); $logger->pushGlobalActionLog("{$generalName}{$josaYi} {$itemName}{$josaUl} 습득했습니다!"); - $logger->pushGlobalHistoryLog("【보물발견】{$nationName}{$generalName}{$josaYi} {$itemName}{$josaUl} 습득했습니다!"); + $logger->pushGlobalHistoryLog("【보물수배】{$nationName}{$generalName}{$josaYi} {$itemName}{$josaUl} 습득했습니다!"); + + $userLogger = new UserLogger($general->getVar('owner')); + $userLogger->push(sprintf("유니크 %s 경매로 %d 포인트 사용", $itemName, $highestBid->amount), "inheritPoint"); $general->applyDB($db); - $givenUnique = $gameStor->getValue('givenUnique') ?? []; - $givenUnique[$itemKey] = ($givenUnique[$itemKey] ?? 0) + 1; - $gameStor->setValue('givenUnique', $givenUnique); return null; } } diff --git a/hwe/sammo/Command/General/che_장비매매.php b/hwe/sammo/Command/General/che_장비매매.php index a7faaf89..a786c8d2 100644 --- a/hwe/sammo/Command/General/che_장비매매.php +++ b/hwe/sammo/Command/General/che_장비매매.php @@ -188,22 +188,6 @@ class che_장비매매 extends Command\GeneralCommand $nationName = $general->getStaticNation()['name']; $logger->pushGlobalActionLog("{$generalName}{$josaYi} {$itemName}{$josaUl} 판매했습니다!"); $logger->pushGlobalHistoryLog("【판매】{$nationName}{$generalName}{$josaYi} {$itemName}{$josaUl} 판매했습니다!"); - - $gameStor = KVStorage::getStorage($db, 'game_env'); - $givenUnique = $gameStor->getValue('givenUnique') ?? []; - if (key_exists($itemCode, $givenUnique)) { - $givenUniqueCnt = $givenUnique[$itemCode]; - $givenUniqueCnt -= 1; - if ($givenUniqueCnt <= 0) { - unset($givenUnique[$itemCode]); - } else { - $givenUnique[$itemCode] = $givenUniqueCnt; - } - } else { - //XXX: 처리하지 못한 코드가 있는가? - //FIXME: 여기에서 무언가 경고를 내야함 - } - $gameStor->setValue('givenUnique', $givenUnique); } } diff --git a/hwe/sammo/DummyGeneral.php b/hwe/sammo/DummyGeneral.php index 88312519..6d01d40f 100644 --- a/hwe/sammo/DummyGeneral.php +++ b/hwe/sammo/DummyGeneral.php @@ -4,67 +4,79 @@ namespace sammo; use sammo\Enums\InheritanceKey; -class DummyGeneral extends General{ - public function __construct(bool $initLogger=true){ +class DummyGeneral extends General +{ + public function __construct(bool $initLogger = true) + { $raw = [ - 'no'=>0, - 'name'=>'Dummy', - 'npc'=>3, - 'city'=>0, - 'nation'=>0, - 'officer_level'=>0, - 'crewtype'=>-1, - 'turntime'=>'2012-03-04 05:06:07.000000', - 'experience'=>0, - 'dedication'=>0, - 'gold'=>0, - 'rice'=>0, - 'leadership'=>10, - 'strength'=>10, - 'intel'=>10, + 'no' => 0, + 'name' => 'Dummy', + 'npc' => 3, + 'city' => 0, + 'nation' => 0, + 'officer_level' => 0, + 'crewtype' => -1, + 'turntime' => '2012-03-04 05:06:07.000000', + 'experience' => 0, + 'dedication' => 0, + 'gold' => 0, + 'rice' => 0, + 'leadership' => 10, + 'strength' => 10, + 'intel' => 10, + 'imgsvr' => 0, + 'picture' => 'default.jpg', ]; $this->raw = $raw; $this->resultTurn = new LastTurn(); - if($initLogger){ + if ($initLogger) { $this->initLogger(1, 1); } } - public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{ + public function getBattleInitSkillTriggerList(WarUnit $unit): ?WarUnitTriggerCaller + { return new WarUnitTriggerCaller(); } - public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{ + public function getBattlePhaseSkillTriggerList(WarUnit $unit): ?WarUnitTriggerCaller + { return new WarUnitTriggerCaller(); } - public function onCalcStat(General $general, string $statName, $value, $aux=null){ + public function onCalcStat(General $general, string $statName, $value, $aux = null) + { return $value; } - public function onCalcOpposeStat(General $general, string $statName, $value, $aux=null){ + public function onCalcOpposeStat(General $general, string $statName, $value, $aux = null) + { return $value; } - public function getInheritancePoint(InheritanceKey $key, &$aux = null, bool $forceCalc = false): int|float{ + public function getInheritancePoint(InheritanceKey $key, &$aux = null, bool $forceCalc = false): int|float + { return 0; } - public function setInheritancePoint(InheritanceKey $key, $value, $aux = null){ + public function setInheritancePoint(InheritanceKey $key, $value, $aux = null) + { return; } - public function increaseInheritancePoint(InheritanceKey $key, $value, $aux = null){ + public function increaseInheritancePoint(InheritanceKey $key, $value, $aux = null) + { return; } - function applyDB($db):bool{ - if($this->logger){ + function applyDB($db): bool + { + if ($this->logger) { $this->initLogger($this->logger->getYear(), $this->logger->getMonth()); } return true; } -} \ No newline at end of file +} diff --git a/hwe/ts/PageAuction.vue b/hwe/ts/PageAuction.vue index 43c77a1f..b0dc4b07 100644 --- a/hwe/ts/PageAuction.vue +++ b/hwe/ts/PageAuction.vue @@ -1,12 +1,12 @@