feat: 재선택 현재 능력치 기준 표시

This commit is contained in:
2026-07-28 16:56:02 +00:00
parent 883080e275
commit 8b2748d3d4
4 changed files with 107 additions and 22 deletions
+22 -11
View File
@@ -10,13 +10,22 @@ function sortTokens(&$tokens){
});
}
function putInfoText(&$info){
if (($info['event100Growth'] ?? false) === true) {
$initialStats = CentennialAllStarGrowthService::calculateUserInitialStats($info);
$info['initialLeadership'] = $initialStats['leadership'];
$info['initialStrength'] = $initialStats['strength'];
$info['initialIntel'] = $initialStats['intel'];
}
function putInfoText(&$info, ?array $currentTargetEnv){
if (($info['event100Growth'] ?? false) === true) {
if ($currentTargetEnv === null) {
$displayStats = CentennialAllStarGrowthService::calculateUserInitialStats($info);
$info['selectionStatLabel'] = '시작 능력치';
} else {
$displayStats = CentennialAllStarGrowthService::calculateUserCurrentTargetStats(
$info,
$currentTargetEnv
);
$info['selectionStatLabel'] = '현재 변경 기준 능력치';
}
$info['selectionLeadership'] = $displayStats['leadership'];
$info['selectionStrength'] = $displayStats['strength'];
$info['selectionIntel'] = $displayStats['intel'];
}
if(key_exists('specialDomestic', $info)){
$class = buildGeneralSpecialDomesticClass($info['specialDomestic']);
@@ -41,7 +50,8 @@ $now = $oNow->format('Y-m-d H:i:s');
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$npcmode = $gameStor->getValue('npcmode');
$eventEnv = $gameStor->getValues(['npcmode', 'startyear', 'year', 'month']);
$npcmode = $eventEnv['npcmode'];
if($npcmode!=2){
Json::die([
'result'=>false,
@@ -49,7 +59,8 @@ if($npcmode!=2){
]);
}
$rawGeneral = $db->queryFirstRow('SELECT no, aux FROM general WHERE `owner` = %i', $userID);
$rawGeneral = $db->queryFirstRow('SELECT no, aux FROM general WHERE `owner` = %i', $userID);
$currentTargetEnv = $rawGeneral ? $eventEnv : null;
if($rawGeneral){
$generalAux = Json::decode($rawGeneral['aux']);
if(key_exists('next_change', $generalAux)&& $generalAux['next_change'] > $now){
@@ -69,7 +80,7 @@ if($tokens){
foreach($tokens as $token){
$valid_until = $token['reserved_until'];
$info = Json::decode($token['info']);
putInfoText($info);
putInfoText($info, $currentTargetEnv);
$info['uniqueName'] = $token['unique_name'];
$pick[] = $info;
}
@@ -90,7 +101,7 @@ $valid_until = null;
foreach(pickGeneralFromPool($db, $rng, $userID, 14) as $pickObj){
$valid_until = $pickObj->getValidUntil();
$info = $pickObj->getInfo();
putInfoText($info);
putInfoText($info, $currentTargetEnv);
$pick[] = $info;
}
sortTokens($pick);//좀 무식하지만..
+40 -2
View File
@@ -105,6 +105,41 @@ final class CentennialAllStarGrowthService
return $result;
}
/**
* Returns the event stat baseline that a newly selected target receives at
* the supplied game date. Organic growth can still leave the actual stat
* above this baseline.
*
* @return array{leadership:int,strength:int,intel:int}
*/
public static function calculateUserCurrentTargetStats(
array $targetInfo,
array $env
): array {
$initialStats = self::calculateUserInitialStats($targetInfo);
$progress = self::calculateProgress(
(int) $env['startyear'],
(int) $env['year'],
(int) $env['month']
);
$result = [];
foreach (self::STAT_KEYS as $key) {
$target = min(
GameConst::$maxLevel,
max(0, (int) ($targetInfo[$key] ?? 0))
);
$result[$key] = max(
$initialStats[$key],
CentennialAllStarGrowth::statFloor(
$target,
GameConst::$defaultStatMin,
$progress
)
);
}
return $result;
}
public static function prepareInitialUser(
GeneralBuilder $builder,
array $targetInfo
@@ -224,6 +259,9 @@ final class CentennialAllStarGrowthService
$nextUserInitialStats = $targetChanged && $isUserTarget
? self::calculateUserInitialStats($targetInfo)
: ($aux['userInitialStats'] ?? null);
$userCurrentTargetStats = $isUserTarget
? self::calculateUserCurrentTargetStats($targetInfo, $env)
: null;
$changed = false;
foreach (self::STAT_KEYS as $key) {
@@ -236,8 +274,8 @@ final class CentennialAllStarGrowthService
GameConst::$defaultStatMin,
$progress
);
if ($nextUserInitialStats !== null) {
$floor = max($floor, (int) ($nextUserInitialStats[$key] ?? 0));
if ($userCurrentTargetStats !== null) {
$floor = $userCurrentTargetStats[$key];
}
$current = (int) $general->getVar($key);
if ($targetChanged) {
+11 -9
View File
@@ -32,9 +32,10 @@ type CardItem = {
leadership?: number,
strength?: number,
intel?: number,
initialLeadership?: number,
initialStrength?: number,
initialIntel?: number,
selectionStatLabel?: string,
selectionLeadership?: number,
selectionStrength?: number,
selectionIntel?: number,
dex?: number[],
}
@@ -58,9 +59,9 @@ const templateGeneralCard = '<div class="general_card">\
<%if(leadership){%>\
<%leadership%> / <%strength%> / <%intel%><br>\
<%}%>\
<%if(initialLeadership){%>\
<b>시작 능력치</b><br>\
<%initialLeadership%> / <%initialStrength%> / <%initialIntel%><br>\
<%if(selectionStatLabel){%>\
<b><%selectionStatLabel%></b><br>\
<%selectionLeadership%> / <%selectionStrength%> / <%selectionIntel%><br>\
<%}%>\
<%if(personalText){%><%personalText%><br><%}%>\
<%if(specialDomesticText||specialWarText){%>\
@@ -215,9 +216,10 @@ function printGenerals(value: GeneralPoolResponse) {
'leadership': null,
'strength': null,
'intel': null,
'initialLeadership': null,
'initialStrength': null,
'initialIntel': null,
'selectionStatLabel': null,
'selectionLeadership': null,
'selectionStrength': null,
'selectionIntel': null,
'personalText': null,
'specialDomesticText': null,
'specialWarText': null,
+34
View File
@@ -100,6 +100,40 @@ final class CentennialAllStarGrowthTest extends TestCase
]));
}
public function testCurrentReselectionBaselineUsesCurrentYearProgress(): void
{
$target = [
'leadership' => 100,
'strength' => 15,
'intel' => 100,
];
self::assertSame([
'leadership' => 75,
'strength' => 15,
'intel' => 75,
], CentennialAllStarGrowthService::calculateUserCurrentTargetStats(
$target,
['startyear' => 180, 'year' => 180, 'month' => 1]
));
self::assertSame([
'leadership' => 83,
'strength' => 15,
'intel' => 83,
], CentennialAllStarGrowthService::calculateUserCurrentTargetStats(
$target,
['startyear' => 180, 'year' => 192, 'month' => 1]
));
self::assertSame([
'leadership' => 100,
'strength' => 15,
'intel' => 100,
], CentennialAllStarGrowthService::calculateUserCurrentTargetStats(
$target,
['startyear' => 180, 'year' => 195, 'month' => 1]
));
}
public function testInitialUserGrantMakesInitialAllocationReplaceable(): void
{
$initial = CentennialAllStarGrowthService::calculateUserInitialStats([