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();