Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8bf8ba922 | ||
|
|
95f66e4c39 |
@@ -243,11 +243,14 @@ $templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
||||
"SELECT nation,no,name,owner_name as ownerName, owner, picture, imgsvr,
|
||||
experience, dedication,
|
||||
dex1, dex2, dex3, dex4, dex5,
|
||||
horse, weapon, book, item
|
||||
horse, weapon, book, item, aux
|
||||
FROM general WHERE %l",
|
||||
$btn == "NPC 보기" ? "npc>=2" : "npc<2"
|
||||
) as $general) {
|
||||
$generalID = $general['no'];
|
||||
foreach (['dex1', 'dex2', 'dex3', 'dex4', 'dex5'] as $dexKey) {
|
||||
$general[$dexKey] = CentennialAllStarGrowthService::recordableRawValue($general, $dexKey);
|
||||
}
|
||||
$general['bgColor'] = $nationColor[$general['nation']] ?? GameConst::$basecolor4;
|
||||
$general['fgColor'] = newColor($general['bgColor']);
|
||||
$general['nationName'] = $nationName[$general['nation']];
|
||||
@@ -427,4 +430,4 @@ $templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
||||
+5
-2
@@ -1401,8 +1401,11 @@ function CheckHall($no)
|
||||
|
||||
foreach ($types as [$typeName, $valueType]) {
|
||||
|
||||
if ($valueType === 'natural') {
|
||||
$value = $generalObj->getVar($typeName);
|
||||
if ($valueType === 'natural') {
|
||||
$value = $generalObj->getVar($typeName);
|
||||
if (in_array($typeName, ['dex1', 'dex2', 'dex3', 'dex4', 'dex5'], true)) {
|
||||
$value = CentennialAllStarGrowthService::recordableValue($generalObj, $typeName);
|
||||
}
|
||||
} else if ($valueType === 'rank') {
|
||||
$value = $generalObj->getRankVar(RankColumn::from($typeName));
|
||||
} else if ($valueType === 'calc') {
|
||||
|
||||
@@ -6,10 +6,19 @@ include "func.php";
|
||||
|
||||
WebUtil::requireAJAX();
|
||||
|
||||
$pick = Util::getPost('pick');
|
||||
$leadership = Util::getPost('leadership', 'int', GameConst::$defaultStatMin);
|
||||
$strength = Util::getPost('leadership', 'int', GameConst::$defaultStatMin);
|
||||
$intel = Util::getPost('leadership', 'int', GameConst::$defaultStatMin);
|
||||
$pick = Util::getPost('pick');
|
||||
$leadership = Util::getPost('leadership', 'int', GameConst::$defaultStatMin);
|
||||
$isCentennialAllStar = CentennialAllStarGrowthService::isActive();
|
||||
$strength = Util::getPost(
|
||||
$isCentennialAllStar ? 'strength' : 'leadership',
|
||||
'int',
|
||||
GameConst::$defaultStatMin
|
||||
);
|
||||
$intel = Util::getPost(
|
||||
$isCentennialAllStar ? 'intel' : 'leadership',
|
||||
'int',
|
||||
GameConst::$defaultStatMin
|
||||
);
|
||||
$personal = Util::getPost('personal', 'string', null);
|
||||
$use_own_picture = Util::getPost('use_own_picture', 'bool', false);
|
||||
|
||||
@@ -78,9 +87,19 @@ if ($gencount >= $maxgeneral) {
|
||||
]);
|
||||
}
|
||||
|
||||
$poolClass = getGeneralPoolClass(GameConst::$targetGeneralPool);
|
||||
/** @var AbsGeneralPool */
|
||||
$pickedGeneral = new $poolClass($db, $selectInfo, $now);
|
||||
$poolClass = getGeneralPoolClass(GameConst::$targetGeneralPool);
|
||||
/** @var AbsGeneralPool */
|
||||
if ($isCentennialAllStar) {
|
||||
$rng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
|
||||
UniqueConst::$hiddenSeed,
|
||||
'selectPickedGeneral',
|
||||
$userID,
|
||||
$pick
|
||||
)));
|
||||
$pickedGeneral = new $poolClass($db, $rng, $selectInfo, $now);
|
||||
} else {
|
||||
$pickedGeneral = new $poolClass($db, $selectInfo, $now);
|
||||
}
|
||||
|
||||
$builder = $pickedGeneral->getGeneralBuilder();
|
||||
|
||||
@@ -105,7 +124,10 @@ foreach(GameConst::$generalPoolAllowOption as $allowOption){
|
||||
if(!$personal || $personal == 'Random'){
|
||||
$personal = Util::choiceRandom(GameConst::$availablePersonality);
|
||||
}
|
||||
if(!array_search($personal, GameConst::$availablePersonality)){
|
||||
$invalidPersonal = $isCentennialAllStar
|
||||
? !in_array($personal, GameConst::$availablePersonality, true)
|
||||
: !array_search($personal, GameConst::$availablePersonality);
|
||||
if($invalidPersonal){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'올바르지 않은 성격입니다.'
|
||||
@@ -167,4 +189,4 @@ $rootDB->insert('member_log', [
|
||||
Json::die([
|
||||
'result'=>true,
|
||||
'reason'=>'success'
|
||||
]);
|
||||
]);
|
||||
|
||||
@@ -33,12 +33,13 @@ if(!$generalID){
|
||||
}
|
||||
|
||||
list(
|
||||
$year,
|
||||
$month,
|
||||
$maxgeneral,
|
||||
$npcmode,
|
||||
$turnterm
|
||||
) = $gameStor->getValuesAsArray(['year', 'month', 'maxgeneral', 'npcmode', 'turnterm']);
|
||||
$year,
|
||||
$month,
|
||||
$startYear,
|
||||
$maxgeneral,
|
||||
$npcmode,
|
||||
$turnterm
|
||||
) = $gameStor->getValuesAsArray(['year', 'month', 'startyear', 'maxgeneral', 'npcmode', 'turnterm']);
|
||||
|
||||
if($npcmode!=2){
|
||||
Json::die([
|
||||
@@ -101,11 +102,36 @@ $db->update('select_pool',[
|
||||
'reserved_until'=>null,
|
||||
], '(owner=%i or reserved_until < %s) AND general_id is NULL', $userID, $now);
|
||||
|
||||
if(key_exists('leadership', $info)){
|
||||
$generalObj->updateVar('leadership', $info['leadership']);
|
||||
$generalObj->updateVar('strength', $info['strength']);
|
||||
$generalObj->updateVar('intel', $info['intel']);
|
||||
}
|
||||
$isCentennialAllStar = CentennialAllStarGrowthService::isActive();
|
||||
if ($isCentennialAllStar) {
|
||||
CentennialAllStarGrowthService::applyTarget($generalObj, $info, [
|
||||
'startyear' => $startYear,
|
||||
'year' => $year,
|
||||
'month' => $month,
|
||||
]);
|
||||
} else {
|
||||
if(key_exists('leadership', $info)){
|
||||
$generalObj->updateVar('leadership', $info['leadership']);
|
||||
$generalObj->updateVar('strength', $info['strength']);
|
||||
$generalObj->updateVar('intel', $info['intel']);
|
||||
}
|
||||
if(key_exists('dex', $info)){
|
||||
$generalObj->updateVar('dex1', $info['dex'][0]);
|
||||
$generalObj->updateVar('dex2', $info['dex'][1]);
|
||||
$generalObj->updateVar('dex3', $info['dex'][2]);
|
||||
$generalObj->updateVar('dex4', $info['dex'][3]);
|
||||
$generalObj->updateVar('dex5', $info['dex'][4]);
|
||||
}
|
||||
if(key_exists('ego', $info)){
|
||||
$generalObj->updateVar('personal', $info['ego']);
|
||||
}
|
||||
if(key_exists('specialDomestic', $info)){
|
||||
$generalObj->updateVar('special', $info['specialDomestic']);
|
||||
}
|
||||
if(key_exists('specialWar', $info)){
|
||||
$generalObj->updateVar('special2', $info['specialWar']);
|
||||
}
|
||||
}
|
||||
if(key_exists('picture', $info)){
|
||||
$generalObj->updateVar('imgsvr', $info['imgsvr']);
|
||||
$generalObj->updateVar('picture', $info['picture']);
|
||||
@@ -113,22 +139,6 @@ if(key_exists('picture', $info)){
|
||||
if(key_exists('generalName', $info)){
|
||||
$generalObj->updateVar('name', $info['generalName']);
|
||||
}
|
||||
if(key_exists('dex', $info)){
|
||||
$generalObj->updateVar('dex1', $info['dex'][0]);
|
||||
$generalObj->updateVar('dex2', $info['dex'][1]);
|
||||
$generalObj->updateVar('dex3', $info['dex'][2]);
|
||||
$generalObj->updateVar('dex4', $info['dex'][3]);
|
||||
$generalObj->updateVar('dex5', $info['dex'][4]);
|
||||
}
|
||||
if(key_exists('ego', $info)){
|
||||
$generalObj->updateVar('personal', $info['ego']);
|
||||
}
|
||||
if(key_exists('specialDomestic', $info)){
|
||||
$generalObj->updateVar('special', $info['specialDomestic']);
|
||||
}
|
||||
if(key_exists('specialWar', $info)){
|
||||
$generalObj->updateVar('special2', $info['specialWar']);
|
||||
}
|
||||
$generalObj->setAuxVar('next_change', TimeUtil::nowAddMinutes(12 * $turnterm));
|
||||
|
||||
$userNick = $ownerInfo['name'];
|
||||
@@ -148,4 +158,4 @@ $generalObj->applyDB($db);
|
||||
Json::die([
|
||||
'result'=>true,
|
||||
'reason'=>'success'
|
||||
]);
|
||||
]);
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
use sammo\Scenario\GeneralBuilder;
|
||||
|
||||
final class CentennialAllStarGrowthService
|
||||
{
|
||||
public const POOL_CLASS = 'SPoolUnderU100';
|
||||
public const AUX_KEY = 'event100_allstar';
|
||||
public const TRAIT_UNLOCK_PROGRESS = 0.4;
|
||||
|
||||
private const STAT_KEYS = ['leadership', 'strength', 'intel'];
|
||||
private const DEX_KEYS = ['dex1', 'dex2', 'dex3', 'dex4', 'dex5'];
|
||||
|
||||
public static function isActive(): bool
|
||||
{
|
||||
return GameConst::$targetGeneralPool === self::POOL_CLASS;
|
||||
}
|
||||
|
||||
public static function initialAux(array $targetInfo): array
|
||||
{
|
||||
return [
|
||||
'targetId' => (string) ($targetInfo['uniqueName'] ?? ''),
|
||||
'granted' => array_fill_keys(array_merge(self::STAT_KEYS, self::DEX_KEYS), 0),
|
||||
'progressMonth' => -1,
|
||||
'milestone' => 0,
|
||||
'naturalSpecialDomestic' => null,
|
||||
'eventSpecialDomestic' => null,
|
||||
];
|
||||
}
|
||||
|
||||
public static function attachInitialTarget(GeneralBuilder $builder, array $targetInfo): void
|
||||
{
|
||||
$builder->setAuxVar(self::AUX_KEY, self::initialAux($targetInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutates the General object but leaves persistence to the caller.
|
||||
*
|
||||
* @return array{progress:float,milestone:int,previousMilestone:int,targetChanged:bool,changed:bool}
|
||||
*/
|
||||
public static function applyTarget(General $general, array $targetInfo, array $env): array
|
||||
{
|
||||
$startYear = (int) $env['startyear'];
|
||||
$year = (int) $env['year'];
|
||||
$month = (int) $env['month'];
|
||||
$progress = CentennialAllStarGrowth::progress($startYear, $year, $month);
|
||||
$progressMonth = max(0, ($year - $startYear) * 12 + $month - 1);
|
||||
$targetId = (string) ($targetInfo['uniqueName'] ?? '');
|
||||
|
||||
$aux = $general->getAuxVar(self::AUX_KEY);
|
||||
if (!is_array($aux)) {
|
||||
$aux = self::initialAux($targetInfo);
|
||||
}
|
||||
$granted = is_array($aux['granted'] ?? null)
|
||||
? $aux['granted']
|
||||
: array_fill_keys(array_merge(self::STAT_KEYS, self::DEX_KEYS), 0);
|
||||
$targetChanged = ($aux['targetId'] ?? '') !== $targetId;
|
||||
$changed = false;
|
||||
|
||||
foreach (self::STAT_KEYS as $key) {
|
||||
if (!array_key_exists($key, $targetInfo)) {
|
||||
continue;
|
||||
}
|
||||
$target = min(GameConst::$maxLevel, max(0, (int) $targetInfo[$key]));
|
||||
$floor = CentennialAllStarGrowth::statFloor(
|
||||
$target,
|
||||
GameConst::$defaultStatMin,
|
||||
$progress
|
||||
);
|
||||
$current = (int) $general->getVar($key);
|
||||
if ($targetChanged) {
|
||||
$result = CentennialAllStarGrowth::replaceTarget(
|
||||
$current,
|
||||
(int) ($granted[$key] ?? 0),
|
||||
$floor
|
||||
);
|
||||
} else {
|
||||
$result = CentennialAllStarGrowth::advance(
|
||||
$current,
|
||||
(int) ($granted[$key] ?? 0),
|
||||
$floor
|
||||
);
|
||||
}
|
||||
if ($result['value'] !== $current) {
|
||||
$general->updateVar($key, $result['value']);
|
||||
$changed = true;
|
||||
}
|
||||
$granted[$key] = $result['granted'];
|
||||
}
|
||||
|
||||
$targetDex = $targetInfo['dex'] ?? [];
|
||||
foreach (self::DEX_KEYS as $idx => $key) {
|
||||
if (!array_key_exists($idx, $targetDex)) {
|
||||
continue;
|
||||
}
|
||||
$target = min(GameConst::$dexLimit, max(0, (int) $targetDex[$idx]));
|
||||
$floor = CentennialAllStarGrowth::dexFloor($target, $progress);
|
||||
$current = (int) $general->getVar($key);
|
||||
if ($targetChanged) {
|
||||
$result = CentennialAllStarGrowth::replaceTarget(
|
||||
$current,
|
||||
(int) ($granted[$key] ?? 0),
|
||||
$floor
|
||||
);
|
||||
} else {
|
||||
$result = CentennialAllStarGrowth::advance(
|
||||
$current,
|
||||
(int) ($granted[$key] ?? 0),
|
||||
$floor
|
||||
);
|
||||
}
|
||||
if ($result['value'] !== $current) {
|
||||
$general->updateVar($key, $result['value']);
|
||||
$changed = true;
|
||||
}
|
||||
$granted[$key] = $result['granted'];
|
||||
}
|
||||
|
||||
$oldEventSpecial = $aux['eventSpecialDomestic'] ?? null;
|
||||
if ($targetChanged && $oldEventSpecial !== null
|
||||
&& $general->getVar('special') === $oldEventSpecial
|
||||
) {
|
||||
$general->updateVar(
|
||||
'special',
|
||||
$aux['naturalSpecialDomestic'] ?? GameConst::$defaultSpecialDomestic
|
||||
);
|
||||
$changed = true;
|
||||
$aux['eventSpecialDomestic'] = null;
|
||||
}
|
||||
|
||||
$targetSpecial = $targetInfo['specialDomestic'] ?? null;
|
||||
if ($progress >= self::TRAIT_UNLOCK_PROGRESS && is_string($targetSpecial) && $targetSpecial !== '') {
|
||||
if (($aux['naturalSpecialDomestic'] ?? null) === null) {
|
||||
$aux['naturalSpecialDomestic'] = $general->getVar('special');
|
||||
}
|
||||
if ($general->getVar('special') !== $targetSpecial) {
|
||||
$general->updateVar('special', $targetSpecial);
|
||||
$changed = true;
|
||||
}
|
||||
$aux['eventSpecialDomestic'] = $targetSpecial;
|
||||
}
|
||||
|
||||
$previousMilestone = (int) ($aux['milestone'] ?? 0);
|
||||
$milestone = min(5, (int) floor($progress * 5 + 0.0000001));
|
||||
$aux['targetId'] = $targetId;
|
||||
$aux['granted'] = $granted;
|
||||
$aux['progressMonth'] = max((int) ($aux['progressMonth'] ?? -1), $progressMonth);
|
||||
$aux['milestone'] = max($previousMilestone, $milestone);
|
||||
$general->setAuxVar(self::AUX_KEY, $aux);
|
||||
|
||||
return [
|
||||
'progress' => $progress,
|
||||
'milestone' => $milestone,
|
||||
'previousMilestone' => $previousMilestone,
|
||||
'targetChanged' => $targetChanged,
|
||||
'changed' => $changed || $targetChanged || $milestone > $previousMilestone,
|
||||
];
|
||||
}
|
||||
|
||||
public static function recordableValue(General $general, string $key): int
|
||||
{
|
||||
$aux = $general->getAuxVar(self::AUX_KEY);
|
||||
$granted = is_array($aux) && is_array($aux['granted'] ?? null)
|
||||
? (int) ($aux['granted'][$key] ?? 0)
|
||||
: 0;
|
||||
return CentennialAllStarGrowth::recordableValue((int) $general->getVar($key), $granted);
|
||||
}
|
||||
|
||||
public static function recordableRawValue(array $general, string $key): int
|
||||
{
|
||||
$aux = Json::decode($general['aux'] ?? '{}');
|
||||
$eventAux = is_array($aux[self::AUX_KEY] ?? null) ? $aux[self::AUX_KEY] : [];
|
||||
$granted = is_array($eventAux['granted'] ?? null)
|
||||
? (int) ($eventAux['granted'][$key] ?? 0)
|
||||
: 0;
|
||||
return CentennialAllStarGrowth::recordableValue((int) ($general[$key] ?? 0), $granted);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Event\Action;
|
||||
|
||||
use sammo\ActionLogger;
|
||||
use sammo\CentennialAllStarGrowthService;
|
||||
use sammo\DB;
|
||||
use sammo\General;
|
||||
use sammo\Json;
|
||||
|
||||
class AdvanceCentennialAllStar extends \sammo\Event\Action
|
||||
{
|
||||
public function run(array $env)
|
||||
{
|
||||
if (!CentennialAllStarGrowthService::isActive()) {
|
||||
return [__CLASS__, 0];
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$updated = 0;
|
||||
foreach ($db->query(
|
||||
'SELECT general.no, select_pool.info
|
||||
FROM general
|
||||
JOIN select_pool ON select_pool.general_id = general.no'
|
||||
) as $row) {
|
||||
$general = General::createObjFromDB((int) $row['no']);
|
||||
$targetInfo = Json::decode($row['info']);
|
||||
$result = CentennialAllStarGrowthService::applyTarget($general, $targetInfo, $env);
|
||||
|
||||
if ($result['milestone'] > $result['previousMilestone']) {
|
||||
$percent = $result['milestone'] * 20;
|
||||
$general->getLogger()->pushGeneralActionLog(
|
||||
"<L>올스타 동조율</>이 <C>{$percent}%</>에 도달했습니다!",
|
||||
ActionLogger::PLAIN
|
||||
);
|
||||
$general->getLogger()->pushGeneralHistoryLog(
|
||||
"<L>올스타 동조율 {$percent}% 달성</>"
|
||||
);
|
||||
}
|
||||
if ($general->applyDB($db)) {
|
||||
$updated++;
|
||||
}
|
||||
}
|
||||
|
||||
return [__CLASS__, $updated];
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\GeneralPool;
|
||||
|
||||
use sammo\AbsFromUserPool;
|
||||
use sammo\CentennialAllStarGrowthService;
|
||||
use sammo\Json;
|
||||
use sammo\RandUtil;
|
||||
|
||||
class SPoolUnderU100 extends AbsFromUserPool
|
||||
{
|
||||
public function __construct(\MeekroDB $db, RandUtil $rng, array $info, string $validUntil)
|
||||
{
|
||||
$targetInfo = $info;
|
||||
$initialInfo = $info;
|
||||
foreach ([
|
||||
'leadership',
|
||||
'strength',
|
||||
'intel',
|
||||
'experience',
|
||||
'dedication',
|
||||
'dex',
|
||||
'specialDomestic',
|
||||
'specialWar',
|
||||
] as $targetKey) {
|
||||
unset($initialInfo[$targetKey]);
|
||||
}
|
||||
|
||||
parent::__construct($db, $rng, $initialInfo, $validUntil);
|
||||
$this->info = $targetInfo;
|
||||
CentennialAllStarGrowthService::attachInitialTarget($this->builder, $targetInfo);
|
||||
}
|
||||
|
||||
public static function getPoolName(): string
|
||||
{
|
||||
return '100기 올스타 클래식';
|
||||
}
|
||||
|
||||
public static function initPool(\MeekroDB $db)
|
||||
{
|
||||
$jsonData = Json::decode(file_get_contents(__DIR__ . '/Pool/UnderS100.json'));
|
||||
$columns = $jsonData['columns'];
|
||||
$sqlValues = [];
|
||||
foreach ($jsonData['data'] as $idx => $rawItem) {
|
||||
if (count($rawItem) !== count($columns)) {
|
||||
throw new \RuntimeException(($rawItem[0] ?? (string) $idx) . ' Error');
|
||||
}
|
||||
$item = array_combine($columns, $rawItem);
|
||||
$uniqueName = sprintf('A100%04d', $idx + 1);
|
||||
$item['uniqueName'] = $uniqueName;
|
||||
$item['event100Growth'] = true;
|
||||
$sqlValues[] = [
|
||||
'unique_name' => $uniqueName,
|
||||
'info' => Json::encode($item),
|
||||
];
|
||||
}
|
||||
$db->insert('select_pool', $sqlValues);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"title": "【공백지】 100기 올스타 클래식",
|
||||
"startYear": 180,
|
||||
"map": {
|
||||
"mapName": "miniche",
|
||||
"targetGeneralPool": "SPoolUnderU100",
|
||||
"generalPoolAllowOption": ["stat", "ego", "picture"]
|
||||
},
|
||||
"history": [
|
||||
"<C>●</>180년 1월:<L><b>【100기 이벤트】</b></> 역대 장수들이 평범한 능력으로 다시 모여, 지난 전성기의 힘과 서서히 동조하기 시작했다!"
|
||||
],
|
||||
"const": {
|
||||
"npcBanMessageProb": 1
|
||||
},
|
||||
"events": [
|
||||
[
|
||||
"month", 8000,
|
||||
true,
|
||||
["AdvanceCentennialAllStar"]
|
||||
],
|
||||
[
|
||||
"month", 1000,
|
||||
["Date", "==", null, 12],
|
||||
["CreateManyNPC", 100, 0],
|
||||
["DeleteEvent"]
|
||||
],
|
||||
[
|
||||
"month", 1000,
|
||||
["Date", "==", 181, 12],
|
||||
["ChangeCity", "occupied", {
|
||||
"pop": "+60000",
|
||||
"agri": "+1200",
|
||||
"comm": "+1200"
|
||||
}]
|
||||
],
|
||||
[
|
||||
"destroy_nation", 1000,
|
||||
["and",
|
||||
["Date", ">=", 183, 1],
|
||||
["RemainNation", "==", 1]
|
||||
],
|
||||
["BlockScoutAction"],
|
||||
["DeleteEvent"]
|
||||
]
|
||||
]
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import { unwrap } from '@util/unwrap';
|
||||
import { TemplateEngine } from '@util/TemplateEngine';
|
||||
import { Tooltip } from 'bootstrap';
|
||||
import { trim } from 'lodash-es';
|
||||
type CardItem = {
|
||||
type CardItem = {
|
||||
uniqueName: string,
|
||||
|
||||
imgsvr: 0|1,
|
||||
@@ -26,9 +26,14 @@ type CardItem = {
|
||||
specialWarInfo?: string,
|
||||
specialWarText?: string,
|
||||
|
||||
personal?: string,
|
||||
personalText?: string,
|
||||
}
|
||||
personal?: string,
|
||||
personalText?: string,
|
||||
event100Growth?: boolean,
|
||||
leadership?: number,
|
||||
strength?: number,
|
||||
intel?: number,
|
||||
dex?: number[],
|
||||
}
|
||||
|
||||
type GeneralPoolResponse = {
|
||||
result: true,
|
||||
@@ -42,9 +47,10 @@ declare let currentGeneralInfo: CardItem | undefined;
|
||||
declare const cards: Record<string, CardItem>;
|
||||
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>\
|
||||
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(leadership){%>\
|
||||
<%leadership%> / <%strength%> / <%intel%><br>\
|
||||
<%}%>\
|
||||
@@ -137,12 +143,16 @@ async function buildGeneral(e: JQuery.Event) {
|
||||
method: 'post',
|
||||
responseType: 'json',
|
||||
data: convertFormData({
|
||||
pick: unwrap(currentGeneralInfo).uniqueName,
|
||||
use_own_picture: $('#use_own_picture').is(':checked'),
|
||||
leadership: parseInt(unwrap_any<string>($('#leadership').val())),
|
||||
strength: parseInt(unwrap_any<string>($('#leadership').val())),
|
||||
intel: parseInt(unwrap_any<string>($('#leadership').val())),
|
||||
personal: unwrap_any<string>($('#selChar').val())
|
||||
pick: unwrap(currentGeneralInfo).uniqueName,
|
||||
use_own_picture: $('#use_own_picture').is(':checked'),
|
||||
leadership: parseInt(unwrap_any<string>($('#leadership').val())),
|
||||
strength: parseInt(unwrap_any<string>(
|
||||
$(unwrap(currentGeneralInfo).event100Growth ? '#strength' : '#leadership').val()
|
||||
)),
|
||||
intel: parseInt(unwrap_any<string>(
|
||||
$(unwrap(currentGeneralInfo).event100Growth ? '#intel' : '#leadership').val()
|
||||
)),
|
||||
personal: unwrap_any<string>($('#selChar').val())
|
||||
})
|
||||
})
|
||||
result = response.data;
|
||||
@@ -287,4 +297,4 @@ $(async function ($) {
|
||||
$('.custom_stat').show();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
"main": "js/index.js",
|
||||
"scripts": {
|
||||
"test": "npm-run-all test-php-gateway test-ts",
|
||||
"test-php-gateway": "vendor/bin/phpunit --bootstrap vendor/autoload.php tests",
|
||||
"test-php-gateway": "vendor/bin/phpunit --do-not-cache-result --bootstrap vendor/autoload.php tests",
|
||||
"test-ts": "mocha",
|
||||
"build": "webpack",
|
||||
"buildDev": "webpack --mode=development",
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Build the static 100th-season all-star pool from a tab-separated query result.
|
||||
*
|
||||
* Usage:
|
||||
* mariadb --batch --raw --skip-column-names DATABASE \
|
||||
* < src/centennial_allstar_candidates.sql \
|
||||
* | php src/build_centennial_allstar_pool.php OUTPUT.json
|
||||
*/
|
||||
|
||||
const OUTPUT_COLUMNS = [
|
||||
'generalName',
|
||||
'leadership',
|
||||
'strength',
|
||||
'intel',
|
||||
'specialDomestic',
|
||||
'dex',
|
||||
'imgsvr',
|
||||
'picture',
|
||||
'sourcePhase',
|
||||
'sourceServerId',
|
||||
'sourceGeneralNo',
|
||||
'selectionReasons',
|
||||
];
|
||||
|
||||
const LEGACY_SPECIAL_WAR_MAP = [
|
||||
40 => 'che_event_귀병',
|
||||
41 => 'che_event_신산',
|
||||
42 => 'che_event_환술',
|
||||
43 => 'che_event_집중',
|
||||
44 => 'che_event_신중',
|
||||
45 => 'che_event_반계',
|
||||
50 => 'che_event_보병',
|
||||
51 => 'che_event_궁병',
|
||||
52 => 'che_event_기병',
|
||||
53 => 'che_event_공성',
|
||||
60 => 'che_event_돌격',
|
||||
61 => 'che_event_무쌍',
|
||||
62 => 'che_event_견고',
|
||||
63 => 'che_event_위압',
|
||||
70 => 'che_event_저격',
|
||||
71 => 'che_event_필살',
|
||||
72 => 'che_event_징병',
|
||||
73 => 'che_event_의술',
|
||||
74 => 'che_event_격노',
|
||||
75 => 'che_event_척사',
|
||||
];
|
||||
|
||||
function fail(string $message): never
|
||||
{
|
||||
fwrite(STDERR, "error: {$message}\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
function firstInt(array $data, array $keys): int
|
||||
{
|
||||
foreach ($keys as $key) {
|
||||
if (array_key_exists($key, $data) && is_numeric($data[$key])) {
|
||||
return (int) $data[$key];
|
||||
}
|
||||
}
|
||||
fail('missing numeric field: ' . implode(' or ', $keys));
|
||||
}
|
||||
|
||||
function normalizeEventSpecial(mixed $rawSpecial): ?string
|
||||
{
|
||||
if (is_numeric($rawSpecial)) {
|
||||
return LEGACY_SPECIAL_WAR_MAP[(int) $rawSpecial] ?? null;
|
||||
}
|
||||
if (
|
||||
!is_string($rawSpecial)
|
||||
|| $rawSpecial === ''
|
||||
|| $rawSpecial === '0'
|
||||
|| strcasecmp($rawSpecial, 'none') === 0
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
if (str_starts_with($rawSpecial, 'che_event_')) {
|
||||
return $rawSpecial;
|
||||
}
|
||||
if (str_starts_with($rawSpecial, 'che_')) {
|
||||
return 'che_event_' . substr($rawSpecial, strlen('che_'));
|
||||
}
|
||||
fail("unknown historical war special: {$rawSpecial}");
|
||||
}
|
||||
|
||||
function decodeSourceRow(string $line, int $lineNo): array
|
||||
{
|
||||
$fields = explode("\t", rtrim($line, "\r\n"), 6);
|
||||
if (count($fields) !== 6) {
|
||||
fail("line {$lineNo}: expected 6 tab-separated fields, got " . count($fields));
|
||||
}
|
||||
|
||||
[$phase, $serverId, $generalNo, $name, $rawData, $rawReasons] = $fields;
|
||||
$data = json_decode($rawData, true, 512, JSON_THROW_ON_ERROR);
|
||||
if (!is_array($data)) {
|
||||
fail("line {$lineNo}: general data is not an object");
|
||||
}
|
||||
|
||||
$phaseNo = (int) $phase;
|
||||
$sourceGeneralNo = (int) $generalNo;
|
||||
if ($phaseNo < 1 || $phaseNo > 99 || $sourceGeneralNo <= 2) {
|
||||
fail("line {$lineNo}: invalid phase/general number");
|
||||
}
|
||||
|
||||
$sourceName = trim($name);
|
||||
if ($sourceName === '') {
|
||||
fail("line {$lineNo}: empty general name");
|
||||
}
|
||||
$generalName = sprintf('【%d기】%s', $phaseNo, $sourceName);
|
||||
if (mb_strlen($generalName) > 32) {
|
||||
fail("line {$lineNo}: generated name exceeds 32 characters: {$generalName}");
|
||||
}
|
||||
|
||||
$dex = [
|
||||
firstInt($data, ['dex1', 'dex0']),
|
||||
firstInt($data, ['dex2', 'dex10']),
|
||||
firstInt($data, ['dex3', 'dex20']),
|
||||
firstInt($data, ['dex4', 'dex30']),
|
||||
firstInt($data, ['dex5', 'dex40']),
|
||||
];
|
||||
foreach ($dex as $value) {
|
||||
if ($value < 0) {
|
||||
fail("line {$lineNo}: negative dex value");
|
||||
}
|
||||
}
|
||||
|
||||
$reasons = $rawReasons === '' ? [] : explode(',', $rawReasons);
|
||||
sort($reasons, SORT_STRING);
|
||||
|
||||
return [
|
||||
$generalName,
|
||||
firstInt($data, ['leadership', 'leader']),
|
||||
firstInt($data, ['strength', 'power']),
|
||||
firstInt($data, ['intel']),
|
||||
normalizeEventSpecial($data['special2'] ?? null),
|
||||
$dex,
|
||||
firstInt($data, ['imgsvr']),
|
||||
is_string($data['picture'] ?? null) && $data['picture'] !== ''
|
||||
? $data['picture']
|
||||
: 'default.jpg',
|
||||
$phaseNo,
|
||||
$serverId,
|
||||
$sourceGeneralNo,
|
||||
$reasons,
|
||||
];
|
||||
}
|
||||
|
||||
if ($argc !== 2) {
|
||||
fail('usage: php build_centennial_allstar_pool.php OUTPUT.json');
|
||||
}
|
||||
|
||||
$outputPath = $argv[1];
|
||||
$rows = [];
|
||||
$seenSources = [];
|
||||
$nameIndexes = [];
|
||||
$phaseCounts = [];
|
||||
$reasonCounts = [];
|
||||
$lineNo = 0;
|
||||
|
||||
while (($line = fgets(STDIN)) !== false) {
|
||||
$lineNo++;
|
||||
if (trim($line) === '') {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
$row = decodeSourceRow($line, $lineNo);
|
||||
} catch (JsonException $e) {
|
||||
fail("line {$lineNo}: invalid JSON: {$e->getMessage()}");
|
||||
}
|
||||
|
||||
$sourceKey = "{$row[8]}:{$row[10]}";
|
||||
if (isset($seenSources[$sourceKey])) {
|
||||
fail("line {$lineNo}: duplicate source general {$sourceKey}");
|
||||
}
|
||||
$seenSources[$sourceKey] = true;
|
||||
$nameIndexes[$row[0]][] = count($rows);
|
||||
$phaseCounts[$row[8]] = ($phaseCounts[$row[8]] ?? 0) + 1;
|
||||
foreach ($row[11] as $reason) {
|
||||
$reasonGroup = str_starts_with($reason, 'chief:') ? 'chief' : 'hall';
|
||||
$reasonCounts[$reasonGroup] = ($reasonCounts[$reasonGroup] ?? 0) + 1;
|
||||
}
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
if ($rows === []) {
|
||||
fail('no input rows');
|
||||
}
|
||||
foreach ($nameIndexes as $generalName => $indexes) {
|
||||
if (count($indexes) === 1) {
|
||||
continue;
|
||||
}
|
||||
foreach ($indexes as $index) {
|
||||
$rows[$index][0] .= "#{$rows[$index][10]}";
|
||||
if (mb_strlen($rows[$index][0]) > 32) {
|
||||
fail("disambiguated name exceeds 32 characters: {$rows[$index][0]}");
|
||||
}
|
||||
}
|
||||
}
|
||||
ksort($phaseCounts, SORT_NUMERIC);
|
||||
if (array_keys($phaseCounts) !== range(1, 99)) {
|
||||
fail('input does not cover every phase from 1 through 99');
|
||||
}
|
||||
|
||||
$payload = [
|
||||
'columns' => OUTPUT_COLUMNS,
|
||||
'data' => $rows,
|
||||
];
|
||||
$encoded = json_encode(
|
||||
$payload,
|
||||
JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR
|
||||
) . "\n";
|
||||
|
||||
$outputDir = dirname($outputPath);
|
||||
if (!is_dir($outputDir)) {
|
||||
fail("output directory does not exist: {$outputDir}");
|
||||
}
|
||||
$tempPath = tempnam($outputDir, basename($outputPath) . '.tmp.');
|
||||
if ($tempPath === false) {
|
||||
fail("could not create temporary output in {$outputDir}");
|
||||
}
|
||||
if (file_put_contents($tempPath, $encoded) === false || !rename($tempPath, $outputPath)) {
|
||||
@unlink($tempPath);
|
||||
fail("could not write output: {$outputPath}");
|
||||
}
|
||||
|
||||
fwrite(
|
||||
STDERR,
|
||||
sprintf(
|
||||
"wrote %d candidates across phases %d-%d (%d hall reasons, %d chief reasons)\n",
|
||||
count($rows),
|
||||
min(array_keys($phaseCounts)),
|
||||
max(array_keys($phaseCounts)),
|
||||
$reasonCounts['hall'] ?? 0,
|
||||
$reasonCounts['chief'] ?? 0,
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,130 @@
|
||||
WITH
|
||||
phases AS (
|
||||
SELECT
|
||||
e.no AS phase_no,
|
||||
e.server_id,
|
||||
g.winner_nation,
|
||||
e.l12name,
|
||||
e.l12pic,
|
||||
e.l11name,
|
||||
e.l11pic,
|
||||
e.l10name,
|
||||
e.l10pic,
|
||||
e.l9name,
|
||||
e.l9pic,
|
||||
e.l8name,
|
||||
e.l8pic,
|
||||
e.l7name,
|
||||
e.l7pic,
|
||||
e.l6name,
|
||||
e.l6pic,
|
||||
e.l5name,
|
||||
e.l5pic
|
||||
FROM emperior e
|
||||
LEFT JOIN ng_games g ON g.server_id = e.server_id
|
||||
WHERE e.no BETWEEN 1 AND 99
|
||||
),
|
||||
hall_eligible AS (
|
||||
SELECT
|
||||
p.phase_no,
|
||||
h.server_id,
|
||||
h.general_no,
|
||||
h.type,
|
||||
h.value,
|
||||
h.id
|
||||
FROM phases p
|
||||
JOIN hall h ON h.server_id = p.server_id
|
||||
JOIN ng_old_generals og
|
||||
ON og.server_id = h.server_id
|
||||
AND og.general_no = h.general_no
|
||||
WHERE h.general_no > 2
|
||||
AND CAST(COALESCE(JSON_VALUE(og.data, '$.npc'), 0) AS SIGNED) = 0
|
||||
),
|
||||
hall_ranked AS (
|
||||
SELECT
|
||||
phase_no,
|
||||
server_id,
|
||||
general_no,
|
||||
type,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY server_id, type
|
||||
ORDER BY value DESC, id ASC
|
||||
) AS hall_rank
|
||||
FROM hall_eligible
|
||||
),
|
||||
selection_reasons AS (
|
||||
SELECT
|
||||
phase_no,
|
||||
server_id,
|
||||
general_no,
|
||||
CONCAT('hall:', type) AS reason
|
||||
FROM hall_ranked
|
||||
WHERE hall_rank <= 10
|
||||
),
|
||||
chief_slots AS (
|
||||
SELECT phase_no, server_id, winner_nation, 12 AS officer_level, l12name AS name, l12pic AS picture FROM phases
|
||||
UNION ALL
|
||||
SELECT phase_no, server_id, winner_nation, 11, l11name, l11pic FROM phases
|
||||
UNION ALL
|
||||
SELECT phase_no, server_id, winner_nation, 10, l10name, l10pic FROM phases
|
||||
UNION ALL
|
||||
SELECT phase_no, server_id, winner_nation, 9, l9name, l9pic FROM phases
|
||||
UNION ALL
|
||||
SELECT phase_no, server_id, winner_nation, 8, l8name, l8pic FROM phases
|
||||
UNION ALL
|
||||
SELECT phase_no, server_id, winner_nation, 7, l7name, l7pic FROM phases
|
||||
UNION ALL
|
||||
SELECT phase_no, server_id, winner_nation, 6, l6name, l6pic FROM phases
|
||||
UNION ALL
|
||||
SELECT phase_no, server_id, winner_nation, 5, l5name, l5pic FROM phases
|
||||
),
|
||||
chief_reasons AS (
|
||||
SELECT
|
||||
c.phase_no,
|
||||
c.server_id,
|
||||
og.general_no,
|
||||
CONCAT('chief:', c.officer_level) AS reason
|
||||
FROM chief_slots c
|
||||
JOIN ng_old_generals og
|
||||
ON og.server_id = c.server_id
|
||||
AND og.name = c.name
|
||||
AND SUBSTRING_INDEX(
|
||||
COALESCE(JSON_VALUE(og.data, '$.picture'), ''),
|
||||
'?=',
|
||||
1
|
||||
) = SUBSTRING_INDEX(COALESCE(c.picture, ''), '?=', 1)
|
||||
AND (
|
||||
CAST(COALESCE(JSON_VALUE(og.data, '$.officer_level'), -1) AS SIGNED) = c.officer_level
|
||||
OR (
|
||||
JSON_VALUE(og.data, '$.officer_level') IS NULL
|
||||
AND (
|
||||
c.winner_nation IS NULL
|
||||
OR CAST(JSON_VALUE(og.data, '$.nation') AS SIGNED) = c.winner_nation
|
||||
)
|
||||
)
|
||||
)
|
||||
WHERE og.general_no > 2
|
||||
),
|
||||
all_reasons AS (
|
||||
SELECT phase_no, server_id, general_no, reason FROM selection_reasons
|
||||
UNION ALL
|
||||
SELECT phase_no, server_id, general_no, reason FROM chief_reasons
|
||||
)
|
||||
SELECT
|
||||
r.phase_no,
|
||||
r.server_id,
|
||||
r.general_no,
|
||||
og.name,
|
||||
og.data,
|
||||
GROUP_CONCAT(DISTINCT r.reason ORDER BY r.reason SEPARATOR ',') AS reasons
|
||||
FROM all_reasons r
|
||||
JOIN ng_old_generals og
|
||||
ON og.server_id = r.server_id
|
||||
AND og.general_no = r.general_no
|
||||
GROUP BY
|
||||
r.phase_no,
|
||||
r.server_id,
|
||||
r.general_no,
|
||||
og.name,
|
||||
og.data
|
||||
ORDER BY r.phase_no, r.general_no;
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
final class CentennialAllStarGrowth
|
||||
{
|
||||
public const DEFAULT_GROWTH_YEARS = 15;
|
||||
|
||||
public static function progress(
|
||||
int $startYear,
|
||||
int $year,
|
||||
int $month,
|
||||
int $growthYears = self::DEFAULT_GROWTH_YEARS
|
||||
): float {
|
||||
if ($growthYears <= 0) {
|
||||
throw new \InvalidArgumentException('growthYears must be positive');
|
||||
}
|
||||
if ($month < 1 || $month > 12) {
|
||||
throw new \InvalidArgumentException('month must be between 1 and 12');
|
||||
}
|
||||
|
||||
$elapsedMonths = max(0, ($year - $startYear) * 12 + $month - 1);
|
||||
return min(1.0, $elapsedMonths / ($growthYears * 12));
|
||||
}
|
||||
|
||||
public static function statFloor(int $target, int $minimum, float $progress): int
|
||||
{
|
||||
$progress = self::clampProgress($progress);
|
||||
if ($target <= $minimum) {
|
||||
return $target;
|
||||
}
|
||||
return min($target, (int) floor($minimum + ($target - $minimum) * $progress));
|
||||
}
|
||||
|
||||
public static function dexFloor(int $target, float $progress): int
|
||||
{
|
||||
$progress = self::clampProgress($progress);
|
||||
return min($target, (int) floor($target * $progress * $progress));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{value:int, granted:int, delta:int}
|
||||
*/
|
||||
public static function advance(int $current, int $granted, int $floor): array
|
||||
{
|
||||
$delta = max(0, $floor - $current);
|
||||
return [
|
||||
'value' => $current + $delta,
|
||||
'granted' => max(0, $granted) + $delta,
|
||||
'delta' => $delta,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{value:int, granted:int, organic:int}
|
||||
*/
|
||||
public static function replaceTarget(int $current, int $oldGranted, int $newFloor): array
|
||||
{
|
||||
$organic = max(0, $current - max(0, $oldGranted));
|
||||
$value = max($organic, $newFloor);
|
||||
return [
|
||||
'value' => $value,
|
||||
'granted' => $value - $organic,
|
||||
'organic' => $organic,
|
||||
];
|
||||
}
|
||||
|
||||
public static function recordableValue(int $current, int $granted): int
|
||||
{
|
||||
return max(0, $current - max(0, $granted));
|
||||
}
|
||||
|
||||
private static function clampProgress(float $progress): float
|
||||
{
|
||||
return max(0.0, min(1.0, $progress));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use sammo\CentennialAllStarGrowth;
|
||||
use sammo\CentennialAllStarGrowthService;
|
||||
|
||||
require_once __DIR__ . '/../hwe/sammo/CentennialAllStarGrowthService.php';
|
||||
|
||||
final class CentennialAllStarGrowthTest extends TestCase
|
||||
{
|
||||
public function testProgressMilestones(): void
|
||||
{
|
||||
self::assertSame(0.0, CentennialAllStarGrowth::progress(180, 180, 1));
|
||||
self::assertEqualsWithDelta(0.2, CentennialAllStarGrowth::progress(180, 183, 1), 0.000001);
|
||||
self::assertEqualsWithDelta(0.4, CentennialAllStarGrowth::progress(180, 186, 1), 0.000001);
|
||||
self::assertSame(1.0, CentennialAllStarGrowth::progress(180, 195, 1));
|
||||
self::assertSame(1.0, CentennialAllStarGrowth::progress(180, 210, 1));
|
||||
}
|
||||
|
||||
public function testLowStatGrowsWhileHigherStatStays(): void
|
||||
{
|
||||
$floor = CentennialAllStarGrowth::statFloor(90, 15, 0.6);
|
||||
self::assertSame(60, $floor);
|
||||
self::assertSame(
|
||||
['value' => 70, 'granted' => 0, 'delta' => 0],
|
||||
CentennialAllStarGrowth::advance(70, 0, $floor)
|
||||
);
|
||||
self::assertSame(
|
||||
['value' => 60, 'granted' => 10, 'delta' => 10],
|
||||
CentennialAllStarGrowth::advance(50, 0, $floor)
|
||||
);
|
||||
}
|
||||
|
||||
public function testReselectDropsOldGrantAndKeepsOrganicGrowth(): void
|
||||
{
|
||||
self::assertSame(
|
||||
['value' => 82, 'granted' => 7, 'organic' => 75],
|
||||
CentennialAllStarGrowth::replaceTarget(86, 11, 82)
|
||||
);
|
||||
self::assertSame(
|
||||
['value' => 90, 'granted' => 0, 'organic' => 90],
|
||||
CentennialAllStarGrowth::replaceTarget(101, 11, 82)
|
||||
);
|
||||
}
|
||||
|
||||
public function testRepeatedAdvanceIsIdempotent(): void
|
||||
{
|
||||
$first = CentennialAllStarGrowth::advance(50, 0, 60);
|
||||
$second = CentennialAllStarGrowth::advance($first['value'], $first['granted'], 60);
|
||||
self::assertSame(60, $second['value']);
|
||||
self::assertSame(10, $second['granted']);
|
||||
self::assertSame(0, $second['delta']);
|
||||
self::assertSame(50, CentennialAllStarGrowth::recordableValue(60, 10));
|
||||
}
|
||||
|
||||
public function testDexUsesSlowEarlyCurve(): void
|
||||
{
|
||||
self::assertSame(0, CentennialAllStarGrowth::dexFloor(900000, 0));
|
||||
self::assertSame(36000, CentennialAllStarGrowth::dexFloor(900000, 0.2));
|
||||
self::assertSame(144000, CentennialAllStarGrowth::dexFloor(900000, 0.4));
|
||||
self::assertSame(900000, CentennialAllStarGrowth::dexFloor(900000, 1));
|
||||
}
|
||||
|
||||
public function testUntrackedGeneralKeepsFullHallValue(): void
|
||||
{
|
||||
self::assertSame(
|
||||
123456,
|
||||
CentennialAllStarGrowthService::recordableRawValue(
|
||||
['dex1' => 123456, 'aux' => '{}'],
|
||||
'dex1'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class CentennialAllStarPoolTest extends TestCase
|
||||
{
|
||||
private const POOL_PATH = __DIR__ . '/../hwe/sammo/GeneralPool/Pool/UnderS100.json';
|
||||
|
||||
public function testPoolCoversEveryCompletedPhase(): void
|
||||
{
|
||||
$pool = json_decode(
|
||||
file_get_contents(self::POOL_PATH),
|
||||
true,
|
||||
512,
|
||||
JSON_THROW_ON_ERROR
|
||||
);
|
||||
self::assertSame(
|
||||
[
|
||||
'generalName',
|
||||
'leadership',
|
||||
'strength',
|
||||
'intel',
|
||||
'specialDomestic',
|
||||
'dex',
|
||||
'imgsvr',
|
||||
'picture',
|
||||
'sourcePhase',
|
||||
'sourceServerId',
|
||||
'sourceGeneralNo',
|
||||
'selectionReasons',
|
||||
],
|
||||
$pool['columns']
|
||||
);
|
||||
self::assertCount(5757, $pool['data']);
|
||||
|
||||
$column = array_flip($pool['columns']);
|
||||
$phases = [];
|
||||
$sourceKeys = [];
|
||||
$generalNames = [];
|
||||
foreach ($pool['data'] as $row) {
|
||||
self::assertCount(count($pool['columns']), $row);
|
||||
|
||||
$phase = $row[$column['sourcePhase']];
|
||||
$sourceKey = "{$phase}:{$row[$column['sourceGeneralNo']]}";
|
||||
self::assertArrayNotHasKey($sourceKey, $sourceKeys);
|
||||
$sourceKeys[$sourceKey] = true;
|
||||
$phases[$phase] = true;
|
||||
|
||||
$generalName = $row[$column['generalName']];
|
||||
self::assertArrayNotHasKey($generalName, $generalNames);
|
||||
$generalNames[$generalName] = true;
|
||||
|
||||
self::assertCount(5, $row[$column['dex']]);
|
||||
self::assertNotEmpty($row[$column['selectionReasons']]);
|
||||
foreach ($row[$column['selectionReasons']] as $reason) {
|
||||
self::assertMatchesRegularExpression(
|
||||
'/^(hall:[a-z0-9_]+|chief:(?:5|6|7|8|9|10|11|12))$/',
|
||||
$reason
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ksort($phases, SORT_NUMERIC);
|
||||
self::assertSame(range(1, 99), array_keys($phases));
|
||||
}
|
||||
|
||||
public function testEveryHistoricalEventSpecialHasAnImplementation(): void
|
||||
{
|
||||
$pool = json_decode(
|
||||
file_get_contents(self::POOL_PATH),
|
||||
true,
|
||||
512,
|
||||
JSON_THROW_ON_ERROR
|
||||
);
|
||||
$column = array_flip($pool['columns']);
|
||||
|
||||
foreach ($pool['data'] as $row) {
|
||||
$special = $row[$column['specialDomestic']];
|
||||
if ($special === null) {
|
||||
continue;
|
||||
}
|
||||
self::assertFileExists(
|
||||
__DIR__ . "/../hwe/sammo/ActionSpecialDomestic/{$special}.php"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user