refac: General 객체 생성을 GeneralQueryMode를 활용
- 기존 $constructMode - 버그 있음..?
This commit is contained in:
+3
-1
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
@@ -74,7 +76,7 @@ if (!$gen) {
|
|||||||
$gen = $generalBasicList[0]['no'];
|
$gen = $generalBasicList[0]['no'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$generalObj = General::createGeneralObjFromDB($gen);
|
$generalObj = General::createGeneralObjFromDB($gen, null, GeneralQueryMode::FullWithAccessLog);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|||||||
+2
-1
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Enums\RankColumn;
|
use sammo\Enums\RankColumn;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
@@ -566,7 +567,7 @@ if ($str3) {
|
|||||||
$tournamentRankerList = General::createGeneralObjListFromDB(
|
$tournamentRankerList = General::createGeneralObjListFromDB(
|
||||||
$db->queryFirstColumn('SELECT general_id FROM rank_data WHERE `type`= %s ORDER BY value DESC LIMIT 40', $gameColumn->value),
|
$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'],
|
[$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) {
|
usort($tournamentRankerList, function (General $lhs, General $rhs) use ($gameColumn, $winColumn, $drawColumn, $loseColumn) {
|
||||||
$result = - ($lhs->getRankVar($gameColumn) <=> $rhs->getRankVar($gameColumn));
|
$result = - ($lhs->getRankVar($gameColumn) <=> $rhs->getRankVar($gameColumn));
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ $templates = new \League\Plates\Engine('templates');
|
|||||||
$city['trade'] = "- ";
|
$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) {
|
if ($showDetailedInfo) {
|
||||||
$generals = $db->query(
|
$generals = $db->query(
|
||||||
'SELECT %l from general where city=%i order by turntime',
|
'SELECT %l from general where city=%i order by turntime',
|
||||||
|
|||||||
+2
-1
@@ -3,6 +3,7 @@
|
|||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
use sammo\Enums\GeneralAccessLogColumn;
|
use sammo\Enums\GeneralAccessLogColumn;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Enums\TableName;
|
use sammo\Enums\TableName;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
@@ -23,7 +24,7 @@ $gameStor->cacheValues(['turntime', 'opentime', 'autorun_user', 'npcmode']);
|
|||||||
|
|
||||||
increaseRefresh("내정보", 1);
|
increaseRefresh("내정보", 1);
|
||||||
|
|
||||||
$me = General::createGeneralObjFromDB($generalID);
|
$me = General::createGeneralObjFromDB($generalID, null, GeneralQueryMode::FullWithAccessLog);
|
||||||
|
|
||||||
$myset = $me->getVar('myset');
|
$myset = $me->getVar('myset');
|
||||||
if ($myset > 0) {
|
if ($myset > 0) {
|
||||||
|
|||||||
+3
-2
@@ -7,6 +7,7 @@ use Ds\Set;
|
|||||||
use sammo\Enums\AuctionType;
|
use sammo\Enums\AuctionType;
|
||||||
use sammo\Enums\GeneralAccessLogColumn;
|
use sammo\Enums\GeneralAccessLogColumn;
|
||||||
use sammo\Enums\GeneralColumn;
|
use sammo\Enums\GeneralColumn;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Enums\InheritanceKey;
|
use sammo\Enums\InheritanceKey;
|
||||||
use sammo\Enums\RankColumn;
|
use sammo\Enums\RankColumn;
|
||||||
|
|
||||||
@@ -1323,7 +1324,7 @@ function CheckHall($no)
|
|||||||
["betrate", 'calc'],
|
["betrate", 'calc'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$generalObj = General::createGeneralObjFromDB($no, null, 2);
|
$generalObj = General::createGeneralObjFromDB($no);
|
||||||
|
|
||||||
$ttw = $generalObj->getRankVar(RankColumn::ttw);
|
$ttw = $generalObj->getRankVar(RankColumn::ttw);
|
||||||
$ttd = $generalObj->getRankVar(RankColumn::ttd);
|
$ttd = $generalObj->getRankVar(RankColumn::ttd);
|
||||||
@@ -1720,7 +1721,7 @@ function deleteNation(General $lord, bool $applyDB): array
|
|||||||
$lordID
|
$lordID
|
||||||
),
|
),
|
||||||
['npc', 'owner', 'gold', 'rice', 'experience', 'explevel', 'dedication', 'dedlevel', 'belong', 'aux'],
|
['npc', 'owner', 'gold', 'rice', 'experience', 'explevel', 'dedication', 'dedlevel', 'belong', 'aux'],
|
||||||
1
|
GeneralQueryMode::Lite,
|
||||||
);
|
);
|
||||||
$nationGeneralList[$lordID] = $lord;
|
$nationGeneralList[$lordID] = $lord;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Enums\MessageType;
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
@@ -50,7 +51,7 @@ else{
|
|||||||
'troop','officer_level','npc','picture','imgsvr',
|
'troop','officer_level','npc','picture','imgsvr',
|
||||||
'permission','penalty','belong', 'crewtype',
|
'permission','penalty','belong', 'crewtype',
|
||||||
'experience', 'dedication', 'betray', 'dedlevel', 'explevel', 'makelimit', 'aux',
|
'experience', 'dedication', 'betray', 'dedlevel', 'explevel', 'makelimit', 'aux',
|
||||||
], 1);
|
], GeneralQueryMode::Lite);
|
||||||
|
|
||||||
if($general instanceof DummyGeneral){
|
if($general instanceof DummyGeneral){
|
||||||
Json::die([
|
Json::die([
|
||||||
|
|||||||
+2
-1
@@ -3,6 +3,7 @@
|
|||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
use sammo\DTO\VoteInfo;
|
use sammo\DTO\VoteInfo;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
@@ -58,7 +59,7 @@ if ($limitState >= 2) {
|
|||||||
exit();
|
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()));
|
$generalObj->setRawCity($db->queryFirstRow('SELECT * FROM city WHERE city = %i', $generalObj->getCityID()));
|
||||||
$scenario = $gameStor->scenario_text;
|
$scenario = $gameStor->scenario_text;
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -3,6 +3,7 @@
|
|||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
use sammo\Enums\EventTarget;
|
use sammo\Enums\EventTarget;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
|
|
||||||
function processWar(string $warSeed, General $attackerGeneral, array $rawAttackerNation, array $rawDefenderCity)
|
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);
|
$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'));
|
$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[] */
|
/** @var WarUnit[] */
|
||||||
$defenderList = [];
|
$defenderList = [];
|
||||||
@@ -595,7 +596,7 @@ function ConquerCity(array $admin, General $general, array $city)
|
|||||||
|
|
||||||
$lord = new General($db->queryFirstRow(
|
$lord = new General($db->queryFirstRow(
|
||||||
'SELECT %l FROM general WHERE nation = %i AND officer_level = %i LIMIT 1',
|
'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,
|
$defenderNationID,
|
||||||
12
|
12
|
||||||
), null, null, $city, $loseNation, $year, $month, false);
|
), null, null, $city, $loseNation, $year, $month, false);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use sammo\DTO\AuctionBidItem;
|
|||||||
use sammo\DTO\AuctionInfo;
|
use sammo\DTO\AuctionInfo;
|
||||||
use sammo\Enums\APIRecoveryType;
|
use sammo\Enums\APIRecoveryType;
|
||||||
use sammo\Enums\AuctionType;
|
use sammo\Enums\AuctionType;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Enums\InheritanceKey;
|
use sammo\Enums\InheritanceKey;
|
||||||
use sammo\InheritancePointManager;
|
use sammo\InheritancePointManager;
|
||||||
use sammo\TimeUtil;
|
use sammo\TimeUtil;
|
||||||
@@ -76,7 +77,7 @@ class GetUniqueItemAuctionDetail extends \sammo\BaseAPI
|
|||||||
$inheritMgr = InheritancePointManager::getInstance();
|
$inheritMgr = InheritancePointManager::getInstance();
|
||||||
//preveious라서 column을 최대한 비울 수 있다.
|
//preveious라서 column을 최대한 비울 수 있다.
|
||||||
$remainPoint = $inheritMgr->getInheritancePoint(
|
$remainPoint = $inheritMgr->getInheritancePoint(
|
||||||
General::createGeneralObjFromDB($generalID, ['owner'], 0),
|
General::createGeneralObjFromDB($generalID, ['owner'], GeneralQueryMode::Core),
|
||||||
InheritanceKey::previous
|
InheritanceKey::previous
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use sammo\Enums\APIRecoveryType;
|
|||||||
use sammo\Enums\CityColumn;
|
use sammo\Enums\CityColumn;
|
||||||
use sammo\Enums\GeneralAccessLogColumn;
|
use sammo\Enums\GeneralAccessLogColumn;
|
||||||
use sammo\Enums\GeneralColumn;
|
use sammo\Enums\GeneralColumn;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Enums\RankColumn;
|
use sammo\Enums\RankColumn;
|
||||||
use sammo\GameConst;
|
use sammo\GameConst;
|
||||||
use sammo\General;
|
use sammo\General;
|
||||||
@@ -533,7 +534,7 @@ class GetFrontInfo extends \sammo\BaseAPI
|
|||||||
{
|
{
|
||||||
$generalID = $session->generalID;
|
$generalID = $session->generalID;
|
||||||
//NOTE: 이 경우 staticNation 정보를 조회한다.
|
//NOTE: 이 경우 staticNation 정보를 조회한다.
|
||||||
$general = General::createGeneralObjFromDB($generalID);
|
$general = General::createGeneralObjFromDB($generalID, null, GeneralQueryMode::FullWithAccessLog);
|
||||||
$nationID = $general->getNationID();
|
$nationID = $general->getNationID();
|
||||||
$cityID = $general->getCityID();
|
$cityID = $general->getCityID();
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace sammo\API\Nation;
|
|||||||
use ArrayObject;
|
use ArrayObject;
|
||||||
use sammo\DB;
|
use sammo\DB;
|
||||||
use sammo\Enums\APIRecoveryType;
|
use sammo\Enums\APIRecoveryType;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\General;
|
use sammo\General;
|
||||||
use sammo\Session;
|
use sammo\Session;
|
||||||
use sammo\Util;
|
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(
|
$rawGeneralList = Util::convertArrayToDict(
|
||||||
$db->query(
|
$db->query(
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace sammo\API\Nation;
|
|||||||
|
|
||||||
use sammo\DB;
|
use sammo\DB;
|
||||||
use sammo\Enums\APIRecoveryType;
|
use sammo\Enums\APIRecoveryType;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\GameConst;
|
use sammo\GameConst;
|
||||||
use sammo\General;
|
use sammo\General;
|
||||||
use sammo\KVStorage;
|
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');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$gameEnv = $gameStor->getValues(['year', 'month', 'startyear']);
|
$gameEnv = $gameStor->getValues(['year', 'month', 'startyear']);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use sammo\Session;
|
|||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use sammo\DB;
|
use sammo\DB;
|
||||||
use sammo\Enums\APIRecoveryType;
|
use sammo\Enums\APIRecoveryType;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\GameConst;
|
use sammo\GameConst;
|
||||||
use sammo\General;
|
use sammo\General;
|
||||||
use sammo\Json;
|
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 [
|
return [
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use DateTimeInterface;
|
|||||||
use sammo\DB;
|
use sammo\DB;
|
||||||
use sammo\DTO\VoteComment;
|
use sammo\DTO\VoteComment;
|
||||||
use sammo\Enums\APIRecoveryType;
|
use sammo\Enums\APIRecoveryType;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\General;
|
use sammo\General;
|
||||||
use sammo\Session;
|
use sammo\Session;
|
||||||
use sammo\TimeUtil;
|
use sammo\TimeUtil;
|
||||||
@@ -40,7 +41,7 @@ class AddComment extends \sammo\BaseAPI
|
|||||||
$text = mb_substr($this->args['text'], 0, 200);
|
$text = mb_substr($this->args['text'], 0, 200);
|
||||||
|
|
||||||
$generalID = $session->generalID;
|
$generalID = $session->generalID;
|
||||||
$general = General::createGeneralObjFromDB($generalID, [], 0);
|
$general = General::createGeneralObjFromDB($generalID, null, GeneralQueryMode::Core);
|
||||||
$generalName = $general->getName();
|
$generalName = $general->getName();
|
||||||
$nationID = $general->getNationID();
|
$nationID = $general->getNationID();
|
||||||
$nationName = $general->getStaticNation()['name'];
|
$nationName = $general->getStaticNation()['name'];
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use DateTimeInterface;
|
|||||||
use sammo\DB;
|
use sammo\DB;
|
||||||
use sammo\DTO\VoteInfo;
|
use sammo\DTO\VoteInfo;
|
||||||
use sammo\Enums\APIRecoveryType;
|
use sammo\Enums\APIRecoveryType;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\General;
|
use sammo\General;
|
||||||
use sammo\Json;
|
use sammo\Json;
|
||||||
use sammo\KVStorage;
|
use sammo\KVStorage;
|
||||||
@@ -105,7 +106,7 @@ class Vote extends \sammo\BaseAPI
|
|||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$voteReward = $gameStor->getValue('develcost') * 5;
|
$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);
|
$general->increaseVar('gold', $voteReward);
|
||||||
$uniqueRng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
|
$uniqueRng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
|
||||||
UniqueConst::$hiddenSeed,
|
UniqueConst::$hiddenSeed,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace sammo;
|
|||||||
use Ds\Map;
|
use Ds\Map;
|
||||||
use sammo\DTO\BettingInfo;
|
use sammo\DTO\BettingInfo;
|
||||||
use sammo\DTO\BettingItem;
|
use sammo\DTO\BettingItem;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Enums\RankColumn;
|
use sammo\Enums\RankColumn;
|
||||||
|
|
||||||
class Betting
|
class Betting
|
||||||
@@ -401,7 +402,7 @@ class Betting
|
|||||||
$userLogger->flush();
|
$userLogger->flush();
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
foreach ($rewardList as $rewardItem) {
|
||||||
$gambler = $generalList[$rewardItem['generalID']];
|
$gambler = $generalList[$rewardItem['generalID']];
|
||||||
$reward = Util::round($rewardItem['amount']);
|
$reward = Util::round($rewardItem['amount']);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use function \sammo\getNationStaticInfo;
|
|||||||
use function sammo\tryUniqueItemLottery;
|
use function sammo\tryUniqueItemLottery;
|
||||||
|
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
|
|
||||||
class che_등용 extends Command\GeneralCommand
|
class che_등용 extends Command\GeneralCommand
|
||||||
{
|
{
|
||||||
@@ -77,7 +77,7 @@ class che_등용 extends Command\GeneralCommand
|
|||||||
|
|
||||||
protected function initWithArg()
|
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);
|
$this->setDestGeneral($destGeneral);
|
||||||
|
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class che_등용수락 extends Command\GeneralCommand{
|
|||||||
|
|
||||||
protected function initWithArg()
|
protected function initWithArg()
|
||||||
{
|
{
|
||||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, 2);
|
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null);
|
||||||
$this->setDestGeneral($destGeneral);
|
$this->setDestGeneral($destGeneral);
|
||||||
$this->setDestNation($this->arg['destNationID'], ['gennum', 'scout']);
|
$this->setDestNation($this->arg['destNationID'], ['gennum', 'scout']);
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ use function\sammo\tryUniqueItemLottery;
|
|||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Enums\InheritanceKey;
|
use sammo\Enums\InheritanceKey;
|
||||||
|
|
||||||
class che_선양 extends Command\GeneralCommand
|
class che_선양 extends Command\GeneralCommand
|
||||||
@@ -65,7 +66,7 @@ class che_선양 extends Command\GeneralCommand
|
|||||||
|
|
||||||
protected function initWithArg()
|
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->setDestGeneral($destGeneral);
|
||||||
|
|
||||||
$this->fullConditionConstraints = [
|
$this->fullConditionConstraints = [
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use function \sammo\tryUniqueItemLottery;
|
|||||||
use function \sammo\getNationStaticInfo;
|
use function \sammo\getNationStaticInfo;
|
||||||
|
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Enums\InheritanceKey;
|
use sammo\Enums\InheritanceKey;
|
||||||
|
|
||||||
class che_장수대상임관 extends Command\GeneralCommand{
|
class che_장수대상임관 extends Command\GeneralCommand{
|
||||||
@@ -83,7 +84,7 @@ class che_장수대상임관 extends Command\GeneralCommand{
|
|||||||
protected function initWithArg()
|
protected function initWithArg()
|
||||||
{
|
{
|
||||||
$destGeneralID = $this->arg['destGeneralID'];
|
$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->setDestGeneral($destGeneral);
|
||||||
$this->setDestNation($this->destGeneralObj->getVar('nation'), ['gennum', 'scout']);
|
$this->setDestNation($this->destGeneralObj->getVar('nation'), ['gennum', 'scout']);
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use \sammo\Command;
|
|||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
|
|
||||||
use function sammo\tryUniqueItemLottery;
|
use function sammo\tryUniqueItemLottery;
|
||||||
|
|
||||||
@@ -86,7 +87,7 @@ class che_증여 extends Command\GeneralCommand
|
|||||||
|
|
||||||
protected function initWithArg()
|
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->setDestGeneral($destGeneral);
|
||||||
|
|
||||||
$this->fullConditionConstraints = [
|
$this->fullConditionConstraints = [
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use function \sammo\searchDistance;
|
|||||||
|
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
use sammo\CityConst;
|
use sammo\CityConst;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Enums\RankColumn;
|
use sammo\Enums\RankColumn;
|
||||||
use sammo\RandUtil;
|
use sammo\RandUtil;
|
||||||
|
|
||||||
@@ -268,7 +269,7 @@ class che_화계 extends Command\GeneralCommand
|
|||||||
$destCityGeneralList = [];
|
$destCityGeneralList = [];
|
||||||
|
|
||||||
$cityGeneralID = $db->queryFirstColumn('SELECT no FROM general WHERE city = %i AND nation = %i', $destCityID, $destNationID);
|
$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) {
|
foreach ($destCityGeneralList as &$destCityGeneral) {
|
||||||
$destCityGeneral->setRawCity($this->destCity);
|
$destCityGeneral->setRawCity($this->destCity);
|
||||||
unset($destCityGeneral);
|
unset($destCityGeneral);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ use function \sammo\GetImageURL;
|
|||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Enums\MessageType;
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
class che_몰수 extends Command\NationCommand
|
class che_몰수 extends Command\NationCommand
|
||||||
@@ -91,7 +92,7 @@ class che_몰수 extends Command\NationCommand
|
|||||||
|
|
||||||
protected function initWithArg()
|
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);
|
$this->setDestGeneral($destGeneral);
|
||||||
|
|
||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
@@ -206,7 +207,7 @@ class che_몰수 extends Command\NationCommand
|
|||||||
], 'nation=%i', $nationID);
|
], 'nation=%i', $nationID);
|
||||||
|
|
||||||
$josaUl = JosaUtil::pick($amountText, '을');
|
$josaUl = JosaUtil::pick($amountText, '을');
|
||||||
|
|
||||||
$destGeneral->getLogger()->pushGeneralActionLog("{$resName} {$amountText}{$josaUl} 몰수 당했습니다.", ActionLogger::PLAIN);
|
$destGeneral->getLogger()->pushGeneralActionLog("{$resName} {$amountText}{$josaUl} 몰수 당했습니다.", ActionLogger::PLAIN);
|
||||||
$logger->pushGeneralActionLog("<Y>{$destGeneral->getName()}</>에게서 {$resName} <C>$amountText</>{$josaUl} 몰수했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog("<Y>{$destGeneral->getName()}</>에게서 {$resName} <C>$amountText</>{$josaUl} 몰수했습니다. <1>$date</>");
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ use function \sammo\cutTurn;
|
|||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
|
|
||||||
class che_발령 extends Command\NationCommand
|
class che_발령 extends Command\NationCommand
|
||||||
{
|
{
|
||||||
@@ -71,7 +72,7 @@ class che_발령 extends Command\NationCommand
|
|||||||
{
|
{
|
||||||
$this->setDestCity($this->arg['destCityID']);
|
$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);
|
$this->setDestGeneral($destGeneral);
|
||||||
|
|
||||||
if ($this->arg['destGeneralID'] == $this->getGeneral()->getID()) {
|
if ($this->arg['destGeneralID'] == $this->getGeneral()->getID()) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ use function \sammo\getNationStaticInfo;
|
|||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Json;
|
use sammo\Json;
|
||||||
use sammo\KVStorage;
|
use sammo\KVStorage;
|
||||||
use sammo\RandUtil;
|
use sammo\RandUtil;
|
||||||
@@ -103,7 +104,7 @@ class che_불가침수락 extends Command\NationCommand
|
|||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
$relYear = $env['year'] - $env['startyear'];
|
$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->setDestGeneral($destGeneral);
|
||||||
$this->setDestNation($this->arg['destNationID']);
|
$this->setDestNation($this->arg['destNationID']);
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ use function \sammo\getNationStaticInfo;
|
|||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\RandUtil;
|
use sammo\RandUtil;
|
||||||
|
|
||||||
class che_불가침파기수락 extends Command\NationCommand
|
class che_불가침파기수락 extends Command\NationCommand
|
||||||
@@ -77,7 +78,7 @@ class che_불가침파기수락 extends Command\NationCommand
|
|||||||
|
|
||||||
protected function initWithArg()
|
protected function initWithArg()
|
||||||
{
|
{
|
||||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], [], 1);
|
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, GeneralQueryMode::Lite);
|
||||||
$this->setDestGeneral($destGeneral);
|
$this->setDestGeneral($destGeneral);
|
||||||
$this->setDestNation($this->arg['destNationID']);
|
$this->setDestNation($this->arg['destNationID']);
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ use function \sammo\getNationStaticInfo;
|
|||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
|
|
||||||
class che_종전수락 extends Command\NationCommand
|
class che_종전수락 extends Command\NationCommand
|
||||||
{
|
{
|
||||||
@@ -86,7 +87,7 @@ class che_종전수락 extends Command\NationCommand
|
|||||||
|
|
||||||
protected function initWithArg()
|
protected function initWithArg()
|
||||||
{
|
{
|
||||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], [], 1);
|
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, GeneralQueryMode::Lite);
|
||||||
$this->setDestGeneral($destGeneral);
|
$this->setDestGeneral($destGeneral);
|
||||||
$this->setDestNation($this->arg['destNationID']);
|
$this->setDestNation($this->arg['destNationID']);
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use \sammo\Command;
|
|||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
|
|
||||||
class che_포상 extends Command\NationCommand
|
class che_포상 extends Command\NationCommand
|
||||||
{
|
{
|
||||||
@@ -81,7 +82,7 @@ class che_포상 extends Command\NationCommand
|
|||||||
|
|
||||||
protected function initWithArg()
|
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->setDestGeneral($destGeneral);
|
||||||
|
|
||||||
if($this->arg['destGeneralID'] == $this->getGeneral()->getID()){
|
if($this->arg['destGeneralID'] == $this->getGeneral()->getID()){
|
||||||
@@ -168,7 +169,7 @@ class che_포상 extends Command\NationCommand
|
|||||||
], 'nation=%i', $nationID);
|
], 'nation=%i', $nationID);
|
||||||
|
|
||||||
$josaUl = JosaUtil::pick($amountText, '을');
|
$josaUl = JosaUtil::pick($amountText, '을');
|
||||||
|
|
||||||
$destGeneral->getLogger()->pushGeneralActionLog("{$resName} <C>{$amountText}</>{$josaUl} 포상으로 받았습니다.", ActionLogger::PLAIN);
|
$destGeneral->getLogger()->pushGeneralActionLog("{$resName} <C>{$amountText}</>{$josaUl} 포상으로 받았습니다.", ActionLogger::PLAIN);
|
||||||
$logger->pushGeneralActionLog("<Y>{$destGeneral->getName()}</>에게 {$resName} <C>$amountText</>{$josaUl} 수여했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog("<Y>{$destGeneral->getName()}</>에게 {$resName} <C>$amountText</>{$josaUl} 수여했습니다. <1>$date</>");
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use \sammo\{
|
|||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Event\Action;
|
use sammo\Event\Action;
|
||||||
|
|
||||||
class che_필사즉생 extends Command\NationCommand{
|
class che_필사즉생 extends Command\NationCommand{
|
||||||
@@ -94,7 +95,7 @@ class che_필사즉생 extends Command\NationCommand{
|
|||||||
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <M>필사즉생</>을 발동하였습니다.";
|
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <M>필사즉생</>을 발동하였습니다.";
|
||||||
|
|
||||||
$targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
$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);
|
$targetGeneral->getLogger()->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
||||||
if($targetGeneral->getVar('train') < 100){
|
if($targetGeneral->getVar('train') < 100){
|
||||||
$targetGeneral->setVar('train', 100);
|
$targetGeneral->setVar('train', 100);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Enums\MessageType;
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
class DiplomaticMessage extends Message{
|
class DiplomaticMessage extends Message{
|
||||||
@@ -75,7 +76,7 @@ class DiplomaticMessage extends Message{
|
|||||||
|
|
||||||
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
|
$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(), [
|
$commandObj = buildNationCommandClass('che_불가침수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [
|
||||||
'destNationID'=>$this->src->nationID,
|
'destNationID'=>$this->src->nationID,
|
||||||
@@ -99,7 +100,7 @@ class DiplomaticMessage extends Message{
|
|||||||
protected function cancelNA(){
|
protected function cancelNA(){
|
||||||
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
|
$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(), [
|
$commandObj = buildNationCommandClass('che_불가침파기수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [
|
||||||
'destNationID'=>$this->src->nationID,
|
'destNationID'=>$this->src->nationID,
|
||||||
@@ -121,7 +122,7 @@ class DiplomaticMessage extends Message{
|
|||||||
protected function stopWar(){
|
protected function stopWar(){
|
||||||
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
|
$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(), [
|
$commandObj = buildNationCommandClass('che_종전수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [
|
||||||
'destNationID'=>$this->src->nationID,
|
'destNationID'=>$this->src->nationID,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class MergeInheritPointRank extends \sammo\Event\Action
|
|||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$generals = General::createGeneralObjListFromDB(null, null, 2);
|
$generals = General::createGeneralObjListFromDB(null, null);
|
||||||
|
|
||||||
$points = new Map();
|
$points = new Map();
|
||||||
$points->allocate(count($generals));
|
$points->allocate(count($generals));
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace sammo\Event\Action;
|
|||||||
use sammo\ActionLogger;
|
use sammo\ActionLogger;
|
||||||
use sammo\CityConst;
|
use sammo\CityConst;
|
||||||
use sammo\DB;
|
use sammo\DB;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Enums\InheritanceKey;
|
use sammo\Enums\InheritanceKey;
|
||||||
use sammo\GameConst;
|
use sammo\GameConst;
|
||||||
use sammo\General;
|
use sammo\General;
|
||||||
@@ -139,7 +140,7 @@ class UpdateNationLevel extends \sammo\Event\Action
|
|||||||
$nation['nation'],
|
$nation['nation'],
|
||||||
$targetKillTurn
|
$targetKillTurn
|
||||||
);
|
);
|
||||||
$nationGenList = General::createGeneralObjListFromDB($nationGenIDList, ['belong', 'npc', 'aux'], 2);
|
$nationGenList = General::createGeneralObjListFromDB($nationGenIDList, ['belong', 'npc', 'aux']);
|
||||||
$chiefID = null;
|
$chiefID = null;
|
||||||
|
|
||||||
$uniqueLotteryWeightList = [];
|
$uniqueLotteryWeightList = [];
|
||||||
@@ -214,7 +215,7 @@ class UpdateNationLevel extends \sammo\Event\Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($chiefID) {
|
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->increaseInheritancePoint(InheritanceKey::unifier, 250 * $levelDiff);
|
||||||
$chiefObj->applyDB($db);
|
$chiefObj->applyDB($db);
|
||||||
}
|
}
|
||||||
|
|||||||
+38
-20
@@ -5,6 +5,7 @@ namespace sammo;
|
|||||||
use Ds\Map;
|
use Ds\Map;
|
||||||
use sammo\Command\GeneralCommand;
|
use sammo\Command\GeneralCommand;
|
||||||
use sammo\Enums\GeneralAccessLogColumn;
|
use sammo\Enums\GeneralAccessLogColumn;
|
||||||
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Enums\InheritanceKey;
|
use sammo\Enums\InheritanceKey;
|
||||||
use sammo\Enums\RankColumn;
|
use sammo\Enums\RankColumn;
|
||||||
use sammo\WarUnitTrigger as WarUnitTrigger;
|
use sammo\WarUnitTrigger as WarUnitTrigger;
|
||||||
@@ -1031,7 +1032,7 @@ class General implements iAction
|
|||||||
return $caller;
|
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'];
|
$minimumColumn = ['no', 'name', 'npc', 'city', 'nation', 'officer_level', 'officer_city'];
|
||||||
$defaultEventColumn = [
|
$defaultEventColumn = [
|
||||||
@@ -1055,7 +1056,17 @@ class General implements iAction
|
|||||||
];
|
];
|
||||||
|
|
||||||
if ($reqColumns === null) {
|
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[] */
|
/** @var RankColumn[] */
|
||||||
@@ -1086,28 +1097,35 @@ class General implements iAction
|
|||||||
$subColumn[] = $column;
|
$subColumn[] = $column;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($constructMode > 1) {
|
switch ($queryMode) {
|
||||||
return [array_unique(array_merge($defaultEventColumn, $subColumn)), $rankColumn, $accessLogColumn];
|
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 ?int[] $generalIDList
|
||||||
* @param null|array<string|RankColumn> $column
|
* @param null|array<string|RankColumn> $column
|
||||||
* @param int $constructMode
|
* @param GeneralQueryMode $queryMode
|
||||||
* @return \sammo\General[]
|
* @return \sammo\General[]
|
||||||
* @throws MustNotBeReachedException
|
* @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 === []) {
|
if ($generalIDList === []) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
if ($constructMode > 0) {
|
if ($queryMode->value > 0) {
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
|
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
|
||||||
} else {
|
} else {
|
||||||
@@ -1120,7 +1138,7 @@ class General implements iAction
|
|||||||
* @var RankColumn[] $rankColumn
|
* @var RankColumn[] $rankColumn
|
||||||
* @var GeneralAccessLogColumn[] $accessLogColumn
|
* @var GeneralAccessLogColumn[] $accessLogColumn
|
||||||
*/
|
*/
|
||||||
[$column, $rankColumn, $accessLogColumn] = static::mergeQueryColumn($column, $constructMode);
|
[$column, $rankColumn, $accessLogColumn] = static::mergeQueryColumn($column, $queryMode);
|
||||||
|
|
||||||
if ($generalIDList === null) {
|
if ($generalIDList === null) {
|
||||||
$rawGenerals = Util::convertArrayToDict(
|
$rawGenerals = Util::convertArrayToDict(
|
||||||
@@ -1175,22 +1193,22 @@ class General implements iAction
|
|||||||
$result = [];
|
$result = [];
|
||||||
foreach ($generalIDList as $generalID) {
|
foreach ($generalIDList as $generalID) {
|
||||||
if (!key_exists($generalID, $rawGenerals)) {
|
if (!key_exists($generalID, $rawGenerals)) {
|
||||||
$result[$generalID] = new DummyGeneral($constructMode > 0);
|
$result[$generalID] = new DummyGeneral($queryMode->value > 0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($rawRanks->hasKey($generalID) && $rawRanks[$generalID]->count() !== count($rankColumn)) {
|
if ($rawRanks->hasKey($generalID) && $rawRanks[$generalID]->count() !== count($rankColumn)) {
|
||||||
throw new \RuntimeException('column의 수가 일치하지 않음 : ' . $generalID);
|
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;
|
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();
|
$db = DB::db();
|
||||||
if ($constructMode > 0) {
|
if ($queryMode->value > 0) {
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
|
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
|
||||||
} else {
|
} else {
|
||||||
@@ -1203,7 +1221,7 @@ class General implements iAction
|
|||||||
* @var RankColumn[] $rankColumn
|
* @var RankColumn[] $rankColumn
|
||||||
* @var GeneralAccessLogCoumn[] $accessLogColumn
|
* @var GeneralAccessLogCoumn[] $accessLogColumn
|
||||||
*/
|
*/
|
||||||
[$column, $rankColumn, $accessLogColumn] = static::mergeQueryColumn($column, $constructMode);
|
[$column, $rankColumn, $accessLogColumn] = static::mergeQueryColumn($column, $queryMode);
|
||||||
|
|
||||||
/** @var Map<GeneralAccessLog,int>|null */
|
/** @var Map<GeneralAccessLog,int>|null */
|
||||||
$rawAccessLog = null;
|
$rawAccessLog = null;
|
||||||
@@ -1220,20 +1238,20 @@ class General implements iAction
|
|||||||
);
|
);
|
||||||
|
|
||||||
$rawAccessLog = new Map();
|
$rawAccessLog = new Map();
|
||||||
foreach($accessLogColumn as $accessLogKey) {
|
foreach ($accessLogColumn as $accessLogKey) {
|
||||||
if(!key_exists($accessLogKey->value, $rawGeneral)){
|
if (!key_exists($accessLogKey->value, $rawGeneral)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$rawAccessLog[$accessLogKey] = $rawGeneral[$accessLogKey->value];
|
$rawAccessLog[$accessLogKey] = $rawGeneral[$accessLogKey->value];
|
||||||
unset($rawGeneral[$accessLogKey->value]);
|
unset($rawGeneral[$accessLogKey->value]);
|
||||||
}
|
}
|
||||||
if($rawAccessLog->count() === 0){
|
if ($rawAccessLog->count() === 0) {
|
||||||
$rawAccessLog = null;
|
$rawAccessLog = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$rawGeneral) {
|
if (!$rawGeneral) {
|
||||||
return new DummyGeneral($constructMode > 0);
|
return new DummyGeneral($queryMode->value > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$rawRankValues = new Map();
|
$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;
|
return $general;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3514,7 +3514,7 @@ class GeneralAI
|
|||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$generalIDList = $db->queryFirstColumn('SELECT no FROM general WHERE nation = %i AND no != %i', $nationID, $this->general->getID());
|
$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;
|
$lastWar = \PHP_INT_MAX;
|
||||||
foreach ($nationGenerals as $nationGeneral) {
|
foreach ($nationGenerals as $nationGeneral) {
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class RaiseInvaderMessage extends Message
|
|||||||
}
|
}
|
||||||
|
|
||||||
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
|
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
|
||||||
$general = \sammo\General::createGeneralObjFromDB($receiverID, null, 2);
|
$general = \sammo\General::createGeneralObjFromDB($receiverID);
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class ScoutMessage extends Message{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
|
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
|
||||||
$general = \sammo\General::createGeneralObjFromDB($receiverID, null, 2);
|
$general = \sammo\General::createGeneralObjFromDB($receiverID);
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user