diff --git a/hwe/func.php b/hwe/func.php index 9029954a..24d3a532 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1620,14 +1620,17 @@ function giveRandomUniqueItem(General $general, string $acquireType): bool function rollbackInheritUniqueTrial(General $general, string $itemKey, string $reason) { + $ownerID = $general->getVar('owner'); $db = DB::db(); $itemTrials = $general->getAuxVar('inheritUniqueTrial'); + LogText("선택유니크 롤백:{$ownerID}", [$itemKey, $itemTrials]); unset($itemTrials[$itemKey]); $general->setAuxVar('inheritUniqueTrial', $itemTrials); + $trialStor = KVStorage::getStorage($db, "ut_{$itemKey}"); $ownTrial = $trialStor->getValue("u{$ownerID}"); @@ -1636,6 +1639,7 @@ function rollbackInheritUniqueTrial(General $general, string $itemKey, string $r [,, $amount] = $ownTrial; $trialStor->deleteValue("u{$ownerID}"); $general->increaseInheritancePoint('previous', $amount); + LogText("선택유니크 롤백포인트:{$ownerID}", $amount); } $itemObj = buildItemClass($itemKey); @@ -1646,7 +1650,7 @@ function rollbackInheritUniqueTrial(General $general, string $itemKey, string $r $unlimited = new \DateTime('9999-12-31'); $src = new MessageTarget(0, '', 0, 'System', '#000000'); - $dest = new MessageTarget($general->getID(), $general->getName(), $general->getNationID(), $staticNation['name'], $staticNation['color'], $general->getVar('icon')); + $dest = new MessageTarget($general->getID(), $general->getName(), $general->getNationID(), $staticNation['name'], $staticNation['color'], GetImageURL($general->getVar('imgsvr'), $general->getVar('picture'))); $josaUl = JosaUtil::pick($itemName, '을'); $msg = new Message( Message::MSGTYPE_PRIVATE, @@ -1659,22 +1663,25 @@ function rollbackInheritUniqueTrial(General $general, string $itemKey, string $r ); $msg->send(true); + $general->applyDB($db); } function tryInheritUniqueItem(General $general, string $acquireType = '아이템'): bool { $ownerID = $general->getVar('owner'); if (!$ownerID) { + LogText("선택유니크 실패???: {$ownerID}", $general->getName()); return false; } $itemTrials = $general->getAuxVar('inheritUniqueTrial') ?? []; arsort($itemTrials); + LogText("선택유니크항목: {$ownerID}", $itemTrials); $db = DB::db(); - $acquireTarget = null; - $acquireType = null; + $ownTarget = null; + $ownType = null; foreach ($itemTrials as $itemKey => $amount) { $availableItemTypes = []; @@ -1729,6 +1736,8 @@ function tryInheritUniqueItem(General $general, string $acquireType = '아이템 return $rhsAmount <=> $lhsAmount; //큰 값이 앞에 오도록 }); + LogText("선택유니크상태 {$ownerID} {$itemKey}", $anyTrials); + //공동 1등인데 본인이 있을 수도 있다. [,, $topAmount] = $anyTrials[0]; if ($amount < $topAmount) { @@ -1747,38 +1756,40 @@ function tryInheritUniqueItem(General $general, string $acquireType = '아이템 } //내가 1위다 - if (!$acquireTarget) { + if ($ownTarget !== null) { //이미 다른 아이템을 얻기로 되어있다. continue; } - $acquireTarget = $itemKey; - $acquireType = $itemType; + $ownTarget = $itemKey; + $ownType = $itemType; } unset($itemKey); unset($itemType); - if (!$acquireTarget) { + if ($ownTarget === null) { return false; } - $trialStor = KVStorage::getStorage($db, "ut_{$acquireTarget}"); + LogText("선택유니크획득{$ownerID}", $ownTarget); + + $trialStor = KVStorage::getStorage($db, "ut_{$ownTarget}"); $trialStor->deleteValue("u{$ownerID}"); //rollbackInheritUniqueTrial 과정 때문에 새로 받아와야함 $itemTrials = $general->getAuxVar('inheritUniqueTrial'); - unset($itemTrials[$acquireTarget]); + unset($itemTrials[$ownTarget]); $general->setAuxVar('inheritUniqueTrial', $itemTrials); $nationName = $general->getStaticNation()['name']; $generalName = $general->getName(); $josaYi = JosaUtil::pick($generalName, '이'); - $itemObj = buildItemClass($acquireTarget); + $itemObj = buildItemClass($ownTarget); $itemName = $itemObj->getName(); $itemRawName = $itemObj->getRawName(); $josaUl = JosaUtil::pick($itemRawName, '을'); - $general->setVar($acquireType, $acquireTarget); + $general->setVar($ownType, $ownTarget); $logger = $general->getLogger(); @@ -1788,6 +1799,8 @@ function tryInheritUniqueItem(General $general, string $acquireType = '아이템 $logger->pushGlobalActionLog("{$generalName}{$josaYi} {$itemName}{$josaUl} 습득했습니다!"); $logger->pushGlobalHistoryLog("【{$acquireType}】{$nationName}{$generalName}{$josaYi} {$itemName}{$josaUl} 습득했습니다!"); + $general->applyDB($db); + return true; } @@ -1802,6 +1815,7 @@ function tryUniqueItemLottery(General $general, string $acquireType = '아이템 $inheritUnique = $general->getAuxVar('inheritUniqueTrial'); if ($inheritUnique && count($inheritUnique)) { + LogText("유니크 준비?? {$general->getID()}", $inheritUnique); $trialResult = tryInheritUniqueItem($general, $acquireType); if ($trialResult) { return true; diff --git a/hwe/sammo/API/General/Join.php b/hwe/sammo/API/General/Join.php index 5e3d4527..b3eac283 100644 --- a/hwe/sammo/API/General/Join.php +++ b/hwe/sammo/API/General/Join.php @@ -373,12 +373,7 @@ class Join extends \sammo\BaseAPI if ($inheritRequiredPoint > 0) { $inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$userID}"); - $inheritStor->setValue('previous', [$inheritTotalPoint - $inheritRequiredPoint, [ - 'inheritBonusStat'=>$inheritBonusStat, - 'inheritCity'=>$inheritCity, - 'inheritSpecial'=>$inheritSpecial, - 'inheritTurntime'=>$inheritTurntime, - ]]); + $inheritStor->setValue('previous', [$inheritTotalPoint - $inheritRequiredPoint, null]); } $me = [ diff --git a/hwe/sammo/API/InheritAction/BuyHiddenBuff.php b/hwe/sammo/API/InheritAction/BuyHiddenBuff.php index f3aa517f..964a9010 100644 --- a/hwe/sammo/API/InheritAction/BuyHiddenBuff.php +++ b/hwe/sammo/API/InheritAction/BuyHiddenBuff.php @@ -72,7 +72,7 @@ class BuyHiddenBuff extends \sammo\BaseAPI $inheritBuffList[$type] = $level; $general->setAuxVar('inheritBuff', $inheritBuffList); - $inheritStor->setValue('previous', [$previousPoint - $reqAmount, [$type, $level]]); + $inheritStor->setValue('previous', [$previousPoint - $reqAmount, null]); $general->applyDB($db); return null; } diff --git a/hwe/sammo/API/InheritAction/BuyRandomUnique.php b/hwe/sammo/API/InheritAction/BuyRandomUnique.php index 6aaf56b4..ffaba187 100644 --- a/hwe/sammo/API/InheritAction/BuyRandomUnique.php +++ b/hwe/sammo/API/InheritAction/BuyRandomUnique.php @@ -45,7 +45,7 @@ class BuyRandomUnique extends \sammo\BaseAPI } $general->setAuxVar('inheritRandomUnique', TimeUtil::now()); - $inheritStor->setValue('previous', [$previousPoint - GameConst::$inheritItemRandomPoint, 'BuyRandomUnique']); + $inheritStor->setValue('previous', [$previousPoint - GameConst::$inheritItemRandomPoint, null]); $general->applyDB($db); return null; } diff --git a/hwe/sammo/API/InheritAction/BuySpecificUnique.php b/hwe/sammo/API/InheritAction/BuySpecificUnique.php index b2885d6f..f833b010 100644 --- a/hwe/sammo/API/InheritAction/BuySpecificUnique.php +++ b/hwe/sammo/API/InheritAction/BuySpecificUnique.php @@ -72,7 +72,7 @@ class BuySpecificUnique extends \sammo\BaseAPI $itemTrials[$itemKey] = $amount; $general->setAuxVar('inheritUniqueTrial', $itemTrials); - $inheritStor->setValue('previous', [$previousPoint - $amount, ['BuySpecificUnique', $itemKey, $amount]]); + $inheritStor->setValue('previous', [$previousPoint - $amount, null]); $trialStor->setValue("u{$userID}", [$userID, $generalID, $amount]); $general->applyDB($db); return null; diff --git a/hwe/sammo/API/InheritAction/ResetSpecialWar.php b/hwe/sammo/API/InheritAction/ResetSpecialWar.php index a22e6395..4d833694 100644 --- a/hwe/sammo/API/InheritAction/ResetSpecialWar.php +++ b/hwe/sammo/API/InheritAction/ResetSpecialWar.php @@ -62,7 +62,7 @@ class ResetSpecialWar extends \sammo\BaseAPI $general->setAuxVar('inheritResetSpecialWar', $nextLevel); $general->setVar('special2', 'None'); - $inheritStor->setValue('previous', [$previousPoint - $reqPoint, 'ResetSpecialWar']); + $inheritStor->setValue('previous', [$previousPoint - $reqPoint, null]); $general->applyDB($db); return null; } diff --git a/hwe/sammo/API/InheritAction/ResetTurnTime.php b/hwe/sammo/API/InheritAction/ResetTurnTime.php index b4120874..6f19dc75 100644 --- a/hwe/sammo/API/InheritAction/ResetTurnTime.php +++ b/hwe/sammo/API/InheritAction/ResetTurnTime.php @@ -66,7 +66,7 @@ class ResetTurnTime extends \sammo\BaseAPI $general->setVar('turntime', TimeUtil::format($turnTime, true)); $general->setAuxVar('inheritResetTurnTime', $nextLevel); - $inheritStor->setValue('previous', [$previousPoint - $reqPoint, 'ResetTurnTime']); + $inheritStor->setValue('previous', [$previousPoint - $reqPoint, null]); $general->applyDB($db); return null; } diff --git a/hwe/sammo/API/InheritAction/SetNextSpecialWar.php b/hwe/sammo/API/InheritAction/SetNextSpecialWar.php index 195e50d8..f21f36c5 100644 --- a/hwe/sammo/API/InheritAction/SetNextSpecialWar.php +++ b/hwe/sammo/API/InheritAction/SetNextSpecialWar.php @@ -68,7 +68,7 @@ class SetNextSpecialWar extends \sammo\BaseAPI } $general->setAuxVar('inheritSpecificSpecialWar', $type); - $inheritStor->setValue('previous', [$previousPoint - $reqAmount, ['SetNextSpecialWar', $type]]); + $inheritStor->setValue('previous', [$previousPoint - $reqAmount, null]); $general->applyDB($db); return null; } diff --git a/hwe/v_inheritPoint.php b/hwe/v_inheritPoint.php index 433d4908..3f40e938 100644 --- a/hwe/v_inheritPoint.php +++ b/hwe/v_inheritPoint.php @@ -17,7 +17,7 @@ $me = General::createGeneralObjFromDB($generalID); $currentInheritBuff = []; -foreach ($me->getAuxVar('inheritBuff') as $buff => $buffLevel) { +foreach ($me->getAuxVar('inheritBuff')??[] as $buff => $buffLevel) { if (!key_exists($buff, TriggerInheritBuff::BUFF_KEY_TEXT)) { continue; }