feat: 유산 포인트 획득, 소모 정도를 동적으로 명장 일람 항목으로 기록

- 1월, 7월
- 베팅, 베팅 당첨을 소모/획득으로 분리
- 일단 유산 포인트 획득은 별도 분리
This commit is contained in:
2022-05-10 03:26:34 +09:00
parent 16906e960e
commit b2e297bbb3
13 changed files with 122 additions and 8 deletions
+53
View File
@@ -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);