feat: extend S100 dex sync through year 205
This commit is contained in:
@@ -10,6 +10,8 @@ final class CentennialAllStarGrowthService
|
||||
public const AUX_KEY = 'event100_allstar';
|
||||
public const TRAIT_UNLOCK_PROGRESS = 0.4;
|
||||
public const NPC_PROGRESS_MULTIPLIER = 0.9;
|
||||
public const DEX_EXTENSION_START_YEAR_OFFSET = 20;
|
||||
public const DEX_EXTENSION_YEARS = 5;
|
||||
|
||||
private const STAT_KEYS = ['leadership', 'strength', 'intel'];
|
||||
private const DEX_KEYS = ['dex1', 'dex2', 'dex3', 'dex4', 'dex5'];
|
||||
@@ -41,6 +43,7 @@ final class CentennialAllStarGrowthService
|
||||
'dexFloor' => array_fill_keys(self::DEX_KEYS, 0),
|
||||
'progressMonth' => -1,
|
||||
'milestone' => 0,
|
||||
'dexExtensionMilestone' => 0,
|
||||
'naturalSpecialDomestic' => null,
|
||||
'eventSpecialDomestic' => null,
|
||||
'userInitialStats' => $userInitialStats,
|
||||
@@ -236,7 +239,7 @@ final class CentennialAllStarGrowthService
|
||||
if ($targetRatio < 0 || $targetRatio > 1) {
|
||||
throw new \InvalidArgumentException('dex target ratio must be between 0 and 1');
|
||||
}
|
||||
$target = min(GameConst::$dexLimit, max(0, $target));
|
||||
$target = self::calculateDexExtendedTarget($target, $env);
|
||||
$scaledTarget = (int) floor($target * $targetRatio);
|
||||
$progress = self::calculateProgress(
|
||||
(int) $env['startyear'],
|
||||
@@ -246,10 +249,34 @@ final class CentennialAllStarGrowthService
|
||||
return CentennialAllStarGrowth::dexFloor($scaledTarget, $progress);
|
||||
}
|
||||
|
||||
public static function calculateDexExtensionProgress(array $env): float
|
||||
{
|
||||
return CentennialAllStarGrowth::progress(
|
||||
(int) $env['startyear'] + self::DEX_EXTENSION_START_YEAR_OFFSET,
|
||||
(int) $env['year'],
|
||||
(int) $env['month'],
|
||||
self::DEX_EXTENSION_YEARS
|
||||
);
|
||||
}
|
||||
|
||||
public static function calculateDexExtendedTarget(int $target, array $env): int
|
||||
{
|
||||
$target = max(0, $target);
|
||||
$baseTarget = min(GameConst::$dexLimit, $target);
|
||||
$extensionTarget = max(0, $target - $baseTarget);
|
||||
if ($extensionTarget === 0) {
|
||||
return $baseTarget;
|
||||
}
|
||||
|
||||
return $baseTarget + (int) floor(
|
||||
$extensionTarget * self::calculateDexExtensionProgress($env)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutates the General object but leaves persistence to the caller.
|
||||
*
|
||||
* @return array{progress:float,milestone:int,previousMilestone:int,targetChanged:bool,changed:bool}
|
||||
* @return array{progress:float,milestone:int,previousMilestone:int,dexExtensionMilestone:int,previousDexExtensionMilestone:int,hasDexExtensionTarget:bool,targetChanged:bool,changed:bool}
|
||||
*/
|
||||
public static function applyTarget(
|
||||
General $general,
|
||||
@@ -339,10 +366,14 @@ final class CentennialAllStarGrowthService
|
||||
}
|
||||
|
||||
$targetDex = $targetInfo['dex'] ?? [];
|
||||
$hasDexExtensionTarget = false;
|
||||
foreach (self::DEX_KEYS as $idx => $key) {
|
||||
if (!array_key_exists($idx, $targetDex)) {
|
||||
continue;
|
||||
}
|
||||
if ((int) $targetDex[$idx] > GameConst::$dexLimit) {
|
||||
$hasDexExtensionTarget = true;
|
||||
}
|
||||
$floor = max(
|
||||
0,
|
||||
self::calculateDexTargetFloor(
|
||||
@@ -399,12 +430,21 @@ final class CentennialAllStarGrowthService
|
||||
|
||||
$previousMilestone = (int) ($aux['milestone'] ?? 0);
|
||||
$milestone = min(5, (int) floor($progress * 5 + 0.0000001));
|
||||
$previousDexExtensionMilestone = (int) ($aux['dexExtensionMilestone'] ?? 0);
|
||||
$dexExtensionProgress = self::calculateDexExtensionProgress($env);
|
||||
$dexExtensionMilestone = $hasDexExtensionTarget
|
||||
? min(5, (int) floor($dexExtensionProgress * 5 + 0.0000001))
|
||||
: 0;
|
||||
$aux['targetId'] = $targetId;
|
||||
$aux['granted'] = $granted;
|
||||
$aux['dexConsumed'] = $dexConsumed;
|
||||
$aux['dexFloor'] = $dexFloor;
|
||||
$aux['progressMonth'] = max((int) ($aux['progressMonth'] ?? -1), $progressMonth);
|
||||
$aux['milestone'] = max($previousMilestone, $milestone);
|
||||
$aux['dexExtensionMilestone'] = max(
|
||||
$previousDexExtensionMilestone,
|
||||
$dexExtensionMilestone
|
||||
);
|
||||
$aux['userInitialStats'] = $nextUserInitialStats;
|
||||
$aux['dexTargetRatio'] = $dexTargetRatio;
|
||||
$general->setAuxVar(self::AUX_KEY, $aux);
|
||||
@@ -413,8 +453,14 @@ final class CentennialAllStarGrowthService
|
||||
'progress' => $progress,
|
||||
'milestone' => $milestone,
|
||||
'previousMilestone' => $previousMilestone,
|
||||
'dexExtensionMilestone' => $dexExtensionMilestone,
|
||||
'previousDexExtensionMilestone' => $previousDexExtensionMilestone,
|
||||
'hasDexExtensionTarget' => $hasDexExtensionTarget,
|
||||
'targetChanged' => $targetChanged,
|
||||
'changed' => $changed || $targetChanged || $milestone > $previousMilestone,
|
||||
'changed' => $changed
|
||||
|| $targetChanged
|
||||
|| $milestone > $previousMilestone
|
||||
|| $dexExtensionMilestone > $previousDexExtensionMilestone,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,18 @@ class AdvanceCentennialAllStar extends \sammo\Event\Action
|
||||
"<L>올스타 동조율 {$percent}% 달성</>"
|
||||
);
|
||||
}
|
||||
if ($result['hasDexExtensionTarget']
|
||||
&& $result['dexExtensionMilestone'] > $result['previousDexExtensionMilestone']
|
||||
) {
|
||||
$percent = $result['dexExtensionMilestone'] * 20;
|
||||
$general->getLogger()->pushGeneralActionLog(
|
||||
"<L>추가 숙련 동조율</>이 <C>{$percent}%</>에 도달했습니다!",
|
||||
ActionLogger::PLAIN
|
||||
);
|
||||
$general->getLogger()->pushGeneralHistoryLog(
|
||||
"<L>추가 숙련 동조율 {$percent}% 달성</>"
|
||||
);
|
||||
}
|
||||
if ($general->applyDB($db)) {
|
||||
$updated++;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ declare const validCustomOption: string[];
|
||||
const templateGeneralCard = '<div class="general_card">\
|
||||
<h4 class="bg1 with_border"><%generalName%></h4>\
|
||||
<h4><img src="<%iconPath%>" height=64 width=64></h4><p>\
|
||||
<%if(event100Growth){%><b>195년 최종 동조 목표</b><br><%}%>\
|
||||
<%if(event100Growth){%><b>역사 장수 최종 목표</b><br>능력치·기본 숙련 195년 / 추가 숙련 205년 동조<br><%}%>\
|
||||
<%if(leadership){%>\
|
||||
<%leadership%> / <%strength%> / <%intel%><br>\
|
||||
<%}%>\
|
||||
|
||||
Reference in New Issue
Block a user