feat: 재선택 현재 능력치 기준 표시
This commit is contained in:
+22
-11
@@ -10,13 +10,22 @@ function sortTokens(&$tokens){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function putInfoText(&$info){
|
function putInfoText(&$info, ?array $currentTargetEnv){
|
||||||
if (($info['event100Growth'] ?? false) === true) {
|
if (($info['event100Growth'] ?? false) === true) {
|
||||||
$initialStats = CentennialAllStarGrowthService::calculateUserInitialStats($info);
|
if ($currentTargetEnv === null) {
|
||||||
$info['initialLeadership'] = $initialStats['leadership'];
|
$displayStats = CentennialAllStarGrowthService::calculateUserInitialStats($info);
|
||||||
$info['initialStrength'] = $initialStats['strength'];
|
$info['selectionStatLabel'] = '시작 능력치';
|
||||||
$info['initialIntel'] = $initialStats['intel'];
|
} 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)){
|
if(key_exists('specialDomestic', $info)){
|
||||||
$class = buildGeneralSpecialDomesticClass($info['specialDomestic']);
|
$class = buildGeneralSpecialDomesticClass($info['specialDomestic']);
|
||||||
@@ -41,7 +50,8 @@ $now = $oNow->format('Y-m-d H:i:s');
|
|||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
$npcmode = $gameStor->getValue('npcmode');
|
$eventEnv = $gameStor->getValues(['npcmode', 'startyear', 'year', 'month']);
|
||||||
|
$npcmode = $eventEnv['npcmode'];
|
||||||
if($npcmode!=2){
|
if($npcmode!=2){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'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){
|
if($rawGeneral){
|
||||||
$generalAux = Json::decode($rawGeneral['aux']);
|
$generalAux = Json::decode($rawGeneral['aux']);
|
||||||
if(key_exists('next_change', $generalAux)&& $generalAux['next_change'] > $now){
|
if(key_exists('next_change', $generalAux)&& $generalAux['next_change'] > $now){
|
||||||
@@ -69,7 +80,7 @@ if($tokens){
|
|||||||
foreach($tokens as $token){
|
foreach($tokens as $token){
|
||||||
$valid_until = $token['reserved_until'];
|
$valid_until = $token['reserved_until'];
|
||||||
$info = Json::decode($token['info']);
|
$info = Json::decode($token['info']);
|
||||||
putInfoText($info);
|
putInfoText($info, $currentTargetEnv);
|
||||||
$info['uniqueName'] = $token['unique_name'];
|
$info['uniqueName'] = $token['unique_name'];
|
||||||
$pick[] = $info;
|
$pick[] = $info;
|
||||||
}
|
}
|
||||||
@@ -90,7 +101,7 @@ $valid_until = null;
|
|||||||
foreach(pickGeneralFromPool($db, $rng, $userID, 14) as $pickObj){
|
foreach(pickGeneralFromPool($db, $rng, $userID, 14) as $pickObj){
|
||||||
$valid_until = $pickObj->getValidUntil();
|
$valid_until = $pickObj->getValidUntil();
|
||||||
$info = $pickObj->getInfo();
|
$info = $pickObj->getInfo();
|
||||||
putInfoText($info);
|
putInfoText($info, $currentTargetEnv);
|
||||||
$pick[] = $info;
|
$pick[] = $info;
|
||||||
}
|
}
|
||||||
sortTokens($pick);//좀 무식하지만..
|
sortTokens($pick);//좀 무식하지만..
|
||||||
|
|||||||
@@ -105,6 +105,41 @@ final class CentennialAllStarGrowthService
|
|||||||
return $result;
|
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(
|
public static function prepareInitialUser(
|
||||||
GeneralBuilder $builder,
|
GeneralBuilder $builder,
|
||||||
array $targetInfo
|
array $targetInfo
|
||||||
@@ -224,6 +259,9 @@ final class CentennialAllStarGrowthService
|
|||||||
$nextUserInitialStats = $targetChanged && $isUserTarget
|
$nextUserInitialStats = $targetChanged && $isUserTarget
|
||||||
? self::calculateUserInitialStats($targetInfo)
|
? self::calculateUserInitialStats($targetInfo)
|
||||||
: ($aux['userInitialStats'] ?? null);
|
: ($aux['userInitialStats'] ?? null);
|
||||||
|
$userCurrentTargetStats = $isUserTarget
|
||||||
|
? self::calculateUserCurrentTargetStats($targetInfo, $env)
|
||||||
|
: null;
|
||||||
$changed = false;
|
$changed = false;
|
||||||
|
|
||||||
foreach (self::STAT_KEYS as $key) {
|
foreach (self::STAT_KEYS as $key) {
|
||||||
@@ -236,8 +274,8 @@ final class CentennialAllStarGrowthService
|
|||||||
GameConst::$defaultStatMin,
|
GameConst::$defaultStatMin,
|
||||||
$progress
|
$progress
|
||||||
);
|
);
|
||||||
if ($nextUserInitialStats !== null) {
|
if ($userCurrentTargetStats !== null) {
|
||||||
$floor = max($floor, (int) ($nextUserInitialStats[$key] ?? 0));
|
$floor = $userCurrentTargetStats[$key];
|
||||||
}
|
}
|
||||||
$current = (int) $general->getVar($key);
|
$current = (int) $general->getVar($key);
|
||||||
if ($targetChanged) {
|
if ($targetChanged) {
|
||||||
|
|||||||
@@ -32,9 +32,10 @@ type CardItem = {
|
|||||||
leadership?: number,
|
leadership?: number,
|
||||||
strength?: number,
|
strength?: number,
|
||||||
intel?: number,
|
intel?: number,
|
||||||
initialLeadership?: number,
|
selectionStatLabel?: string,
|
||||||
initialStrength?: number,
|
selectionLeadership?: number,
|
||||||
initialIntel?: number,
|
selectionStrength?: number,
|
||||||
|
selectionIntel?: number,
|
||||||
dex?: number[],
|
dex?: number[],
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,9 +59,9 @@ const templateGeneralCard = '<div class="general_card">\
|
|||||||
<%if(leadership){%>\
|
<%if(leadership){%>\
|
||||||
<%leadership%> / <%strength%> / <%intel%><br>\
|
<%leadership%> / <%strength%> / <%intel%><br>\
|
||||||
<%}%>\
|
<%}%>\
|
||||||
<%if(initialLeadership){%>\
|
<%if(selectionStatLabel){%>\
|
||||||
<b>시작 능력치</b><br>\
|
<b><%selectionStatLabel%></b><br>\
|
||||||
<%initialLeadership%> / <%initialStrength%> / <%initialIntel%><br>\
|
<%selectionLeadership%> / <%selectionStrength%> / <%selectionIntel%><br>\
|
||||||
<%}%>\
|
<%}%>\
|
||||||
<%if(personalText){%><%personalText%><br><%}%>\
|
<%if(personalText){%><%personalText%><br><%}%>\
|
||||||
<%if(specialDomesticText||specialWarText){%>\
|
<%if(specialDomesticText||specialWarText){%>\
|
||||||
@@ -215,9 +216,10 @@ function printGenerals(value: GeneralPoolResponse) {
|
|||||||
'leadership': null,
|
'leadership': null,
|
||||||
'strength': null,
|
'strength': null,
|
||||||
'intel': null,
|
'intel': null,
|
||||||
'initialLeadership': null,
|
'selectionStatLabel': null,
|
||||||
'initialStrength': null,
|
'selectionLeadership': null,
|
||||||
'initialIntel': null,
|
'selectionStrength': null,
|
||||||
|
'selectionIntel': null,
|
||||||
'personalText': null,
|
'personalText': null,
|
||||||
'specialDomesticText': null,
|
'specialDomesticText': null,
|
||||||
'specialWarText': null,
|
'specialWarText': null,
|
||||||
|
|||||||
@@ -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
|
public function testInitialUserGrantMakesInitialAllocationReplaceable(): void
|
||||||
{
|
{
|
||||||
$initial = CentennialAllStarGrowthService::calculateUserInitialStats([
|
$initial = CentennialAllStarGrowthService::calculateUserInitialStats([
|
||||||
|
|||||||
Reference in New Issue
Block a user