유산 포인트 초기화/저장 구조 추가

This commit is contained in:
2021-08-08 03:02:42 +09:00
parent a62cc65b53
commit 44bd408471
4 changed files with 94 additions and 10 deletions
+4
View File
@@ -24,3 +24,7 @@ foreach ($db->queryFirstColumn(
) as $generalNo) { ) as $generalNo) {
CheckHall($generalNo); CheckHall($generalNo);
} }
foreach(General::createGeneralObjListFromDB($db->queryFirstColumn('SELECT `no` FROM general WHERE npc = 0')) as $genObj){
$genObj->mergeTotalInheritancePoint();
}
+15
View File
@@ -988,6 +988,10 @@ function checkEmperior()
foreach ($db->queryFirstColumn('SELECT no FROM general WHERE npc<2 AND age>=%i', GameConst::$minPushHallAge) as $hallGeneralNo) { foreach ($db->queryFirstColumn('SELECT no FROM general WHERE npc<2 AND age>=%i', GameConst::$minPushHallAge) as $hallGeneralNo) {
CheckHall($hallGeneralNo); CheckHall($hallGeneralNo);
} }
foreach(General::createGeneralObjListFromDB($db->queryFirstColumn('SELECT `no` FROM general WHERE npc = 0')) as $genObj){
$genObj->mergeTotalInheritancePoint();
}
[$totalPop, $totalMaxPop] = $db->queryFirstList('SELECT SUM(pop), SUM(pop_max) FROM city'); [$totalPop, $totalMaxPop] = $db->queryFirstList('SELECT SUM(pop), SUM(pop_max) FROM city');
$pop = "{$totalPop} / {$totalMaxPop}"; $pop = "{$totalPop} / {$totalMaxPop}";
@@ -1132,3 +1136,14 @@ function checkEmperior()
//연감 월결산 //연감 월결산
LogHistory(); LogHistory();
} }
function resetInheritanceUser(int $userID){
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$userID}");
$totalPoint = 0;
foreach($inheritStor->getAll() as [$value,]){
$totalPoint += $value;
}
$totalPoint = Util::toInt($totalPoint);
$inheritStor->resetValues();
$inheritStor->setValue('previous', [$totalPoint, null]);
}
+2
View File
@@ -266,6 +266,8 @@ foreach(Util::range(GameConst::$maxTurn) as $turnIdx){
} }
$db->insert('general_turn', $turnRows); $db->insert('general_turn', $turnRows);
resetInheritanceUser($userID);
$rank_data = []; $rank_data = [];
foreach(array_keys(General::RANK_COLUMN) as $rankColumn){ foreach(array_keys(General::RANK_COLUMN) as $rankColumn){
$rank_data[] = [ $rank_data[] = [
+73 -10
View File
@@ -553,6 +553,8 @@ class General implements iAction{
$generalName = $this->getName(); $generalName = $this->getName();
$this->mergeTotalInheritancePoint();
// 군주였으면 유지 이음 // 군주였으면 유지 이음
$officerLevel = $this->getVar('officer_level'); $officerLevel = $this->getVar('officer_level');
if($officerLevel == 12) { if($officerLevel == 12) {
@@ -606,6 +608,12 @@ class General implements iAction{
$generalName = $this->getName(); $generalName = $this->getName();
$ownerID = $this->getVar('owner');
if($ownerID){
$this->mergeTotalInheritancePoint();
resetInheritanceUser($ownerID);
}
$this->multiplyVarWithLimit('leadership', 0.85, 10); $this->multiplyVarWithLimit('leadership', 0.85, 10);
$this->multiplyVarWithLimit('strength', 0.85, 10); $this->multiplyVarWithLimit('strength', 0.85, 10);
$this->multiplyVarWithLimit('intel', 0.85, 10); $this->multiplyVarWithLimit('intel', 0.85, 10);
@@ -1165,10 +1173,19 @@ class General implements iAction{
throw new \OutOfRangeException("{$key}는 유산 타입이 아님"); throw new \OutOfRangeException("{$key}는 유산 타입이 아님");
} }
$ownerID = $this->getVar('owner');
if(!$ownerID){
return 0;
}
if($this->getVar('npc') != 0){
return 0;
}
[$storeType, $multiplier, ] = $inheritType; [$storeType, $multiplier, ] = $inheritType;
if($storeType === true){ if($storeType === true){
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$this->getID()}"); $inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$ownerID}");
[$value, $aux] = $inheritStor->getValue($key); [$value, $aux] = $inheritStor->getValue($key);
return $value; return $value;
} }
@@ -1235,7 +1252,21 @@ class General implements iAction{
throw new \InvalidArgumentException("{$key}는 1:1 유산 포인트가 아님"); throw new \InvalidArgumentException("{$key}는 1:1 유산 포인트가 아님");
} }
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$this->getID()}"); $ownerID = $this->getVar('owner');
if(!$ownerID){
return;
}
if($this->getVar('npc') != 0){
return;
}
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
if($gameStor->isunited != 0){
return;
}
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$ownerID}");
$inheritStor->setValue($key, [$value, $aux]); $inheritStor->setValue($key, [$value, $aux]);
} }
@@ -1254,7 +1285,21 @@ class General implements iAction{
throw new \InvalidArgumentException("{$key}는 직접 저장형 유산 포인트가 아님"); throw new \InvalidArgumentException("{$key}는 직접 저장형 유산 포인트가 아님");
} }
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$this->getID()}"); $ownerID = $this->getVar('owner');
if(!$ownerID){
return;
}
if($this->getVar('npc') != 0){
return;
}
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
if($gameStor->isunited != 0){
return;
}
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$ownerID}");
[$oldValue, $oldAux] = $inheritStor->getValue($key)??[0, null]; [$oldValue, $oldAux] = $inheritStor->getValue($key)??[0, null];
if($oldAux !== $aux){ if($oldAux !== $aux){
@@ -1265,13 +1310,31 @@ class General implements iAction{
$inheritStor->setValue($key, [$newValue, $aux]); $inheritStor->setValue($key, [$newValue, $aux]);
} }
public function calcTotalInheritancePoint(): int{ public function mergeTotalInheritancePoint(){
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$this->getID()}"); $ownerID = $this->getVar('owner');
$inheritStor->cacheAll(); if(!$ownerID){
$total = 0; return;
foreach(array_keys(static::INHERITANCE_KEY) as $key){
$total += $this->getInheritancePoint($key);
} }
return Util::toInt($total);
if($this->getVar('npc') != 0){
return;
}
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$ownerID}");
$inheritStor->cacheAll();
foreach(static::INHERITANCE_KEY as $key=>[$storType, ,]){
$point = $this->getInheritancePoint($key);
if($storType === true){
continue;
}
$inheritStor->setValue($key, $point);
}
$oldInheritStor = KVStorage::getStorage(DB::db(), "inheritance_result");
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
$serverID = UniqueConst::$serverID;
$year = $gameStor->year;
$month = $gameStor->month;
$oldInheritStor->setValue("{$serverID}_{$ownerID}_{$this->getID()}_{$year}_{$month}", $inheritStor->getAll(true));
} }
} }