From c9dd8730198feaabc44a0a8add19cf49879a0148 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Thu, 6 Jul 2023 17:38:32 +0000 Subject: [PATCH] =?UTF-8?q?refac,=20wip:=20=EB=B2=8C=EC=A0=90(connect,=20c?= =?UTF-8?q?on)=20=EB=B3=80=EA=B2=BD=20-=20=EB=B2=8C=EC=A0=90:=20refreshSco?= =?UTF-8?q?reTotal=20-=20=EC=88=9C=EA=B0=84=EB=B2=8C=EC=A0=90:=20refreshSc?= =?UTF-8?q?ore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/a_genList.php | 15 ++-- hwe/a_traffic.php | 16 ++-- hwe/b_myGenInfo.php | 10 ++- hwe/func.php | 4 +- hwe/func_converter.php | 2 +- hwe/func_gamerule.php | 4 +- hwe/sammo/API/General/GetFrontInfo.php | 6 +- hwe/sammo/API/Global/GeneralList.php | 9 +- hwe/sammo/API/Nation/GeneralList.php | 32 ++++--- hwe/sammo/Enums/GeneralAccessLogColumn.php | 4 +- hwe/sammo/Enums/GeneralColumn.php | 2 - hwe/sammo/General.php | 83 ++++++++++++++----- hwe/test-ts/formatScore.test.ts | 70 ++++++++-------- hwe/ts/components/GeneralBasicCard.vue | 8 +- hwe/ts/components/GeneralList.vue | 18 ++-- hwe/ts/components/GeneralLiteCard.vue | 8 +- hwe/ts/defs/API/Nation.ts | 4 +- hwe/ts/defs/gridDefs.ts | 12 +-- hwe/ts/defs/index.ts | 4 +- hwe/ts/select_npc.ts | 2 +- ...tConnectScore.ts => formatRefreshScore.ts} | 10 +-- hwe/ts/utilGame/index.ts | 2 +- 22 files changed, 194 insertions(+), 131 deletions(-) rename hwe/ts/utilGame/{formatConnectScore.ts => formatRefreshScore.ts} (51%) diff --git a/hwe/a_genList.php b/hwe/a_genList.php index d9a7e45f..aebeac24 100644 --- a/hwe/a_genList.php +++ b/hwe/a_genList.php @@ -102,7 +102,7 @@ if ($gameStor->isunited) { 6 => ['dedication', true], 7 => ['officer_level', true], 8 => ['killturn', false], - 9 => ['connect', true], + 9 => ['refresh_score_total', true], 10 => ['experience', true], 11 => ['personal', true], 12 => ['special', true], @@ -111,7 +111,12 @@ if ($gameStor->isunited) { 15 => ['npc', true], ][$type]; - $generalList = $db->query('SELECT owner,no,picture,imgsvr,npc,age,nation,special,special2,personal,name,injury,leadership,strength,intel,experience,dedication,officer_level,killturn,connect from general order by %b %l', $orderKey, $orderDesc ? 'desc' : ''); + $generalList = $db->query( + 'SELECT owner,no,picture,imgsvr,npc,age,nation,special,special2,personal,name,injury,leadership,strength,intel,experience,dedication,officer_level,killturn,refresh_score_total + FROM `general` LEFT JOIN `general_access_log` ON general.no = general_access_log.general_id order by %b %l', + $orderKey, + $orderDesc ? 'desc' : '' + ); echo " @@ -163,7 +168,7 @@ if ($gameStor->isunited) { $name = $name . '
(' . $ownerNameList[$general['owner']] . ')'; } - $general['connect'] = Util::round($general['connect'], -1); + $general['refresh_score_total'] = Util::round($general['refresh_score_total'], -1); $imageTemp = GetImageURL($general['imgsvr']); echo " @@ -192,8 +197,8 @@ if ($gameStor->isunited) { - + "; } echo " diff --git a/hwe/a_traffic.php b/hwe/a_traffic.php index f66f39ad..cf37a83f 100644 --- a/hwe/a_traffic.php +++ b/hwe/a_traffic.php @@ -25,10 +25,10 @@ $online = []; $curonline = getOnlineNum(); foreach ($log as $i => $value) { $parse = Json::decode($value); - if(is_array($parse) === false){ + if (is_array($parse) === false) { continue; } - if(count($parse) < 5){ + if (count($parse) < 5) { continue; } $date[$i] = $parse[0]; @@ -196,16 +196,14 @@ if ($admin['maxonline'] < $curonline) { $db->queryFirstField('SELECT sum(`connect`) as `connect` from general'), - 'refresh' => $db->queryFirstField('SELECT sum(`refresh`) as `refresh` from general_access_log'), + ...$db->queryFirstRow('SELECT sum(`refresh`) as `refresh`, sum(`refresh_score_total`) as `refresh_score_total` from general_access_log'), 'name' => '접속자 총합' ]; $top5Refresh = $db->query( - 'SELECT `name`, `log`.`refresh`, `connect` FROM `general_access_log` AS `log` - INNER JOIN `general` ON `log`.`general_id` = `general`.`no` ORDER BY `log`.`refresh` DESC LIMIT 5'); - - $refresh_result = array_merge([$max_refresh], $db->query('SELECT `no`,`name`,refresh,`connect` FROM general ORDER BY refresh DESC LIMIT 5')); + 'SELECT `name`, `log`.`refresh`, `refresh_score_total` FROM `general_access_log` AS `log` + INNER JOIN `general` ON `log`.`general_id` = `general`.`no` ORDER BY `log`.`refresh` DESC LIMIT 5' + ); foreach (array_merge([$totalRefresh], $top5Refresh) as $i => $user) { $w = round($user['refresh'] / max(1, $max_refresh['refresh']) * 100, 1); @@ -214,7 +212,7 @@ if ($admin['maxonline'] < $curonline) { ?> - +
$strength $intel {$general['killturn']}{$general['connect']}"; - echo "
【" . getConnect($general['connect']) . "】
" . $general['refresh_score_total'] ?? 0; + echo "
【" . getRefreshScoreText($general['refresh_score_total'] ?? 0) . "】
()() diff --git a/hwe/b_myGenInfo.php b/hwe/b_myGenInfo.php index 5e3bec52..8045c7f0 100644 --- a/hwe/b_myGenInfo.php +++ b/hwe/b_myGenInfo.php @@ -97,7 +97,7 @@ if ($gameStor->isunited) { 7 => ['gold', true], 8 => ['rice', true], 9 => ['crew', true], - 10 => ['connect', true], + 10 => ['refresh_score_total', true], 11 => ['personal', true], 12 => ['special', true], 13 => ['special2', true], @@ -105,7 +105,9 @@ if ($gameStor->isunited) { 15 => ['npc', true], ][$type]; - $generalList = $db->query('SELECT owner,no,picture,imgsvr,npc,age,nation,special,special2,personal,name,injury,leadership,strength,intel,experience,dedication,officer_level,killturn,connect,gold,rice,crew,belong from general where nation = %i order by %b %l', $me['nation'], $orderKey, $orderDesc ? 'desc' : ''); + $generalList = $db->query( + 'SELECT owner,no,picture,imgsvr,npc,age,nation,special,special2,personal,name,injury,leadership,strength,intel,experience,dedication,officer_level,killturn,refresh_score_total,gold,rice,crew,belong + FROM `general` LEFT JOIN `general_access_log` ON general.no = general_access_log.general_id where nation = %i order by %b %l', $me['nation'], $orderKey, $orderDesc ? 'desc' : ''); echo " @@ -173,8 +175,8 @@ if ($gameStor->isunited) { - + "; } echo " diff --git a/hwe/func.php b/hwe/func.php index 8ab5cc54..b1ed51b6 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -644,7 +644,7 @@ function generalInfo(General $generalObj) $age = "{$age} 세"; } - $connectCnt = round($generalObj->getVar('connect'), -1); + $refreshScoreTotal = round($generalObj->getVar(GeneralAccessLogColumn::refreshScoreTotal) ?? 0, -1); $specialDomestic = $generalObj->getVar('special') === GameConst::$defaultSpecialDomestic ? "{$generalObj->getVar('specage')}세" : "" . displayiActionObjInfo($generalObj->getSpecialDomestic()) . ""; @@ -753,7 +753,7 @@ function generalInfo(General $generalObj) - +
" . displayCharInfo($general['personal']) . " " . displaySpecialDomesticInfo($general['special']) . " / " . displaySpecialWarInfo($general['special2']) . " {$general['belong']}{$general['connect']}"; - echo "
(" . getConnect($general['connect']) . ")
". $general['refresh_score_total'] ?? 0; + echo "
(" . getRefreshScoreText($general['refresh_score_total'] ?? 0) . ")
부대 {$troopInfo} 벌점" . getConnect($connectCnt) . " {$connectCnt}({$generalObj->getVar('con')})" . getRefreshScoreText($refreshScoreTotal) . " {$refreshScoreTotal}({$generalObj->getVar('con')})
"; } diff --git a/hwe/func_converter.php b/hwe/func_converter.php index 8015975f..84bbf0ca 100644 --- a/hwe/func_converter.php +++ b/hwe/func_converter.php @@ -133,7 +133,7 @@ function getNationType(?string $type) { } -function getConnect($con) { +function getRefreshScoreText($con) { if($con < 50) $conname = '안함'; elseif($con < 100) $conname = '무관심'; elseif($con < 200) $conname = '가끔'; diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index 7955d031..bc4f491c 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -202,8 +202,10 @@ function preUpdateMonthly() $admin = $gameStor->getValues(['startyear', 'year', 'month']); //접률감소, 건국제한-1 + $db->update('general_access_log', [ + 'refresh_score_total' => $db->sqleval('floor(refresh_score_total*0.99)'), + ], true); $db->update('general', [ - 'connect' => $db->sqleval('floor(connect*0.99)'), 'makelimit' => $db->sqleval('greatest(0, makelimit - 1)'), ], true); //전략제한-1, 외교제한-1, 세율동기화 diff --git a/hwe/sammo/API/General/GetFrontInfo.php b/hwe/sammo/API/General/GetFrontInfo.php index 035e3901..dfddd964 100644 --- a/hwe/sammo/API/General/GetFrontInfo.php +++ b/hwe/sammo/API/General/GetFrontInfo.php @@ -9,6 +9,7 @@ use sammo\DB; use sammo\DTO\VoteInfo; use sammo\Enums\APIRecoveryType; use sammo\Enums\CityColumn; +use sammo\Enums\GeneralAccessLogColumn; use sammo\Enums\GeneralColumn; use sammo\Enums\RankColumn; use sammo\GameConst; @@ -383,7 +384,8 @@ class GetFrontInfo extends \sammo\BaseAPI 'specialWar' => $general->getVar(GeneralColumn::special2), // GameObjClassKey; 'personal' => $general->getVar(GeneralColumn::personal), // GameObjClassKey; 'belong' => $general->getVar(GeneralColumn::belong), // number; - 'connect' => $general->getVar(GeneralColumn::connect), // number; + + 'refreshScoreTotal' => $general->getVar(GeneralAccessLogColumn::refreshScoreTotal), // number; 'officerLevel' => $general->getVar(GeneralColumn::officer_level), // number; 'officerLevelText' => getOfficerLevelText($general->getVar(GeneralColumn::officer_level), $rawNation['level']), // string; @@ -400,7 +402,7 @@ class GetFrontInfo extends \sammo\BaseAPI 'troop' => $general->getVar(GeneralColumn::troop), // number; //P0 End - 'con' => $general->getVar(GeneralColumn::con), // number; + 'refreshScore' => $general->getVar(GeneralAccessLogColumn::refreshScore), // number; 'specage' => $general->getVar(GeneralColumn::specage), // number; 'specage2' => $general->getVar(GeneralColumn::specage2), // number; 'leadership_exp' => $general->getVar(GeneralColumn::leadership_exp), // number; diff --git a/hwe/sammo/API/Global/GeneralList.php b/hwe/sammo/API/Global/GeneralList.php index dd54b7df..5355bb2d 100644 --- a/hwe/sammo/API/Global/GeneralList.php +++ b/hwe/sammo/API/Global/GeneralList.php @@ -62,7 +62,8 @@ class GeneralList extends \sammo\BaseAPI $session->setReadOnly(); - $rawGeneralList = $db->queryAllLists('SELECT owner,no,picture,imgsvr,npc,age,nation,special,special2,personal,name,owner_name as ownerName,injury,leadership,strength,intel,experience,dedication,officer_level,killturn,connect from general'); + $rawGeneralList = $db->queryAllLists( + 'SELECT owner,no,picture,imgsvr,npc,age,nation,special,special2,personal,name,owner_name as ownerName,injury,leadership,strength,intel,experience,dedication,officer_level,killturn,refresh_score_total from `general` LEFT JOIN `general_access_log` ON general.no = general_access_log.general_id'); $ownerNameList = []; if ($gameStor->isunited) { @@ -73,7 +74,7 @@ class GeneralList extends \sammo\BaseAPI $generalList = []; foreach ($rawGeneralList as $rawGeneral) { - [$owner, $no, $picture, $imgsvr, $npc, $age, $nation, $special, $special2, $personal, $name, $ownerName, $injury, $leadership, $strength, $intel, $experience, $dedication, $officerLevel, $killturn, $connectCnt] = $rawGeneral; + [$owner, $no, $picture, $imgsvr, $npc, $age, $nation, $special, $special2, $personal, $name, $ownerName, $injury, $leadership, $strength, $intel, $experience, $dedication, $officerLevel, $killturn, $refreshScoreTotal] = $rawGeneral; if (key_exists($owner, $ownerNameList)) { $ownerName = $ownerNameList[$owner]; @@ -104,7 +105,7 @@ class GeneralList extends \sammo\BaseAPI getDed($dedication), getOfficerLevelText($officerLevel, $nationArr['level']), $killturn, - $connectCnt + $refreshScoreTotal ]; } @@ -129,6 +130,8 @@ class GeneralList extends \sammo\BaseAPI 'honorText', 'dedLevelText', 'officerLevelText', + 'killturn', + 'refreshScoreTotal', ]; $result = [ diff --git a/hwe/sammo/API/Nation/GeneralList.php b/hwe/sammo/API/Nation/GeneralList.php index 7aee9809..17c9011d 100644 --- a/hwe/sammo/API/Nation/GeneralList.php +++ b/hwe/sammo/API/Nation/GeneralList.php @@ -44,12 +44,10 @@ class GeneralList extends \sammo\BaseAPI 'special2' => 0, 'personal' => 0, 'belong' => 0, - 'connect' => 0, 'troop' => 0, 'city' => 0, - 'con' => 1, 'specage' => 0, 'specage2' => 0, 'leadership_exp' => 1, @@ -83,6 +81,11 @@ class GeneralList extends \sammo\BaseAPI 'owner_name' => 9, //안씀. + + //acessLog + 'refresh_score_total' => 0, + 'refresh_score' => 1, + //RANK 'warnum' => 1, 'killnum' => 1, @@ -156,9 +159,18 @@ class GeneralList extends \sammo\BaseAPI - [$queryColumns, $rankColumns] = General::mergeQueryColumn(array_keys(static::$viewColumns), 1); + [$queryColumns, $rankColumns, $accessLogColumns] = General::mergeQueryColumn(array_keys(static::$viewColumns), 1); - $rawGeneralList = Util::convertArrayToDict($db->query('SELECT %l from general WHERE nation = %i ORDER BY turntime ASC', Util::formatListOfBackticks($queryColumns), $nationID), 'no'); + $rawGeneralList = Util::convertArrayToDict( + $db->query( + 'SELECT %l, %l from `general` LEFT JOIN general_access_log + ON `general`.`no` = general_access_log.general_id WHERE nation = %i ORDER BY turntime ASC', + Util::formatListOfBackticks($queryColumns), + Util::formatListOfBackticks($accessLogColumns), + $nationID + ), + 'no' + ); /** @var ArrayObject[] */ $troops = []; @@ -179,19 +191,19 @@ class GeneralList extends \sammo\BaseAPI if ($this->permission >= 1 || count($troops)) { $reservedCommandTargetGeneralIDList = []; - if($this->permission >= 1){ + if ($this->permission >= 1) { foreach ($rawGeneralList as $rawGeneral) { if ($rawGeneral['npc'] < 2) { $reservedCommandTargetGeneralIDList[$rawGeneral['no']] = $rawGeneral['no']; } } } - foreach($troops as $troop){ + foreach ($troops as $troop) { $reservedCommandTargetGeneralIDList[$troop['id']] = $troop['id']; } - if($reservedCommandTargetGeneralIDList){ + if ($reservedCommandTargetGeneralIDList) { $rawTurnList = $db->query( 'SELECT general_id, turn_idx, action, arg, brief FROM general_turn WHERE general_id IN %li AND turn_idx < 5 ORDER BY general_id asc, turn_idx asc', array_values($reservedCommandTargetGeneralIDList) @@ -278,11 +290,11 @@ class GeneralList extends \sammo\BaseAPI $resultColumns[$column] = $column; } - foreach ($troops as $troop){ + foreach ($troops as $troop) { $troopLeaderID = $troop['id']; - $troop['reservedCommand'] = array_map(function($turnObj){ + $troop['reservedCommand'] = array_map(function ($turnObj) { $brief = $turnObj['brief']; - if($brief == '집합'){ + if ($brief == '집합') { return $brief; } return '-'; diff --git a/hwe/sammo/Enums/GeneralAccessLogColumn.php b/hwe/sammo/Enums/GeneralAccessLogColumn.php index 05bc14c3..0119e116 100644 --- a/hwe/sammo/Enums/GeneralAccessLogColumn.php +++ b/hwe/sammo/Enums/GeneralAccessLogColumn.php @@ -9,6 +9,6 @@ enum GeneralAccessLogColumn: string { case lastRefresh = 'last_refresh'; case refresh = 'refresh'; //순간 갱신 횟수(00:00에 초기화) case refreshTotal = 'refresh_total'; //누적 갱신 횟수 - case refreshScore = 'refreshScore'; //순간 벌점(턴 시간에 초기화) - case refreshScoreTotal = 'refreshScoreTotal'; //누적 벌점(지속적으로 감소, refreshScoreTotal <= refreshTotal) + case refreshScore = 'refresh_score'; //순간 벌점(턴 시간에 초기화) + case refreshScoreTotal = 'refresh_score_total'; //누적 벌점(지속적으로 감소, refreshScoreTotal <= refreshTotal) } \ No newline at end of file diff --git a/hwe/sammo/Enums/GeneralColumn.php b/hwe/sammo/Enums/GeneralColumn.php index ebdefcd6..1f4b3a74 100644 --- a/hwe/sammo/Enums/GeneralColumn.php +++ b/hwe/sammo/Enums/GeneralColumn.php @@ -15,8 +15,6 @@ enum GeneralColumn: string{ case bornyear = 'bornyear'; case deadyear = 'deadyear'; case newmsg = 'newmsg'; - case con = 'con'; - case connect = 'connect'; case picture = 'picture'; case imgsvr = 'imgsvr'; case name = 'name'; diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index fbbd806c..1980238a 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -330,7 +330,7 @@ class General implements iAction function getCrewTypeObj(): GameUnitDetail { - if($this->crewType === null) { + if ($this->crewType === null) { throw new \InvalidArgumentException('Invalid CrewType:' . $this->getVar('crewtype')); } return $this->crewType; @@ -845,7 +845,7 @@ class General implements iAction $this->increaseVar($statName, -1); $result = true; } else if ($this->getVar($statExpName) >= $limit) { - if($this->getVar($statName) < GameConst::$maxLevel) { + if ($this->getVar($statName) < GameConst::$maxLevel) { $logger->pushGeneralActionLog("{$statNickName}이 1 올랐습니다!", ActionLogger::PLAIN); $this->increaseVar($statName, 1); } @@ -857,7 +857,8 @@ class General implements iAction return $result; } - protected function getActionList(): array{ + protected function getActionList(): array + { return array_merge([ $this->nationType, $this->officerLevelObj, @@ -1024,7 +1025,7 @@ class General implements iAction 'personal', 'special', 'special2', 'defence_train', 'tnmt', 'npc', 'npc_org', 'deadyear', 'npcmsg', 'dex1', 'dex2', 'dex3', 'dex4', 'dex5', 'betray', 'recent_war', 'last_turn', 'myset', - 'specage', 'specage2', 'con', 'connect', 'aux', 'permission', 'penalty', + 'specage', 'specage2', 'refresh_score', 'refresh_score_total', 'aux', 'permission', 'penalty', ]; if ($reqColumns === null) { @@ -1034,25 +1035,36 @@ class General implements iAction /** @var RankColumn[] */ $rankColumn = []; $subColumn = []; + $accessLogColumn = []; foreach ($reqColumns as $column) { if ($column instanceof RankColumn) { $rankColumn[] = $column; continue; } - - $rankKey = RankColumn::tryFrom($column); - if ($rankKey !== null) { - $rankColumn[] = $rankKey; - } else { - $subColumn[] = $column; + if ($column instanceof GeneralAccessLogColumn) { + $accessLogColumn[] = $column; + continue; } + + + $enumKey = RankColumn::tryFrom($column); + if ($enumKey !== null) { + $rankColumn[] = $enumKey; + continue; + } + $enumKey = GeneralAccessLogColumn::tryFrom($column); + if ($enumKey !== null) { + $accessLogColumn[] = $enumKey; + continue; + } + $subColumn[] = $column; } if ($constructMode > 1) { - return [array_unique(array_merge($defaultEventColumn, $subColumn)), $rankColumn]; + return [array_unique(array_merge($defaultEventColumn, $subColumn)), $rankColumn, $accessLogColumn]; } - return [array_unique(array_merge($minimumColumn, $subColumn)), $rankColumn]; + return [array_unique(array_merge($minimumColumn, $subColumn)), $rankColumn, $accessLogColumn]; } /** @@ -1080,20 +1092,49 @@ class General implements iAction /** * @var string[] $column * @var RankColumn[] $rankColumn + * @var GeneralAccessLogColumn[] $accessLogColumn */ - [$column, $rankColumn] = static::mergeQueryColumn($column, $constructMode); + [$column, $rankColumn, $accessLogColumn] = static::mergeQueryColumn($column, $constructMode); if ($generalIDList === null) { - $rawGenerals = Util::convertArrayToDict( - $db->query('SELECT %l FROM general WHERE 1', Util::formatListOfBackticks($column)), - 'no' - ); + if (!$accessLogColumn) { + $rawGenerals = Util::convertArrayToDict( + $db->query('SELECT %l FROM general WHERE 1', Util::formatListOfBackticks($column)), + 'no' + ); + } else { + $rawGenerals = Util::convertArrayToDict( + $db->query( + 'SELECT %l, %l FROM `general` LEFT JOIN general_access_log + ON general.no = general_access_log.general_id WHERE 1', + Util::formatListOfBackticks($column), + Util::formatListOfBackticks($accessLogColumn) + ), + 'no' + ); + } + $generalIDList = array_keys($rawGenerals); } else { - $rawGenerals = Util::convertArrayToDict( - $db->query('SELECT %l FROM general WHERE no IN %li', Util::formatListOfBackticks($column), $generalIDList), - 'no' - ); + if(!$accessLogColumn){ + $rawGenerals = Util::convertArrayToDict( + $db->query('SELECT %l FROM general WHERE no IN %li', Util::formatListOfBackticks($column), $generalIDList), + 'no' + ); + } + else{ + $rawGenerals = Util::convertArrayToDict( + $db->query( + 'SELECT %l, %l FROM `general` LEFT JOIN general_access_log + ON general.no = general_access_log.general_id WHERE no IN %li', + Util::formatListOfBackticks($column), + Util::formatListOfBackticks($accessLogColumn), + $generalIDList + ), + 'no' + ); + } + } diff --git a/hwe/test-ts/formatScore.test.ts b/hwe/test-ts/formatScore.test.ts index 771b1602..771702cb 100644 --- a/hwe/test-ts/formatScore.test.ts +++ b/hwe/test-ts/formatScore.test.ts @@ -1,48 +1,48 @@ import chai, { assert } from "chai"; import _ from "lodash-es"; -import { formatConnectScore } from "../ts/utilGame/formatConnectScore"; +import { formatRefreshScore } from "../ts/utilGame/formatRefreshScore"; import { formatDexLevel } from "../ts/utilGame/formatDexLevel"; import { formatDefenceTrain } from "../ts/utilGame/formatDefenceTrain"; import { formatHonor } from "../ts/utilGame/formatHonor"; -describe("formatConnectScore", () => { - it("connectScoreEqual", () => { - assert.equal(formatConnectScore(0), "안함"); - assert.equal(formatConnectScore(50), "무관심"); - assert.equal(formatConnectScore(100), "보통"); - assert.equal(formatConnectScore(200), "가끔"); - assert.equal(formatConnectScore(400), "자주"); - assert.equal(formatConnectScore(800), "열심"); - assert.equal(formatConnectScore(1600), "중독"); - assert.equal(formatConnectScore(3200), "폐인"); - assert.equal(formatConnectScore(6400), "경고"); - assert.equal(formatConnectScore(12800), "헐..."); +describe("formatRefreshScore", () => { + it("refreshScoreEqual", () => { + assert.equal(formatRefreshScore(0), "안함"); + assert.equal(formatRefreshScore(50), "무관심"); + assert.equal(formatRefreshScore(100), "보통"); + assert.equal(formatRefreshScore(200), "가끔"); + assert.equal(formatRefreshScore(400), "자주"); + assert.equal(formatRefreshScore(800), "열심"); + assert.equal(formatRefreshScore(1600), "중독"); + assert.equal(formatRefreshScore(3200), "폐인"); + assert.equal(formatRefreshScore(6400), "경고"); + assert.equal(formatRefreshScore(12800), "헐..."); }); - it("connectScore+1", () => { - assert.equal(formatConnectScore(1), "안함"); - assert.equal(formatConnectScore(51), "무관심"); - assert.equal(formatConnectScore(101), "보통"); - assert.equal(formatConnectScore(201), "가끔"); - assert.equal(formatConnectScore(401), "자주"); - assert.equal(formatConnectScore(801), "열심"); - assert.equal(formatConnectScore(1601), "중독"); - assert.equal(formatConnectScore(3201), "폐인"); - assert.equal(formatConnectScore(6401), "경고"); - assert.equal(formatConnectScore(12801), "헐..."); + it("refreshScore+1", () => { + assert.equal(formatRefreshScore(1), "안함"); + assert.equal(formatRefreshScore(51), "무관심"); + assert.equal(formatRefreshScore(101), "보통"); + assert.equal(formatRefreshScore(201), "가끔"); + assert.equal(formatRefreshScore(401), "자주"); + assert.equal(formatRefreshScore(801), "열심"); + assert.equal(formatRefreshScore(1601), "중독"); + assert.equal(formatRefreshScore(3201), "폐인"); + assert.equal(formatRefreshScore(6401), "경고"); + assert.equal(formatRefreshScore(12801), "헐..."); }); - it("connectScoreF-1", () => { - assert.equal(formatConnectScore(49), "안함"); - assert.equal(formatConnectScore(99), "무관심"); - assert.equal(formatConnectScore(199), "보통"); - assert.equal(formatConnectScore(399), "가끔"); - assert.equal(formatConnectScore(799), "자주"); - assert.equal(formatConnectScore(1599), "열심"); - assert.equal(formatConnectScore(3199), "중독"); - assert.equal(formatConnectScore(6399), "폐인"); - assert.equal(formatConnectScore(11799), "경고"); - assert.equal(formatConnectScore(20000), "헐..."); + it("refreshScoreF-1", () => { + assert.equal(formatRefreshScore(49), "안함"); + assert.equal(formatRefreshScore(99), "무관심"); + assert.equal(formatRefreshScore(199), "보통"); + assert.equal(formatRefreshScore(399), "가끔"); + assert.equal(formatRefreshScore(799), "자주"); + assert.equal(formatRefreshScore(1599), "열심"); + assert.equal(formatRefreshScore(3199), "중독"); + assert.equal(formatRefreshScore(6399), "폐인"); + assert.equal(formatRefreshScore(11799), "경고"); + assert.equal(formatRefreshScore(20000), "헐..."); }); }); diff --git a/hwe/ts/components/GeneralBasicCard.vue b/hwe/ts/components/GeneralBasicCard.vue index 0314516d..82b64512 100644 --- a/hwe/ts/components/GeneralBasicCard.vue +++ b/hwe/ts/components/GeneralBasicCard.vue @@ -151,8 +151,8 @@
벌점
-
- {{ formatConnectScore(general.connect) }} {{ general.connect.toLocaleString() }}점({{ general.con }}) +
+ {{ formatRefreshScore(general.refreshScoreTotal) }} {{ general.refreshScoreTotal.toLocaleString() }}점({{ general.refreshScore }})
@@ -168,7 +168,7 @@ import { unwrap } from "@/util/unwrap"; import type { GameConstStore } from "@/GameConstStore"; import { formatGeneralTypeCall } from "@/utilGame/formatGeneralTypeCall"; import { nextExpLevelRemain } from "@/utilGame/nextExpLevelRemain"; -import { formatConnectScore } from "@/utilGame/formatConnectScore"; +import { formatRefreshScore } from "@/utilGame/formatRefreshScore"; import SammoBar from "@/components/SammoBar.vue"; import { parseTime } from "@/util/parseTime"; import { clamp } from "lodash-es"; @@ -341,7 +341,7 @@ watch( grid-column: 2 / 4; } -.general-connect-score { +.general-refresh-score-total { grid-column: 5 / 8; } diff --git a/hwe/ts/components/GeneralList.vue b/hwe/ts/components/GeneralList.vue index 32c80188..df1de86b 100644 --- a/hwe/ts/components/GeneralList.vue +++ b/hwe/ts/components/GeneralList.vue @@ -106,7 +106,7 @@ import type { GameConstStore } from "@/GameConstStore"; import { unwrap } from "@/util/unwrap"; import SimpleTooltipCell from "@/gridCellRenderer/SimpleTooltipCell.vue"; import GridTooltipCell, { type GridCellInfo } from "@/gridCellRenderer/GridTooltipCell.vue"; -import { formatConnectScore } from "@/utilGame/formatConnectScore"; +import { formatRefreshScore } from "@/utilGame/formatRefreshScore"; import { convertSearch초성 } from "@/util/convertSearch초성"; import { isString } from "lodash-es"; import { formatDefenceTrain } from "@/utilGame/formatDefenceTrain"; @@ -353,7 +353,7 @@ type headerType = | "trainAtmos" | "specials" | "reservedCommandShort" - | "killturnAndConnect" + | "killturnAndRefresh" | "years" | "warResults"; @@ -1117,18 +1117,18 @@ const columnRawDefs = ref }, ], }, - killturnAndConnect: { - groupId: "killturnAndConnect", + killturnAndRefresh: { + groupId: "killturnAndRefresh", headerName: "기타", children: [ { - colId: "killturnAndConnect", + colId: "killturnAndRefresh", headerName: "삭/벌", cellRenderer: ({ data }: GenValueParams) => { if (data === undefined) { return "?"; } - return `${data.killturn.toLocaleString()}턴
${data.connect.toLocaleString()}점`; + return `${data.killturn.toLocaleString()}턴
${data.refreshScoreTotal.toLocaleString()}점`; }, cellClass: rightAlignClass, columnGroupShow: "closed", @@ -1149,14 +1149,14 @@ const columnRawDefs = ref columnGroupShow: "open", }, { - colId: "connect", + colId: "refreshScoreTotal", headerName: "벌점", - field: "connect", + field: "refreshScoreTotal", cellRenderer: ({ data }: GenValueParams) => { if (data === undefined) { return "?"; } - return `${data.connect.toLocaleString()}점
(${formatConnectScore(data.connect)})`; + return `${data.refreshScoreTotal.toLocaleString()}점
(${formatRefreshScore(data.refreshScoreTotal)})`; }, ...sortableNumber, width: 70, diff --git a/hwe/ts/components/GeneralLiteCard.vue b/hwe/ts/components/GeneralLiteCard.vue index c1a57f74..af4fd67d 100644 --- a/hwe/ts/components/GeneralLiteCard.vue +++ b/hwe/ts/components/GeneralLiteCard.vue @@ -78,8 +78,8 @@
{{ general.killturn }} 턴
벌점
-
- {{ formatConnectScore(general.connect) }} {{ general.connect.toLocaleString() }}점 +
+ {{ formatRefreshScore(general.refreshScoreTotal) }} {{ general.refreshScoreTotal.toLocaleString() }}점
@@ -94,7 +94,7 @@ import type { NationStaticItem } from "@/defs"; import { unwrap } from "@/util/unwrap"; import type { GameConstStore } from "@/GameConstStore"; import { formatGeneralTypeCall } from "@/utilGame/formatGeneralTypeCall"; -import { formatConnectScore } from "@/utilGame/formatConnectScore"; +import { formatRefreshScore } from "@/utilGame/formatRefreshScore"; import { calcInjury } from "@/utilGame/calcInjury"; import type { GameIActionInfo } from "@/defs/GameObj"; import { isValidObjKey } from "@/utilGame/isValidObjKey"; @@ -204,7 +204,7 @@ watch( font-weight: bold; } -.general-connect-score { +.general-refresh-score-total { grid-column: 5 / 8; } diff --git a/hwe/ts/defs/API/Nation.ts b/hwe/ts/defs/API/Nation.ts index 38b49a7c..2f88ecb3 100644 --- a/hwe/ts/defs/API/Nation.ts +++ b/hwe/ts/defs/API/Nation.ts @@ -27,7 +27,7 @@ export type GeneralListItemP0 = { specialWar: GameObjClassKey; personal: GameObjClassKey; belong: number; - connect: number; + refreshScoreTotal: number; officerLevel: number; //권한에따라 태수,군사,시종 노출 여부가 다름 officerLevelText: string; @@ -46,7 +46,7 @@ export type GeneralListItemP0 = { }; export type GeneralListItemP1 = { - con: number; + refreshScore: number; specage: number; specage2: number; leadership_exp: number; diff --git a/hwe/ts/defs/gridDefs.ts b/hwe/ts/defs/gridDefs.ts index 1eca66a7..ff680414 100644 --- a/hwe/ts/defs/gridDefs.ts +++ b/hwe/ts/defs/gridDefs.ts @@ -210,7 +210,7 @@ export const defaultDisplaySetting: Record<"war" | "normal", GridDisplaySetting> sort: null, }, { - colId: "killturnAndConnect_1", + colId: "killturnAndRefresh_1", width: 70, hide: false, sort: null, @@ -222,7 +222,7 @@ export const defaultDisplaySetting: Record<"war" | "normal", GridDisplaySetting> sort: null, }, { - colId: "connect", + colId: "refreshScoreTotal", width: 70, hide: true, sort: null, @@ -310,7 +310,7 @@ export const defaultDisplaySetting: Record<"war" | "normal", GridDisplaySetting> open: false, }, { - groupId: "killturnAndConnect", + groupId: "killturnAndRefresh", open: true, }, { @@ -522,7 +522,7 @@ export const defaultDisplaySetting: Record<"war" | "normal", GridDisplaySetting> sort: null, }, { - colId: "killturnAndConnect_1", + colId: "killturnAndRefresh_1", width: 70, hide: false, sort: null, @@ -534,7 +534,7 @@ export const defaultDisplaySetting: Record<"war" | "normal", GridDisplaySetting> sort: null, }, { - colId: "connect", + colId: "refreshScoreTotal", width: 70, hide: false, sort: "desc", @@ -623,7 +623,7 @@ export const defaultDisplaySetting: Record<"war" | "normal", GridDisplaySetting> open: false }, { - groupId: "killturnAndConnect", + groupId: "killturnAndRefresh", open: true }, { diff --git a/hwe/ts/defs/index.ts b/hwe/ts/defs/index.ts index 9b43eaf1..be20079a 100644 --- a/hwe/ts/defs/index.ts +++ b/hwe/ts/defs/index.ts @@ -39,7 +39,7 @@ export type PublicGeneralItem = { dedicationStr: string, officerLevelStr: string, killturn: number, - connect: number, + refreshScoreTotal: number, } @@ -55,7 +55,7 @@ export type GeneralListResponse = { PublicGeneralItem['leadership'], PublicGeneralItem['lbonus'], PublicGeneralItem['strength'], PublicGeneralItem['intel'], PublicGeneralItem['explevel'], PublicGeneralItem['experienceStr'], PublicGeneralItem['dedicationStr'], PublicGeneralItem['officerLevelStr'], - PublicGeneralItem['killturn'], PublicGeneralItem['connect'] + PublicGeneralItem['killturn'], PublicGeneralItem['refreshScoreTotal'] ][], token?: Record, } diff --git a/hwe/ts/select_npc.ts b/hwe/ts/select_npc.ts index dd986bbc..354fbd32 100644 --- a/hwe/ts/select_npc.ts +++ b/hwe/ts/select_npc.ts @@ -273,7 +273,7 @@ function printGeneralList(value: GeneralListResponse) { dedicationStr: rawGeneral[18], officerLevelStr: rawGeneral[19], killturn: rawGeneral[20], - connect: rawGeneral[21], + refreshScoreTotal: rawGeneral[21], reserved: 0 }; if (general.npc < 2) { diff --git a/hwe/ts/utilGame/formatConnectScore.ts b/hwe/ts/utilGame/formatRefreshScore.ts similarity index 51% rename from hwe/ts/utilGame/formatConnectScore.ts rename to hwe/ts/utilGame/formatRefreshScore.ts index 73e869a0..677e9f74 100644 --- a/hwe/ts/utilGame/formatConnectScore.ts +++ b/hwe/ts/utilGame/formatRefreshScore.ts @@ -1,6 +1,6 @@ import bs from "binary-search"; -const connectMap: [number, string][] = [ +const refreshScoreMap: [number, string][] = [ [0, "안함"], [50, "무관심"], [100, "보통"], @@ -13,11 +13,11 @@ const connectMap: [number, string][] = [ [12800, "헐..."], ]; -export function formatConnectScore(connect: number) { - const idx = bs(connectMap, connect, ([key], needle) => key - needle); +export function formatRefreshScore(refreshScore: number) { + const idx = bs(refreshScoreMap, refreshScore, ([key], needle) => key - needle); if (idx >= 0) { - return connectMap[idx][1] ?? "?"; + return refreshScoreMap[idx][1] ?? "?"; } const uidx = (~idx) - 1; - return connectMap[uidx][1]; + return refreshScoreMap[uidx][1]; } diff --git a/hwe/ts/utilGame/index.ts b/hwe/ts/utilGame/index.ts index cf9046a0..66a96717 100644 --- a/hwe/ts/utilGame/index.ts +++ b/hwe/ts/utilGame/index.ts @@ -1,6 +1,6 @@ export { calcInjury } from './calcInjury'; export { formatCityName } from './formatCityName'; -export { formatConnectScore } from './formatConnectScore'; +export { formatRefreshScore } from './formatRefreshScore'; export { formatDefenceTrain } from './formatDefenceTrain'; export { formatDexLevel } from './formatDexLevel'; export { formatGeneralTypeCall } from './formatGeneralTypeCall';