feat: extend S100 dex sync through year 205
This commit is contained in:
@@ -371,6 +371,209 @@ final class CentennialAllStarGrowthTest extends TestCase
|
||||
self::assertSame(900000, CentennialAllStarGrowth::dexFloor(900000, 1));
|
||||
}
|
||||
|
||||
public function testDexExtensionRunsFromYear200ThroughYear205(): void
|
||||
{
|
||||
$env = static fn(int $year, int $month): array => [
|
||||
'startyear' => 180,
|
||||
'year' => $year,
|
||||
'month' => $month,
|
||||
];
|
||||
|
||||
self::assertSame(0.0, CentennialAllStarGrowthService::calculateDexExtensionProgress($env(199, 12)));
|
||||
self::assertSame(0.0, CentennialAllStarGrowthService::calculateDexExtensionProgress($env(200, 1)));
|
||||
self::assertEqualsWithDelta(
|
||||
0.2,
|
||||
CentennialAllStarGrowthService::calculateDexExtensionProgress($env(201, 1)),
|
||||
0.000001
|
||||
);
|
||||
self::assertEqualsWithDelta(
|
||||
0.5,
|
||||
CentennialAllStarGrowthService::calculateDexExtensionProgress($env(202, 7)),
|
||||
0.000001
|
||||
);
|
||||
self::assertSame(1.0, CentennialAllStarGrowthService::calculateDexExtensionProgress($env(205, 1)));
|
||||
self::assertSame(1.0, CentennialAllStarGrowthService::calculateDexExtensionProgress($env(210, 1)));
|
||||
}
|
||||
|
||||
public function testDexExtensionOnlyAddsHistoricalTargetAboveOneMillion(): void
|
||||
{
|
||||
$env = static fn(int $year, int $month): array => [
|
||||
'startyear' => 180,
|
||||
'year' => $year,
|
||||
'month' => $month,
|
||||
];
|
||||
|
||||
self::assertSame(
|
||||
900000,
|
||||
CentennialAllStarGrowthService::calculateDexTargetFloor(900000, $env(205, 1))
|
||||
);
|
||||
self::assertSame(
|
||||
1000000,
|
||||
CentennialAllStarGrowthService::calculateDexTargetFloor(2000000, $env(199, 12))
|
||||
);
|
||||
self::assertSame(
|
||||
1000000,
|
||||
CentennialAllStarGrowthService::calculateDexTargetFloor(2000000, $env(200, 1))
|
||||
);
|
||||
self::assertSame(
|
||||
1200000,
|
||||
CentennialAllStarGrowthService::calculateDexTargetFloor(2000000, $env(201, 1))
|
||||
);
|
||||
self::assertSame(
|
||||
1500000,
|
||||
CentennialAllStarGrowthService::calculateDexTargetFloor(2000000, $env(202, 7))
|
||||
);
|
||||
self::assertSame(
|
||||
2000000,
|
||||
CentennialAllStarGrowthService::calculateDexTargetFloor(2000000, $env(205, 1))
|
||||
);
|
||||
}
|
||||
|
||||
public function testEveryCandidateDexTargetExtendsMonotonicallyToItsHistoricalValue(): void
|
||||
{
|
||||
$pool = json_decode(
|
||||
file_get_contents(__DIR__ . '/../hwe/sammo/GeneralPool/Pool/UnderS100.json'),
|
||||
true,
|
||||
512,
|
||||
JSON_THROW_ON_ERROR
|
||||
);
|
||||
$columns = array_flip($pool['columns']);
|
||||
$dates = [
|
||||
['startyear' => 180, 'year' => 199, 'month' => 7],
|
||||
['startyear' => 180, 'year' => 200, 'month' => 1],
|
||||
['startyear' => 180, 'year' => 201, 'month' => 1],
|
||||
['startyear' => 180, 'year' => 202, 'month' => 7],
|
||||
['startyear' => 180, 'year' => 205, 'month' => 1],
|
||||
];
|
||||
$extendedCandidateCount = 0;
|
||||
$maximumTarget = 0;
|
||||
|
||||
foreach ($pool['data'] as $row) {
|
||||
$hasExtendedTarget = false;
|
||||
foreach ($row[$columns['dex']] as $target) {
|
||||
$target = (int) $target;
|
||||
$maximumTarget = max($maximumTarget, $target);
|
||||
$hasExtendedTarget = $hasExtendedTarget || $target > GameConst::$dexLimit;
|
||||
$floors = array_map(
|
||||
static fn(array $env): int => CentennialAllStarGrowthService::calculateDexTargetFloor(
|
||||
$target,
|
||||
$env
|
||||
),
|
||||
$dates
|
||||
);
|
||||
self::assertSame(
|
||||
min(GameConst::$dexLimit, $target),
|
||||
$floors[0],
|
||||
$row[$columns['generalName']]
|
||||
);
|
||||
self::assertSame($floors[0], $floors[1], $row[$columns['generalName']]);
|
||||
$sortedFloors = $floors;
|
||||
sort($sortedFloors, SORT_NUMERIC);
|
||||
self::assertSame($sortedFloors, $floors, $row[$columns['generalName']]);
|
||||
self::assertSame($target, $floors[4], $row[$columns['generalName']]);
|
||||
}
|
||||
if ($hasExtendedTarget) {
|
||||
$extendedCandidateCount++;
|
||||
}
|
||||
}
|
||||
|
||||
self::assertSame(208, $extendedCandidateCount);
|
||||
self::assertSame(2990401, $maximumTarget);
|
||||
}
|
||||
|
||||
public function testNpcReceivesFortyPercentOfExtendedHistoricalDexTarget(): void
|
||||
{
|
||||
$ratio = GameConst::$centennialNpcDexTargetRatio;
|
||||
|
||||
self::assertSame(
|
||||
400000,
|
||||
CentennialAllStarGrowthService::calculateDexTargetFloor(
|
||||
2000000,
|
||||
['startyear' => 180, 'year' => 200, 'month' => 1],
|
||||
$ratio
|
||||
)
|
||||
);
|
||||
self::assertSame(
|
||||
480000,
|
||||
CentennialAllStarGrowthService::calculateDexTargetFloor(
|
||||
2000000,
|
||||
['startyear' => 180, 'year' => 201, 'month' => 1],
|
||||
$ratio
|
||||
)
|
||||
);
|
||||
self::assertSame(
|
||||
800000,
|
||||
CentennialAllStarGrowthService::calculateDexTargetFloor(
|
||||
2000000,
|
||||
['startyear' => 180, 'year' => 205, 'month' => 1],
|
||||
$ratio
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testDexExtensionNeverLowersNaturalGrowthAndKeepsItRecordable(): void
|
||||
{
|
||||
$target = $this->singleDexTarget('extended', 0, 2000000);
|
||||
$vars = $this->emptyGeneralVars();
|
||||
$aux = CentennialAllStarGrowthService::initialAux($target, []);
|
||||
$general = $this->createStateGeneralMock($vars, $aux);
|
||||
|
||||
CentennialAllStarGrowthService::applyTarget(
|
||||
$general,
|
||||
$target,
|
||||
['startyear' => 180, 'year' => 199, 'month' => 7]
|
||||
);
|
||||
self::assertSame(1000000, $vars['dex1']);
|
||||
self::assertSame(1000000, $aux['granted']['dex1']);
|
||||
|
||||
$vars['dex1'] += 300000;
|
||||
$result = CentennialAllStarGrowthService::applyTarget(
|
||||
$general,
|
||||
$target,
|
||||
['startyear' => 180, 'year' => 201, 'month' => 1]
|
||||
);
|
||||
self::assertSame(1300000, $vars['dex1']);
|
||||
self::assertSame(1000000, $aux['granted']['dex1']);
|
||||
self::assertSame(300000, CentennialAllStarGrowthService::recordableValue($general, 'dex1'));
|
||||
self::assertSame(1, $result['dexExtensionMilestone']);
|
||||
self::assertSame(0, $result['previousDexExtensionMilestone']);
|
||||
|
||||
$result = CentennialAllStarGrowthService::applyTarget(
|
||||
$general,
|
||||
$target,
|
||||
['startyear' => 180, 'year' => 205, 'month' => 1]
|
||||
);
|
||||
self::assertSame(2000000, $vars['dex1']);
|
||||
self::assertSame(1700000, $aux['granted']['dex1']);
|
||||
self::assertSame(300000, CentennialAllStarGrowthService::recordableValue($general, 'dex1'));
|
||||
self::assertSame(5, $result['dexExtensionMilestone']);
|
||||
self::assertSame(1, $result['previousDexExtensionMilestone']);
|
||||
}
|
||||
|
||||
public function testDexExtensionDoesNotRefillConsumedConversionBudget(): void
|
||||
{
|
||||
$target = $this->singleDexTarget('extended-consumed', 0, 2000000);
|
||||
$vars = $this->emptyGeneralVars();
|
||||
$vars['dex1'] = 800000;
|
||||
$aux = CentennialAllStarGrowthService::initialAux($target, []);
|
||||
$aux['granted']['dex1'] = 800000;
|
||||
$aux['dexConsumed']['dex1'] = 200000;
|
||||
$aux['dexFloor']['dex1'] = 800000;
|
||||
$general = $this->createStateGeneralMock($vars, $aux);
|
||||
|
||||
CentennialAllStarGrowthService::applyTarget(
|
||||
$general,
|
||||
$target,
|
||||
['startyear' => 180, 'year' => 205, 'month' => 1]
|
||||
);
|
||||
|
||||
self::assertSame(1800000, $vars['dex1']);
|
||||
self::assertSame(1800000, $aux['granted']['dex1']);
|
||||
self::assertSame(200000, $aux['dexConsumed']['dex1']);
|
||||
self::assertSame(1800000, $aux['dexFloor']['dex1']);
|
||||
self::assertSame(0, CentennialAllStarGrowthService::recordableValue($general, 'dex1'));
|
||||
}
|
||||
|
||||
public function testNpcDexStopsAtFortyPercentOfHistoricalTarget(): void
|
||||
{
|
||||
$target = 900000;
|
||||
@@ -945,10 +1148,10 @@ final class CentennialAllStarGrowthTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
private function singleDexTarget(string $id, int $dexIndex): array
|
||||
private function singleDexTarget(string $id, int $dexIndex, int $amount = 900000): array
|
||||
{
|
||||
$dex = [0, 0, 0, 0, 0];
|
||||
$dex[$dexIndex] = 900000;
|
||||
$dex[$dexIndex] = $amount;
|
||||
return [
|
||||
'uniqueName' => $id,
|
||||
'leadership' => 100,
|
||||
|
||||
Reference in New Issue
Block a user