game: 빙의장도 유산 획득이 가능하도록 수정
- 유산 실 반영 시점을 은퇴, 천통 시점으로 변경
This commit is contained in:
@@ -26,5 +26,7 @@ foreach ($db->queryFirstColumn(
|
||||
}
|
||||
|
||||
foreach(General::createGeneralObjListFromDB($db->queryFirstColumn('SELECT `no` FROM general WHERE npc = 0')) as $genObj){
|
||||
$genObj->mergeTotalInheritancePoint();
|
||||
$genObj->mergeTotalInheritancePoint(true);
|
||||
applyInheritanceUser($genObj->getID());
|
||||
$genObj->clearInheritancePoint();
|
||||
}
|
||||
@@ -1028,7 +1028,9 @@ function checkEmperior()
|
||||
$genObj->increaseInheritancePoint('unifier', 2000);
|
||||
};
|
||||
}
|
||||
$genObj->mergeTotalInheritancePoint();
|
||||
$genObj->mergeTotalInheritancePoint(true);
|
||||
applyInheritanceUser($genObj->getID());
|
||||
$genObj->clearInheritancePoint();
|
||||
}
|
||||
|
||||
$gameStor->isunited = 2;
|
||||
@@ -1182,8 +1184,10 @@ function checkEmperior()
|
||||
LogHistory();
|
||||
}
|
||||
|
||||
function resetInheritanceUser(int $userID, bool $isRebirth = false): float
|
||||
function applyInheritanceUser(int $userID, bool $isRebirth = false): float
|
||||
{
|
||||
//FIXME: 은퇴, 사망, 천통 시점에 바로 반영한다면 여기가 아니라 general class로 이동하는 것이 옳음
|
||||
//또한 굳이 merge, apply, clean 3단계를 거쳐야 할 이유도 없음
|
||||
$rebirthDegraded = [
|
||||
'dex' => 0.5,
|
||||
];
|
||||
|
||||
@@ -73,6 +73,8 @@ if ($gencount >= $maxgeneral) {
|
||||
]);
|
||||
}
|
||||
|
||||
$genAux = Json::decode($db->queryFirstField('SELECT aux FROM general WHERE no = %i', $pick)??'{}');
|
||||
$genAux['pickYearMonth'] = Util::joinYearMonth($year, $month);
|
||||
//등록 시작
|
||||
$db->update('general', [
|
||||
'owner_name'=>$userNick,
|
||||
@@ -81,6 +83,7 @@ $db->update('general', [
|
||||
'defence_train'=>80,
|
||||
'permission'=>'normal',
|
||||
'owner'=>$userID,
|
||||
'aux'=>Json::encode($genAux)
|
||||
], 'owner <= 0 AND npc = 2 AND no = %i', $pick);
|
||||
|
||||
if(!$db->affectedRows()){
|
||||
|
||||
@@ -26,7 +26,7 @@ use function sammo\cutTurn;
|
||||
use function sammo\getGeneralSpecialWarName;
|
||||
use function sammo\getRandTurn;
|
||||
use function sammo\pushAdminLog;
|
||||
use function sammo\resetInheritanceUser;
|
||||
use function sammo\applyInheritanceUser;
|
||||
|
||||
class Join extends \sammo\BaseAPI
|
||||
{
|
||||
@@ -155,7 +155,7 @@ class Join extends \sammo\BaseAPI
|
||||
|
||||
$admin = $gameStor->getValues(['scenario', 'turnterm', 'turntime', 'show_img_level', 'startyear', 'year', 'month']);
|
||||
|
||||
$inheritTotalPoint = resetInheritanceUser($userID);
|
||||
$inheritTotalPoint = applyInheritanceUser($userID);
|
||||
$inheritRequiredPoint = 0;
|
||||
|
||||
$userLogger = new UserLogger($userID, $admin['year'], $admin['month'], false);
|
||||
|
||||
@@ -54,7 +54,7 @@ class DummyGeneral extends General{
|
||||
return;
|
||||
}
|
||||
|
||||
public function mergeTotalInheritancePoint(){
|
||||
public function mergeTotalInheritancePoint(bool $isEnd=false){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+49
-6
@@ -652,6 +652,8 @@ class General implements iAction
|
||||
}
|
||||
|
||||
$this->mergeTotalInheritancePoint();
|
||||
applyInheritanceUser($this->getID());
|
||||
$this->clearInheritancePoint();
|
||||
}
|
||||
|
||||
|
||||
@@ -711,7 +713,8 @@ class General implements iAction
|
||||
$ownerID = $this->getVar('owner');
|
||||
if ($ownerID) {
|
||||
$this->mergeTotalInheritancePoint();
|
||||
resetInheritanceUser($ownerID, true);
|
||||
applyInheritanceUser($ownerID, true);
|
||||
$this->clearInheritancePoint();
|
||||
}
|
||||
|
||||
$this->multiplyVarWithLimit('leadership', 0.85, 10);
|
||||
@@ -1320,7 +1323,7 @@ class General implements iAction
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($this->getVar('npc') != 0) {
|
||||
if ($this->getVar('npc') >= 2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1443,7 +1446,7 @@ class General implements iAction
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->getVar('npc') != 0) {
|
||||
if ($this->getVar('npc') >= 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1463,17 +1466,58 @@ class General implements iAction
|
||||
$inheritStor->setValue($key, [$newValue, $aux]);
|
||||
}
|
||||
|
||||
public function mergeTotalInheritancePoint()
|
||||
public function clearInheritancePoint(){
|
||||
$ownerID = $this->getVar('owner');
|
||||
if(!$ownerID){
|
||||
return;
|
||||
}
|
||||
|
||||
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$ownerID}");
|
||||
$allPoints = $inheritStor->getAll();
|
||||
if (!$allPoints || count($allPoints) == 0) {
|
||||
//비었으므로 리셋 안함
|
||||
return;
|
||||
}
|
||||
if (count($allPoints) == 1 && key_exists('previous', $allPoints)) {
|
||||
//이미 리셋되었으므로 리셋 안함
|
||||
return;
|
||||
}
|
||||
|
||||
$previousPointInfo = $allPoints['previous'];
|
||||
$inheritStor->resetValues();
|
||||
$inheritStor->setValue('previous', $previousPointInfo);
|
||||
}
|
||||
|
||||
public function mergeTotalInheritancePoint(bool $isEnd=false)
|
||||
{
|
||||
$ownerID = $this->getVar('owner');
|
||||
if (!$ownerID) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->getVar('npc') != 0) {
|
||||
if ($this->getVar('npc') > 1){
|
||||
return;
|
||||
}
|
||||
|
||||
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
|
||||
$gameStor->cacheValues(['year', 'startyear', 'month']);
|
||||
|
||||
if ($this->getVar('npc') == 1) {
|
||||
if(!$isEnd){
|
||||
return;
|
||||
}
|
||||
|
||||
$pickYearMonth = $this->getAuxVar('pickYearMonth');
|
||||
if($pickYearMonth === null){
|
||||
return;
|
||||
}
|
||||
[$startYear, $year] = $gameStor->getValuesAsArray(['startyear', 'year']);
|
||||
|
||||
if(($year - $pickYearMonth) * 2 <= ($year - $startYear)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$ownerID}");
|
||||
$inheritStor->cacheAll();
|
||||
foreach (static::INHERITANCE_KEY as $key => [$storType,,]) {
|
||||
@@ -1486,7 +1530,6 @@ class General implements iAction
|
||||
}
|
||||
|
||||
$oldInheritStor = KVStorage::getStorage(DB::db(), "inheritance_result");
|
||||
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
|
||||
$serverID = UniqueConst::$serverID;
|
||||
$year = $gameStor->year;
|
||||
$month = $gameStor->month;
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ if ($gencount >= $admin['maxgeneral']) {
|
||||
die(WebUtil::errorBackMsg("더 이상 등록할 수 없습니다."));
|
||||
}
|
||||
|
||||
$inheritTotalPoint = resetInheritanceUser($userID);
|
||||
$inheritTotalPoint = applyInheritanceUser($userID);
|
||||
|
||||
$nationList = $db->query('SELECT nation,`name`,color,scout FROM nation');
|
||||
$nationList = Util::convertArrayToDict($nationList, 'nation');
|
||||
|
||||
Reference in New Issue
Block a user