diff --git a/hwe/j_get_select_pool.php b/hwe/j_get_select_pool.php index 3d0d4a79..d5c9a07e 100644 --- a/hwe/j_get_select_pool.php +++ b/hwe/j_get_select_pool.php @@ -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);//좀 무식하지만.. diff --git a/hwe/sammo/CentennialAllStarGrowthService.php b/hwe/sammo/CentennialAllStarGrowthService.php index d2b1e47e..6f031ec3 100644 --- a/hwe/sammo/CentennialAllStarGrowthService.php +++ b/hwe/sammo/CentennialAllStarGrowthService.php @@ -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) { diff --git a/hwe/ts/select_general_from_pool.ts b/hwe/ts/select_general_from_pool.ts index f042ab98..03801c77 100644 --- a/hwe/ts/select_general_from_pool.ts +++ b/hwe/ts/select_general_from_pool.ts @@ -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 = '