refac, game: 은퇴 시 포인트 반영 방식 변경
- 반영하지 않고 은퇴 이후로 넘기는 포인트 추가 - 은퇴시 계수를 Obj로 이동
This commit is contained in:
@@ -27,7 +27,6 @@ foreach ($db->queryFirstColumn(
|
|||||||
|
|
||||||
$inheritPointManager = InheritancePointManager::getInstance();
|
$inheritPointManager = InheritancePointManager::getInstance();
|
||||||
foreach(General::createGeneralObjListFromDB($db->queryFirstColumn('SELECT `no` FROM general WHERE npc = 0')) as $genObj){
|
foreach(General::createGeneralObjListFromDB($db->queryFirstColumn('SELECT `no` FROM general WHERE npc = 0')) as $genObj){
|
||||||
$inheritPointManager->mergeTotalInheritancePoint($genObj, true);
|
$inheritPointManager->mergeTotalInheritancePoint($genObj);
|
||||||
$inheritPointManager->applyInheritanceUser($genObj->getVar('owner'));
|
$inheritPointManager->applyInheritanceUser($genObj->getVar('owner'));
|
||||||
$inheritPointManager->clearInheritancePoint($genObj);
|
|
||||||
}
|
}
|
||||||
@@ -1092,9 +1092,8 @@ function checkEmperior()
|
|||||||
}
|
}
|
||||||
processSumInheritPointRank();
|
processSumInheritPointRank();
|
||||||
foreach ($allUserGenerals as $genObj) {
|
foreach ($allUserGenerals as $genObj) {
|
||||||
$inheritPointManager->mergeTotalInheritancePoint($genObj, true);
|
$inheritPointManager->mergeTotalInheritancePoint($genObj);
|
||||||
$inheritPointManager->applyInheritanceUser($genObj->getVar('owner'));
|
$inheritPointManager->applyInheritanceUser($genObj->getVar('owner'));
|
||||||
$inheritPointManager->clearInheritancePoint($genObj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$gameStor->isunited = 2;
|
$gameStor->isunited = 2;
|
||||||
|
|||||||
@@ -626,7 +626,6 @@ class General implements iAction
|
|||||||
$inheritPointManager = InheritancePointManager::getInstance();
|
$inheritPointManager = InheritancePointManager::getInstance();
|
||||||
$inheritPointManager->mergeTotalInheritancePoint($this);
|
$inheritPointManager->mergeTotalInheritancePoint($this);
|
||||||
$inheritPointManager->applyInheritanceUser($this->getVar('owner'));
|
$inheritPointManager->applyInheritanceUser($this->getVar('owner'));
|
||||||
$inheritPointManager->clearInheritancePoint($this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -686,9 +685,8 @@ class General implements iAction
|
|||||||
|
|
||||||
$ownerID = $this->getVar('owner');
|
$ownerID = $this->getVar('owner');
|
||||||
if ($ownerID) {
|
if ($ownerID) {
|
||||||
$inheritPointManager->mergeTotalInheritancePoint($this);
|
$inheritPointManager->mergeTotalInheritancePoint($this, true);
|
||||||
$inheritPointManager->applyInheritanceUser($ownerID, true);
|
$inheritPointManager->applyInheritanceUser($ownerID, true);
|
||||||
$inheritPointManager->clearInheritancePoint($this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->multiplyVarWithLimit('leadership', 0.85, 10);
|
$this->multiplyVarWithLimit('leadership', 0.85, 10);
|
||||||
@@ -1331,8 +1329,8 @@ class General implements iAction
|
|||||||
return InheritancePointManager::getInstance()->increaseInheritancePoint($this, $key, $value, $aux);
|
return InheritancePointManager::getInstance()->increaseInheritancePoint($this, $key, $value, $aux);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mergeTotalInheritancePoint(bool $isEnd = false)
|
public function mergeTotalInheritancePoint(bool $isRebirth = false)
|
||||||
{
|
{
|
||||||
InheritancePointManager::getInstance()->mergeTotalInheritancePoint($this, $isEnd);
|
InheritancePointManager::getInstance()->mergeTotalInheritancePoint($this, $isRebirth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,18 +17,18 @@ class InheritancePointManager
|
|||||||
private function __construct()
|
private function __construct()
|
||||||
{
|
{
|
||||||
$inheritanceKey = new Map();
|
$inheritanceKey = new Map();
|
||||||
$inheritanceKey->put(InheritanceKey::previous, new InheritancePointType(true, 1, '기존 포인트'));
|
$inheritanceKey->put(InheritanceKey::previous, new InheritancePointType(true, 1, '기존 포인트', 1));
|
||||||
$inheritanceKey->put(InheritanceKey::lived_month, new InheritancePointType(true, 1, '생존'));
|
$inheritanceKey->put(InheritanceKey::lived_month, new InheritancePointType(true, 1, '생존', 1));
|
||||||
$inheritanceKey->put(InheritanceKey::max_belong, new InheritancePointType(false, 10, '최대 임관년 수'));
|
$inheritanceKey->put(InheritanceKey::max_belong, new InheritancePointType(false, 10, '최대 임관년 수', null));
|
||||||
$inheritanceKey->put(InheritanceKey::max_domestic_critical, new InheritancePointType(true, 1, '최대 연속 내정 성공'));
|
$inheritanceKey->put(InheritanceKey::max_domestic_critical, new InheritancePointType(true, 1, '최대 연속 내정 성공', null));
|
||||||
$inheritanceKey->put(InheritanceKey::active_action, new InheritancePointType(true, 3, '능동 행동 수'));
|
$inheritanceKey->put(InheritanceKey::active_action, new InheritancePointType(true, 3, '능동 행동 수', 1));
|
||||||
//$inheritanceKey->put(InheritanceKey::snipe_combat, new InheritancePointType(true, 10, '병종 상성 우위 횟수'));
|
//$inheritanceKey->put(InheritanceKey::snipe_combat, new InheritancePointType(true, 10, '병종 상성 우위 횟수'));
|
||||||
$inheritanceKey->put(InheritanceKey::combat, new InheritancePointType(['rank', RankColumn::warnum], 5, '전투 횟수'));
|
$inheritanceKey->put(InheritanceKey::combat, new InheritancePointType(['rank', RankColumn::warnum], 5, '전투 횟수', 1));
|
||||||
$inheritanceKey->put(InheritanceKey::sabotage, new InheritancePointType(['rank', RankColumn::firenum], 20, '계략 성공 횟수'));
|
$inheritanceKey->put(InheritanceKey::sabotage, new InheritancePointType(['rank', RankColumn::firenum], 20, '계략 성공 횟수', 1));
|
||||||
$inheritanceKey->put(InheritanceKey::unifier, new InheritancePointType(true, 1, '천통 기여'));
|
$inheritanceKey->put(InheritanceKey::unifier, new InheritancePointType(true, 1, '천통 기여', null));
|
||||||
$inheritanceKey->put(InheritanceKey::dex, new InheritancePointType(false, 0.001, '숙련도'));
|
$inheritanceKey->put(InheritanceKey::dex, new InheritancePointType(false, 0.001, '숙련도', 0.5));
|
||||||
$inheritanceKey->put(InheritanceKey::tournament, new InheritancePointType(true, 1, '토너먼트'));
|
$inheritanceKey->put(InheritanceKey::tournament, new InheritancePointType(true, 1, '토너먼트', 0.5));
|
||||||
$inheritanceKey->put(InheritanceKey::betting, new InheritancePointType(false, 10, '베팅 당첨'));
|
$inheritanceKey->put(InheritanceKey::betting, new InheritancePointType(false, 10, '베팅 당첨', null));
|
||||||
$this->inheritanceKey = $inheritanceKey;
|
$this->inheritanceKey = $inheritanceKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,9 +258,8 @@ class InheritancePointManager
|
|||||||
$inheritStor->setValue($key->value, [$newValue, $aux]);
|
$inheritStor->setValue($key->value, [$newValue, $aux]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clearInheritancePoint(General $general)
|
public function clearInheritancePoint(?int $ownerID)
|
||||||
{
|
{
|
||||||
$ownerID = $general->getVar('owner');
|
|
||||||
if (!$ownerID) {
|
if (!$ownerID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -281,7 +280,7 @@ class InheritancePointManager
|
|||||||
$inheritStor->setValue(InheritanceKey::previous->value, $previousPointInfo);
|
$inheritStor->setValue(InheritanceKey::previous->value, $previousPointInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mergeTotalInheritancePoint(General $general, bool $isEnd = false)
|
public function mergeTotalInheritancePoint(General $general, bool $isRebirth = false)
|
||||||
{
|
{
|
||||||
$ownerID = $general->getVar('owner');
|
$ownerID = $general->getVar('owner');
|
||||||
if (!$ownerID) {
|
if (!$ownerID) {
|
||||||
@@ -296,7 +295,7 @@ class InheritancePointManager
|
|||||||
$gameStor->cacheValues(['year', 'startyear', 'month']);
|
$gameStor->cacheValues(['year', 'startyear', 'month']);
|
||||||
|
|
||||||
if ($general->getVar('npc') == 1) {
|
if ($general->getVar('npc') == 1) {
|
||||||
if (!$isEnd) {
|
if ($isRebirth) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,18 +330,14 @@ class InheritancePointManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function applyInheritanceUser(int $userID, bool $isRebirth = false): float
|
function applyInheritanceUser(int $ownerID, bool $isRebirth = false): float
|
||||||
{
|
{
|
||||||
if ($userID === 0) {
|
if ($ownerID === 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: 굳이 merge, apply, clean 3단계를 거쳐야 할 이유가 없음
|
//FIXME: 굳이 merge, apply, clean 3단계를 거쳐야 할 이유가 없음
|
||||||
/** @var Map<InheritanceKey,float> */
|
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$ownerID}");
|
||||||
$rebirthDegraded = new Map();
|
|
||||||
$rebirthDegraded[InheritanceKey::dex] = 0.5;
|
|
||||||
|
|
||||||
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$userID}");
|
|
||||||
$totalPoint = 0;
|
$totalPoint = 0;
|
||||||
/** @var array<string,array{0:float,1:string|float}> */
|
/** @var array<string,array{0:float,1:string|float}> */
|
||||||
$allPoints = $inheritStor->getAll();
|
$allPoints = $inheritStor->getAll();
|
||||||
@@ -355,15 +350,27 @@ class InheritancePointManager
|
|||||||
return $allPoints[InheritanceKey::previous->value][0];
|
return $allPoints[InheritanceKey::previous->value][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
$userLogger = new UserLogger($userID);
|
$userLogger = new UserLogger($ownerID);
|
||||||
|
|
||||||
$previousPoint = ($allPoints[InheritanceKey::previous->value] ?? [0, 0])[0];
|
$previousPoint = ($allPoints[InheritanceKey::previous->value] ?? [0, 0])[0];
|
||||||
|
|
||||||
foreach ($allPoints as $rKey => [$value,]) {
|
$keepValues = [];
|
||||||
|
|
||||||
|
foreach ($allPoints as $rKey => [$value, $auxV]) {
|
||||||
$key = InheritanceKey::from($rKey);
|
$key = InheritanceKey::from($rKey);
|
||||||
if ($isRebirth && $rebirthDegraded->hasKey($key)) {
|
|
||||||
$value *= $rebirthDegraded[$key];
|
/** @var InheritancePointType */
|
||||||
|
$keyTypeObj = $this->inheritanceKey->get($key);
|
||||||
|
|
||||||
|
if($isRebirth){
|
||||||
|
if($keyTypeObj->rebirthStoreCoeff === null){
|
||||||
|
$keepValues[$rKey] = [$value, $auxV];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$value *= $keyTypeObj->rebirthStoreCoeff;
|
||||||
}
|
}
|
||||||
|
|
||||||
$keyText = $this->getInheritancePointType($key)->info;
|
$keyText = $this->getInheritancePointType($key)->info;
|
||||||
$userLogger->push("{$keyText} 포인트 {$value} 증가", "inheritPoint");
|
$userLogger->push("{$keyText} 포인트 {$value} 증가", "inheritPoint");
|
||||||
$totalPoint += $value;
|
$totalPoint += $value;
|
||||||
@@ -373,6 +380,10 @@ class InheritancePointManager
|
|||||||
$userLogger->flush();
|
$userLogger->flush();
|
||||||
|
|
||||||
$inheritStor->resetValues();
|
$inheritStor->resetValues();
|
||||||
|
|
||||||
|
foreach($keepValues as $rKey => $pointPair){
|
||||||
|
$inheritStor->setValue($rKey, $pointPair);
|
||||||
|
}
|
||||||
$inheritStor->setValue(InheritanceKey::previous->value, [$totalPoint, null]);
|
$inheritStor->setValue(InheritanceKey::previous->value, [$totalPoint, null]);
|
||||||
return $totalPoint;
|
return $totalPoint;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ class InheritancePointType{
|
|||||||
public bool|array $storeType,
|
public bool|array $storeType,
|
||||||
public int|float $pointCoeff,
|
public int|float $pointCoeff,
|
||||||
public string $info,
|
public string $info,
|
||||||
|
public ?float $rebirthStoreCoeff,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user