feat: 유산 포인트 획득, 소모 정도를 동적으로 명장 일람 항목으로 기록
- 1월, 7월 - 베팅, 베팅 당첨을 소모/획득으로 분리 - 일단 유산 포인트 획득은 별도 분리
This commit is contained in:
@@ -387,6 +387,9 @@ class Join extends \sammo\BaseAPI
|
||||
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$userID}");
|
||||
$inheritStor->setValue('previous', [$inheritTotalPoint - $inheritRequiredPoint, null]);
|
||||
$userLogger->flush();
|
||||
$db->update('rank_data', [
|
||||
'value'=>$db->sqleval('value + %i', $inheritRequiredPoint)
|
||||
], 'general_id = %i AND type = %s', $generalID, RankColumn::inherit_point_spent_dynamic->value);
|
||||
}
|
||||
|
||||
$me = [
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace sammo\API\InheritAction;
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\Enums\RankColumn;
|
||||
use sammo\GameConst;
|
||||
use sammo\General;
|
||||
use sammo\KVStorage;
|
||||
@@ -80,6 +81,7 @@ class BuyHiddenBuff extends \sammo\BaseAPI
|
||||
$inheritBuffList[$type] = $level;
|
||||
$general->setAuxVar('inheritBuff', $inheritBuffList);
|
||||
$inheritStor->setValue('previous', [$previousPoint - $reqAmount, null]);
|
||||
$general->increaseRankVar(RankColumn::inherit_point_spent_dynamic, $reqAmount);
|
||||
$general->applyDB($db);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace sammo\API\InheritAction;
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\Enums\RankColumn;
|
||||
use sammo\GameConst;
|
||||
use sammo\General;
|
||||
use sammo\KVStorage;
|
||||
@@ -52,6 +53,7 @@ class BuyRandomUnique extends \sammo\BaseAPI
|
||||
|
||||
$general->setAuxVar('inheritRandomUnique', TimeUtil::now());
|
||||
$inheritStor->setValue('previous', [$previousPoint - $reqAmount, null]);
|
||||
$general->increaseRankVar(RankColumn::inherit_point_spent_dynamic, $reqAmount);
|
||||
$general->applyDB($db);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace sammo\API\InheritAction;
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\Enums\RankColumn;
|
||||
use sammo\GameConst;
|
||||
use sammo\General;
|
||||
use sammo\KVStorage;
|
||||
@@ -82,6 +83,7 @@ class BuySpecificUnique extends \sammo\BaseAPI
|
||||
$itemTrials[$itemKey] = $amount;
|
||||
$general->setAuxVar('inheritUniqueTrial', $itemTrials);
|
||||
$inheritStor->setValue('previous', [$previousPoint - $amount, null]);
|
||||
$general->increaseRankVar(RankColumn::inherit_point_spent_dynamic, $amount);
|
||||
$trialStor->setValue("u{$userID}", [$userID, $generalID, $amount]);
|
||||
$general->applyDB($db);
|
||||
return null;
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace sammo\API\InheritAction;
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\Enums\RankColumn;
|
||||
use sammo\GameConst;
|
||||
use sammo\General;
|
||||
use sammo\KVStorage;
|
||||
@@ -68,6 +69,7 @@ class ResetSpecialWar extends \sammo\BaseAPI
|
||||
$general->setAuxVar('inheritResetSpecialWar', $nextLevel);
|
||||
$general->setVar('special2', 'None');
|
||||
$inheritStor->setValue('previous', [$previousPoint - $reqPoint, null]);
|
||||
$general->increaseRankVar(RankColumn::inherit_point_spent_dynamic, $reqPoint);
|
||||
$general->applyDB($db);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use DateTimeImmutable;
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\Enums\RankColumn;
|
||||
use sammo\GameConst;
|
||||
use sammo\General;
|
||||
use sammo\KVStorage;
|
||||
@@ -77,6 +78,7 @@ class ResetTurnTime extends \sammo\BaseAPI
|
||||
$general->setVar('turntime', TimeUtil::format($turnTime, true));
|
||||
$general->setAuxVar('inheritResetTurnTime', $nextLevel);
|
||||
$inheritStor->setValue('previous', [$previousPoint - $reqPoint, null]);
|
||||
$general->increaseRankVar(RankColumn::inherit_point_spent_dynamic, $reqPoint);
|
||||
$general->applyDB($db);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace sammo\API\InheritAction;
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\Enums\RankColumn;
|
||||
use sammo\GameConst;
|
||||
use sammo\General;
|
||||
use sammo\KVStorage;
|
||||
@@ -77,6 +78,7 @@ class SetNextSpecialWar extends \sammo\BaseAPI
|
||||
|
||||
$general->setAuxVar('inheritSpecificSpecialWar', $type);
|
||||
$inheritStor->setValue('previous', [$previousPoint - $reqAmount, null]);
|
||||
$general->increaseRankVar(RankColumn::inherit_point_spent_dynamic, $reqAmount);
|
||||
$general->applyDB($db);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -166,6 +166,9 @@ class Betting
|
||||
$userLogger = new UserLogger($userID);
|
||||
$userLogger->push("{$amount} 포인트를 베팅에 사용", "inheritPoint");
|
||||
$userLogger->flush();
|
||||
$db->update('rank_data', [
|
||||
'value'=>$db->sqleval('value + %i', $amount)
|
||||
], 'general_id = %i AND type = %s', $generalID, RankColumn::inherit_point_spent_dynamic->value);
|
||||
} else {
|
||||
$db->update('general', [
|
||||
'gold' => $db->sqleval('gold - %i', $amount)
|
||||
@@ -363,6 +366,11 @@ class Betting
|
||||
$inheritStor->setValue('previous', [$nextPoint, 0]);
|
||||
$inheritStor->invalidateCacheValue('previous'); //XXX: 실제로는 previous 값을 사용할 수 없도록 락을 걸어야 한다.
|
||||
|
||||
$generalID = $rewardItem['generalID'];
|
||||
$db->update('rank_data', [
|
||||
'value'=>$db->sqleval('value + %i', $amount)
|
||||
], 'general_id = %i AND type = %s', $generalID, RankColumn::inherit_point_earned_by_action->value);
|
||||
|
||||
$amountText = number_format($amount);
|
||||
$previousPointText = number_format($previousPoint);
|
||||
$nextPointText = number_format($nextPoint);
|
||||
|
||||
@@ -78,14 +78,14 @@ enum RankColumn: string
|
||||
case occupied = 'occupied';
|
||||
|
||||
/** 유산 포인트 획득(지연) */
|
||||
case inherit_point_earned = 'inherit_point_earned';
|
||||
case inherit_point_earned = 'inherit_earned';
|
||||
/** 유산 포인트 소모(지연) */
|
||||
case inherit_point_spent = 'inherit_point_spent';
|
||||
case inherit_point_spent = 'inherit_spent';
|
||||
|
||||
/** 유산 포인트 획득량(merge 명령) */
|
||||
case inherit_point_earned_by_merge = 'inherit_point_earned_dynamic';
|
||||
case inherit_point_earned_by_merge = 'inherit_earned_dyn';
|
||||
/** 유산 포인트 획득량(베팅 등 별도 명령) */
|
||||
case inherit_point_earned_by_action = 'inherit_point_earned_by_action';
|
||||
case inherit_point_earned_by_action = 'inherit_earned_act';
|
||||
/** 유산 포인트 소모량(증감 있음) */
|
||||
case inherit_point_spent_dynamic = 'inherit_point_spent_dynamic';
|
||||
case inherit_point_spent_dynamic = 'inherit_spent_dyn';
|
||||
}
|
||||
|
||||
@@ -636,6 +636,7 @@ class General implements iAction
|
||||
|
||||
if ($refundPoint > 0) {
|
||||
$this->increaseInheritancePoint(InheritanceKey::previous, $refundPoint);
|
||||
$this->increaseRankVar(RankColumn::inherit_point_spent_dynamic, -$refundPoint);
|
||||
}
|
||||
|
||||
$inheritPointManager = InheritancePointManager::getInstance();
|
||||
|
||||
@@ -49,6 +49,59 @@ class InheritancePointManager
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<General> $generals
|
||||
* @return Map<int, int|float>
|
||||
*/
|
||||
public function getInheritancePointFromAll(array $generals, InheritanceKey $key, ?array &$aux = null, bool $forceCalc = false): Map
|
||||
{
|
||||
$inheritType = $this->getInheritancePointType($key);
|
||||
|
||||
$storeType = $inheritType->storeType;
|
||||
$multiplier = $inheritType->pointCoeff;
|
||||
|
||||
$result = new Map();
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
if ($storeType === true || ($gameStor->isunited != 0 && !$forceCalc)) {
|
||||
$ownerMap = [];
|
||||
foreach ($generals as $general) {
|
||||
$ownerMap[$general->getVar('owner')] = $general->getID();
|
||||
}
|
||||
|
||||
(array_map(fn (General $gen) => $gen->getID(), $generals));
|
||||
$ownerMap = Util::convertPairArrayToDict($db->queryAllLists('SELECT `owner`, `no` FROM `general`'));
|
||||
foreach (KVStorage::getValuesFromInterNamespace($db, "storage", $key) as $namespace => $value) {
|
||||
if (!str_starts_with($namespace, 'inheritance_')) {
|
||||
continue;
|
||||
}
|
||||
$userID = Util::toInt(substr($namespace, strlen('inheritance_')));
|
||||
if (!key_exists($userID, $ownerMap)) {
|
||||
continue;
|
||||
}
|
||||
[$value,] = $value;
|
||||
|
||||
$result[$ownerMap[$userID]] = $value;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$auxTmp = [];
|
||||
foreach ($generals as $general) {
|
||||
$generalID = $general->getID();
|
||||
$auxSub = null;
|
||||
$value = $this->getInheritancePoint($general, $key, $auxSub, $forceCalc);
|
||||
$auxTmp[$generalID] = $auxSub;
|
||||
$result[$generalID] = $value;
|
||||
}
|
||||
$aux = $auxTmp;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getInheritancePoint(General $general, InheritanceKey $key, &$aux = null, bool $forceCalc = false): int|float|null
|
||||
{
|
||||
$inheritType = $this->getInheritancePointType($key);
|
||||
|
||||
Reference in New Issue
Block a user