From f8cc0c9c92f1e0d0082971ab001a96a940e94f7c Mon Sep 17 00:00:00 2001 From: Hide_D Date: Tue, 4 Jul 2023 16:09:32 +0000 Subject: [PATCH 01/21] =?UTF-8?q?feat:=20GeneralAccessLog=20table=20?= =?UTF-8?q?=EC=A4=80=EB=B9=84=20-=20general=20=ED=85=8C=EC=9D=B4=EB=B8=94?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=9C=A0=EC=A0=80=20=EC=A0=91=EC=86=8D?= =?UTF-8?q?=EA=B3=BC=20=EA=B4=80=EB=A0=A8=ED=95=9C=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EB=A7=8C=20=EB=B6=84=EB=A6=AC=20-=20ip=20=EC=A0=95=EB=B3=B4?= =?UTF-8?q?=EB=8A=94=20api=20=EC=A0=91=EC=86=8D=EB=B6=80=EC=97=90=EC=84=9C?= =?UTF-8?q?=20=EA=B8=B0=EB=A1=9D=ED=95=98=EB=AF=80=EB=A1=9C=20=EC=A0=9C?= =?UTF-8?q?=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/DTO/GeneralAccessLog.php | 42 ++++++++++++++++++++++ hwe/sammo/Enums/GeneralAccessLogColumn.php | 15 ++++++++ hwe/sql/reset.sql | 1 + hwe/sql/schema.sql | 17 +++++++++ 4 files changed, 75 insertions(+) create mode 100644 hwe/sammo/DTO/GeneralAccessLog.php create mode 100644 hwe/sammo/Enums/GeneralAccessLogColumn.php diff --git a/hwe/sammo/DTO/GeneralAccessLog.php b/hwe/sammo/DTO/GeneralAccessLog.php new file mode 100644 index 00000000..35898da0 --- /dev/null +++ b/hwe/sammo/DTO/GeneralAccessLog.php @@ -0,0 +1,42 @@ + Date: Tue, 4 Jul 2023 16:56:12 +0000 Subject: [PATCH 02/21] =?UTF-8?q?feat:=20GeneralAccessLog=20=EA=B5=AC?= =?UTF-8?q?=EC=A1=B0=20=EB=B3=80=EA=B2=BD=20-=20=EA=B8=B0=EB=B3=B8?= =?UTF-8?q?=EA=B0=92=20=EC=B5=9C=EB=8C=80=ED=95=9C=20=EB=A7=8E=EC=9D=B4=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/DTO/GeneralAccessLog.php | 5 +++-- hwe/sql/schema.sql | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/hwe/sammo/DTO/GeneralAccessLog.php b/hwe/sammo/DTO/GeneralAccessLog.php index 35898da0..6e4924b8 100644 --- a/hwe/sammo/DTO/GeneralAccessLog.php +++ b/hwe/sammo/DTO/GeneralAccessLog.php @@ -20,7 +20,8 @@ class GeneralAccessLog extends \LDTO\DTO public ?int $userID, #[RawName('nation_id')] - public int $nationID, + #[NullIsUndefined] + public ?int $nationID, #[RawName('last_refresh')] #[Convert(DateTimeConverter::class)] @@ -28,7 +29,7 @@ class GeneralAccessLog extends \LDTO\DTO #[RawName('last_connect')] #[Convert(DateTimeConverter::class)] - public \DateTimeImmutable $lastConnect, + public ?\DateTimeImmutable $lastConnect, #[RawName('login_total')] public int $loginTotal, diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index b99b3239..834e5c2b 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -106,12 +106,12 @@ CREATE TABLE `general_access_log` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `general_id` INT(11) NOT NULL, `user_id` INT(11) NULL DEFAULT NULL, - `nation_id` INT(11) NOT NULL, - `last_refresh` DATETIME NOT NULL, - `last_connect` DATETIME NOT NULL, - `login_total` INT(11) NOT NULL, - `refresh` INT(11) NOT NULL, - `refresh_total` INT(11) NOT NULL, + `nation_id` INT(11) NULL DEFAULT NULL, + `last_refresh` DATETIME NULL DEFAULT NULL, + `last_connect` DATETIME NULL DEFAULT NULL, + `login_total` INT(11) NOT NULL DEFAULT '0', + `refresh` INT(11) NOT NULL DEFAULT '0', + `refresh_total` INT(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE INDEX `general_id` (`general_id`), INDEX `nation_id` (`nation_id`) -- 2.54.0 From ea80b85b335303b7968c959c9613b755309c4550 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Tue, 4 Jul 2023 16:58:27 +0000 Subject: [PATCH 03/21] =?UTF-8?q?refac:=20=EA=B0=B1=EC=8B=A0=20=EC=8B=9C?= =?UTF-8?q?=20refresh=EB=A5=BC=20general=5Faccess=5Flog=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func.php | 22 ++++++++++++++-------- hwe/sammo/General.php | 7 +++++++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/hwe/func.php b/hwe/func.php index 4b70d3b5..8b2e7766 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -5,6 +5,7 @@ namespace sammo; use DateTime; use Ds\Set; use sammo\Enums\AuctionType; +use sammo\Enums\GeneralAccessLogColumn; use sammo\Enums\InheritanceKey; use sammo\Enums\RankColumn; @@ -998,7 +999,8 @@ function increaseRefresh($type = "", $cnt = 1) $generalID = $session->generalID; $userGrade = $session->userGrade; - $date = TimeUtil::now(); + $dateObj = new \DateTimeImmutable(); + $date = TimeUtil::format($dateObj, false); $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); @@ -1020,13 +1022,17 @@ function increaseRefresh($type = "", $cnt = 1) $gameStor->refresh = $gameStor->refresh + $cnt; //TODO: +로 증가하는 값은 별도로 분리 - $db->update('general', [ - 'lastrefresh' => $date, - 'con' => $db->sqleval('con + %i', $cnt), - 'connect' => $db->sqleval('connect + %i', $cnt), - 'refcnt' => $db->sqleval('refcnt + %i', $cnt), - 'refresh' => $db->sqleval('refresh + %i', $cnt) - ], 'owner=%i', $userID); + $db->insertUpdate('general_access_log', [ + GeneralAccessLogColumn::generalID->value => $generalID, + GeneralAccessLogColumn::userID->value => $userID, + GeneralAccessLogColumn::lastRefresh->value => $date, + GeneralAccessLogColumn::refreshTotal->value => $db->sqleval('%b + %i', GeneralAccessLogColumn::refreshTotal->value, $cnt), + GeneralAccessLogColumn::refresh->value => $db->sqleval('%b + %i', GeneralAccessLogColumn::refresh->value, $cnt), + ], [ + GeneralAccessLogColumn::lastRefresh->value => $date, + GeneralAccessLogColumn::refreshTotal->value => $db->sqleval('%b + %i', GeneralAccessLogColumn::refreshTotal->value, $cnt), + GeneralAccessLogColumn::refresh->value => $db->sqleval('%b + %i', GeneralAccessLogColumn::refresh->value, $cnt), + ]); $serverPath = __DIR__; diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index 03b8b7bc..b7a4b7fc 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -4,6 +4,7 @@ namespace sammo; use Ds\Map; use sammo\Command\GeneralCommand; +use sammo\Enums\GeneralAccessLogColumn; use sammo\Enums\InheritanceKey; use sammo\Enums\RankColumn; use sammo\WarUnitTrigger as WarUnitTrigger; @@ -792,6 +793,12 @@ class General implements iAction 'nation_id' => $updateVals['nation'] ], 'general_id = %i', $generalID); $result = true; + + if($this->getNPCType() < 2){ + $db->update('general_access_log', [ + GeneralAccessLogColumn::nationID->value => $updateVals['nation'] + ], '%b = %i', GeneralAccessLogColumn::generalID->value, $generalID); + } } $this->flushUpdateValues(); } -- 2.54.0 From b0cdf3ccb506eaa78a7dffa37fe83533fccf43a0 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Tue, 4 Jul 2023 17:00:46 +0000 Subject: [PATCH 04/21] =?UTF-8?q?refac:=20General::lastconnect=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20-=20=EC=95=88=EC=93=B0=EB=8A=94=EB=8D=B0..=3F=20-?= =?UTF-8?q?=20api=5Flog=EB=A1=9C=20=EC=96=B4=EB=8A=90=EC=83=88=20=EC=9D=B4?= =?UTF-8?q?=EC=A0=84=EB=90=9C=EA=B1=B4=EA=B0=80=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/API/General/Join.php | 1 - hwe/sammo/Enums/GeneralColumn.php | 1 - hwe/sql/schema.sql | 1 - 3 files changed, 3 deletions(-) diff --git a/hwe/sammo/API/General/Join.php b/hwe/sammo/API/General/Join.php index 15a95ea4..796dcc0b 100644 --- a/hwe/sammo/API/General/Join.php +++ b/hwe/sammo/API/General/Join.php @@ -414,7 +414,6 @@ class Join extends \sammo\BaseAPI 'officer_level' => 0, 'turntime' => $turntime, 'killturn' => 6, - 'lastconnect' => $now, 'lastrefresh' => $now, 'crewtype' => GameUnitConst::DEFAULT_CREWTYPE, 'makelimit' => 0, diff --git a/hwe/sammo/Enums/GeneralColumn.php b/hwe/sammo/Enums/GeneralColumn.php index ee3e6bac..dc40b6dd 100644 --- a/hwe/sammo/Enums/GeneralColumn.php +++ b/hwe/sammo/Enums/GeneralColumn.php @@ -58,7 +58,6 @@ enum GeneralColumn: string{ case recent_war = 'recent_war'; case makelimit = 'makelimit'; case killturn = 'killturn'; - case lastconnect = 'lastconnect'; case lastrefresh = 'lastrefresh'; case ip = 'ip'; case block = 'block'; diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index 834e5c2b..bff6f4cd 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -54,7 +54,6 @@ CREATE TABLE `general` ( `recent_war` DATETIME(6) NULL DEFAULT NULL, `makelimit` INT(2) NULL DEFAULT '0', `killturn` INT(3) NULL DEFAULT NULL, - `lastconnect` DATETIME NULL DEFAULT NULL, `lastrefresh` DATETIME NULL DEFAULT NULL, `ip` VARCHAR(40) NULL DEFAULT '', `block` INT(1) NULL DEFAULT '0', -- 2.54.0 From 50408ed5163945f71d052900ae8a5625203e1653 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Tue, 4 Jul 2023 17:12:02 +0000 Subject: [PATCH 05/21] feat: TableName Enum --- hwe/sammo/Enums/TableName.php | 60 +++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 hwe/sammo/Enums/TableName.php diff --git a/hwe/sammo/Enums/TableName.php b/hwe/sammo/Enums/TableName.php new file mode 100644 index 00000000..8e3f64a2 --- /dev/null +++ b/hwe/sammo/Enums/TableName.php @@ -0,0 +1,60 @@ + Date: Tue, 4 Jul 2023 17:29:57 +0000 Subject: [PATCH 06/21] =?UTF-8?q?refac:=20lastrefresh=EB=A5=BC=20general?= =?UTF-8?q?=5Faccess=5Flog=EB=A1=9C=20=EC=9D=B4=EC=A0=84=20-=20last=5Frefr?= =?UTF-8?q?esh=EC=97=90=20index=EB=A5=BC=20=EA=B1=B8=20=EA=B2=83=EC=9D=B8?= =?UTF-8?q?=EC=A7=80=EB=8A=94=20=EA=B3=A0=EB=A0=A4=20=ED=95=84=EC=9A=94=20?= =?UTF-8?q?=20=20-=20=EC=95=88=20=EA=B1=B0=EB=8A=94=EA=B2=8C=20=EC=B0=A8?= =?UTF-8?q?=EB=9D=BC=EB=A6=AC=20=EB=82=98=EC=9D=84=20=EC=88=98=EB=8F=84=20?= =?UTF-8?q?=EC=9E=88=EC=9D=8C=20-=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=B4?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EB=8A=94=20=EA=B0=92=20=ED=99=95=EC=9D=B8:?= =?UTF-8?q?=20nation=5Fid,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/b_myPage.php | 12 +++++++++- hwe/func.php | 24 +++++++++++++------ .../API/General/BuildNationCandidate.php | 2 +- hwe/sammo/API/General/DieOnPrestart.php | 11 +++++++-- hwe/sammo/API/General/Join.php | 8 ++++++- hwe/sammo/Enums/GeneralColumn.php | 1 - hwe/sammo/General.php | 2 +- hwe/sammo/Scenario/GeneralBuilder.php | 1 - hwe/sql/schema.sql | 2 -- 9 files changed, 46 insertions(+), 17 deletions(-) diff --git a/hwe/b_myPage.php b/hwe/b_myPage.php index ad96b814..d62183fc 100644 --- a/hwe/b_myPage.php +++ b/hwe/b_myPage.php @@ -2,6 +2,9 @@ namespace sammo; +use sammo\Enums\GeneralAccessLogColumn; +use sammo\Enums\TableName; + include "lib.php"; include "func.php"; @@ -29,7 +32,14 @@ if ($myset > 0) { $submit = 'hidden'; } -$targetTime = addTurn($me->getVar('lastrefresh'), $gameStor->turnterm, GameConst::$minTurnDieOnPrestart); +$lastRefresh = $db->queryFirstField( + 'SELECT %b FROM %b WHERE %b = %i', + GeneralAccessLogColumn::lastRefresh->value, + TableName::generalAccessLog->value, + GeneralAccessLogColumn::generalID->value, $generalID +); + +$targetTime = addTurn($lastRefresh, $gameStor->turnterm, GameConst::$minTurnDieOnPrestart); if ($gameStor->turntime <= $gameStor->opentime) { //서버 가오픈시 할 수 있는 행동 if ($me->getNPCType() == 0 && $me->getNationID() == 0) { diff --git a/hwe/func.php b/hwe/func.php index 8b2e7766..9f253179 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -6,6 +6,7 @@ use DateTime; use Ds\Set; use sammo\Enums\AuctionType; use sammo\Enums\GeneralAccessLogColumn; +use sammo\Enums\GeneralColumn; use sammo\Enums\InheritanceKey; use sammo\Enums\RankColumn; @@ -1007,16 +1008,16 @@ function increaseRefresh($type = "", $cnt = 1) $isunited = $gameStor->isunited; $opentime = $gameStor->opentime; - if($userGrade == 6){ + if ($userGrade == 6) { return; } - if($isunited == 2){ + if ($isunited == 2) { return; } - if(!$generalID){ + if (!$generalID) { return; } - if($opentime > $date){ + if ($opentime > $date) { return; } @@ -1039,7 +1040,7 @@ function increaseRefresh($type = "", $cnt = 1) $serverID = UniqueConst::$serverID; $logPath = "{$serverPath}/logs/{$serverID}/api_log.db"; - $logDB = FileDB::db($logPath, $serverPath. '/../f_install/sql/api_log.sql'); + $logDB = FileDB::db($logPath, $serverPath . '/../f_install/sql/api_log.sql'); $ip = $_SERVER['REMOTE_ADDR'] ?? 'local'; $date = date('Y-m-d H:i:s'); @@ -1214,7 +1215,16 @@ function updateOnline() //동접수 $startTurn = cutTurn($gameStor->turntime, $gameStor->turnterm, false); - $onlineUser = $db->query('SELECT no,name,nation FROM general WHERE lastrefresh >= %s AND npc < 2', $startTurn); + $onlineUser = $db->query( + 'SELECT %b, %b, %b FROM `general_access_log` as `log` INNER JOIN `general` ON `log`.%b = `general`.%b WHERE %b >= %s', + GeneralColumn::no->value, + GeneralColumn::name->value, + GeneralColumn::nation->value, + GeneralAccessLogColumn::generalID->value, + GeneralColumn::no->value, + GeneralAccessLogColumn::lastRefresh->value, + $startTurn + ); $onlineNum = count($onlineUser); $onlineNationUsers = Util::arrayGroupBy($onlineUser, 'nation'); @@ -1742,7 +1752,7 @@ function deleteNation(General $lord, bool $applyDB): array // 전 장수 재야로 foreach ($nationGeneralList as $general) { - if($general->getNPCType() < 2){ + if ($general->getNPCType() < 2) { $general->setAuxVar( InheritanceKey::max_belong->value, max( diff --git a/hwe/sammo/API/General/BuildNationCandidate.php b/hwe/sammo/API/General/BuildNationCandidate.php index 75816a7a..8ce2e797 100644 --- a/hwe/sammo/API/General/BuildNationCandidate.php +++ b/hwe/sammo/API/General/BuildNationCandidate.php @@ -39,7 +39,7 @@ class BuildNationCandidate extends \sammo\BaseAPI $gameStor = KVStorage::getStorage($db, 'game_env'); $gameStor->cacheValues(['opentime', 'turntime']); - $general = $db->queryFirstRow('SELECT no,name,nation,owner_name,npc,lastrefresh FROM general WHERE owner=%i', $userID); + $general = $db->queryFirstRow('SELECT no,name,nation,owner_name,npc FROM general WHERE owner=%i', $userID); if (!$general) { return '장수가 없습니다'; diff --git a/hwe/sammo/API/General/DieOnPrestart.php b/hwe/sammo/API/General/DieOnPrestart.php index c9650bb2..eee54801 100644 --- a/hwe/sammo/API/General/DieOnPrestart.php +++ b/hwe/sammo/API/General/DieOnPrestart.php @@ -5,6 +5,7 @@ namespace sammo\API\General; use sammo\DB; use sammo\DummyGeneral; use sammo\Enums\APIRecoveryType; +use sammo\Enums\GeneralAccessLogColumn; use sammo\GameConst; use sammo\Session; use sammo\General; @@ -37,7 +38,13 @@ class DieOnPrestart extends \sammo\BaseAPI $gameStor = KVStorage::getStorage($db, 'game_env'); $gameStor->cacheValues(['turnterm', 'opentime', 'turntime', 'year', 'month']); - $general = $db->queryFirstRow('SELECT no,name,nation,owner_name,npc,lastrefresh FROM general WHERE owner=%i AND npc = 0', $userID); + $general = $db->queryFirstRow('SELECT no,name,nation,owner_name,npc FROM general WHERE owner=%i AND npc = 0', $userID); + $lastRefresh = $db->queryFirstField( + 'SELECT %b FROM general_access_log WHERE %b = %i', + GeneralAccessLogColumn::lastRefresh->value, + GeneralAccessLogColumn::generalID, + $general['no'] + ); if (!$general) { return '장수가 없습니다'; @@ -55,7 +62,7 @@ class DieOnPrestart extends \sammo\BaseAPI } //서버 가오픈시 할 수 있는 행동 - $targetTime = addTurn($general['lastrefresh'], $gameStor->turnterm, GameConst::$minTurnDieOnPrestart); + $targetTime = addTurn($lastRefresh, $gameStor->turnterm, GameConst::$minTurnDieOnPrestart); if ($targetTime > TimeUtil::now()) { $targetTimeShort = substr($targetTime, 0, 19); return "아직 삭제할 수 없습니다. {$targetTimeShort} 부터 가능합니다."; diff --git a/hwe/sammo/API/General/Join.php b/hwe/sammo/API/General/Join.php index 796dcc0b..91087876 100644 --- a/hwe/sammo/API/General/Join.php +++ b/hwe/sammo/API/General/Join.php @@ -8,6 +8,7 @@ use sammo\Auction; use sammo\CityConst; use sammo\DB; use sammo\Enums\APIRecoveryType; +use sammo\Enums\GeneralAccessLogColumn; use sammo\Enums\RankColumn; use sammo\GameConst; use sammo\GameUnitConst; @@ -414,7 +415,6 @@ class Join extends \sammo\BaseAPI 'officer_level' => 0, 'turntime' => $turntime, 'killturn' => 6, - 'lastrefresh' => $now, 'crewtype' => GameUnitConst::DEFAULT_CREWTYPE, 'makelimit' => 0, 'betray' => $betray, @@ -427,6 +427,12 @@ class Join extends \sammo\BaseAPI 'special2' => $special2 ]); $generalID = $db->insertId(); + $db->insert('general_access_log', [ + GeneralAccessLogColumn::generalID->value => $generalID, + GeneralAccessLogColumn::userID->value => $userID, + GeneralAccessLogColumn::nationID->value => 1, + GeneralAccessLogColumn::lastRefresh->value => $now, + ]); if($blockCustomGeneralName){ //XXX: 클래스가 이게 맞나? diff --git a/hwe/sammo/Enums/GeneralColumn.php b/hwe/sammo/Enums/GeneralColumn.php index dc40b6dd..c312e0f2 100644 --- a/hwe/sammo/Enums/GeneralColumn.php +++ b/hwe/sammo/Enums/GeneralColumn.php @@ -58,7 +58,6 @@ enum GeneralColumn: string{ case recent_war = 'recent_war'; case makelimit = 'makelimit'; case killturn = 'killturn'; - case lastrefresh = 'lastrefresh'; case ip = 'ip'; case block = 'block'; case dedlevel = 'dedlevel'; diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index b7a4b7fc..55d699d7 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -1030,7 +1030,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', 'lastrefresh', 'permission', 'penalty', + 'specage', 'specage2', 'con', 'connect', 'aux', 'permission', 'penalty', ]; if ($reqColumns === null) { diff --git a/hwe/sammo/Scenario/GeneralBuilder.php b/hwe/sammo/Scenario/GeneralBuilder.php index b0d352da..31ddb4a1 100644 --- a/hwe/sammo/Scenario/GeneralBuilder.php +++ b/hwe/sammo/Scenario/GeneralBuilder.php @@ -708,7 +708,6 @@ class GeneralBuilder{ 'dex4'=>$this->dex4, 'dex5'=>$this->dex5, 'aux'=>\sammo\Json::encode($this->aux), - 'lastrefresh'=>TimeUtil::now(), ]); $this->generalID = $db->insertId(); $turnRows = []; diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index bff6f4cd..ba84682c 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -54,7 +54,6 @@ CREATE TABLE `general` ( `recent_war` DATETIME(6) NULL DEFAULT NULL, `makelimit` INT(2) NULL DEFAULT '0', `killturn` INT(3) NULL DEFAULT NULL, - `lastrefresh` DATETIME NULL DEFAULT NULL, `ip` VARCHAR(40) NULL DEFAULT '', `block` INT(1) NULL DEFAULT '0', `dedlevel` INT(2) NULL DEFAULT '0', @@ -86,7 +85,6 @@ CREATE TABLE `general` ( INDEX `officer_level` (`nation`, `officer_level`), INDEX `officer_city` (`officer_city`, `officer_level`), INDEX `name` (`name`), - INDEX `last_refresh` (`lastrefresh`), CONSTRAINT `json1` CHECK (json_valid(`last_turn`)), CONSTRAINT `json2` CHECK (json_valid(`aux`)), CONSTRAINT `json3` CHECK (json_valid(`penalty`)) -- 2.54.0 From 9bf7bd0fda163a5e9cf29e49b3e69bc070a089d0 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Tue, 4 Jul 2023 17:51:57 +0000 Subject: [PATCH 07/21] =?UTF-8?q?refac,wip:=20refresh=20=EC=88=98=EC=B9=98?= =?UTF-8?q?=EB=A5=BC=20=EC=9D=B4=EC=A0=84=20=EC=A4=91=20-=20connect,=20con?= =?UTF-8?q?=EC=9D=84=20=EC=9E=8A=EC=97=88=EC=9D=8C!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/a_traffic.php | 17 +++++++++++++---- hwe/func.php | 20 +------------------- hwe/sammo/API/General/Join.php | 1 - hwe/sammo/DTO/GeneralAccessLog.php | 11 ----------- hwe/sammo/Enums/GeneralAccessLogColumn.php | 3 --- hwe/sammo/Enums/GeneralColumn.php | 3 --- hwe/sammo/General.php | 6 ------ hwe/sql/schema.sql | 8 -------- src/sammo/Session.php | 6 ------ 9 files changed, 14 insertions(+), 61 deletions(-) diff --git a/hwe/a_traffic.php b/hwe/a_traffic.php index b14e35f9..f66f39ad 100644 --- a/hwe/a_traffic.php +++ b/hwe/a_traffic.php @@ -2,6 +2,8 @@ namespace sammo; +use sammo\Enums\GeneralAccessLogColumn; + include "lib.php"; include "func.php"; @@ -193,12 +195,19 @@ if ($admin['maxonline'] < $curonline) { queryFirstRow('SELECT sum(refresh) as refresh, sum(`connect`) as `connect` from general'); - $max_refresh['name'] = '접속자 총합'; + $totalRefresh = [ + 'connect' => $db->queryFirstField('SELECT sum(`connect`) as `connect` from general'), + 'refresh' => $db->queryFirstField('SELECT sum(`refresh`) as `refresh` from general_access_log'), + 'name' => '접속자 총합' + ]; - $refresh_result = array_merge([$max_refresh], $db->query('SELECT `name`,refresh,`connect` FROM general ORDER BY refresh DESC LIMIT 5')); + $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'); - foreach ($refresh_result as $i => $user) { + $refresh_result = array_merge([$max_refresh], $db->query('SELECT `no`,`name`,refresh,`connect` FROM general ORDER BY refresh DESC LIMIT 5')); + + foreach (array_merge([$totalRefresh], $top5Refresh) as $i => $user) { $w = round($user['refresh'] / max(1, $max_refresh['refresh']) * 100, 1); $w2 = round(100 - $w, 1); $color = getTrafficColor($w); diff --git a/hwe/func.php b/hwe/func.php index 9f253179..8ab5cc54 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1069,9 +1069,6 @@ function updateTraffic() $admin = $gameStor->getValues(['year', 'month', 'refresh', 'maxonline', 'maxrefresh']); /** @var array{year:int,month:int,refresh:int,maxonline:int,maxrefresh:int} $admin */ - //최다갱신자 - $user = $db->queryFirstRow('select name,refresh from general order by refresh desc limit 1'); - if ($admin['maxrefresh'] < $admin['refresh']) { $admin['maxrefresh'] = $admin['refresh']; } @@ -1082,22 +1079,7 @@ function updateTraffic() $gameStor->maxrefresh = $admin['maxrefresh']; $gameStor->maxonline = $admin['maxonline']; - $db->update('general', ['refresh' => 0], true); - - $date = TimeUtil::now(); - //일시|년|월|총갱신|접속자|최다갱신자 - file_put_contents( - __DIR__ . "/logs/" . UniqueConst::$serverID . "/_traffic.txt", - Json::encode([ - $date, - $admin['year'], - $admin['month'], - $admin['refresh'], - $online, - $user['name'] . "(" . $user['refresh'] . ")" - ]) . "\n", - FILE_APPEND - ); + $db->update('general_access_log', ['refresh' => 0], true); } function CheckOverhead() diff --git a/hwe/sammo/API/General/Join.php b/hwe/sammo/API/General/Join.php index 91087876..d4713ddb 100644 --- a/hwe/sammo/API/General/Join.php +++ b/hwe/sammo/API/General/Join.php @@ -430,7 +430,6 @@ class Join extends \sammo\BaseAPI $db->insert('general_access_log', [ GeneralAccessLogColumn::generalID->value => $generalID, GeneralAccessLogColumn::userID->value => $userID, - GeneralAccessLogColumn::nationID->value => 1, GeneralAccessLogColumn::lastRefresh->value => $now, ]); diff --git a/hwe/sammo/DTO/GeneralAccessLog.php b/hwe/sammo/DTO/GeneralAccessLog.php index 6e4924b8..fac2424b 100644 --- a/hwe/sammo/DTO/GeneralAccessLog.php +++ b/hwe/sammo/DTO/GeneralAccessLog.php @@ -19,21 +19,10 @@ class GeneralAccessLog extends \LDTO\DTO #[RawName('user_id')] public ?int $userID, - #[RawName('nation_id')] - #[NullIsUndefined] - public ?int $nationID, - #[RawName('last_refresh')] #[Convert(DateTimeConverter::class)] public \DateTimeImmutable $lastRefresh, - #[RawName('last_connect')] - #[Convert(DateTimeConverter::class)] - public ?\DateTimeImmutable $lastConnect, - - #[RawName('login_total')] - public int $loginTotal, - public int $refresh, #[RawName('refresh_total')] diff --git a/hwe/sammo/Enums/GeneralAccessLogColumn.php b/hwe/sammo/Enums/GeneralAccessLogColumn.php index cec80081..21290e3d 100644 --- a/hwe/sammo/Enums/GeneralAccessLogColumn.php +++ b/hwe/sammo/Enums/GeneralAccessLogColumn.php @@ -6,10 +6,7 @@ enum GeneralAccessLogColumn: string { case id = 'id'; case generalID = 'general_id'; case userID = 'user_id'; - case nationID = 'nation_id'; case lastRefresh = 'last_refresh'; - case lastConnect = 'last_connect'; - case loginTotal = 'login_total'; case refresh = 'refresh'; case refreshTotal = 'refresh_total'; } \ No newline at end of file diff --git a/hwe/sammo/Enums/GeneralColumn.php b/hwe/sammo/Enums/GeneralColumn.php index c312e0f2..ebdefcd6 100644 --- a/hwe/sammo/Enums/GeneralColumn.php +++ b/hwe/sammo/Enums/GeneralColumn.php @@ -17,9 +17,6 @@ enum GeneralColumn: string{ case newmsg = 'newmsg'; case con = 'con'; case connect = 'connect'; - case refresh = 'refresh'; - case logcnt = 'logcnt'; - case refcnt = 'refcnt'; case picture = 'picture'; case imgsvr = 'imgsvr'; case name = 'name'; diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index 55d699d7..fbbd806c 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -793,12 +793,6 @@ class General implements iAction 'nation_id' => $updateVals['nation'] ], 'general_id = %i', $generalID); $result = true; - - if($this->getNPCType() < 2){ - $db->update('general_access_log', [ - GeneralAccessLogColumn::nationID->value => $updateVals['nation'] - ], '%b = %i', GeneralAccessLogColumn::generalID->value, $generalID); - } } $this->flushUpdateValues(); } diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index ba84682c..c335de84 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -13,9 +13,6 @@ CREATE TABLE `general` ( `newmsg` INT(1) NULL DEFAULT '0', `con` INT(6) NOT NULL DEFAULT '0', `connect` INT(6) NOT NULL DEFAULT '0', - `refresh` INT(6) NOT NULL DEFAULT '0', - `logcnt` INT(6) NULL DEFAULT '1', - `refcnt` INT(6) NULL DEFAULT '1', `picture` VARCHAR(40) NOT NULL, `imgsvr` INT(1) NOT NULL DEFAULT '0', `name` VARCHAR(32) NOT NULL COLLATE 'utf8mb4_bin', @@ -54,7 +51,6 @@ CREATE TABLE `general` ( `recent_war` DATETIME(6) NULL DEFAULT NULL, `makelimit` INT(2) NULL DEFAULT '0', `killturn` INT(3) NULL DEFAULT NULL, - `ip` VARCHAR(40) NULL DEFAULT '', `block` INT(1) NULL DEFAULT '0', `dedlevel` INT(2) NULL DEFAULT '0', `explevel` INT(2) NULL DEFAULT '0', @@ -103,15 +99,11 @@ CREATE TABLE `general_access_log` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `general_id` INT(11) NOT NULL, `user_id` INT(11) NULL DEFAULT NULL, - `nation_id` INT(11) NULL DEFAULT NULL, `last_refresh` DATETIME NULL DEFAULT NULL, - `last_connect` DATETIME NULL DEFAULT NULL, - `login_total` INT(11) NOT NULL DEFAULT '0', `refresh` INT(11) NOT NULL DEFAULT '0', `refresh_total` INT(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE INDEX `general_id` (`general_id`), - INDEX `nation_id` (`nation_id`) ) COLLATE='utf8mb4_general_ci' ENGINE=Aria diff --git a/src/sammo/Session.php b/src/sammo/Session.php index b04e4d92..e10a7f28 100644 --- a/src/sammo/Session.php +++ b/src/sammo/Session.php @@ -288,12 +288,6 @@ class Session } } - $db->update('general', [ - 'logcnt' => $db->sqleval('logcnt+1'), - 'ip' => Util::get_client_ip(true), - 'lastConnect' => TimeUtil::now() - ], 'owner = %i', $userID); - $this->set($serverID.static::GAME_KEY_DATE, $now); $this->set($serverID.static::GAME_KEY_GENERAL_ID, $generalID); $this->set($serverID.static::GAME_KEY_GENERAL_NAME, $generalName); -- 2.54.0 From 3ae49456b1393ef6910e76103fb826b983d8bad8 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Tue, 4 Jul 2023 17:57:08 +0000 Subject: [PATCH 08/21] =?UTF-8?q?fix:=20general=5Faccess=5Flog=EC=97=90=20?= =?UTF-8?q?=EB=B2=8C=EC=A0=90=20=EA=B4=80=EB=A0=A8=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EB=88=84=EB=9D=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/DTO/GeneralAccessLog.php | 6 ++++++ hwe/sammo/Enums/GeneralAccessLogColumn.php | 6 ++++-- hwe/sql/schema.sql | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hwe/sammo/DTO/GeneralAccessLog.php b/hwe/sammo/DTO/GeneralAccessLog.php index fac2424b..d70731f6 100644 --- a/hwe/sammo/DTO/GeneralAccessLog.php +++ b/hwe/sammo/DTO/GeneralAccessLog.php @@ -27,6 +27,12 @@ class GeneralAccessLog extends \LDTO\DTO #[RawName('refresh_total')] public int $refreshTotal, + + #[RawName('refresh_score')] + public int $refreshScore, + + #[RawName('refresh_score_total')] + public int $refreshScoreTotal, ) { } } \ No newline at end of file diff --git a/hwe/sammo/Enums/GeneralAccessLogColumn.php b/hwe/sammo/Enums/GeneralAccessLogColumn.php index 21290e3d..05bc14c3 100644 --- a/hwe/sammo/Enums/GeneralAccessLogColumn.php +++ b/hwe/sammo/Enums/GeneralAccessLogColumn.php @@ -7,6 +7,8 @@ enum GeneralAccessLogColumn: string { case generalID = 'general_id'; case userID = 'user_id'; case lastRefresh = 'last_refresh'; - case refresh = 'refresh'; - case refreshTotal = 'refresh_total'; + case refresh = 'refresh'; //순간 갱신 횟수(00:00에 초기화) + case refreshTotal = 'refresh_total'; //누적 갱신 횟수 + case refreshScore = 'refreshScore'; //순간 벌점(턴 시간에 초기화) + case refreshScoreTotal = 'refreshScoreTotal'; //누적 벌점(지속적으로 감소, refreshScoreTotal <= refreshTotal) } \ No newline at end of file diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index c335de84..ba20a63b 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -102,6 +102,8 @@ CREATE TABLE `general_access_log` ( `last_refresh` DATETIME NULL DEFAULT NULL, `refresh` INT(11) NOT NULL DEFAULT '0', `refresh_total` INT(11) NOT NULL DEFAULT '0', + `refresh_score` INT(11) NOT NULL DEFAULT '0', + `refresh_score_total` INT(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE INDEX `general_id` (`general_id`), ) -- 2.54.0 From c9dd8730198feaabc44a0a8add19cf49879a0148 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Thu, 6 Jul 2023 17:38:32 +0000 Subject: [PATCH 09/21] =?UTF-8?q?refac,=20wip:=20=EB=B2=8C=EC=A0=90(connec?= =?UTF-8?q?t,=20con)=20=EB=B3=80=EA=B2=BD=20-=20=EB=B2=8C=EC=A0=90:=20refr?= =?UTF-8?q?eshScoreTotal=20-=20=EC=88=9C=EA=B0=84=EB=B2=8C=EC=A0=90:=20ref?= =?UTF-8?q?reshScore?= 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'; -- 2.54.0 From 49429e1e7e505de4ca0b1d3e08533dff0b0d7aef Mon Sep 17 00:00:00 2001 From: Hide_D Date: Thu, 6 Jul 2023 18:38:50 +0000 Subject: [PATCH 10/21] refac, wip: con -> refreshScore --- hwe/_admin2_submit.php | 20 +++++++-------- hwe/a_genList.php | 9 ++++--- hwe/a_kingdomList.php | 9 ++++--- hwe/b_betting.php | 11 +++++--- hwe/b_genList.php | 11 +++++--- hwe/b_tournament.php | 12 +++++---- hwe/func.php | 25 +++++++++---------- hwe/func_converter.php | 24 +++++++++--------- hwe/func_gamerule.php | 4 +-- hwe/j_board_article_add.php | 11 +++++--- hwe/j_board_comment_add.php | 11 +++++--- hwe/j_board_get_articles.php | 12 +++++---- hwe/j_diplomacy_destroy_letter.php | 9 ++++--- hwe/j_diplomacy_get_letter.php | 12 +++++---- hwe/j_diplomacy_respond_letter.php | 9 ++++--- hwe/j_diplomacy_rollback_letter.php | 9 ++++--- hwe/j_diplomacy_send_letter.php | 9 ++++--- hwe/j_general_log_old.php | 11 +++++--- hwe/j_set_npc_control.php | 5 +++- hwe/old_index.php | 11 ++++---- hwe/sammo/API/Betting/GetBettingList.php | 9 ++++--- hwe/sammo/API/General/GetFrontInfo.php | 6 ++--- hwe/sammo/API/Global/GeneralList.php | 9 ++++--- hwe/sammo/API/Global/GetHistory.php | 9 ++++--- hwe/sammo/API/Message/GetOldMessage.php | 2 +- hwe/sammo/API/Message/GetRecentMessage.php | 2 +- hwe/sammo/API/Message/SendMessage.php | 11 +++++--- hwe/sammo/API/Nation/GeneralList.php | 9 ++++--- hwe/sammo/API/Nation/GetGeneralLog.php | 8 +++--- .../API/NationCommand/GetReservedCommand.php | 9 ++++--- hwe/sammo/Event/Action/InvaderEnding.php | 2 +- hwe/sammo/ResetHelper.php | 2 +- hwe/sammo/TurnExecutionHelper.php | 4 ++- hwe/t_diplomacy.php | 9 ++++--- hwe/v_NPCControl.php | 9 ++++--- hwe/v_auction.php | 3 --- hwe/v_board.php | 9 +------ hwe/v_history.php | 3 --- hwe/v_nationStratFinan.php | 9 ++++--- 39 files changed, 209 insertions(+), 149 deletions(-) diff --git a/hwe/_admin2_submit.php b/hwe/_admin2_submit.php index a5359528..968d34d4 100644 --- a/hwe/_admin2_submit.php +++ b/hwe/_admin2_submit.php @@ -38,13 +38,13 @@ if ($genlist) { } switch ($btn) { case "전체 접속허용": - $db->update('general', [ - 'con' => 0 + $db->update('general_access_log', [ + 'refresh_score' => 0 ], true); break; case "전체 접속제한": - $db->update('general', [ - 'con' => 1000 + $db->update('general_access_log', [ + 'refresh_score' => 1000 ], true); break; case "블럭 해제": @@ -186,14 +186,14 @@ switch ($btn) { ], '`no` IN %li', $genlist); break; case "접속 허용": - $db->update('general', [ - 'con' => 0 - ], '`no` IN %li', $genlist); + $db->update('general_access_log', [ + 'refresh_score' => 0 + ], '`general_id` IN %li', $genlist); break; case "접속 제한": - $db->update('general', [ - 'con' => 1000 - ], '`no` IN %li', $genlist); + $db->update('general_access_log', [ + 'refresh_score' => 1000 + ], '`general_id` IN %li', $genlist); break; case "메세지 전달": $text = $msg ?? ''; diff --git a/hwe/a_genList.php b/hwe/a_genList.php index aebeac24..68c6bcbf 100644 --- a/hwe/a_genList.php +++ b/hwe/a_genList.php @@ -16,10 +16,13 @@ $gameStor = KVStorage::getStorage($db, 'game_env'); increaseRefresh("장수일람", 2); -$me = $db->queryFirstRow('SELECT con,turntime FROM general WHERE owner = %i', $userID); +$me = $db->queryFirstRow( + 'SELECT refresh_score,turntime FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner = %i', $userID +); -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { printLimitMsg($me['turntime']); exit(); } diff --git a/hwe/a_kingdomList.php b/hwe/a_kingdomList.php index 7f45c2c9..d54444cc 100644 --- a/hwe/a_kingdomList.php +++ b/hwe/a_kingdomList.php @@ -13,10 +13,13 @@ $gameStor = KVStorage::getStorage($db, 'game_env'); $gameStor->cacheValues(['killturn', 'autorun_user', 'turnterm']); increaseRefresh("세력일람", 2); -$me = $db->queryFirstRow('SELECT con, turntime FROM general WHERE owner=%i', $userID); +$me = $db->queryFirstRow( + 'SELECT refresh_score, turntime FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID +); -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { printLimitMsg($me['turntime']); exit(); } diff --git a/hwe/b_betting.php b/hwe/b_betting.php index d97c5a96..7fdd8ecd 100644 --- a/hwe/b_betting.php +++ b/hwe/b_betting.php @@ -21,12 +21,15 @@ $generalID = $session->generalID; -$me = $db->queryFirstRow('SELECT no,tournament,con,turntime from general where owner=%i', $userID); +$me = $db->queryFirstRow( + 'SELECT no,tournament,refresh_score,turntime FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id where owner=%i', $userID +); $admin = $gameStor->getValues(['tournament', 'phase', 'tnmt_type', 'turnterm', 'develcost']); $turnTerm = $admin['turnterm']; -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { printLimitMsg($me['turntime']); exit(); } @@ -107,7 +110,7 @@ if ($str3) { ?> - diff --git a/hwe/b_genList.php b/hwe/b_genList.php index 5725b7b2..0cbae607 100644 --- a/hwe/b_genList.php +++ b/hwe/b_genList.php @@ -19,12 +19,15 @@ $gameStor = KVStorage::getStorage($db, 'game_env'); increaseRefresh("암행부", 1); -$me = $db->queryFirstRow('SELECT no,nation,officer_level,con,turntime,belong,permission,penalty from general where owner=%i', $userID); +$me = $db->queryFirstRow( + 'SELECT no,nation,officer_level,refresh_score,turntime,belong,permission,penalty FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID +); $nationLevel = $db->queryFirstField('SELECT level FROM nation WHERE nation=%i', $me['nation']); -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { printLimitMsg($me['turntime']); exit(); } @@ -45,7 +48,7 @@ $templates = new \League\Plates\Engine('templates'); ?> - diff --git a/hwe/b_tournament.php b/hwe/b_tournament.php index ea74537a..461c18d1 100644 --- a/hwe/b_tournament.php +++ b/hwe/b_tournament.php @@ -14,14 +14,16 @@ $gameStor = KVStorage::getStorage($db, 'game_env'); increaseRefresh("토너먼트", 1); TurnExecutionHelper::executeAllCommand(); -$me = $db->queryFirstRow('select no,tournament,con,turntime from general where owner=%i', $userID); -$generalID = $session->generalID; +$me = $db->queryFirstRow( + 'SELECT no,tournament,refresh_score,turntime from `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id where owner=%i', $userID +); $admin = $gameStor->getValues(['tournament', 'phase', 'turnterm', 'tnmt_msg', 'tnmt_type', 'develcost', 'tnmt_trig']); $turnTerm = $admin['turnterm']; -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { printLimitMsg($me['turntime']); exit(); } @@ -100,7 +102,7 @@ $globalBetTotal = array_sum($globalBet); ?> - diff --git a/hwe/func.php b/hwe/func.php index b1ed51b6..90f5da0a 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -105,10 +105,9 @@ function GetImageURL($imgsvr, $filepath = '') } /** - * @param null|int $con 장수의 벌점 - * @param null|int $conlimit 최대 벌점 + * @param null|int $refreshScore 장수의 벌점 */ -function checkLimit($con = null) +function checkLimit($refreshScore = null) { $session = Session::getInstance(); if ($session->userGrade >= 4) { @@ -118,15 +117,15 @@ function checkLimit($con = null) $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); - if ($con === null) { - $con = $db->queryFirstField('SELECT con FROM general WHERE `owner`=%i', Session::getUserID()); + if ($refreshScore === null) { + $refreshScore = $db->queryFirstField('SELECT refresh_score FROM general_access_log WHERE `general_id`=%i', Session::getGeneralID()); } - $conlimit = $gameStor->conlimit; + $refreshLimit = $gameStor->refreshLimit; - if ($con > $conlimit) { + if ($refreshScore > $refreshLimit) { return 2; //접속제한 90%이면 경고문구 - } elseif ($con > $conlimit * 0.9) { + } elseif ($refreshScore > $refreshLimit * 0.9) { return 1; } else { return 0; @@ -753,7 +752,7 @@ function generalInfo(General $generalObj)
부대 {$troopInfo} 벌점" . getRefreshScoreText($refreshScoreTotal) . " {$refreshScoreTotal}({$generalObj->getVar('con')})" . getRefreshScoreText($refreshScoreTotal) . " {$refreshScoreTotal}({$generalObj->getVar('refresh_score')})
"; } @@ -1087,13 +1086,13 @@ function CheckOverhead() //서버정보 $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); - list($turnterm, $conlimit) = $gameStor->getValuesAsArray(['turnterm', 'conlimit']); + [$turnterm, $refreshLimit] = $gameStor->getValuesAsArray(['turnterm', 'refreshLimit']); - $con = Util::round(pow($turnterm, 0.6) * 3) * 10; + $nextRefreshLimit = Util::round(pow($turnterm, 0.6) * 3) * 10; - if ($con != $conlimit) { - $gameStor->conlimit = $con; + if ($nextRefreshLimit != $refreshLimit) { + $gameStor->refreshLimit = $nextRefreshLimit; } } diff --git a/hwe/func_converter.php b/hwe/func_converter.php index 84bbf0ca..97d60796 100644 --- a/hwe/func_converter.php +++ b/hwe/func_converter.php @@ -133,19 +133,19 @@ function getNationType(?string $type) { } -function getRefreshScoreText($con) { - if($con < 50) $conname = '안함'; - elseif($con < 100) $conname = '무관심'; - elseif($con < 200) $conname = '가끔'; - elseif($con < 400) $conname = '보통'; - elseif($con < 800) $conname = '자주'; - elseif($con < 1600) $conname = '열심'; - elseif($con < 3200) $conname = '중독'; - elseif($con < 6400) $conname = '폐인'; - elseif($con < 12800) $conname = '경고'; - else $conname = '헐...'; +function getRefreshScoreText($score) { + if($score < 50) $scoreName = '안함'; + elseif($score < 100) $scoreName = '무관심'; + elseif($score < 200) $scoreName = '가끔'; + elseif($score < 400) $scoreName = '보통'; + elseif($score < 800) $scoreName = '자주'; + elseif($score < 1600) $scoreName = '열심'; + elseif($score < 3200) $scoreName = '중독'; + elseif($score < 6400) $scoreName = '폐인'; + elseif($score < 12800) $scoreName = '경고'; + else $scoreName = '헐...'; - return $conname; + return $scoreName; } function getNationType2(?string $type) { diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index bc4f491c..465c97eb 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -698,7 +698,7 @@ function checkEmperior() $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); - $admin = $gameStor->getValues(['year', 'month', 'isunited', 'conlimit']); + $admin = $gameStor->getValues(['year', 'month', 'isunited', 'refreshLimit']); if ($admin['isunited'] != 0) { return; } @@ -760,7 +760,7 @@ function checkEmperior() } $gameStor->isunited = 2; - $gameStor->conlimit = $gameStor->conlimit * 100; + $gameStor->refreshLimit = $gameStor->refreshLimit * 100; foreach ($db->queryFirstColumn('SELECT no FROM general WHERE npc<2 AND age>=%i', GameConst::$minPushHallAge) as $hallGeneralNo) { CheckHall($hallGeneralNo); diff --git a/hwe/j_board_article_add.php b/hwe/j_board_article_add.php index 4b4b3a89..35ea3ae6 100644 --- a/hwe/j_board_article_add.php +++ b/hwe/j_board_article_add.php @@ -17,10 +17,13 @@ $text = Util::getPost('text'); increaseRefresh("회의실", 1); -$me = $db->queryFirstRow('SELECT no, nation, name, officer_level, permission, con, turntime, belong, penalty, `picture`,`imgsvr` FROM general WHERE owner=%i', $userID); +$me = $db->queryFirstRow( + 'SELECT no, nation, name, officer_level, permission, refresh_score, turntime, belong, penalty, `picture`,`imgsvr` FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID +); -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { Json::die([ 'result'=>false, 'reason'=>'접속 제한입니다.' @@ -50,7 +53,7 @@ if($permission < 0){ 'result'=>false, 'reason'=>'국가에 소속되어있지 않습니다.' ]); - + } else if ($isSecretBoard && $permission < 2) { Json::die([ diff --git a/hwe/j_board_comment_add.php b/hwe/j_board_comment_add.php index 12ada898..4fc660be 100644 --- a/hwe/j_board_comment_add.php +++ b/hwe/j_board_comment_add.php @@ -16,10 +16,13 @@ $text = Util::getPost('text'); increaseRefresh("회의실", 1); -$me = $db->queryFirstRow('SELECT no, nation, name, officer_level, permission, con, turntime, belong, penalty FROM general WHERE owner=%i', $userID); +$me = $db->queryFirstRow( + 'SELECT no, nation, name, officer_level, permission, refresh_score, turntime, belong, penalty FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID +); -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { Json::die([ 'result'=>false, 'reason'=>'접속 제한입니다.' @@ -58,7 +61,7 @@ if($permission < 0){ 'result'=>false, 'reason'=>'국가에 소속되어있지 않습니다.' ]); - + } else if ($isSecretBoard && $permission < 2) { Json::die([ diff --git a/hwe/j_board_get_articles.php b/hwe/j_board_get_articles.php index 9b902cf4..5a740f23 100644 --- a/hwe/j_board_get_articles.php +++ b/hwe/j_board_get_articles.php @@ -16,11 +16,14 @@ $isSecretBoard = Util::getPost('isSecret', 'bool', false); increaseRefresh("회의실", 1); -$me = $db->queryFirstRow('SELECT no, nation, officer_level, permission, con, turntime, belong, penalty FROM general WHERE owner=%i', $userID); +$me = $db->queryFirstRow( + 'SELECT no, nation, officer_level, permission, refresh_score, turntime, belong, penalty FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID +); -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { Json::die([ 'result'=>false, 'reason'=>'접속 제한입니다.' @@ -33,7 +36,7 @@ if($permission < 0){ 'result'=>false, 'reason'=>'국가에 소속되어있지 않습니다.' ]); - + } else if ($isSecretBoard && $permission < 2) { Json::die([ @@ -72,4 +75,3 @@ Json::die([ 'articles'=>$articles, 'reason'=>'success' ]); - diff --git a/hwe/j_diplomacy_destroy_letter.php b/hwe/j_diplomacy_destroy_letter.php index fec91ff8..f7ed149e 100644 --- a/hwe/j_diplomacy_destroy_letter.php +++ b/hwe/j_diplomacy_destroy_letter.php @@ -17,10 +17,13 @@ $letterNo = Util::getPost('letterNo', 'int'); increaseRefresh("외교부", 1); -$me = $db->queryFirstRow('SELECT no, name, nation, officer_level, permission, con, turntime, belong, penalty, picture, imgsvr FROM general WHERE owner=%i', $userID); +$me = $db->queryFirstRow( + 'SELECT no, name, nation, officer_level, permission, refresh_score, turntime, belong, penalty, picture, imgsvr FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID +); -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { Json::die([ 'result'=>false, 'reason'=>'접속 제한입니다.' diff --git a/hwe/j_diplomacy_get_letter.php b/hwe/j_diplomacy_get_letter.php index 39aed480..425eb7d7 100644 --- a/hwe/j_diplomacy_get_letter.php +++ b/hwe/j_diplomacy_get_letter.php @@ -16,11 +16,14 @@ $isSecretBoard = Util::getPost('isSecret', 'bool', false); increaseRefresh("외교부", 1); -$me = $db->queryFirstRow('SELECT no, nation, officer_level, permission, con, turntime, belong, penalty FROM general WHERE owner=%i', $userID); +$me = $db->queryFirstRow( + 'SELECT no, nation, officer_level, permission, refresh_score, turntime, belong, penalty FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID +); -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { Json::die([ 'result'=>false, 'reason'=>'접속 제한입니다.' @@ -33,7 +36,7 @@ if($permission < 0){ 'result'=>false, 'reason'=>'국가에 소속되어있지 않습니다.' ]); - + } $letters = []; @@ -83,4 +86,3 @@ Json::die([ 'myNationID'=>$me['nation'], 'reason'=>'success' ]); - diff --git a/hwe/j_diplomacy_respond_letter.php b/hwe/j_diplomacy_respond_letter.php index 42a30ab1..ce8c4d8f 100644 --- a/hwe/j_diplomacy_respond_letter.php +++ b/hwe/j_diplomacy_respond_letter.php @@ -22,10 +22,13 @@ $reason = Util::getPost('reason', 'string', ''); increaseRefresh("외교부", 1); -$me = $db->queryFirstRow('SELECT no, name, nation, officer_level, permission, con, turntime, belong, penalty, picture, imgsvr FROM general WHERE owner=%i', $userID); +$me = $db->queryFirstRow( + 'SELECT no, name, nation, officer_level, permission, refresh_score, turntime, belong, penalty, picture, imgsvr FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID +); -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { Json::die([ 'result'=>false, 'reason'=>'접속 제한입니다.' diff --git a/hwe/j_diplomacy_rollback_letter.php b/hwe/j_diplomacy_rollback_letter.php index 5908776d..f8bc1f9b 100644 --- a/hwe/j_diplomacy_rollback_letter.php +++ b/hwe/j_diplomacy_rollback_letter.php @@ -17,10 +17,13 @@ $letterNo = Util::getPost('letterNo', 'int'); increaseRefresh("외교부", 1); -$me = $db->queryFirstRow('SELECT no, name, nation, officer_level, permission, con, turntime, belong, penalty, picture, imgsvr FROM general WHERE owner=%i', $userID); +$me = $db->queryFirstRow( + 'SELECT no, name, nation, officer_level, permission, refresh_score, turntime, belong, penalty, picture, imgsvr FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID +); -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { Json::die([ 'result'=>false, 'reason'=>'접속 제한입니다.' diff --git a/hwe/j_diplomacy_send_letter.php b/hwe/j_diplomacy_send_letter.php index 728759bd..ea05671e 100644 --- a/hwe/j_diplomacy_send_letter.php +++ b/hwe/j_diplomacy_send_letter.php @@ -24,10 +24,13 @@ if($prevNo < 1){ $prevNo = null; } -$me = $db->queryFirstRow('SELECT no, name, nation, officer_level, permission, con, turntime, belong, penalty, picture, imgsvr FROM general WHERE owner=%i', $userID); +$me = $db->queryFirstRow( + 'SELECT no, name, nation, officer_level, permission, refresh_score, turntime, belong, penalty, picture, imgsvr FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID +); -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { Json::die([ 'result'=>false, 'reason'=>'접속 제한입니다.' diff --git a/hwe/j_general_log_old.php b/hwe/j_general_log_old.php index 0779fef3..99860480 100644 --- a/hwe/j_general_log_old.php +++ b/hwe/j_general_log_old.php @@ -33,12 +33,15 @@ if($generalID <= 0 || $reqTo <= 0){ $db = DB::db(); -$me = $db->queryFirstRow('SELECT no,nation,officer_level,con,turntime,belong,permission,penalty from general where owner=%i', $userID); +$me = $db->queryFirstRow( + 'SELECT no,nation,officer_level,refresh_score,turntime,belong,permission,penalty FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID +); $nationID = $me['nation']; -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { Json::die([ 'result'=>false, 'reason'=>'접속 제한입니다.' @@ -61,7 +64,7 @@ if($generalID !== $targetID){ 'reason'=>'권한이 부족합니다. 수뇌부가 아니거나 사관년도가 부족합니다.' ]); } - + if($testGeneralNationID !== $nationID){ Json::die([ 'result'=>false, diff --git a/hwe/j_set_npc_control.php b/hwe/j_set_npc_control.php index a59d1d85..bc8d0a96 100644 --- a/hwe/j_set_npc_control.php +++ b/hwe/j_set_npc_control.php @@ -39,7 +39,10 @@ if (!$data || !is_array($data)) { $db = DB::db(); -$me = $db->queryFirstRow('SELECT no, name, npc, nation, city, officer_level, con, turntime, belong, permission, penalty FROM general WHERE owner=%i', $userID); +$me = $db->queryFirstRow( + 'SELECT no, name, npc, nation, city, officer_level, refresh_score, turntime, belong, permission, penalty FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID +); $nationID = $me['nation']; diff --git a/hwe/old_index.php b/hwe/old_index.php index 173bed68..704d994f 100644 --- a/hwe/old_index.php +++ b/hwe/old_index.php @@ -29,7 +29,8 @@ if (!$session->isGameLoggedIn()) { } $me = $db->queryFirstRow( - 'SELECT no,con,turntime,newmsg,newvote,`officer_level` from general where owner = %i', + 'SELECT no,refresh_score,turntime,newmsg,newvote,`officer_level` FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner = %i', $userID ); @@ -51,8 +52,8 @@ if ($me['newmsg'] == 1 || $me['newvote'] == 1) { $plock = boolval($db->queryFirstField('SELECT plock FROM plock WHERE `type`="GAME" LIMIT 1')); -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { printLimitMsg($me['turntime']); exit(); } @@ -198,7 +199,7 @@ if ($lastVoteID) {
전체 접속자 수 : online_user_cnt ?> 명
-
턴당 갱신횟수 : conlimit ?>회
+
턴당 갱신횟수 : refreshLimit ?>회
@@ -367,7 +368,7 @@ if ($lastVoteID) {
userID; - $me = $db->queryFirstRow('SELECT no,nation,officer_level,con,turntime,belong,penalty,permission FROM general WHERE owner=%i', $userID); - $con = checkLimit($me['con']); - if ($con >= 2) { + $me = $db->queryFirstRow( + 'SELECT no,nation,officer_level,refresh_score,turntime,belong,penalty,permission FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID + ); + $limitState = checkLimit($me['refresh_score']); + if ($limitState >= 2) { return "접속 제한중입니다."; } diff --git a/hwe/sammo/API/General/GetFrontInfo.php b/hwe/sammo/API/General/GetFrontInfo.php index dfddd964..43def670 100644 --- a/hwe/sammo/API/General/GetFrontInfo.php +++ b/hwe/sammo/API/General/GetFrontInfo.php @@ -174,7 +174,7 @@ class GetFrontInfo extends \sammo\BaseAPI 'online_nation', 'online_user_cnt', 'year', 'month', 'startyear', 'maxgeneral', - 'conlimit', + 'refreshLimit', 'server_cnt', ]); @@ -537,8 +537,8 @@ class GetFrontInfo extends \sammo\BaseAPI $nationID = $general->getNationID(); $cityID = $general->getCityID(); - $con = checkLimit($general->getVar('con')); - if ($con >= 2) { + $limitState = checkLimit($general->getVar('refresh_score') ?? 0); + if ($limitState >= 2) { return [ 'result' => false, 'reason' => '접속 제한중입니다.', diff --git a/hwe/sammo/API/Global/GeneralList.php b/hwe/sammo/API/Global/GeneralList.php index 5355bb2d..27a558a5 100644 --- a/hwe/sammo/API/Global/GeneralList.php +++ b/hwe/sammo/API/Global/GeneralList.php @@ -42,9 +42,12 @@ class GeneralList extends \sammo\BaseAPI $userID = $session->userID; if ($session->isGameLoggedIn()) { increaseRefresh("장수일람", 2); - $me = $db->queryFirstRow('SELECT con, turntime FROM general WHERE owner=%i', $userID); - $con = checkLimit($me['con']); - if ($con >= 2) { + $me = $db->queryFirstRow( + 'SELECT refresh_score, turntime FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID + ); + $limitState = checkLimit($me['refresh_score']); + if ($limitState >= 2) { return '접속 제한중입니다. 1턴 이내에 너무 많은 갱신을 하셨습니다.'; } } else { diff --git a/hwe/sammo/API/Global/GetHistory.php b/hwe/sammo/API/Global/GetHistory.php index 068d883b..c91257b5 100644 --- a/hwe/sammo/API/Global/GetHistory.php +++ b/hwe/sammo/API/Global/GetHistory.php @@ -148,13 +148,16 @@ class GetHistory extends \sammo\BaseAPI } increaseRefresh("연감", 1); - $me = $db->queryFirstRow('SELECT con, turntime FROM general WHERE owner = %i', $session->userID); + $me = $db->queryFirstRow( + 'SELECT refresh_score, turntime FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner = %i', $session->userID + ); if (!$me) { return '장수가 사망했습니다.'; } - $con = checkLimit($me['con']); - if ($con >= 2) { + $limitState = checkLimit($me['refresh_score']); + if ($limitState >= 2) { return templateLimitMsg($me['turntime']); } } diff --git a/hwe/sammo/API/Message/GetOldMessage.php b/hwe/sammo/API/Message/GetOldMessage.php index e683d086..c4c93f17 100644 --- a/hwe/sammo/API/Message/GetOldMessage.php +++ b/hwe/sammo/API/Message/GetOldMessage.php @@ -75,7 +75,7 @@ class GetOldMessage extends \sammo\BaseAPI $db = DB::db(); - $me = $db->queryFirstRow('SELECT `no`,`name`,`nation`,`officer_level`,`con`,`picture`,`imgsvr`,penalty,permission FROM general WHERE `owner`=%i', $userID); + $me = $db->queryFirstRow('SELECT `no`,`name`,`nation`,`officer_level`,`picture`,`imgsvr`,penalty,permission FROM general WHERE `owner`=%i', $userID); if ($me === null) { return '장수가 사망했습니다.'; diff --git a/hwe/sammo/API/Message/GetRecentMessage.php b/hwe/sammo/API/Message/GetRecentMessage.php index ae535db0..41c74a4d 100644 --- a/hwe/sammo/API/Message/GetRecentMessage.php +++ b/hwe/sammo/API/Message/GetRecentMessage.php @@ -73,7 +73,7 @@ class GetRecentMessage extends \sammo\BaseAPI $db = DB::db(); - $me = $db->queryFirstRow('SELECT `no`,`name`,`nation`,`officer_level`,`con`,`picture`,`imgsvr`,penalty,permission FROM general WHERE `owner`=%i', $userID); + $me = $db->queryFirstRow('SELECT `no`,`name`,`nation`,`officer_level`,`picture`,`imgsvr`,penalty,permission FROM general WHERE `owner`=%i', $userID); if ($me === null) { return '장수가 사망했습니다.'; diff --git a/hwe/sammo/API/Message/SendMessage.php b/hwe/sammo/API/Message/SendMessage.php index cc740342..9937bf36 100644 --- a/hwe/sammo/API/Message/SendMessage.php +++ b/hwe/sammo/API/Message/SendMessage.php @@ -108,7 +108,7 @@ class SendMessage extends \sammo\BaseAPI $unlimited = new \DateTime('9999-12-31'); $db = DB::db(); - $destUser = $db->queryFirstRow('SELECT `no`,`name`,`nation`,`officer_level`,`con`,`picture`,`imgsvr`,permission,penalty FROM general WHERE `no`=%i', $destGeneralID); + $destUser = $db->queryFirstRow('SELECT `no`,`name`,`nation`,`officer_level`,`picture`,`imgsvr`,permission,penalty FROM general WHERE `no`=%i', $destGeneralID); if (!$destUser) { return '존재하지 않는 유저입니다.'; @@ -160,15 +160,18 @@ class SendMessage extends \sammo\BaseAPI } $db = DB::db(); - $me = $db->queryFirstRow('SELECT `no`,`name`,`nation`,`officer_level`,`con`,`picture`,`imgsvr`,penalty,permission,belong FROM general WHERE `owner`=%i', $userID); + $me = $db->queryFirstRow( + 'SELECT `no`,`name`,`nation`,`officer_level`,`refresh_score`,`picture`,`imgsvr`,penalty,permission,belong FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE `owner`=%i', $userID + ); if (!$me) { $session->logoutGame(); return '장수가 없습니다.'; } - $con = checkLimit($me['con']); - if ($con >= 2) { + $limitState = checkLimit($me['refresh_score']); + if ($limitState >= 2) { return '접속 제한입니다.'; } diff --git a/hwe/sammo/API/Nation/GeneralList.php b/hwe/sammo/API/Nation/GeneralList.php index 17c9011d..28f17547 100644 --- a/hwe/sammo/API/Nation/GeneralList.php +++ b/hwe/sammo/API/Nation/GeneralList.php @@ -146,9 +146,12 @@ class GeneralList extends \sammo\BaseAPI $gameStor = \sammo\KVStorage::getStorage($db, 'game_env'); $env = $gameStor->getValues(['year', 'month', 'turntime', 'turnterm', 'autorun_user', 'killturn']); - $me = $db->queryFirstRow('SELECT con, turntime, belong, nation, officer_level, permission, penalty FROM general WHERE owner=%i', $session->getUserID()); - $con = checkLimit($me['con']); - if ($con >= 2) { + $me = $db->queryFirstRow( + 'SELECT refresh_score, turntime, belong, nation, officer_level, permission, penalty FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $session->getUserID() + ); + $limitState = checkLimit($me['refresh_score']); + if ($limitState >= 2) { return '접속 제한중입니다. 1턴 이내에 너무 많은 갱신을 하셨습니다.'; } diff --git a/hwe/sammo/API/Nation/GetGeneralLog.php b/hwe/sammo/API/Nation/GetGeneralLog.php index 1be029b2..a9d556f9 100644 --- a/hwe/sammo/API/Nation/GetGeneralLog.php +++ b/hwe/sammo/API/Nation/GetGeneralLog.php @@ -109,10 +109,12 @@ class GetGeneralLog extends \sammo\BaseAPI $reqTo = $this->args['reqTo'] ?? null; $db = DB::db(); - $me = $db->queryFirstRow('SELECT no,nation,officer_level,con,turntime,belong,permission,penalty from general where owner=%i', $userID); + $me = $db->queryFirstRow( + 'SELECT no,nation,officer_level,refresh_score,turntime,belong,permission,penalty FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID); - $con = checkLimit($me['con']); - if ($con >= 2) { + $limitState = checkLimit($me['refresh_score']); + if ($limitState >= 2) { return '접속 제한입니다.'; } diff --git a/hwe/sammo/API/NationCommand/GetReservedCommand.php b/hwe/sammo/API/NationCommand/GetReservedCommand.php index 5eb77e1a..06abcb99 100644 --- a/hwe/sammo/API/NationCommand/GetReservedCommand.php +++ b/hwe/sammo/API/NationCommand/GetReservedCommand.php @@ -39,12 +39,15 @@ class GetReservedCommand extends \sammo\BaseAPI $gameStor = KVStorage::getStorage($db, 'game_env'); $userID = $session->userID; - $me = $db->queryFirstRow('SELECT no,nation,officer_level,con,turntime,belong,penalty,permission FROM general WHERE owner=%i', $userID); + $me = $db->queryFirstRow( + 'SELECT no,nation,officer_level,refresh_score,turntime,belong,penalty,permission FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID + ); $nationLevel = $db->queryFirstField('SELECT level FROM nation WHERE nation = %i', $me['nation']); $nationID = $me['nation']; - $con = checkLimit($me['con']); - if ($con >= 2) { + $limitState = checkLimit($me['refresh_score']); + if ($limitState >= 2) { return "접속 제한중입니다. 1턴 이내에 너무 많은 갱신을 하셨습니다. (다음 갱신 가능 시각 : {$me['turntime']})"; } diff --git a/hwe/sammo/Event/Action/InvaderEnding.php b/hwe/sammo/Event/Action/InvaderEnding.php index d4d5888a..aa458fbc 100644 --- a/hwe/sammo/Event/Action/InvaderEnding.php +++ b/hwe/sammo/Event/Action/InvaderEnding.php @@ -63,7 +63,7 @@ class InvaderEnding extends \sammo\Event\Action{ $gameStor->setValue('isunited', 3); $logger->flush(); - $gameStor->conlimit = $gameStor->conlimit * 100; + $gameStor->refreshLimit = $gameStor->refreshLimit * 100; $eventID = Util::array_get($env['currentEventID']); $db->delete('event', 'id = %i', $eventID); diff --git a/hwe/sammo/ResetHelper.php b/hwe/sammo/ResetHelper.php index 917cb2ba..a6cb8003 100644 --- a/hwe/sammo/ResetHelper.php +++ b/hwe/sammo/ResetHelper.php @@ -280,7 +280,7 @@ class ResetHelper{ 'msg'=>'공지사항',//TODO:공지사항 'maxgeneral'=>GameConst::$defaultMaxGeneral, 'maxnation'=>GameConst::$defaultMaxNation, - 'conlimit'=>30000, + 'refreshLimit'=>30000, 'develcost'=>$develcost, 'turntime'=>$turntime, 'starttime'=>$starttime, diff --git a/hwe/sammo/TurnExecutionHelper.php b/hwe/sammo/TurnExecutionHelper.php index c20a1a76..5621ce2b 100644 --- a/hwe/sammo/TurnExecutionHelper.php +++ b/hwe/sammo/TurnExecutionHelper.php @@ -175,7 +175,9 @@ class TurnExecutionHelper $general = $this->getGeneral(); $generalID = $general->getID(); $logger = $general->getLogger(); - $general->setVar('con', 0); + $db->update('general_access_log', [ + 'refresh_score' => 0, + ], 'general_id=%i', $generalID); $generalName = $general->getName(); diff --git a/hwe/t_diplomacy.php b/hwe/t_diplomacy.php index 1969d018..dc4f6c81 100644 --- a/hwe/t_diplomacy.php +++ b/hwe/t_diplomacy.php @@ -13,11 +13,14 @@ $gameStor = KVStorage::getStorage($db, 'game_env'); increaseRefresh("내무부", 1); -$me = $db->queryFirstRow('SELECT no, nation, officer_level, permission, con, turntime, belong, penalty FROM general WHERE owner=%i', $userID); +$me = $db->queryFirstRow( + 'SELECT no, nation, officer_level, permission, refresh_score, turntime, belong, penalty FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID +); -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { printLimitMsg($me['turntime']); exit(); } diff --git a/hwe/v_NPCControl.php b/hwe/v_NPCControl.php index 6500ccd9..366ecef4 100644 --- a/hwe/v_NPCControl.php +++ b/hwe/v_NPCControl.php @@ -15,13 +15,16 @@ $gameStor->cacheValues(['autorun_user', 'develcost']); increaseRefresh("NPC 정책", 1); -$me = $db->queryFirstRow('SELECT no, npc, nation, city, officer_level, con, turntime, belong, permission, penalty FROM general WHERE owner=%i', $userID); +$me = $db->queryFirstRow( + 'SELECT no, npc, nation, city, officer_level, refresh_score, turntime, belong, permission, penalty FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID +); $nationID = $me['nation']; $nation = $db->queryFirstRow('SELECT nation,level,name,color,type,gold,rice,bill,tech,rate,scout,war,secretlimit,capital FROM nation WHERE nation = %i', $nationID); -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { printLimitMsg($me['turntime']); exit(); } diff --git a/hwe/v_auction.php b/hwe/v_auction.php index dac367e7..820d6b14 100644 --- a/hwe/v_auction.php +++ b/hwe/v_auction.php @@ -12,9 +12,6 @@ $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); $isResAuction = Util::getReq('type') !== 'unique'; - -$me = $db->queryFirstRow('SELECT no, nation, officer_level, permission, con, turntime, belong, penalty FROM general WHERE owner=%i', $userID); - ?> diff --git a/hwe/v_board.php b/hwe/v_board.php index f552a145..2e87beba 100644 --- a/hwe/v_board.php +++ b/hwe/v_board.php @@ -15,14 +15,7 @@ $isSecretBoard = Util::getReq('isSecret', 'bool', false); //increaseRefresh("회의실", 1); -$me = $db->queryFirstRow('SELECT no, nation, officer_level, permission, con, turntime, belong, penalty FROM general WHERE owner=%i', $userID); - - -$con = checkLimit($me['con']); -if ($con >= 2) { - printLimitMsg($me['turntime']); - exit(); -} +$me = $db->queryFirstRow('SELECT no, nation, officer_level, permission, turntime, belong, penalty FROM general WHERE owner=%i', $userID); $permission = checkSecretPermission($me); if ($permission < 0) { diff --git a/hwe/v_history.php b/hwe/v_history.php index aafc1452..7b4113e7 100644 --- a/hwe/v_history.php +++ b/hwe/v_history.php @@ -31,9 +31,6 @@ else{ [$currentYear, $currentMonth] = [$l_year, $l_month]; } - -$me = $db->queryFirstRow('SELECT con, turntime FROM general WHERE owner = %i', $userID); - ?> diff --git a/hwe/v_nationStratFinan.php b/hwe/v_nationStratFinan.php index c2c2647a..bcc1c6f3 100644 --- a/hwe/v_nationStratFinan.php +++ b/hwe/v_nationStratFinan.php @@ -13,10 +13,13 @@ $gameStor = KVStorage::getStorage($db, 'game_env'); increaseRefresh("내무부", 1); -$me = $db->queryFirstRow('SELECT no, nation, officer_level, con, turntime, belong, permission, penalty FROM general WHERE owner=%i', $userID); +$me = $db->queryFirstRow( + 'SELECT no, nation, officer_level, refresh_score, turntime, belong, permission, penalty FROM `general` + LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID +); -$con = checkLimit($me['con']); -if ($con >= 2) { +$limitState = checkLimit($me['refresh_score']); +if ($limitState >= 2) { printLimitMsg($me['turntime']); exit(); } -- 2.54.0 From 758ae06fd92a5c725011fb02196992aa1595356d Mon Sep 17 00:00:00 2001 From: Hide_D Date: Thu, 6 Jul 2023 18:45:35 +0000 Subject: [PATCH 11/21] =?UTF-8?q?refac,=20wip:=20con=20=EC=82=AD=EC=A0=9C,?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EA=B4=80=EB=A0=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/j_select_npc.php | 7 +++++++ hwe/sammo/General.php | 1 + hwe/sammo/TurnExecutionHelper.php | 2 ++ hwe/sql/schema.sql | 2 -- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/hwe/j_select_npc.php b/hwe/j_select_npc.php index e77ebda4..88ddcc71 100644 --- a/hwe/j_select_npc.php +++ b/hwe/j_select_npc.php @@ -1,6 +1,8 @@ update('general', [ 'owner'=>$userID, 'aux'=>Json::encode($genAux) ], 'owner <= 0 AND npc = 2 AND no = %i', $pick); +$db->insertIgnore('general_access_log', [ + GeneralAccessLogColumn::generalID->value => $generalID, + GeneralAccessLogColumn::userID->value => $userID, + GeneralAccessLogColumn::lastRefresh->value => $now, +]); if(!$db->affectedRows()){ Json::die([ diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index 1980238a..96599797 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -678,6 +678,7 @@ class General implements iAction $db->delete('general', 'no=%i', $generalID); $db->delete('general_turn', 'general_id=%i', $generalID); $db->delete('rank_data', 'general_id=%i', $generalID); + $db->delete('general_access_log', 'general_id=%i', $generalID); $this->updatedVar = []; $db->update('nation', [ diff --git a/hwe/sammo/TurnExecutionHelper.php b/hwe/sammo/TurnExecutionHelper.php index 5621ce2b..ca17ad71 100644 --- a/hwe/sammo/TurnExecutionHelper.php +++ b/hwe/sammo/TurnExecutionHelper.php @@ -196,6 +196,8 @@ class TurnExecutionHelper $general->setVar('owner', 0); $general->setVar('defence_train', 80); $general->setVar('owner_name', null); + + $db->delete('general_access_log', 'general_id=%i', $generalID); } else { $general->applyDB($db); $general->kill($db); diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index ba20a63b..70f29443 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -11,8 +11,6 @@ CREATE TABLE `general` ( `bornyear` INT(3) NULL DEFAULT '180', `deadyear` INT(3) NULL DEFAULT '300', `newmsg` INT(1) NULL DEFAULT '0', - `con` INT(6) NOT NULL DEFAULT '0', - `connect` INT(6) NOT NULL DEFAULT '0', `picture` VARCHAR(40) NOT NULL, `imgsvr` INT(1) NOT NULL DEFAULT '0', `name` VARCHAR(32) NOT NULL COLLATE 'utf8mb4_bin', -- 2.54.0 From 6b400f76cfe737accc44a8a1ee6507f62547c467 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Fri, 7 Jul 2023 15:58:18 +0000 Subject: [PATCH 12/21] =?UTF-8?q?fix:=20=EC=98=A4=ED=83=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sql/reset.sql | 2 +- hwe/sql/schema.sql | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hwe/sql/reset.sql b/hwe/sql/reset.sql index 562287b5..e9e9ab2e 100644 --- a/hwe/sql/reset.sql +++ b/hwe/sql/reset.sql @@ -1,7 +1,7 @@ # 장수 테이블 삭제 DROP TABLE IF EXISTS general; DROP TABLE IF EXISTS `general_turn`; -DROP TABLE IF EXISTS `general_acess_log`; +DROP TABLE IF EXISTS `general_access_log`; # 국가 테이블 삭제 DROP TABLE IF EXISTS nation; DROP TABLE IF EXISTS `nation_turn`; diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index 70f29443..dc59b926 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -103,11 +103,11 @@ CREATE TABLE `general_access_log` ( `refresh_score` INT(11) NOT NULL DEFAULT '0', `refresh_score_total` INT(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), - UNIQUE INDEX `general_id` (`general_id`), + UNIQUE INDEX `general_id` (`general_id`) ) COLLATE='utf8mb4_general_ci' -ENGINE=Aria -; +ENGINE=Aria; + ############################## ## 국가 테이블 ############################## -- 2.54.0 From f66008da56e99c447f43b2824b9d7bb5df2cbfeb Mon Sep 17 00:00:00 2001 From: Hide_D Date: Fri, 7 Jul 2023 17:08:05 +0000 Subject: [PATCH 13/21] =?UTF-8?q?refac,=20fix:=20General=20=EA=B0=9D?= =?UTF-8?q?=EC=B2=B4=20=EC=83=9D=EC=84=B1=20=EA=B3=BC=EC=A0=95=EC=97=90?= =?UTF-8?q?=EC=84=9C=20accessLog=20=EB=B6=84=EB=A6=AC=20-=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=EC=9E=90=20=EC=9D=B8=EC=88=98=201=EA=B0=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80,=20-=20mergeQueryColumn=EC=97=90=EC=84=9C=20?= =?UTF-8?q?$accessLogColumn=EC=97=90=20=EC=A0=95=EC=83=81=EC=A0=81?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20enum[]=20=EB=B0=98=EC=98=81=20-=20createGe?= =?UTF-8?q?neralObjListFromDB=EB=A5=BC=20=EC=BF=BC=EB=A6=AC=201=ED=9A=8C?= =?UTF-8?q?=20=EB=B6=84=EB=A6=AC=20-=20General=EC=97=90=20getAccessLogVar(?= =?UTF-8?q?)=20=EC=B6=94=EA=B0=80=20=20=20-=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=A0=9C=EA=B3=B5=20=EC=98=88=EC=A0=95=20?= =?UTF-8?q?'=EC=97=86=EC=9D=8C'=20-=20=EB=B3=80=EA=B2=BD=EB=90=9C=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EC=9E=90=EC=97=90=20=EB=A7=9E=EA=B2=8C=20?= =?UTF-8?q?=ED=98=B8=EC=B6=9C=20=EB=B6=80=20=EB=B3=80=EA=B2=BD=20-=20NPC?= =?UTF-8?q?=EC=9D=B8=20=EA=B2=BD=EC=9A=B0=20accessLog=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=EA=B0=92=EC=9D=B4=20null=EC=9D=BC=20=EC=88=98=20=EC=9E=88?= =?UTF-8?q?=EC=9C=BC=EB=AF=80=EB=A1=9C=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/b_currentCity.php | 2 +- hwe/func.php | 8 +- hwe/func_time_event.php | 2 +- hwe/j_simulate_battle.php | 8 +- hwe/process_war.php | 2 +- hwe/sammo/API/General/GetFrontInfo.php | 6 +- hwe/sammo/API/Global/GeneralList.php | 2 +- hwe/sammo/API/Nation/GeneralList.php | 4 +- .../API/NationCommand/GetReservedCommand.php | 2 +- hwe/sammo/Constraint/ReqGeneralCrewMargin.php | 2 +- hwe/sammo/Event/Action/ProcessIncome.php | 4 +- hwe/sammo/Event/Action/RaiseDisaster.php | 2 +- hwe/sammo/General.php | 126 ++++++++---- hwe/ts/components/GeneralBasicCard.vue | 2 +- hwe/ts/components/GeneralList.vue | 186 +++++++++--------- hwe/ts/components/GeneralLiteCard.vue | 2 +- hwe/ts/defs/API/Nation.ts | 4 +- hwe/ts/utilGame/formatRefreshScore.ts | 3 +- hwe/v_NPCControl.php | 2 +- 19 files changed, 210 insertions(+), 159 deletions(-) diff --git a/hwe/b_currentCity.php b/hwe/b_currentCity.php index f650ad32..565822f6 100644 --- a/hwe/b_currentCity.php +++ b/hwe/b_currentCity.php @@ -327,7 +327,7 @@ $templates = new \League\Plates\Engine('templates'); if ($ourGeneral && !$isNPC) { $turnText = []; - $generalObj = new General($general, null, null, null, null, null, false); + $generalObj = new General($general, null, null, null, null, null, null, false); foreach ($generalTurnList[$generalObj->getID()] as $turnRawIdx => $turn) { $turnIdx = $turnRawIdx + 1; $turnText[] = "{$turnIdx} : $turn"; diff --git a/hwe/func.php b/hwe/func.php index 90f5da0a..bc6d6eba 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1026,12 +1026,16 @@ function increaseRefresh($type = "", $cnt = 1) GeneralAccessLogColumn::generalID->value => $generalID, GeneralAccessLogColumn::userID->value => $userID, GeneralAccessLogColumn::lastRefresh->value => $date, - GeneralAccessLogColumn::refreshTotal->value => $db->sqleval('%b + %i', GeneralAccessLogColumn::refreshTotal->value, $cnt), - GeneralAccessLogColumn::refresh->value => $db->sqleval('%b + %i', GeneralAccessLogColumn::refresh->value, $cnt), + GeneralAccessLogColumn::refreshTotal->value => $cnt, + GeneralAccessLogColumn::refresh->value => $cnt, + GeneralAccessLogColumn::refreshScore->value => $cnt, + GeneralAccessLogColumn::refreshScoreTotal->value => $cnt, ], [ GeneralAccessLogColumn::lastRefresh->value => $date, GeneralAccessLogColumn::refreshTotal->value => $db->sqleval('%b + %i', GeneralAccessLogColumn::refreshTotal->value, $cnt), GeneralAccessLogColumn::refresh->value => $db->sqleval('%b + %i', GeneralAccessLogColumn::refresh->value, $cnt), + GeneralAccessLogColumn::refreshScore->value => $db->sqleval('%b + %i', GeneralAccessLogColumn::refreshScore->value, $cnt), + GeneralAccessLogColumn::refreshScoreTotal->value => $db->sqleval('%b + %i', GeneralAccessLogColumn::refreshScoreTotal->value, $cnt), ]); $serverPath = __DIR__; diff --git a/hwe/func_time_event.php b/hwe/func_time_event.php index aebe8e8e..22086dd8 100644 --- a/hwe/func_time_event.php +++ b/hwe/func_time_event.php @@ -383,7 +383,7 @@ function disaster(RandUtil $rng) { $generalList = array_map( function($rawGeneral) use ($city, $year, $month){ - return new General($rawGeneral, null, $city, null, $year, $month, false); + return new General($rawGeneral, null, null, $city, null, $year, $month, false); }, $generalListByCity[$city['city']]??[] ); diff --git a/hwe/j_simulate_battle.php b/hwe/j_simulate_battle.php index d5cf09b9..a43d1ee1 100644 --- a/hwe/j_simulate_battle.php +++ b/hwe/j_simulate_battle.php @@ -270,7 +270,7 @@ if (key_exists('inheritBuff', $rawAttacker)) { } $rawAttacker['aux'] = Json::encode($rawAttacker['aux']); $rawAttacker['owner'] = 0; -$attackerGeneral = new General($rawAttacker, extractRankVar($rawAttacker), $rawAttackerCity, $rawAttackerNation, $year, $month); +$attackerGeneral = new General($rawAttacker, extractRankVar($rawAttacker), null, $rawAttackerCity, $rawAttackerNation, $year, $month); $attacker = new WarUnitGeneral( $tmpRNG, $attackerGeneral, @@ -308,7 +308,7 @@ foreach ($rawDefenderList as $idx => $rawDefenderGeneral) { $rawDefenderGeneral['aux'] = Json::encode($rawDefenderGeneral['aux']); $rawDefenderGeneral['owner'] = 0; - $defenderGeneral = new General($rawDefenderGeneral, extractRankVar($rawDefenderGeneral), $rawDefenderCity, $rawAttackerNation, $year, $month, true); + $defenderGeneral = new General($rawDefenderGeneral, extractRankVar($rawDefenderGeneral), null, $rawDefenderCity, $rawAttackerNation, $year, $month, true); $defenderList[] = new WarUnitGeneral( $tmpRNG, @@ -382,7 +382,7 @@ function simulateBattle( $warRng = new RandUtil(new LiteHashDRBG($warSeed)); - $attackerGeneral = new General($rawAttacker, extractRankVar($rawAttacker), $rawAttackerCity, $rawAttackerNation, $year, $month); + $attackerGeneral = new General($rawAttacker, extractRankVar($rawAttacker), null, $rawAttackerCity, $rawAttackerNation, $year, $month); $attacker = new WarUnitGeneral( $warRng, $attackerGeneral, @@ -395,7 +395,7 @@ function simulateBattle( $defenderList = []; foreach ($rawDefenderList as $rawDefenderGeneral) { - $defenderGeneral = new General($rawDefenderGeneral, extractRankVar($rawDefenderGeneral), $rawDefenderCity, $rawAttackerNation, $year, $month, true); + $defenderGeneral = new General($rawDefenderGeneral, extractRankVar($rawDefenderGeneral), null, $rawDefenderCity, $rawAttackerNation, $year, $month, true); $defenderList[] = new WarUnitGeneral( $warRng, diff --git a/hwe/process_war.php b/hwe/process_war.php index 4f497991..6e27057d 100644 --- a/hwe/process_war.php +++ b/hwe/process_war.php @@ -598,7 +598,7 @@ function ConquerCity(array $admin, General $general, array $city) Util::formatListOfBackticks(General::mergeQueryColumn(['npc', 'gold', 'rice', 'experience', 'explevel', 'belong', 'dedication', 'dedlevel', 'aux'], 1)[0]), $defenderNationID, 12 - ), null, $city, $loseNation, $year, $month, false); + ), null, null, $city, $loseNation, $year, $month, false); $josaUl = JosaUtil::pick($defenderNationName, '을'); $attackerLogger->pushNationalHistoryLog("{$defenderNationName}{$josaUl} 정복"); diff --git a/hwe/sammo/API/General/GetFrontInfo.php b/hwe/sammo/API/General/GetFrontInfo.php index 43def670..69f7d169 100644 --- a/hwe/sammo/API/General/GetFrontInfo.php +++ b/hwe/sammo/API/General/GetFrontInfo.php @@ -385,7 +385,7 @@ class GetFrontInfo extends \sammo\BaseAPI 'personal' => $general->getVar(GeneralColumn::personal), // GameObjClassKey; 'belong' => $general->getVar(GeneralColumn::belong), // number; - 'refreshScoreTotal' => $general->getVar(GeneralAccessLogColumn::refreshScoreTotal), // number; + 'refreshScoreTotal' => $general->getAccessLogVar(GeneralAccessLogColumn::refreshScoreTotal, 0), // number; 'officerLevel' => $general->getVar(GeneralColumn::officer_level), // number; 'officerLevelText' => getOfficerLevelText($general->getVar(GeneralColumn::officer_level), $rawNation['level']), // string; @@ -402,7 +402,7 @@ class GetFrontInfo extends \sammo\BaseAPI 'troop' => $general->getVar(GeneralColumn::troop), // number; //P0 End - 'refreshScore' => $general->getVar(GeneralAccessLogColumn::refreshScore), // number; + 'refreshScore' => $general->getAccessLogVar(GeneralAccessLogColumn::refreshScore, 0), // number; 'specage' => $general->getVar(GeneralColumn::specage), // number; 'specage2' => $general->getVar(GeneralColumn::specage2), // number; 'leadership_exp' => $general->getVar(GeneralColumn::leadership_exp), // number; @@ -537,7 +537,7 @@ class GetFrontInfo extends \sammo\BaseAPI $nationID = $general->getNationID(); $cityID = $general->getCityID(); - $limitState = checkLimit($general->getVar('refresh_score') ?? 0); + $limitState = checkLimit($general->getAccessLogVar(GeneralAccessLogColumn::refreshScore, 0)); if ($limitState >= 2) { return [ 'result' => false, diff --git a/hwe/sammo/API/Global/GeneralList.php b/hwe/sammo/API/Global/GeneralList.php index 27a558a5..897159fa 100644 --- a/hwe/sammo/API/Global/GeneralList.php +++ b/hwe/sammo/API/Global/GeneralList.php @@ -108,7 +108,7 @@ class GeneralList extends \sammo\BaseAPI getDed($dedication), getOfficerLevelText($officerLevel, $nationArr['level']), $killturn, - $refreshScoreTotal + $refreshScoreTotal ?: 0, ]; } diff --git a/hwe/sammo/API/Nation/GeneralList.php b/hwe/sammo/API/Nation/GeneralList.php index 28f17547..a61424fa 100644 --- a/hwe/sammo/API/Nation/GeneralList.php +++ b/hwe/sammo/API/Nation/GeneralList.php @@ -82,7 +82,7 @@ class GeneralList extends \sammo\BaseAPI 'owner_name' => 9, //안씀. - //acessLog + //accessLog 'refresh_score_total' => 0, 'refresh_score' => 1, @@ -98,6 +98,8 @@ class GeneralList extends \sammo\BaseAPI static $columnRemap = [ 'special' => 'specialDomestic', 'special2' => 'specialWar', + 'refresh_score_total' => 'refreshScoreTotal', + 'refresh_score' => 'refreshScore', 'aux' => null, ]; diff --git a/hwe/sammo/API/NationCommand/GetReservedCommand.php b/hwe/sammo/API/NationCommand/GetReservedCommand.php index 06abcb99..dd08f3b8 100644 --- a/hwe/sammo/API/NationCommand/GetReservedCommand.php +++ b/hwe/sammo/API/NationCommand/GetReservedCommand.php @@ -62,7 +62,7 @@ class GetReservedCommand extends \sammo\BaseAPI $generals = []; foreach ($db->query('SELECT no,name,turntime,npc,city,nation,officer_level FROM general WHERE nation = %i AND officer_level >= 5', $nationID) as $rawGeneral) { - $generals[$rawGeneral['officer_level']] = new General($rawGeneral, null, null, null, $year, $month, false); + $generals[$rawGeneral['officer_level']] = new General($rawGeneral, null, null, null, null, $year, $month, false); } $nationTurnList = []; diff --git a/hwe/sammo/Constraint/ReqGeneralCrewMargin.php b/hwe/sammo/Constraint/ReqGeneralCrewMargin.php index d1d141e2..1f8f5e8d 100644 --- a/hwe/sammo/Constraint/ReqGeneralCrewMargin.php +++ b/hwe/sammo/Constraint/ReqGeneralCrewMargin.php @@ -39,7 +39,7 @@ class ReqGeneralCrewMargin extends Constraint{ //XXX: 왜 General -> obj -> General 변환을 하고 있나? //FIXME: RankVar, city에 따라 통솔이 바뀐다면 이 부분에 문제가 발생. - $generalObj = new General($this->general, null, null, null, null, null, true); + $generalObj = new General($this->general, null, null, null, null, null, null, true); if($reqCrewType->id != $generalObj->getCrewTypeObj()->id){ return true; diff --git a/hwe/sammo/Event/Action/ProcessIncome.php b/hwe/sammo/Event/Action/ProcessIncome.php index f0ad251d..7173070f 100644 --- a/hwe/sammo/Event/Action/ProcessIncome.php +++ b/hwe/sammo/Event/Action/ProcessIncome.php @@ -88,7 +88,7 @@ class ProcessIncome extends \sammo\Event\Action // 각 장수들에게 지급 foreach ($generalRawList as $rawGeneral) { - $generalObj = new General($rawGeneral, null, null, null, $year, $month, false); + $generalObj = new General($rawGeneral, null, null, null, null, $year, $month, false); $gold = Util::round(getBill($generalObj->getVar('dedication')) * $ratio); $generalObj->increaseVar('gold', $gold); @@ -169,7 +169,7 @@ class ProcessIncome extends \sammo\Event\Action // 각 장수들에게 지급 foreach ($generalRawList as $rawGeneral) { - $generalObj = new General($rawGeneral, null, null, null, $year, $month, false); + $generalObj = new General($rawGeneral, null, null, null, null, $year, $month, false); $rice = Util::round(getBill($generalObj->getVar('dedication')) * $ratio); $generalObj->increaseVar('rice', $rice); diff --git a/hwe/sammo/Event/Action/RaiseDisaster.php b/hwe/sammo/Event/Action/RaiseDisaster.php index 28cc3b9a..da7cb8b0 100644 --- a/hwe/sammo/Event/Action/RaiseDisaster.php +++ b/hwe/sammo/Event/Action/RaiseDisaster.php @@ -131,7 +131,7 @@ class RaiseDisaster extends \sammo\Event\Action $generalList = array_map( function ($rawGeneral) use ($city, $year, $month) { - return new General($rawGeneral, null, $city, null, $year, $month, false); + return new General($rawGeneral, null, null, $city, null, $year, $month, false); }, $generalListByCity[$city['city']] ?? [] ); diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index 96599797..9ea8fa3f 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -24,6 +24,9 @@ class General implements iAction /** @var Map */ protected Map $rankVarSet; + /** @var Map */ + protected ?Map $accessLogRead; + /** @var \sammo\ActionLogger */ protected $logger; @@ -79,12 +82,13 @@ class General implements iAction /** * @param array $raw DB row값. * @param null|Map $rawRank + * @param null|Map $rawAccessLog * @param null|array $city DB city 테이블의 row값 * @param int|null $year 게임 연도 * @param int|null $month 게임 월 * @param bool $fullConstruct iAction, 및 ActionLogger 초기화 여부, false인 경우 no, name, city, nation, officer_level 정도로 초기화 가능 */ - public function __construct(array $raw, ?Map $rawRank, ?array $city, ?array $nation, ?int $year, ?int $month, bool $fullConstruct = true) + public function __construct(array $raw, ?Map $rawRank, ?Map $rawAccessLog, ?array $city, ?array $nation, ?int $year, ?int $month, bool $fullConstruct = true) { //TODO: 밖에서 가져오도록 하면 버그 확률이 높아짐. 필요한 raw 값을 직접 구해야함. @@ -110,6 +114,10 @@ class General implements iAction } else { $this->rankVarRead = new Map(); } + + $this->accessLogRead = $rawAccessLog; + + $this->rankVarIncrease = new Map(); $this->rankVarSet = new Map(); @@ -772,6 +780,19 @@ class General implements iAction return $this->rankVarRead[$key]; } + function getAccessLogVar(GeneralAccessLogColumn $key, $defaultValue = null): int | string | null + { + if (!$this->accessLogRead) { + return $defaultValue; + } + + if (!$this->accessLogRead->hasKey($key)) { + return $defaultValue; + } + + return $this->accessLogRead[$key]; + } + /** * @param \MeekroDB $db */ @@ -1026,11 +1047,15 @@ 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', 'refresh_score', 'refresh_score_total', 'aux', 'permission', 'penalty', + 'specage', 'specage2', 'aux', 'permission', 'penalty', + ]; + $fullAcessLogColumn = [ + GeneralAccessLogColumn::refreshScore, + GeneralAccessLogColumn::refreshScoreTotal, ]; if ($reqColumns === null) { - return [$fullColumn, RankColumn::cases()]; + return [$fullColumn, RankColumn::cases(), $fullAcessLogColumn]; } /** @var RankColumn[] */ @@ -1098,44 +1123,17 @@ class General implements iAction [$column, $rankColumn, $accessLogColumn] = static::mergeQueryColumn($column, $constructMode); if ($generalIDList === null) { - 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' - ); - } + $rawGenerals = Util::convertArrayToDict( + $db->query('SELECT %l FROM general WHERE 1', Util::formatListOfBackticks($column)), + 'no' + ); $generalIDList = array_keys($rawGenerals); } else { - 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' - ); - } - + $rawGenerals = Util::convertArrayToDict( + $db->query('SELECT %l FROM general WHERE no IN %li', Util::formatListOfBackticks($column), $generalIDList), + 'no' + ); } @@ -1157,6 +1155,23 @@ class General implements iAction } } + $rawAccessLogs = new Map(); + if ($accessLogColumn) { + $rawValue = $db->query( + 'SELECT `general_id`, %l FROM general_access_log WHERE general_id IN %li', + Util::formatListOfBackticks($accessLogColumn), + $generalIDList + ); + foreach ($rawValue as $rawLog) { + $generalID = $rawLog['general_id']; + $logValue = new Map(); + foreach ($rawLog as $key => $value) { + $logValue[GeneralAccessLogColumn::from($key)] = $value; + } + $rawAccessLogs[$generalID] = $logValue; + } + } + $result = []; foreach ($generalIDList as $generalID) { if (!key_exists($generalID, $rawGenerals)) { @@ -1166,7 +1181,7 @@ class General implements iAction if ($rawRanks->hasKey($generalID) && $rawRanks[$generalID]->count() !== count($rankColumn)) { throw new \RuntimeException('column의 수가 일치하지 않음 : ' . $generalID); } - $result[$generalID] = new static($rawGenerals[$generalID], $rawRanks[$generalID] ?? null, null, null, $year, $month, $constructMode > 1); + $result[$generalID] = new static($rawGenerals[$generalID], $rawRanks[$generalID] ?? null, $rawAccessLogs[$generalID] ?? null, null, null, $year, $month, $constructMode > 1); } return $result; @@ -1186,10 +1201,37 @@ class General implements iAction /** * @var string[] $column * @var RankColumn[] $rankColumn + * @var GeneralAccessLogCoumn[] $accessLogColumn */ - [$column, $rankColumn] = static::mergeQueryColumn($column, $constructMode); + [$column, $rankColumn, $accessLogColumn] = static::mergeQueryColumn($column, $constructMode); + + /** @var Map|null */ + $rawAccessLog = null; + + if (!$accessLogColumn) { + $rawGeneral = $db->queryFirstRow('SELECT %l FROM general WHERE no = %i', Util::formatListOfBackticks($column), $generalID); + } else { + $rawGeneral = $db->queryFirstRow( + 'SELECT %l, %l FROM `general` LEFT JOIN general_access_log + ON general.no = general_access_log.general_id WHERE no = %i', + Util::formatListOfBackticks($column), + Util::formatListOfBackticks($accessLogColumn), + $generalID + ); + + $rawAccessLog = new Map(); + foreach($accessLogColumn as $accessLogKey) { + if(!key_exists($accessLogKey->value, $rawGeneral)){ + continue; + } + $rawAccessLog[$accessLogKey] = $rawGeneral[$accessLogKey->value]; + unset($rawGeneral[$accessLogKey->value]); + } + if($rawAccessLog->count() === 0){ + $rawAccessLog = null; + } + } - $rawGeneral = $db->queryFirstRow('SELECT %l FROM general WHERE no = %i', Util::formatListOfBackticks($column), $generalID); if (!$rawGeneral) { return new DummyGeneral($constructMode > 0); } @@ -1208,7 +1250,7 @@ class General implements iAction } - $general = new static($rawGeneral, $rawRankValues, null, null, $year, $month, $constructMode > 1); + $general = new static($rawGeneral, $rawRankValues, $rawAccessLog, null, null, $year, $month, $constructMode > 1); return $general; } diff --git a/hwe/ts/components/GeneralBasicCard.vue b/hwe/ts/components/GeneralBasicCard.vue index 82b64512..0d1a1e4f 100644 --- a/hwe/ts/components/GeneralBasicCard.vue +++ b/hwe/ts/components/GeneralBasicCard.vue @@ -152,7 +152,7 @@
벌점
- {{ formatRefreshScore(general.refreshScoreTotal) }} {{ general.refreshScoreTotal.toLocaleString() }}점({{ general.refreshScore }}) + {{ formatRefreshScore(general.refreshScoreTotal) }} {{ (general.refreshScoreTotal ?? 0).toLocaleString() }}점({{ general.refreshScore ?? 0 }})
diff --git a/hwe/ts/components/GeneralList.vue b/hwe/ts/components/GeneralList.vue index df1de86b..321cc784 100644 --- a/hwe/ts/components/GeneralList.vue +++ b/hwe/ts/components/GeneralList.vue @@ -42,7 +42,7 @@ class="form-check-label" :for="`column-type-${colID}`" :style="{ - textDecoration: validColumns.has(colID) ? undefined : 'line-through', + textDecoration: validColumns.has(colID) ? undefined : 'line-through' }" > {{ col.getColDef().headerName }} @@ -57,7 +57,7 @@
, - required: true, + required: true }, troops: { type: Object as PropType>, - required: true, + required: true }, height: { type: String as PropType<"static" | "fill" | number | `${number}px` | `${number}%`>, required: false, - default: "static", + default: "static" }, env: { type: Object as PropType, - required: true, + required: true }, toolbarID: { type: String, required: false, - default: undefined, + default: undefined }, role: { type: String, required: false, - default: "generic", + default: "generic" }, availableGeneralClick: { type: Boolean, required: false, - default: true, - }, + default: true + } }); const emit = defineEmits<{ @@ -271,7 +271,7 @@ watch( displaySettingsKey, JSON.stringify({ version: displaySettingVersion, - settings, + settings }) ); console.log("저장!", Array.from(newSettings.keys())); @@ -305,7 +305,7 @@ function storeDisplaySetting() { const setting: GridDisplaySetting = { column: columnApi.value.getColumnState(), - columnGroup: columnApi.value.getColumnGroupState(), + columnGroup: columnApi.value.getColumnGroupState() }; displaySettings.value.set(nickName, setting); @@ -485,14 +485,14 @@ const sortableNumber: Omit = { comparator: (a, b, _a, _b, _desc) => a - b, sortingOrder: ["desc", "asc", null], filter: NumberFilter, - cellClass: rightAlignClass, + cellClass: rightAlignClass }; const defaultColDef = ref({ resizable: true, headerClass: "default-cell-header", cellClass: centerCellClass, floatingFilter: true, - width: 80, + width: 80 }); const columnRawDefs = ref>>({ icon: { @@ -510,7 +510,7 @@ const columnRawDefs = ref }, pinned: "left", cellClass: [props.availableGeneralClick ? "clickable-cell" : "", ...defaultCellClass], - lockPosition: true, + lockPosition: true }, name: { headerName: "장수명", @@ -524,7 +524,7 @@ const columnRawDefs = ref cellStyle: (val: CellClassParams) => { const gen = unwrap(val.data); const style: StyleValue = { - color: getNPCColor(gen.npc), + color: getNPCColor(gen.npc) }; return style as CellStyle; }, @@ -546,7 +546,7 @@ const columnRawDefs = ref cellClass: [props.availableGeneralClick ? "clickable-cell" : "", ...defaultCellClass], filter: true, hide: false, - lockVisible: true, + lockVisible: true }, //npc: { headerName: "NPC", colId: "npc", field: "npc" }, stat: { @@ -562,7 +562,7 @@ const columnRawDefs = ref const gen = unwrap(obj.data); return `${gen.leadership}|${gen.strength}|${gen.intel}`; }, - columnGroupShow: "closed", + columnGroupShow: "closed" }, { colId: "leadership", @@ -571,7 +571,7 @@ const columnRawDefs = ref ...sortableNumber, columnGroupShow: "open", width: 60, - type: "numericColumn", + type: "numericColumn" }, { colId: "strength", @@ -579,7 +579,7 @@ const columnRawDefs = ref field: "strength", ...sortableNumber, columnGroupShow: "open", - width: 60, + width: 60 }, { colId: "intel", @@ -587,9 +587,9 @@ const columnRawDefs = ref field: "intel", ...sortableNumber, columnGroupShow: "open", - width: 60, - }, - ], + width: 60 + } + ] }, officerLevel: { @@ -620,7 +620,7 @@ const columnRawDefs = ref }, filter: true, cellClass: centerCellClass, - width: 70, + width: 70 }, expDedLv: { headerName: "명성/계급", @@ -637,7 +637,7 @@ const columnRawDefs = ref return ""; } return `Lv ${data.explevel}
${data.dedLevelText}`; - }, + } }, { colId: "explevel", @@ -652,7 +652,7 @@ const columnRawDefs = ref }, ...sortableNumber, cellClass: centerCellClass, - columnGroupShow: "open", + columnGroupShow: "open" }, { colId: "dedlevel", @@ -667,14 +667,14 @@ const columnRawDefs = ref }, sortable: true, comparator: (a, b, _a, _b, _desc) => { - return (_a.data?.dedlevel??0) - (_b.data?.dedlevel??0); + return (_a.data?.dedlevel ?? 0) - (_b.data?.dedlevel ?? 0); }, sortingOrder: ["desc", "asc", null], filter: true, cellClass: centerCellClass, - columnGroupShow: "open", - }, - ], + columnGroupShow: "open" + } + ] }, goldRice: { headerName: "자금", @@ -704,7 +704,7 @@ const columnRawDefs = ref const lhsAmount = lhs.gold + lhs.rice; const rhsAmount = rhs.gold + rhs.rice; return lhsAmount - rhsAmount; - }, + } }, { colId: "gold", @@ -713,7 +713,7 @@ const columnRawDefs = ref ...sortableNumber, valueFormatter: numberFormatter("금"), width: 70, - columnGroupShow: "open", + columnGroupShow: "open" }, { colId: "rice", @@ -722,9 +722,9 @@ const columnRawDefs = ref ...sortableNumber, valueFormatter: numberFormatter("쌀"), width: 70, - columnGroupShow: "open", - }, - ], + columnGroupShow: "open" + } + ] }, city: { colId: "city", @@ -744,7 +744,7 @@ const columnRawDefs = ref return ""; } return convertSearch초성(gameConstStore.value.cityConst[data.city].name); - }, + } }, troop: { colId: "troop", @@ -795,7 +795,7 @@ const columnRawDefs = ref const [troopName, troopLeader] = troopInfo; const cityName = gameConstStore.value.cityConst[troopLeader.city].name; return convertSearch초성(`${troopName}$${cityName}`); - }, + } }, crewtypeAndCrew: { groupId: "crewtypeAndCrew", @@ -809,11 +809,11 @@ const columnRawDefs = ref cells: ((): GridCellInfo[][] => { return [ [{ target: "crewtype", iActionMap: gameConstStore.value.iActionInfo.crewtype }], - [{ target: "crew", converter: (value) => [`${value.crew.toLocaleString()}명`, undefined] }], + [{ target: "crew", converter: (value) => [`${value.crew.toLocaleString()}명`, undefined] }] ]; - })(), + })() }, - columnGroupShow: "closed", + columnGroupShow: "closed" }, { colId: "crewtype", @@ -821,7 +821,7 @@ const columnRawDefs = ref field: "crewtype", cellRenderer: SimpleTooltipCell, cellRendererParams: { - iActionMap: gameConstStore.value.iActionInfo.crewtype, + iActionMap: gameConstStore.value.iActionInfo.crewtype }, sortable: true, columnGroupShow: "open", @@ -832,7 +832,7 @@ const columnRawDefs = ref } const name = gameConstStore.value.iActionInfo.crewtype[data.crewtype].name; return convertSearch초성(name); - }, + } }, { colId: "crew", @@ -841,9 +841,9 @@ const columnRawDefs = ref ...sortableNumber, valueFormatter: numberFormatter("명"), width: 70, - columnGroupShow: "open", - }, - ], + columnGroupShow: "open" + } + ] }, trainAtmos: { groupId: "trainAtmos", @@ -859,7 +859,7 @@ const columnRawDefs = ref } return `${data.train}
${data.atmos}`; }, - columnGroupShow: "closed", + columnGroupShow: "closed" }, { colId: "train", @@ -868,7 +868,7 @@ const columnRawDefs = ref ...sortableNumber, valueFormatter: numberFormatter(), width: 70, - columnGroupShow: "open", + columnGroupShow: "open" }, { colId: "atmos", @@ -877,7 +877,7 @@ const columnRawDefs = ref ...sortableNumber, valueFormatter: numberFormatter(), width: 70, - columnGroupShow: "open", + columnGroupShow: "open" }, { colId: "defence_train", @@ -886,9 +886,9 @@ const columnRawDefs = ref sortable: true, sortingOrder: ["desc", "asc", null], valueFormatter: (value: GenValueParams) => formatDefenceTrain(value.value), - width: 50, - }, - ], + width: 50 + } + ] }, specials: { groupId: "specials", @@ -904,13 +904,13 @@ const columnRawDefs = ref [{ target: "personal", iActionMap: gameConstStore.value.iActionInfo.personality }], [ { target: "specialDomestic", iActionMap: gameConstStore.value.iActionInfo.specialDomestic }, - { target: "specialWar", iActionMap: gameConstStore.value.iActionInfo.specialWar }, - ], + { target: "specialWar", iActionMap: gameConstStore.value.iActionInfo.specialWar } + ] ]; - })(), + })() }, width: 80, - columnGroupShow: "closed", + columnGroupShow: "closed" }, { colId: "personal", @@ -918,7 +918,7 @@ const columnRawDefs = ref field: "personal", cellRenderer: SimpleTooltipCell, cellRendererParams: { - iActionMap: gameConstStore.value.iActionInfo.personality, + iActionMap: gameConstStore.value.iActionInfo.personality }, width: 60, sortable: true, @@ -927,7 +927,7 @@ const columnRawDefs = ref filterValueGetter: ({ data }) => { const name = gameConstStore.value.iActionInfo.personality[data.personal].name; return convertSearch초성(name); - }, + } }, { colId: "specialDomestic", @@ -935,7 +935,7 @@ const columnRawDefs = ref field: "specialDomestic", cellRenderer: SimpleTooltipCell, cellRendererParams: { - iActionMap: gameConstStore.value.iActionInfo.specialDomestic, + iActionMap: gameConstStore.value.iActionInfo.specialDomestic }, width: 60, sortable: true, @@ -944,7 +944,7 @@ const columnRawDefs = ref filterValueGetter: ({ data }) => { const name = gameConstStore.value.iActionInfo.specialDomestic[data.specialDomestic].name; return convertSearch초성(name); - }, + } }, { colId: "specialWar", @@ -952,7 +952,7 @@ const columnRawDefs = ref field: "specialWar", cellRenderer: SimpleTooltipCell, cellRendererParams: { - iActionMap: gameConstStore.value.iActionInfo.specialWar, + iActionMap: gameConstStore.value.iActionInfo.specialWar }, width: 60, sortable: true, @@ -961,9 +961,9 @@ const columnRawDefs = ref filterValueGetter: ({ data }) => { const name = gameConstStore.value.iActionInfo.specialWar[data.specialWar].name; return convertSearch초성(name); - }, - }, - ], + } + } + ] }, reservedCommandShort: { groupId: "reservedCommandShort", @@ -1005,9 +1005,9 @@ const columnRawDefs = ref }, cellStyle: { lineHeight: "1em", - fontSize: "0.85em", + fontSize: "0.85em" }, - columnGroupShow: "closed", + columnGroupShow: "closed" }, { colId: "reservedCommand", @@ -1042,11 +1042,11 @@ const columnRawDefs = ref }, cellStyle: { lineHeight: "1em", - fontSize: "0.85em", + fontSize: "0.85em" }, - columnGroupShow: "open", - }, - ], + columnGroupShow: "open" + } + ] }, turntime: { colId: "turntime", @@ -1061,7 +1061,7 @@ const columnRawDefs = ref return turntime.substring(14, 19); }, sortable: true, - cellClass: centerCellClass, + cellClass: centerCellClass }, recent_war: { colId: "recent_war", @@ -1076,7 +1076,7 @@ const columnRawDefs = ref return turntime.substring(14, 19); }, sortable: true, - cellClass: centerCellClass, + cellClass: centerCellClass }, years: { groupId: "years", @@ -1093,7 +1093,7 @@ const columnRawDefs = ref return `${data.age}세
${data.belong}년`; }, cellClass: centerCellClass, - columnGroupShow: "closed", + columnGroupShow: "closed" }, { colId: "age", @@ -1103,7 +1103,7 @@ const columnRawDefs = ref valueFormatter: (v: GenValueParams) => `${v.value}세`, width: 60, cellClass: centerCellClass, - columnGroupShow: "open", + columnGroupShow: "open" }, { colId: "belong", @@ -1113,9 +1113,9 @@ const columnRawDefs = ref valueFormatter: (v: GenValueParams) => `${v.value}년`, width: 60, cellClass: centerCellClass, - columnGroupShow: "open", - }, - ], + columnGroupShow: "open" + } + ] }, killturnAndRefresh: { groupId: "killturnAndRefresh", @@ -1128,11 +1128,11 @@ const columnRawDefs = ref if (data === undefined) { return "?"; } - return `${data.killturn.toLocaleString()}턴
${data.refreshScoreTotal.toLocaleString()}점`; + return `${data.killturn.toLocaleString()}턴
${(data.refreshScoreTotal ?? 0).toLocaleString()}점`; }, cellClass: rightAlignClass, columnGroupShow: "closed", - width: 70, + width: 70 }, { colId: "killturn", @@ -1146,7 +1146,7 @@ const columnRawDefs = ref }, ...sortableNumber, width: 70, - columnGroupShow: "open", + columnGroupShow: "open" }, { colId: "refreshScoreTotal", @@ -1156,13 +1156,15 @@ const columnRawDefs = ref if (data === undefined) { return "?"; } - return `${data.refreshScoreTotal.toLocaleString()}점
(${formatRefreshScore(data.refreshScoreTotal)})`; + return `${(data.refreshScoreTotal ?? 0).toLocaleString()}점
(${formatRefreshScore( + data.refreshScoreTotal + )})`; }, ...sortableNumber, width: 70, - columnGroupShow: "open", - }, - ], + columnGroupShow: "open" + } + ] }, warResults: { groupId: "warResults", @@ -1180,7 +1182,7 @@ const columnRawDefs = ref }, cellClass: centerCellClass, columnGroupShow: "closed", - width: 90, + width: 90 }, { colId: "warnum", @@ -1189,7 +1191,7 @@ const columnRawDefs = ref ...sortableNumber, valueFormatter: numberFormatter("전"), columnGroupShow: "open", - width: 60, + width: 60 }, { colId: "killnum", @@ -1198,7 +1200,7 @@ const columnRawDefs = ref ...sortableNumber, valueFormatter: numberFormatter("승"), columnGroupShow: "open", - width: 60, + width: 60 }, { colId: "killcrew", @@ -1214,10 +1216,10 @@ const columnRawDefs = ref }, valueFormatter: numberFormatter("%"), columnGroupShow: "open", - width: 60, - }, - ], - }, + width: 60 + } + ] + } }); const columnDefs = ref([...Object.values(columnRawDefs.value)]); watch(columnRawDefs, (val) => { diff --git a/hwe/ts/components/GeneralLiteCard.vue b/hwe/ts/components/GeneralLiteCard.vue index af4fd67d..2183b75f 100644 --- a/hwe/ts/components/GeneralLiteCard.vue +++ b/hwe/ts/components/GeneralLiteCard.vue @@ -79,7 +79,7 @@
벌점
- {{ formatRefreshScore(general.refreshScoreTotal) }} {{ general.refreshScoreTotal.toLocaleString() }}점 + {{ formatRefreshScore(general.refreshScoreTotal) }} {{ (general.refreshScoreTotal ?? 0).toLocaleString() }}점
diff --git a/hwe/ts/defs/API/Nation.ts b/hwe/ts/defs/API/Nation.ts index 2f88ecb3..cf221689 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; - refreshScoreTotal: number; + refreshScoreTotal: number | null; officerLevel: number; //권한에따라 태수,군사,시종 노출 여부가 다름 officerLevelText: string; @@ -46,7 +46,7 @@ export type GeneralListItemP0 = { }; export type GeneralListItemP1 = { - refreshScore: number; + refreshScore: number | null; specage: number; specage2: number; leadership_exp: number; diff --git a/hwe/ts/utilGame/formatRefreshScore.ts b/hwe/ts/utilGame/formatRefreshScore.ts index 677e9f74..394cf679 100644 --- a/hwe/ts/utilGame/formatRefreshScore.ts +++ b/hwe/ts/utilGame/formatRefreshScore.ts @@ -13,7 +13,8 @@ const refreshScoreMap: [number, string][] = [ [12800, "헐..."], ]; -export function formatRefreshScore(refreshScore: number) { +export function formatRefreshScore(refreshScore: number | null) { + if (!refreshScore) refreshScore = 0; const idx = bs(refreshScoreMap, refreshScore, ([key], needle) => key - needle); if (idx >= 0) { return refreshScoreMap[idx][1] ?? "?"; diff --git a/hwe/v_NPCControl.php b/hwe/v_NPCControl.php index 366ecef4..c9307359 100644 --- a/hwe/v_NPCControl.php +++ b/hwe/v_NPCControl.php @@ -43,7 +43,7 @@ $nationStor = KVStorage::getStorage($db, $nationID, 'nation_env'); $nationStor->cacheValues(['npc_nation_policy', 'npc_general_policy']); $gameStor->cacheAll(); -$general = new General($me, null, null, $nation, $gameStor->year, $gameStor->month, false); +$general = new General($me, null, null, null, $nation, $gameStor->year, $gameStor->month, false); $rawServerPolicy = $gameStor->getValue('npc_nation_policy') ?? []; $rawNationPolicy = $nationStor->getValue('npc_nation_policy') ?? []; -- 2.54.0 From 161ed97a3486f25476a533c996ff0daa5020a426 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Fri, 7 Jul 2023 17:12:15 +0000 Subject: [PATCH 14/21] =?UTF-8?q?fix:=20GeneralAccessLogColumn=20=EC=9D=B8?= =?UTF-8?q?=EC=9E=90=20=EA=B0=92=20=EB=AC=B8=EC=A0=9C=20-=20PHP=20?= =?UTF-8?q?=EC=A0=9C=EB=B0=9C=20=EB=B0=98=EC=84=B1=20=EC=A2=80...=20?= =?UTF-8?q?=EC=99=9C=20->value=EA=B0=80=20=ED=95=84=EC=9A=94=ED=95=B4..=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/API/General/DieOnPrestart.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hwe/sammo/API/General/DieOnPrestart.php b/hwe/sammo/API/General/DieOnPrestart.php index eee54801..ce5fa56b 100644 --- a/hwe/sammo/API/General/DieOnPrestart.php +++ b/hwe/sammo/API/General/DieOnPrestart.php @@ -42,7 +42,7 @@ class DieOnPrestart extends \sammo\BaseAPI $lastRefresh = $db->queryFirstField( 'SELECT %b FROM general_access_log WHERE %b = %i', GeneralAccessLogColumn::lastRefresh->value, - GeneralAccessLogColumn::generalID, + GeneralAccessLogColumn::generalID->value, $general['no'] ); -- 2.54.0 From ad0770d1beb23d020bf6337e02a6e36e85179ee0 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Fri, 7 Jul 2023 17:20:24 +0000 Subject: [PATCH 15/21] =?UTF-8?q?fix:=20=EC=A0=91=EC=86=8D=EB=9F=89=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EB=B3=80=EC=88=98=EB=AA=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/a_traffic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hwe/a_traffic.php b/hwe/a_traffic.php index cf37a83f..4038c8fe 100644 --- a/hwe/a_traffic.php +++ b/hwe/a_traffic.php @@ -206,7 +206,7 @@ if ($admin['maxonline'] < $curonline) { ); foreach (array_merge([$totalRefresh], $top5Refresh) as $i => $user) { - $w = round($user['refresh'] / max(1, $max_refresh['refresh']) * 100, 1); + $w = round($user['refresh'] / max(1, $totalRefresh['refresh']) * 100, 1); $w2 = round(100 - $w, 1); $color = getTrafficColor($w); ?> -- 2.54.0 From e3c89a37aa1573f318a15ae14872767335848df2 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Fri, 7 Jul 2023 17:29:03 +0000 Subject: [PATCH 16/21] =?UTF-8?q?fix:=20=EA=B5=AC=20=EB=82=B4=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=B3=80=EC=88=98=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EB=AC=B8=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hwe/func.php b/hwe/func.php index bc6d6eba..135780fa 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -643,7 +643,7 @@ function generalInfo(General $generalObj) $age = "{$age} 세"; } - $refreshScoreTotal = round($generalObj->getVar(GeneralAccessLogColumn::refreshScoreTotal) ?? 0, -1); + $refreshScoreTotal = round($generalObj->getAccessLogVar(GeneralAccessLogColumn::refreshScoreTotal) ?? 0, -1); $specialDomestic = $generalObj->getVar('special') === GameConst::$defaultSpecialDomestic ? "{$generalObj->getVar('specage')}세" : "" . displayiActionObjInfo($generalObj->getSpecialDomestic()) . ""; @@ -752,7 +752,7 @@ function generalInfo(General $generalObj) 부대 {$troopInfo} 벌점 - " . getRefreshScoreText($refreshScoreTotal) . " {$refreshScoreTotal}({$generalObj->getVar('refresh_score')}) + " . getRefreshScoreText($refreshScoreTotal) . " {$refreshScoreTotal}({$generalObj->getAccessLogVar(GeneralAccessLogColumn::refreshScore)}) "; } -- 2.54.0 From b4f197b7d83688e240b4b694a3c7c3a937779198 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Fri, 7 Jul 2023 18:14:55 +0000 Subject: [PATCH 17/21] =?UTF-8?q?feat:=20GeneralQueryMode=20Enum=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-=20mergeQueryColumn,=20createGeneralObjLi?= =?UTF-8?q?stFromDB,=20createGeneralObjFromDB=20=ED=98=B8=EC=B6=9C?= =?UTF-8?q?=EC=8B=9C=20=20column=20=ED=8A=B9=EC=88=98=20=EB=AA=A8=EB=93=9C?= =?UTF-8?q?=20=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Enums/GeneralQueryMode.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 hwe/sammo/Enums/GeneralQueryMode.php diff --git a/hwe/sammo/Enums/GeneralQueryMode.php b/hwe/sammo/Enums/GeneralQueryMode.php new file mode 100644 index 00000000..7c78117d --- /dev/null +++ b/hwe/sammo/Enums/GeneralQueryMode.php @@ -0,0 +1,18 @@ + Date: Fri, 7 Jul 2023 18:39:23 +0000 Subject: [PATCH 18/21] =?UTF-8?q?refac:=20General=20=EA=B0=9D=EC=B2=B4=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EC=9D=84=20GeneralQueryMode=EB=A5=BC=20?= =?UTF-8?q?=ED=99=9C=EC=9A=A9=20-=20=EA=B8=B0=EC=A1=B4=20$constructMode=20?= =?UTF-8?q?-=20=EB=B2=84=EA=B7=B8=20=EC=9E=88=EC=9D=8C..=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/_admin7.php | 4 +- hwe/b_betting.php | 3 +- hwe/b_currentCity.php | 2 +- hwe/b_myPage.php | 3 +- hwe/func.php | 5 +- hwe/j_myBossInfo.php | 3 +- hwe/old_index.php | 3 +- hwe/process_war.php | 5 +- .../Auction/GetUniqueItemAuctionDetail.php | 3 +- hwe/sammo/API/General/GetFrontInfo.php | 3 +- hwe/sammo/API/Nation/GeneralList.php | 3 +- hwe/sammo/API/Nation/GetNationInfo.php | 3 +- .../API/NationCommand/GetReservedCommand.php | 3 +- hwe/sammo/API/Vote/AddComment.php | 3 +- hwe/sammo/API/Vote/Vote.php | 3 +- hwe/sammo/Betting.php | 3 +- hwe/sammo/Command/General/che_등용.php | 4 +- hwe/sammo/Command/General/che_등용수락.php | 2 +- hwe/sammo/Command/General/che_선양.php | 3 +- .../Command/General/che_장수대상임관.php | 3 +- hwe/sammo/Command/General/che_증여.php | 3 +- hwe/sammo/Command/General/che_화계.php | 3 +- hwe/sammo/Command/Nation/che_몰수.php | 5 +- hwe/sammo/Command/Nation/che_발령.php | 3 +- hwe/sammo/Command/Nation/che_불가침수락.php | 3 +- .../Command/Nation/che_불가침파기수락.php | 3 +- hwe/sammo/Command/Nation/che_종전수락.php | 3 +- hwe/sammo/Command/Nation/che_포상.php | 5 +- hwe/sammo/Command/Nation/che_필사즉생.php | 3 +- hwe/sammo/DiplomaticMessage.php | 7 ++- .../Event/Action/MergeInheritPointRank.php | 2 +- hwe/sammo/Event/Action/UpdateNationLevel.php | 5 +- hwe/sammo/General.php | 58 ++++++++++++------- hwe/sammo/GeneralAI.php | 2 +- hwe/sammo/RaiseInvaderMessage.php | 2 +- hwe/sammo/ScoutMessage.php | 2 +- 36 files changed, 110 insertions(+), 63 deletions(-) diff --git a/hwe/_admin7.php b/hwe/_admin7.php index cbd7f9e9..e5035cb3 100644 --- a/hwe/_admin7.php +++ b/hwe/_admin7.php @@ -2,6 +2,8 @@ namespace sammo; +use sammo\Enums\GeneralQueryMode; + include "lib.php"; include "func.php"; @@ -74,7 +76,7 @@ if (!$gen) { $gen = $generalBasicList[0]['no']; } -$generalObj = General::createGeneralObjFromDB($gen); +$generalObj = General::createGeneralObjFromDB($gen, null, GeneralQueryMode::FullWithAccessLog); ?> diff --git a/hwe/b_betting.php b/hwe/b_betting.php index 7fdd8ecd..35b4fae8 100644 --- a/hwe/b_betting.php +++ b/hwe/b_betting.php @@ -2,6 +2,7 @@ namespace sammo; +use sammo\Enums\GeneralQueryMode; use sammo\Enums\RankColumn; include "lib.php"; @@ -566,7 +567,7 @@ if ($str3) { $tournamentRankerList = General::createGeneralObjListFromDB( $db->queryFirstColumn('SELECT general_id FROM rank_data WHERE `type`= %s ORDER BY value DESC LIMIT 40', $gameColumn->value), [$prizeColumn->value, $gameColumn->value, $winColumn->value, $drawColumn->value, $loseColumn->value, 'leadership', 'strength', 'intel', 'no', 'npc', 'name'], - 0 + GeneralQueryMode::Core ); usort($tournamentRankerList, function (General $lhs, General $rhs) use ($gameColumn, $winColumn, $drawColumn, $loseColumn) { $result = - ($lhs->getRankVar($gameColumn) <=> $rhs->getRankVar($gameColumn)); diff --git a/hwe/b_currentCity.php b/hwe/b_currentCity.php index 565822f6..7728a5fd 100644 --- a/hwe/b_currentCity.php +++ b/hwe/b_currentCity.php @@ -211,7 +211,7 @@ $templates = new \League\Plates\Engine('templates'); $city['trade'] = "- "; } - $dbColumns = General::mergeQueryColumn(['npc', 'defence_train', 'no', 'picture', 'imgsvr', 'name', 'injury', 'leadership', 'strength', 'intel', 'officer_level', 'nation', 'crewtype', 'crew', 'train', 'atmos'], 2)[0]; + $dbColumns = General::mergeQueryColumn(['npc', 'defence_train', 'no', 'picture', 'imgsvr', 'name', 'injury', 'leadership', 'strength', 'intel', 'officer_level', 'nation', 'crewtype', 'crew', 'train', 'atmos'])[0]; if ($showDetailedInfo) { $generals = $db->query( 'SELECT %l from general where city=%i order by turntime', diff --git a/hwe/b_myPage.php b/hwe/b_myPage.php index d62183fc..9859e0e2 100644 --- a/hwe/b_myPage.php +++ b/hwe/b_myPage.php @@ -3,6 +3,7 @@ namespace sammo; use sammo\Enums\GeneralAccessLogColumn; +use sammo\Enums\GeneralQueryMode; use sammo\Enums\TableName; include "lib.php"; @@ -23,7 +24,7 @@ $gameStor->cacheValues(['turntime', 'opentime', 'autorun_user', 'npcmode']); increaseRefresh("내정보", 1); -$me = General::createGeneralObjFromDB($generalID); +$me = General::createGeneralObjFromDB($generalID, null, GeneralQueryMode::FullWithAccessLog); $myset = $me->getVar('myset'); if ($myset > 0) { diff --git a/hwe/func.php b/hwe/func.php index 135780fa..adae4f2f 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -7,6 +7,7 @@ use Ds\Set; use sammo\Enums\AuctionType; use sammo\Enums\GeneralAccessLogColumn; use sammo\Enums\GeneralColumn; +use sammo\Enums\GeneralQueryMode; use sammo\Enums\InheritanceKey; use sammo\Enums\RankColumn; @@ -1323,7 +1324,7 @@ function CheckHall($no) ["betrate", 'calc'], ]; - $generalObj = General::createGeneralObjFromDB($no, null, 2); + $generalObj = General::createGeneralObjFromDB($no); $ttw = $generalObj->getRankVar(RankColumn::ttw); $ttd = $generalObj->getRankVar(RankColumn::ttd); @@ -1720,7 +1721,7 @@ function deleteNation(General $lord, bool $applyDB): array $lordID ), ['npc', 'owner', 'gold', 'rice', 'experience', 'explevel', 'dedication', 'dedlevel', 'belong', 'aux'], - 1 + GeneralQueryMode::Lite, ); $nationGeneralList[$lordID] = $lord; diff --git a/hwe/j_myBossInfo.php b/hwe/j_myBossInfo.php index 7c3c7674..53f69dfd 100644 --- a/hwe/j_myBossInfo.php +++ b/hwe/j_myBossInfo.php @@ -1,6 +1,7 @@ = 2) { exit(); } -$generalObj = General::createGeneralObjFromDB($me['no']); +$generalObj = General::createGeneralObjFromDB($me['no'], null, GeneralQueryMode::FullWithAccessLog); $generalObj->setRawCity($db->queryFirstRow('SELECT * FROM city WHERE city = %i', $generalObj->getCityID())); $scenario = $gameStor->scenario_text; diff --git a/hwe/process_war.php b/hwe/process_war.php index 6e27057d..c7789a69 100644 --- a/hwe/process_war.php +++ b/hwe/process_war.php @@ -3,6 +3,7 @@ namespace sammo; use sammo\Enums\EventTarget; +use sammo\Enums\GeneralQueryMode; function processWar(string $warSeed, General $attackerGeneral, array $rawAttackerNation, array $rawDefenderCity) { @@ -37,7 +38,7 @@ function processWar(string $warSeed, General $attackerGeneral, array $rawAttacke $city = new WarUnitCity($rng, $rawDefenderCity, $rawDefenderNation, $year, $month, $startYear); $defenderIDList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND city=%i AND nation!=0 and crew > 0 and rice>(crew/100) and train>=defence_train and atmos>=defence_train', $city->getVar('nation'), $city->getVar('city')); - $defenderGeneralList = General::createGeneralObjListFromDB($defenderIDList, null, 2); + $defenderGeneralList = General::createGeneralObjListFromDB($defenderIDList, null); /** @var WarUnit[] */ $defenderList = []; @@ -595,7 +596,7 @@ function ConquerCity(array $admin, General $general, array $city) $lord = new General($db->queryFirstRow( 'SELECT %l FROM general WHERE nation = %i AND officer_level = %i LIMIT 1', - Util::formatListOfBackticks(General::mergeQueryColumn(['npc', 'gold', 'rice', 'experience', 'explevel', 'belong', 'dedication', 'dedlevel', 'aux'], 1)[0]), + Util::formatListOfBackticks(General::mergeQueryColumn(['npc', 'gold', 'rice', 'experience', 'explevel', 'belong', 'dedication', 'dedlevel', 'aux'], GeneralQueryMode::Lite)[0]), $defenderNationID, 12 ), null, null, $city, $loseNation, $year, $month, false); diff --git a/hwe/sammo/API/Auction/GetUniqueItemAuctionDetail.php b/hwe/sammo/API/Auction/GetUniqueItemAuctionDetail.php index 6a7738d7..b3f36e6f 100644 --- a/hwe/sammo/API/Auction/GetUniqueItemAuctionDetail.php +++ b/hwe/sammo/API/Auction/GetUniqueItemAuctionDetail.php @@ -10,6 +10,7 @@ use sammo\DTO\AuctionBidItem; use sammo\DTO\AuctionInfo; use sammo\Enums\APIRecoveryType; use sammo\Enums\AuctionType; +use sammo\Enums\GeneralQueryMode; use sammo\Enums\InheritanceKey; use sammo\InheritancePointManager; use sammo\TimeUtil; @@ -76,7 +77,7 @@ class GetUniqueItemAuctionDetail extends \sammo\BaseAPI $inheritMgr = InheritancePointManager::getInstance(); //preveious라서 column을 최대한 비울 수 있다. $remainPoint = $inheritMgr->getInheritancePoint( - General::createGeneralObjFromDB($generalID, ['owner'], 0), + General::createGeneralObjFromDB($generalID, ['owner'], GeneralQueryMode::Core), InheritanceKey::previous ); diff --git a/hwe/sammo/API/General/GetFrontInfo.php b/hwe/sammo/API/General/GetFrontInfo.php index 69f7d169..c0805c57 100644 --- a/hwe/sammo/API/General/GetFrontInfo.php +++ b/hwe/sammo/API/General/GetFrontInfo.php @@ -11,6 +11,7 @@ use sammo\Enums\APIRecoveryType; use sammo\Enums\CityColumn; use sammo\Enums\GeneralAccessLogColumn; use sammo\Enums\GeneralColumn; +use sammo\Enums\GeneralQueryMode; use sammo\Enums\RankColumn; use sammo\GameConst; use sammo\General; @@ -533,7 +534,7 @@ class GetFrontInfo extends \sammo\BaseAPI { $generalID = $session->generalID; //NOTE: 이 경우 staticNation 정보를 조회한다. - $general = General::createGeneralObjFromDB($generalID); + $general = General::createGeneralObjFromDB($generalID, null, GeneralQueryMode::FullWithAccessLog); $nationID = $general->getNationID(); $cityID = $general->getCityID(); diff --git a/hwe/sammo/API/Nation/GeneralList.php b/hwe/sammo/API/Nation/GeneralList.php index a61424fa..4a740589 100644 --- a/hwe/sammo/API/Nation/GeneralList.php +++ b/hwe/sammo/API/Nation/GeneralList.php @@ -5,6 +5,7 @@ namespace sammo\API\Nation; use ArrayObject; use sammo\DB; use sammo\Enums\APIRecoveryType; +use sammo\Enums\GeneralQueryMode; use sammo\General; use sammo\Session; use sammo\Util; @@ -164,7 +165,7 @@ class GeneralList extends \sammo\BaseAPI - [$queryColumns, $rankColumns, $accessLogColumns] = General::mergeQueryColumn(array_keys(static::$viewColumns), 1); + [$queryColumns, $rankColumns, $accessLogColumns] = General::mergeQueryColumn(array_keys(static::$viewColumns), GeneralQueryMode::Lite); $rawGeneralList = Util::convertArrayToDict( $db->query( diff --git a/hwe/sammo/API/Nation/GetNationInfo.php b/hwe/sammo/API/Nation/GetNationInfo.php index 25eade4f..9191459a 100644 --- a/hwe/sammo/API/Nation/GetNationInfo.php +++ b/hwe/sammo/API/Nation/GetNationInfo.php @@ -4,6 +4,7 @@ namespace sammo\API\Nation; use sammo\DB; use sammo\Enums\APIRecoveryType; +use sammo\Enums\GeneralQueryMode; use sammo\GameConst; use sammo\General; use sammo\KVStorage; @@ -65,7 +66,7 @@ class GetNationInfo extends \sammo\BaseAPI ]; } - $generalObj = General::createGeneralObjFromDB($session->generalID, null, 1); + $generalObj = General::createGeneralObjFromDB($session->generalID, null, GeneralQueryMode::FullWithoutIAction); $gameStor = KVStorage::getStorage($db, 'game_env'); $gameEnv = $gameStor->getValues(['year', 'month', 'startyear']); diff --git a/hwe/sammo/API/NationCommand/GetReservedCommand.php b/hwe/sammo/API/NationCommand/GetReservedCommand.php index dd08f3b8..42f8a9ca 100644 --- a/hwe/sammo/API/NationCommand/GetReservedCommand.php +++ b/hwe/sammo/API/NationCommand/GetReservedCommand.php @@ -6,6 +6,7 @@ use sammo\Session; use DateTimeInterface; use sammo\DB; use sammo\Enums\APIRecoveryType; +use sammo\Enums\GeneralQueryMode; use sammo\GameConst; use sammo\General; use sammo\Json; @@ -112,7 +113,7 @@ class GetReservedCommand extends \sammo\BaseAPI ]; } - $generalObj = General::createGeneralObjFromDB($session->generalID); + $generalObj = General::createGeneralObjFromDB($session->generalID, null, GeneralQueryMode::FullWithoutIAction); return [ diff --git a/hwe/sammo/API/Vote/AddComment.php b/hwe/sammo/API/Vote/AddComment.php index 1d27a9aa..417dd5de 100644 --- a/hwe/sammo/API/Vote/AddComment.php +++ b/hwe/sammo/API/Vote/AddComment.php @@ -6,6 +6,7 @@ use DateTimeInterface; use sammo\DB; use sammo\DTO\VoteComment; use sammo\Enums\APIRecoveryType; +use sammo\Enums\GeneralQueryMode; use sammo\General; use sammo\Session; use sammo\TimeUtil; @@ -40,7 +41,7 @@ class AddComment extends \sammo\BaseAPI $text = mb_substr($this->args['text'], 0, 200); $generalID = $session->generalID; - $general = General::createGeneralObjFromDB($generalID, [], 0); + $general = General::createGeneralObjFromDB($generalID, null, GeneralQueryMode::Core); $generalName = $general->getName(); $nationID = $general->getNationID(); $nationName = $general->getStaticNation()['name']; diff --git a/hwe/sammo/API/Vote/Vote.php b/hwe/sammo/API/Vote/Vote.php index 05a5e1db..bd5474b5 100644 --- a/hwe/sammo/API/Vote/Vote.php +++ b/hwe/sammo/API/Vote/Vote.php @@ -6,6 +6,7 @@ use DateTimeInterface; use sammo\DB; use sammo\DTO\VoteInfo; use sammo\Enums\APIRecoveryType; +use sammo\Enums\GeneralQueryMode; use sammo\General; use sammo\Json; use sammo\KVStorage; @@ -105,7 +106,7 @@ class Vote extends \sammo\BaseAPI $gameStor = KVStorage::getStorage($db, 'game_env'); $voteReward = $gameStor->getValue('develcost') * 5; - $general = General::createGeneralObjFromDB($generalID, ['gold', 'horse', 'weapon', 'book', 'item', 'npc', 'imgsvr', 'picture', 'aux'], 2); + $general = General::createGeneralObjFromDB($generalID, ['gold', 'horse', 'weapon', 'book', 'item', 'npc', 'imgsvr', 'picture', 'aux'], GeneralQueryMode::Lite); $general->increaseVar('gold', $voteReward); $uniqueRng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize( UniqueConst::$hiddenSeed, diff --git a/hwe/sammo/Betting.php b/hwe/sammo/Betting.php index 9a4ec109..52e19192 100644 --- a/hwe/sammo/Betting.php +++ b/hwe/sammo/Betting.php @@ -5,6 +5,7 @@ namespace sammo; use Ds\Map; use sammo\DTO\BettingInfo; use sammo\DTO\BettingItem; +use sammo\Enums\GeneralQueryMode; use sammo\Enums\RankColumn; class Betting @@ -401,7 +402,7 @@ class Betting $userLogger->flush(); } } else { - $generalList = General::createGeneralObjListFromDB(array_unique(Util::squeezeFromArray($rewardList, 'generalID')), ['gold', 'npc', 'betgold'], 1); + $generalList = General::createGeneralObjListFromDB(array_unique(Util::squeezeFromArray($rewardList, 'generalID')), ['gold', 'npc', 'betgold'], GeneralQueryMode::Core); foreach ($rewardList as $rewardItem) { $gambler = $generalList[$rewardItem['generalID']]; $reward = Util::round($rewardItem['amount']); diff --git a/hwe/sammo/Command/General/che_등용.php b/hwe/sammo/Command/General/che_등용.php index 196f6c6a..be224275 100644 --- a/hwe/sammo/Command/General/che_등용.php +++ b/hwe/sammo/Command/General/che_등용.php @@ -21,7 +21,7 @@ use function \sammo\getNationStaticInfo; use function sammo\tryUniqueItemLottery; use \sammo\Constraint\ConstraintHelper; - +use sammo\Enums\GeneralQueryMode; class che_등용 extends Command\GeneralCommand { @@ -77,7 +77,7 @@ class che_등용 extends Command\GeneralCommand protected function initWithArg() { - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation', 'experience', 'dedication'], 0); + $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation', 'experience', 'dedication'], GeneralQueryMode::Core); $this->setDestGeneral($destGeneral); [$reqGold, $reqRice] = $this->getCost(); diff --git a/hwe/sammo/Command/General/che_등용수락.php b/hwe/sammo/Command/General/che_등용수락.php index 6c47e2a3..486da3c9 100644 --- a/hwe/sammo/Command/General/che_등용수락.php +++ b/hwe/sammo/Command/General/che_등용수락.php @@ -68,7 +68,7 @@ class che_등용수락 extends Command\GeneralCommand{ protected function initWithArg() { - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, 2); + $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null); $this->setDestGeneral($destGeneral); $this->setDestNation($this->arg['destNationID'], ['gennum', 'scout']); diff --git a/hwe/sammo/Command/General/che_선양.php b/hwe/sammo/Command/General/che_선양.php index 6fc4f3f3..24e4a95d 100644 --- a/hwe/sammo/Command/General/che_선양.php +++ b/hwe/sammo/Command/General/che_선양.php @@ -19,6 +19,7 @@ use function\sammo\tryUniqueItemLottery; use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; +use sammo\Enums\GeneralQueryMode; use sammo\Enums\InheritanceKey; class che_선양 extends Command\GeneralCommand @@ -65,7 +66,7 @@ class che_선양 extends Command\GeneralCommand protected function initWithArg() { - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'nation'], 1); + $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'nation'], GeneralQueryMode::Core); $this->setDestGeneral($destGeneral); $this->fullConditionConstraints = [ diff --git a/hwe/sammo/Command/General/che_장수대상임관.php b/hwe/sammo/Command/General/che_장수대상임관.php index 5182b55d..ba486e23 100644 --- a/hwe/sammo/Command/General/che_장수대상임관.php +++ b/hwe/sammo/Command/General/che_장수대상임관.php @@ -17,6 +17,7 @@ use function \sammo\tryUniqueItemLottery; use function \sammo\getNationStaticInfo; use \sammo\Constraint\ConstraintHelper; +use sammo\Enums\GeneralQueryMode; use sammo\Enums\InheritanceKey; class che_장수대상임관 extends Command\GeneralCommand{ @@ -83,7 +84,7 @@ class che_장수대상임관 extends Command\GeneralCommand{ protected function initWithArg() { $destGeneralID = $this->arg['destGeneralID']; - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation'], 0); + $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation'], GeneralQueryMode::Core); $this->setDestGeneral($destGeneral); $this->setDestNation($this->destGeneralObj->getVar('nation'), ['gennum', 'scout']); diff --git a/hwe/sammo/Command/General/che_증여.php b/hwe/sammo/Command/General/che_증여.php index a1f1426a..c38493b4 100644 --- a/hwe/sammo/Command/General/che_증여.php +++ b/hwe/sammo/Command/General/che_증여.php @@ -15,6 +15,7 @@ use \sammo\Command; use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; +use sammo\Enums\GeneralQueryMode; use function sammo\tryUniqueItemLottery; @@ -86,7 +87,7 @@ class che_증여 extends Command\GeneralCommand protected function initWithArg() { - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'nation'], 1); + $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'nation'], GeneralQueryMode::Lite); $this->setDestGeneral($destGeneral); $this->fullConditionConstraints = [ diff --git a/hwe/sammo/Command/General/che_화계.php b/hwe/sammo/Command/General/che_화계.php index 385dd53d..1be84a5c 100644 --- a/hwe/sammo/Command/General/che_화계.php +++ b/hwe/sammo/Command/General/che_화계.php @@ -15,6 +15,7 @@ use function \sammo\searchDistance; use \sammo\Constraint\ConstraintHelper; use sammo\CityConst; +use sammo\Enums\GeneralQueryMode; use sammo\Enums\RankColumn; use sammo\RandUtil; @@ -268,7 +269,7 @@ class che_화계 extends Command\GeneralCommand $destCityGeneralList = []; $cityGeneralID = $db->queryFirstColumn('SELECT no FROM general WHERE city = %i AND nation = %i', $destCityID, $destNationID); - $destCityGeneralList = General::createGeneralObjListFromDB($cityGeneralID, ['name', 'city', 'nation', 'officer_level', 'leadership', 'horse', 'strength', 'weapon', 'intel', 'book', 'item', 'last_turn', 'injury', 'special', 'special2', 'injury', 'crewtype', 'crew', 'atmos', 'train'], 2); + $destCityGeneralList = General::createGeneralObjListFromDB($cityGeneralID, ['name', 'city', 'nation', 'officer_level', 'leadership', 'horse', 'strength', 'weapon', 'intel', 'book', 'item', 'last_turn', 'injury', 'special', 'special2', 'injury', 'crewtype', 'crew', 'atmos', 'train']); foreach ($destCityGeneralList as &$destCityGeneral) { $destCityGeneral->setRawCity($this->destCity); unset($destCityGeneral); diff --git a/hwe/sammo/Command/Nation/che_몰수.php b/hwe/sammo/Command/Nation/che_몰수.php index 8cc9ce82..8b51bd94 100644 --- a/hwe/sammo/Command/Nation/che_몰수.php +++ b/hwe/sammo/Command/Nation/che_몰수.php @@ -19,6 +19,7 @@ use function \sammo\GetImageURL; use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; +use sammo\Enums\GeneralQueryMode; use sammo\Enums\MessageType; class che_몰수 extends Command\NationCommand @@ -91,7 +92,7 @@ class che_몰수 extends Command\NationCommand protected function initWithArg() { - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'npc', 'nation', 'imgsvr', 'picture'], 1); + $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'npc', 'nation', 'imgsvr', 'picture'], GeneralQueryMode::Lite); $this->setDestGeneral($destGeneral); $env = $this->env; @@ -206,7 +207,7 @@ class che_몰수 extends Command\NationCommand ], 'nation=%i', $nationID); $josaUl = JosaUtil::pick($amountText, '을'); - + $destGeneral->getLogger()->pushGeneralActionLog("{$resName} {$amountText}{$josaUl} 몰수 당했습니다.", ActionLogger::PLAIN); $logger->pushGeneralActionLog("{$destGeneral->getName()}에게서 {$resName} $amountText{$josaUl} 몰수했습니다. <1>$date"); diff --git a/hwe/sammo/Command/Nation/che_발령.php b/hwe/sammo/Command/Nation/che_발령.php index 7acf90dd..ddc3369a 100644 --- a/hwe/sammo/Command/Nation/che_발령.php +++ b/hwe/sammo/Command/Nation/che_발령.php @@ -21,6 +21,7 @@ use function \sammo\cutTurn; use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; +use sammo\Enums\GeneralQueryMode; class che_발령 extends Command\NationCommand { @@ -71,7 +72,7 @@ class che_발령 extends Command\NationCommand { $this->setDestCity($this->arg['destCityID']); - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, 1); + $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, GeneralQueryMode::Lite); $this->setDestGeneral($destGeneral); if ($this->arg['destGeneralID'] == $this->getGeneral()->getID()) { diff --git a/hwe/sammo/Command/Nation/che_불가침수락.php b/hwe/sammo/Command/Nation/che_불가침수락.php index b422a481..ec348ecd 100644 --- a/hwe/sammo/Command/Nation/che_불가침수락.php +++ b/hwe/sammo/Command/Nation/che_불가침수락.php @@ -20,6 +20,7 @@ use function \sammo\getNationStaticInfo; use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; +use sammo\Enums\GeneralQueryMode; use sammo\Json; use sammo\KVStorage; use sammo\RandUtil; @@ -103,7 +104,7 @@ class che_불가침수락 extends Command\NationCommand $env = $this->env; $relYear = $env['year'] - $env['startyear']; - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], [], 1); + $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, GeneralQueryMode::Lite); $this->setDestGeneral($destGeneral); $this->setDestNation($this->arg['destNationID']); diff --git a/hwe/sammo/Command/Nation/che_불가침파기수락.php b/hwe/sammo/Command/Nation/che_불가침파기수락.php index 1f117ed8..a6962c7e 100644 --- a/hwe/sammo/Command/Nation/che_불가침파기수락.php +++ b/hwe/sammo/Command/Nation/che_불가침파기수락.php @@ -20,6 +20,7 @@ use function \sammo\getNationStaticInfo; use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; +use sammo\Enums\GeneralQueryMode; use sammo\RandUtil; class che_불가침파기수락 extends Command\NationCommand @@ -77,7 +78,7 @@ class che_불가침파기수락 extends Command\NationCommand protected function initWithArg() { - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], [], 1); + $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, GeneralQueryMode::Lite); $this->setDestGeneral($destGeneral); $this->setDestNation($this->arg['destNationID']); diff --git a/hwe/sammo/Command/Nation/che_종전수락.php b/hwe/sammo/Command/Nation/che_종전수락.php index dfbee08c..9e42ac30 100644 --- a/hwe/sammo/Command/Nation/che_종전수락.php +++ b/hwe/sammo/Command/Nation/che_종전수락.php @@ -22,6 +22,7 @@ use function \sammo\getNationStaticInfo; use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; +use sammo\Enums\GeneralQueryMode; class che_종전수락 extends Command\NationCommand { @@ -86,7 +87,7 @@ class che_종전수락 extends Command\NationCommand protected function initWithArg() { - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], [], 1); + $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, GeneralQueryMode::Lite); $this->setDestGeneral($destGeneral); $this->setDestNation($this->arg['destNationID']); diff --git a/hwe/sammo/Command/Nation/che_포상.php b/hwe/sammo/Command/Nation/che_포상.php index fdb73493..790fd504 100644 --- a/hwe/sammo/Command/Nation/che_포상.php +++ b/hwe/sammo/Command/Nation/che_포상.php @@ -15,6 +15,7 @@ use \sammo\Command; use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; +use sammo\Enums\GeneralQueryMode; class che_포상 extends Command\NationCommand { @@ -81,7 +82,7 @@ class che_포상 extends Command\NationCommand protected function initWithArg() { - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'nation'], 1); + $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'nation'], GeneralQueryMode::Lite); $this->setDestGeneral($destGeneral); if($this->arg['destGeneralID'] == $this->getGeneral()->getID()){ @@ -168,7 +169,7 @@ class che_포상 extends Command\NationCommand ], 'nation=%i', $nationID); $josaUl = JosaUtil::pick($amountText, '을'); - + $destGeneral->getLogger()->pushGeneralActionLog("{$resName} {$amountText}{$josaUl} 포상으로 받았습니다.", ActionLogger::PLAIN); $logger->pushGeneralActionLog("{$destGeneral->getName()}에게 {$resName} $amountText{$josaUl} 수여했습니다. <1>$date"); diff --git a/hwe/sammo/Command/Nation/che_필사즉생.php b/hwe/sammo/Command/Nation/che_필사즉생.php index 431b0c63..9d56addb 100644 --- a/hwe/sammo/Command/Nation/che_필사즉생.php +++ b/hwe/sammo/Command/Nation/che_필사즉생.php @@ -15,6 +15,7 @@ use \sammo\{ use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; +use sammo\Enums\GeneralQueryMode; use sammo\Event\Action; class che_필사즉생 extends Command\NationCommand{ @@ -94,7 +95,7 @@ class che_필사즉생 extends Command\NationCommand{ $broadcastMessage = "{$generalName}{$josaYi} 필사즉생을 발동하였습니다."; $targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID); - foreach(General::createGeneralObjListFromDB($targetGeneralList, ['train', 'atmos'], 1) as $targetGeneral){ + foreach(General::createGeneralObjListFromDB($targetGeneralList, ['train', 'atmos'], GeneralQueryMode::Lite) as $targetGeneral){ $targetGeneral->getLogger()->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN); if($targetGeneral->getVar('train') < 100){ $targetGeneral->setVar('train', 100); diff --git a/hwe/sammo/DiplomaticMessage.php b/hwe/sammo/DiplomaticMessage.php index 96afcc65..a57e2538 100644 --- a/hwe/sammo/DiplomaticMessage.php +++ b/hwe/sammo/DiplomaticMessage.php @@ -1,6 +1,7 @@ dest->generalID, ['picture', 'imgsvr', 'aux'], 1); + $destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], GeneralQueryMode::Core); $commandObj = buildNationCommandClass('che_불가침수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [ 'destNationID'=>$this->src->nationID, @@ -99,7 +100,7 @@ class DiplomaticMessage extends Message{ protected function cancelNA(){ $gameStor = KVStorage::getStorage(DB::db(), 'game_env'); - $destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], 1); + $destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], GeneralQueryMode::Core); $commandObj = buildNationCommandClass('che_불가침파기수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [ 'destNationID'=>$this->src->nationID, @@ -121,7 +122,7 @@ class DiplomaticMessage extends Message{ protected function stopWar(){ $gameStor = KVStorage::getStorage(DB::db(), 'game_env'); - $destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], 1); + $destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], GeneralQueryMode::Core); $commandObj = buildNationCommandClass('che_종전수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [ 'destNationID'=>$this->src->nationID, diff --git a/hwe/sammo/Event/Action/MergeInheritPointRank.php b/hwe/sammo/Event/Action/MergeInheritPointRank.php index a93d1e55..47a07880 100644 --- a/hwe/sammo/Event/Action/MergeInheritPointRank.php +++ b/hwe/sammo/Event/Action/MergeInheritPointRank.php @@ -18,7 +18,7 @@ class MergeInheritPointRank extends \sammo\Event\Action { $db = DB::db(); - $generals = General::createGeneralObjListFromDB(null, null, 2); + $generals = General::createGeneralObjListFromDB(null, null); $points = new Map(); $points->allocate(count($generals)); diff --git a/hwe/sammo/Event/Action/UpdateNationLevel.php b/hwe/sammo/Event/Action/UpdateNationLevel.php index ea520cd0..72b7bc26 100644 --- a/hwe/sammo/Event/Action/UpdateNationLevel.php +++ b/hwe/sammo/Event/Action/UpdateNationLevel.php @@ -5,6 +5,7 @@ namespace sammo\Event\Action; use sammo\ActionLogger; use sammo\CityConst; use sammo\DB; +use sammo\Enums\GeneralQueryMode; use sammo\Enums\InheritanceKey; use sammo\GameConst; use sammo\General; @@ -139,7 +140,7 @@ class UpdateNationLevel extends \sammo\Event\Action $nation['nation'], $targetKillTurn ); - $nationGenList = General::createGeneralObjListFromDB($nationGenIDList, ['belong', 'npc', 'aux'], 2); + $nationGenList = General::createGeneralObjListFromDB($nationGenIDList, ['belong', 'npc', 'aux']); $chiefID = null; $uniqueLotteryWeightList = []; @@ -214,7 +215,7 @@ class UpdateNationLevel extends \sammo\Event\Action } if ($chiefID) { - $chiefObj = General::createGeneralObjFromDB($chiefID, ['belong', 'npc', 'aux'], 2); + $chiefObj = General::createGeneralObjFromDB($chiefID, ['belong', 'npc', 'aux'], GeneralQueryMode::Lite); $chiefObj->increaseInheritancePoint(InheritanceKey::unifier, 250 * $levelDiff); $chiefObj->applyDB($db); } diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index 9ea8fa3f..cff326de 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -5,6 +5,7 @@ namespace sammo; use Ds\Map; use sammo\Command\GeneralCommand; use sammo\Enums\GeneralAccessLogColumn; +use sammo\Enums\GeneralQueryMode; use sammo\Enums\InheritanceKey; use sammo\Enums\RankColumn; use sammo\WarUnitTrigger as WarUnitTrigger; @@ -1031,7 +1032,7 @@ class General implements iAction return $caller; } - static public function mergeQueryColumn(?array $reqColumns = null, int $constructMode = 2): array + static public function mergeQueryColumn(?array $reqColumns = null, GeneralQueryMode $queryMode = GeneralQueryMode::Full): array { $minimumColumn = ['no', 'name', 'npc', 'city', 'nation', 'officer_level', 'officer_city']; $defaultEventColumn = [ @@ -1055,7 +1056,17 @@ class General implements iAction ]; if ($reqColumns === null) { - return [$fullColumn, RankColumn::cases(), $fullAcessLogColumn]; + switch ($queryMode) { + case GeneralQueryMode::Core: + return [$minimumColumn, [], []]; + case GeneralQueryMode::Lite: + return [$defaultEventColumn, [], []]; + case GeneralQueryMode::FullWithoutIAction: + case GeneralQueryMode::Full: + return [$fullColumn, RankColumn::cases(), []]; + case GeneralQueryMode::FullWithAccessLog: + return [$fullColumn, RankColumn::cases(), $fullAcessLogColumn]; + } } /** @var RankColumn[] */ @@ -1086,28 +1097,35 @@ class General implements iAction $subColumn[] = $column; } - if ($constructMode > 1) { - return [array_unique(array_merge($defaultEventColumn, $subColumn)), $rankColumn, $accessLogColumn]; + switch ($queryMode) { + case GeneralQueryMode::Core: + case GeneralQueryMode::Lite: + return [array_unique(array_merge($minimumColumn, $subColumn)), $rankColumn, $accessLogColumn]; + case GeneralQueryMode::FullWithoutIAction: + case GeneralQueryMode::Full: + return [array_unique(array_merge($defaultEventColumn, $subColumn)), $rankColumn, $accessLogColumn]; + case GeneralQueryMode::FullWithAccessLog: + return [array_unique(array_merge($fullColumn, $subColumn)), $rankColumn, array_unique(array_merge($fullAcessLogColumn, $accessLogColumn))]; + default: + throw new \RuntimeException('invalid query mode'); } - - return [array_unique(array_merge($minimumColumn, $subColumn)), $rankColumn, $accessLogColumn]; } /** * @param ?int[] $generalIDList * @param null|array $column - * @param int $constructMode + * @param GeneralQueryMode $queryMode * @return \sammo\General[] * @throws MustNotBeReachedException */ - static public function createGeneralObjListFromDB(?array $generalIDList, ?array $column = null, int $constructMode = 2): array + static public function createGeneralObjListFromDB(?array $generalIDList, ?array $column = null, GeneralQueryMode $queryMode = GeneralQueryMode::Full): array { if ($generalIDList === []) { return []; } $db = DB::db(); - if ($constructMode > 0) { + if ($queryMode->value > 0) { $gameStor = KVStorage::getStorage($db, 'game_env'); [$year, $month] = $gameStor->getValuesAsArray(['year', 'month']); } else { @@ -1120,7 +1138,7 @@ class General implements iAction * @var RankColumn[] $rankColumn * @var GeneralAccessLogColumn[] $accessLogColumn */ - [$column, $rankColumn, $accessLogColumn] = static::mergeQueryColumn($column, $constructMode); + [$column, $rankColumn, $accessLogColumn] = static::mergeQueryColumn($column, $queryMode); if ($generalIDList === null) { $rawGenerals = Util::convertArrayToDict( @@ -1175,22 +1193,22 @@ class General implements iAction $result = []; foreach ($generalIDList as $generalID) { if (!key_exists($generalID, $rawGenerals)) { - $result[$generalID] = new DummyGeneral($constructMode > 0); + $result[$generalID] = new DummyGeneral($queryMode->value > 0); continue; } if ($rawRanks->hasKey($generalID) && $rawRanks[$generalID]->count() !== count($rankColumn)) { throw new \RuntimeException('column의 수가 일치하지 않음 : ' . $generalID); } - $result[$generalID] = new static($rawGenerals[$generalID], $rawRanks[$generalID] ?? null, $rawAccessLogs[$generalID] ?? null, null, null, $year, $month, $constructMode > 1); + $result[$generalID] = new static($rawGenerals[$generalID], $rawRanks[$generalID] ?? null, $rawAccessLogs[$generalID] ?? null, null, null, $year, $month, $queryMode->value >= GeneralQueryMode::Full); } return $result; } - static public function createGeneralObjFromDB(int $generalID, ?array $column = null, int $constructMode = 2): self + static public function createGeneralObjFromDB(int $generalID, ?array $column = null, GeneralQueryMode $queryMode = GeneralQueryMode::Full): self { $db = DB::db(); - if ($constructMode > 0) { + if ($queryMode->value > 0) { $gameStor = KVStorage::getStorage($db, 'game_env'); [$year, $month] = $gameStor->getValuesAsArray(['year', 'month']); } else { @@ -1203,7 +1221,7 @@ class General implements iAction * @var RankColumn[] $rankColumn * @var GeneralAccessLogCoumn[] $accessLogColumn */ - [$column, $rankColumn, $accessLogColumn] = static::mergeQueryColumn($column, $constructMode); + [$column, $rankColumn, $accessLogColumn] = static::mergeQueryColumn($column, $queryMode); /** @var Map|null */ $rawAccessLog = null; @@ -1220,20 +1238,20 @@ class General implements iAction ); $rawAccessLog = new Map(); - foreach($accessLogColumn as $accessLogKey) { - if(!key_exists($accessLogKey->value, $rawGeneral)){ + foreach ($accessLogColumn as $accessLogKey) { + if (!key_exists($accessLogKey->value, $rawGeneral)) { continue; } $rawAccessLog[$accessLogKey] = $rawGeneral[$accessLogKey->value]; unset($rawGeneral[$accessLogKey->value]); } - if($rawAccessLog->count() === 0){ + if ($rawAccessLog->count() === 0) { $rawAccessLog = null; } } if (!$rawGeneral) { - return new DummyGeneral($constructMode > 0); + return new DummyGeneral($queryMode->value > 0); } $rawRankValues = new Map(); @@ -1250,7 +1268,7 @@ class General implements iAction } - $general = new static($rawGeneral, $rawRankValues, $rawAccessLog, null, null, $year, $month, $constructMode > 1); + $general = new static($rawGeneral, $rawRankValues, $rawAccessLog, null, null, $year, $month, $queryMode->value >= GeneralQueryMode::Full); return $general; } diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php index 122bda5f..0a8a5018 100644 --- a/hwe/sammo/GeneralAI.php +++ b/hwe/sammo/GeneralAI.php @@ -3514,7 +3514,7 @@ class GeneralAI $db = DB::db(); $generalIDList = $db->queryFirstColumn('SELECT no FROM general WHERE nation = %i AND no != %i', $nationID, $this->general->getID()); - $nationGenerals = General::createGeneralObjListFromDB($generalIDList, null, 2); + $nationGenerals = General::createGeneralObjListFromDB($generalIDList); $lastWar = \PHP_INT_MAX; foreach ($nationGenerals as $nationGeneral) { diff --git a/hwe/sammo/RaiseInvaderMessage.php b/hwe/sammo/RaiseInvaderMessage.php index ded98277..33b65e89 100644 --- a/hwe/sammo/RaiseInvaderMessage.php +++ b/hwe/sammo/RaiseInvaderMessage.php @@ -66,7 +66,7 @@ class RaiseInvaderMessage extends Message } $gameStor = KVStorage::getStorage(DB::db(), 'game_env'); - $general = \sammo\General::createGeneralObjFromDB($receiverID, null, 2); + $general = \sammo\General::createGeneralObjFromDB($receiverID); $logger = $general->getLogger(); diff --git a/hwe/sammo/ScoutMessage.php b/hwe/sammo/ScoutMessage.php index 76a54d48..0a5ffe23 100644 --- a/hwe/sammo/ScoutMessage.php +++ b/hwe/sammo/ScoutMessage.php @@ -65,7 +65,7 @@ class ScoutMessage extends Message{ } $gameStor = KVStorage::getStorage(DB::db(), 'game_env'); - $general = \sammo\General::createGeneralObjFromDB($receiverID, null, 2); + $general = \sammo\General::createGeneralObjFromDB($receiverID); $logger = $general->getLogger(); -- 2.54.0 From e106a6a3cf9f9b200160297916e7a3c4bf022f23 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Fri, 7 Jul 2023 18:44:36 +0000 Subject: [PATCH 19/21] =?UTF-8?q?fix:=20queryMode=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20-=20=EC=95=84=EB=8B=88=20PHP=EC=95=BC=20en?= =?UTF-8?q?um=EC=97=90=20->value=20=EC=A2=80..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/General.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index cff326de..cb856ef0 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -1199,7 +1199,7 @@ class General implements iAction if ($rawRanks->hasKey($generalID) && $rawRanks[$generalID]->count() !== count($rankColumn)) { throw new \RuntimeException('column의 수가 일치하지 않음 : ' . $generalID); } - $result[$generalID] = new static($rawGenerals[$generalID], $rawRanks[$generalID] ?? null, $rawAccessLogs[$generalID] ?? null, null, null, $year, $month, $queryMode->value >= GeneralQueryMode::Full); + $result[$generalID] = new static($rawGenerals[$generalID], $rawRanks[$generalID] ?? null, $rawAccessLogs[$generalID] ?? null, null, null, $year, $month, $queryMode->value >= GeneralQueryMode::Full->value); } return $result; @@ -1268,7 +1268,7 @@ class General implements iAction } - $general = new static($rawGeneral, $rawRankValues, $rawAccessLog, null, null, $year, $month, $queryMode->value >= GeneralQueryMode::Full); + $general = new static($rawGeneral, $rawRankValues, $rawAccessLog, null, null, $year, $month, $queryMode->value >= GeneralQueryMode::Full->value); return $general; } -- 2.54.0 From 79dedea47c8b10946fb0c8dbdd078da6836c5ffe Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sat, 8 Jul 2023 02:04:17 +0000 Subject: [PATCH 20/21] =?UTF-8?q?fix:=20=EB=AC=BC=EC=9E=90=EC=9B=90?= =?UTF-8?q?=EC=A1=B0=20=EC=A1=B0=EC=82=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Command/Nation/che_물자원조.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hwe/sammo/Command/Nation/che_물자원조.php b/hwe/sammo/Command/Nation/che_물자원조.php index a95aa84d..8f9ba797 100644 --- a/hwe/sammo/Command/Nation/che_물자원조.php +++ b/hwe/sammo/Command/Nation/che_물자원조.php @@ -216,15 +216,15 @@ class che_물자원조 extends Command\NationCommand } $josaUlRiceAmount = JosaUtil::pick($riceAmountText, '을'); - - $logger->pushGeneralHistoryLog("{$destNationName}{$josaRo} 금{$goldAmountText} 쌀{$riceAmountText}{$josaUl} 지원"); - $logger->pushNationalHistoryLog("{$destNationName}{$josaRo} 금{$goldAmountText} 쌀{$riceAmountText}{$josaUl} 지원"); + + $logger->pushGeneralHistoryLog("{$destNationName}{$josaRo} 금{$goldAmountText} 쌀{$riceAmountText}{$josaUlRiceAmount} 지원"); + $logger->pushNationalHistoryLog("{$destNationName}{$josaRo} 금{$goldAmountText} 쌀{$riceAmountText}{$josaUlRiceAmount} 지원"); $logger->pushGlobalHistoryLog("【원조】{$nationName}에서 {$destNationName}{$josaRo} 물자를 지원합니다"); $logger->pushGeneralActionLog($broadcastMessage); $logger->pushGeneralActionLog("{$destNationName}{$josaRo} 물자를 지원합니다. <1>$date", ActionLogger::PLAIN); - $destBroadcastMessage = $broadcastMessage = "{$nationName}에서 금{$goldAmountText} 쌀{$riceAmountText}{$josaUl} 원조했습니다."; + $destBroadcastMessage = $broadcastMessage = "{$nationName}에서 금{$goldAmountText} 쌀{$riceAmountText}{$josaUlRiceAmount} 원조했습니다."; $destChiefList = $db->queryFirstColumn('SELECT no FROM general WHERE officer_level >= 5 AND nation = %i', $destNationID); foreach ($destChiefList as $destChiefID) { $destChiefLogger = new ActionLogger($destChiefID, $nationID, $year, $month); @@ -234,7 +234,7 @@ class che_물자원조 extends Command\NationCommand $josaRoSrc = JosaUtil::pick($nationName, '로'); $destNationLogger = new ActionLogger(0, $destNationID, $year, $month); - $destNationLogger->pushNationalHistoryLog("{$nationName}{$josaRoSrc}부터 금{$goldAmountText} 쌀{$riceAmountText}{$josaUl} 지원 받음"); + $destNationLogger->pushNationalHistoryLog("{$nationName}{$josaRoSrc}부터 금{$goldAmountText} 쌀{$riceAmountText}{$josaUlRiceAmount} 지원 받음"); $destNationStor = KVStorage::getStorage(DB::db(), $destNationID, 'nation_env'); $destRecvAssist = $destNationStor->getValue('recv_assist') ?? []; -- 2.54.0 From b6f5a0c9e99c68e19ae993962270236ca4837cd7 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sat, 8 Jul 2023 02:10:22 +0000 Subject: [PATCH 21/21] =?UTF-8?q?fix:=20GeneralQueryMode::Core=EB=8A=94=20?= =?UTF-8?q?logger=20=EC=97=86=EC=9D=8C=20-=20=EB=94=B0=EB=9D=BC=EC=84=9C?= =?UTF-8?q?=20Lite=20=EA=B6=8C=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Betting.php | 2 +- hwe/sammo/Command/General/che_등용.php | 2 +- hwe/sammo/Command/General/che_선양.php | 2 +- hwe/sammo/Command/General/che_장수대상임관.php | 2 +- hwe/sammo/DiplomaticMessage.php | 6 +++--- hwe/sammo/Enums/GeneralQueryMode.php | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hwe/sammo/Betting.php b/hwe/sammo/Betting.php index 52e19192..2c6604d2 100644 --- a/hwe/sammo/Betting.php +++ b/hwe/sammo/Betting.php @@ -402,7 +402,7 @@ class Betting $userLogger->flush(); } } else { - $generalList = General::createGeneralObjListFromDB(array_unique(Util::squeezeFromArray($rewardList, 'generalID')), ['gold', 'npc', 'betgold'], GeneralQueryMode::Core); + $generalList = General::createGeneralObjListFromDB(array_unique(Util::squeezeFromArray($rewardList, 'generalID')), ['gold', 'npc', 'betgold'], GeneralQueryMode::Lite); foreach ($rewardList as $rewardItem) { $gambler = $generalList[$rewardItem['generalID']]; $reward = Util::round($rewardItem['amount']); diff --git a/hwe/sammo/Command/General/che_등용.php b/hwe/sammo/Command/General/che_등용.php index be224275..0b4b035e 100644 --- a/hwe/sammo/Command/General/che_등용.php +++ b/hwe/sammo/Command/General/che_등용.php @@ -77,7 +77,7 @@ class che_등용 extends Command\GeneralCommand protected function initWithArg() { - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation', 'experience', 'dedication'], GeneralQueryMode::Core); + $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation', 'experience', 'dedication'], GeneralQueryMode::Lite); $this->setDestGeneral($destGeneral); [$reqGold, $reqRice] = $this->getCost(); diff --git a/hwe/sammo/Command/General/che_선양.php b/hwe/sammo/Command/General/che_선양.php index 24e4a95d..23be46a6 100644 --- a/hwe/sammo/Command/General/che_선양.php +++ b/hwe/sammo/Command/General/che_선양.php @@ -66,7 +66,7 @@ class che_선양 extends Command\GeneralCommand protected function initWithArg() { - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'nation'], GeneralQueryMode::Core); + $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'nation'], GeneralQueryMode::Lite); $this->setDestGeneral($destGeneral); $this->fullConditionConstraints = [ diff --git a/hwe/sammo/Command/General/che_장수대상임관.php b/hwe/sammo/Command/General/che_장수대상임관.php index ba486e23..70bd734b 100644 --- a/hwe/sammo/Command/General/che_장수대상임관.php +++ b/hwe/sammo/Command/General/che_장수대상임관.php @@ -84,7 +84,7 @@ class che_장수대상임관 extends Command\GeneralCommand{ protected function initWithArg() { $destGeneralID = $this->arg['destGeneralID']; - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation'], GeneralQueryMode::Core); + $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation'], GeneralQueryMode::Lite); $this->setDestGeneral($destGeneral); $this->setDestNation($this->destGeneralObj->getVar('nation'), ['gennum', 'scout']); diff --git a/hwe/sammo/DiplomaticMessage.php b/hwe/sammo/DiplomaticMessage.php index a57e2538..1df2c596 100644 --- a/hwe/sammo/DiplomaticMessage.php +++ b/hwe/sammo/DiplomaticMessage.php @@ -76,7 +76,7 @@ class DiplomaticMessage extends Message{ $gameStor = KVStorage::getStorage(DB::db(), 'game_env'); - $destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], GeneralQueryMode::Core); + $destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], GeneralQueryMode::Lite); $commandObj = buildNationCommandClass('che_불가침수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [ 'destNationID'=>$this->src->nationID, @@ -100,7 +100,7 @@ class DiplomaticMessage extends Message{ protected function cancelNA(){ $gameStor = KVStorage::getStorage(DB::db(), 'game_env'); - $destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], GeneralQueryMode::Core); + $destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], GeneralQueryMode::Lite); $commandObj = buildNationCommandClass('che_불가침파기수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [ 'destNationID'=>$this->src->nationID, @@ -122,7 +122,7 @@ class DiplomaticMessage extends Message{ protected function stopWar(){ $gameStor = KVStorage::getStorage(DB::db(), 'game_env'); - $destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], GeneralQueryMode::Core); + $destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], GeneralQueryMode::Lite); $commandObj = buildNationCommandClass('che_종전수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [ 'destNationID'=>$this->src->nationID, diff --git a/hwe/sammo/Enums/GeneralQueryMode.php b/hwe/sammo/Enums/GeneralQueryMode.php index 7c78117d..254e45d2 100644 --- a/hwe/sammo/Enums/GeneralQueryMode.php +++ b/hwe/sammo/Enums/GeneralQueryMode.php @@ -5,7 +5,7 @@ namespace sammo\Enums; // mergeQueryColumn, createGeneralObjListFromDB, createGeneralObjFromDB 호출시 column 특수 모드 지정 enum GeneralQueryMode: int { - /** 장수 식별을 위한 최소한의 정보 */ + /** 장수 식별을 위한 최소한의 정보, logger 초기화 없음 */ case Core = 0; /** 게임 내에서 필수 이벤트 처리를 위한 정보, iAction 제외 */ case Lite = 1; -- 2.54.0