fix: previous inheritPoint 지정값 버그

This commit is contained in:
2021-09-16 02:43:56 +09:00
parent 8964998064
commit bac7602a1f
9 changed files with 33 additions and 24 deletions
+25 -11
View File
@@ -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("<Y>{$generalName}</>{$josaYi} <C>{$itemName}</>{$josaUl} 습득했습니다!");
$logger->pushGlobalHistoryLog("<C><b>【{$acquireType}】</b></><D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} <C>{$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;
+1 -6
View File
@@ -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 = [
@@ -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;
}
@@ -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;
}
@@ -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;
@@ -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;
}
@@ -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;
}
@@ -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;
}
+1 -1
View File
@@ -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;
}