feat: 장수 생성 시 유산 포인트에 따라 생성해주는 기능 추가

This commit is contained in:
2021-09-12 02:59:49 +09:00
parent b8581e3cec
commit 533ba87ef4
4 changed files with 276 additions and 191 deletions
+12 -2
View File
@@ -1150,14 +1150,23 @@ function checkEmperior()
LogHistory();
}
function resetInheritanceUser(int $userID, bool $isRebirth=false){
function resetInheritanceUser(int $userID, bool $isRebirth=false):float{
$rebirthDegraded = [
'dex'=>0.5,
];
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$userID}");
$totalPoint = 0;
foreach($inheritStor->getAll() as $key=>[$value,]){
$allPoints = $inheritStor->getAll();
if(count($allPoints) == 0){
//비었으므로 리셋 안함
return 0;
}
if(count($allPoints) == 1 && key_exists('previous', $allPoints)){
//이미 리셋되었으므로 리셋 안함
return $allPoints['previous'];
}
foreach($allPoints as $key=>[$value,]){
if($isRebirth && key_exists($key, $rebirthDegraded)){
$value *= $rebirthDegraded[$key];
}
@@ -1166,6 +1175,7 @@ function resetInheritanceUser(int $userID, bool $isRebirth=false){
$totalPoint = Util::toInt($totalPoint);
$inheritStor->resetValues();
$inheritStor->setValue('previous', [$totalPoint, null]);
return $totalPoint;
}
function updateMaxDomesticCritical(General $general, $score){