forked from devsam/core
General 클래스를 General, GeneralLite로 분리 (#236)
내부 코드 사용례에서 General 테이블의 column을 일부만 가져오는 경우가 다수 있습니다. 다만 General 클래스에서 각종 iAction에 해당하는 트리거 함수 호출을 위해서는 모든 column을 다 가져와야 정상 동작이 가능한 만큼, iAction interface를 구현한 General 클래스와, 구현하지 않은 GeneralLite 클래스 둘로 나눕니다. 또한 General 클래스에서는 필요한 column을 다 가져오도록 변경합니다. Reviewed-on: https://storage.hided.net/gitea/devsam/core/pulls/236
This commit is contained in:
+2
-3
@@ -15,9 +15,8 @@ return [
|
||||
// Note that the **only** effect of choosing `'5.6'` is to infer
|
||||
// that functions removed in php 7.0 exist.
|
||||
// (See `backward_compatibility_checks` for additional options)
|
||||
"target_php_version" => '8.1',
|
||||
"minimum_target_php_version" => '8.1',
|
||||
'backward_compatibility_checks ' => true,
|
||||
"target_php_version" => '8.2',
|
||||
"minimum_target_php_version" => '8.2',
|
||||
'minimum_severity' => \Phan\Issue::SEVERITY_NORMAL,
|
||||
|
||||
'file_list' => [
|
||||
|
||||
@@ -33,7 +33,7 @@ $src = MessageTarget::buildQuick($session->generalID);
|
||||
$genObjList = [];
|
||||
$env = [];
|
||||
if ($genlist) {
|
||||
$genObjList = General::createGeneralObjListFromDB($genlist);
|
||||
$genObjList = General::createObjListFromDB($genlist);
|
||||
$env = $gameStor->cacheAll();
|
||||
}
|
||||
switch ($btn) {
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ if (!$gen) {
|
||||
$gen = $generalBasicList[0]['no'];
|
||||
}
|
||||
|
||||
$generalObj = General::createGeneralObjFromDB($gen, null, GeneralQueryMode::FullWithAccessLog);
|
||||
$generalObj = General::createObjFromDB($gen, null, GeneralQueryMode::FullWithAccessLog);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
||||
@@ -26,7 +26,7 @@ foreach ($db->queryFirstColumn(
|
||||
}
|
||||
|
||||
$inheritPointManager = InheritancePointManager::getInstance();
|
||||
foreach(General::createGeneralObjListFromDB($db->queryFirstColumn('SELECT `no` FROM general WHERE npc = 0')) as $genObj){
|
||||
foreach(General::createObjListFromDB($db->queryFirstColumn('SELECT `no` FROM general WHERE npc = 0')) as $genObj){
|
||||
$inheritPointManager->mergeTotalInheritancePoint($genObj);
|
||||
$inheritPointManager->applyInheritanceUser($genObj->getVar('owner'));
|
||||
}
|
||||
+4
-3
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace sammo;
|
||||
|
||||
use sammo\Enums\GeneralLiteQueryMode;
|
||||
use sammo\Enums\GeneralQueryMode;
|
||||
use sammo\Enums\RankColumn;
|
||||
|
||||
@@ -564,12 +565,12 @@ if ($str3) {
|
||||
$winColumn = RankColumn::from("{$rankColumn}w");
|
||||
$drawColumn = RankColumn::from("{$rankColumn}d");
|
||||
$loseColumn = RankColumn::from("{$rankColumn}l");
|
||||
$tournamentRankerList = General::createGeneralObjListFromDB(
|
||||
$tournamentRankerList = GeneralLite::createObjListFromDB(
|
||||
$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'],
|
||||
GeneralQueryMode::Core
|
||||
GeneralLiteQueryMode::Core
|
||||
);
|
||||
usort($tournamentRankerList, function (General $lhs, General $rhs) use ($gameColumn, $winColumn, $drawColumn, $loseColumn) {
|
||||
usort($tournamentRankerList, function (GeneralLite $lhs, GeneralLite $rhs) use ($gameColumn, $winColumn, $drawColumn, $loseColumn) {
|
||||
$result = - ($lhs->getRankVar($gameColumn) <=> $rhs->getRankVar($gameColumn));
|
||||
if ($result !== 0) return $result;
|
||||
$result = - (
|
||||
|
||||
@@ -327,8 +327,7 @@ $templates = new \League\Plates\Engine('templates');
|
||||
|
||||
if ($ourGeneral && !$isNPC) {
|
||||
$turnText = [];
|
||||
$generalObj = new General($general, null, null, null, null, null, null, false);
|
||||
foreach ($generalTurnList[$generalObj->getID()] as $turnRawIdx => $turn) {
|
||||
foreach ($generalTurnList[$general['no']] as $turnRawIdx => $turn) {
|
||||
$turnIdx = $turnRawIdx + 1;
|
||||
$turnText[] = "{$turnIdx} : $turn";
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ $gameStor->cacheValues(['turntime', 'opentime', 'autorun_user', 'npcmode']);
|
||||
|
||||
increaseRefresh("내정보", 1);
|
||||
|
||||
$me = General::createGeneralObjFromDB($generalID, null, GeneralQueryMode::FullWithAccessLog);
|
||||
$me = General::createObjFromDB($generalID, null, GeneralQueryMode::FullWithAccessLog);
|
||||
|
||||
$myset = $me->getVar('myset');
|
||||
if ($myset > 0) {
|
||||
|
||||
+3
-4
@@ -149,7 +149,7 @@ function getRandGenName(RandUtil $rng)
|
||||
|
||||
|
||||
|
||||
function cityInfo(General $generalObj)
|
||||
function cityInfo(GeneralLite $generalObj)
|
||||
{
|
||||
$db = DB::db();
|
||||
|
||||
@@ -1324,7 +1324,7 @@ function CheckHall($no)
|
||||
["betrate", 'calc'],
|
||||
];
|
||||
|
||||
$generalObj = General::createGeneralObjFromDB($no);
|
||||
$generalObj = General::createObjFromDB($no);
|
||||
|
||||
$ttw = $generalObj->getRankVar(RankColumn::ttw);
|
||||
$ttd = $generalObj->getRankVar(RankColumn::ttd);
|
||||
@@ -1714,14 +1714,13 @@ function deleteNation(General $lord, bool $applyDB): array
|
||||
$logger->pushGlobalHistoryLog("<R><b>【멸망】</b></><D><b>{$nationName}</b></>{$josaUn} <R>멸망</>했습니다.");
|
||||
|
||||
|
||||
$nationGeneralList = General::createGeneralObjListFromDB(
|
||||
$nationGeneralList = General::createObjListFromDB(
|
||||
$db->queryFirstColumn(
|
||||
'SELECT `no` FROM general WHERE nation=%i AND no != %i',
|
||||
$nationID,
|
||||
$lordID
|
||||
),
|
||||
['npc', 'owner', 'gold', 'rice', 'experience', 'explevel', 'dedication', 'dedlevel', 'belong', 'aux'],
|
||||
GeneralQueryMode::Lite,
|
||||
);
|
||||
$nationGeneralList[$lordID] = $lord;
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ function setGeneralCommand(int $generalID, array $rawTurnList, string $command,
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$env = $gameStor->getAll();
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
|
||||
try{
|
||||
$commandObj = buildGeneralCommandClass($command, $general, $env, $arg);
|
||||
@@ -425,7 +425,7 @@ function setNationCommand(int $generalID, array $turnList, string $command, ?arr
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$env = $gameStor->getAll();
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
|
||||
if($general->getVar('officer_level') < 5){
|
||||
return [
|
||||
|
||||
@@ -451,7 +451,7 @@ function checkWander(RandUtil $rng)
|
||||
|
||||
$wanderers = $db->queryFirstColumn('SELECT general.`no` FROM general LEFT JOIN nation ON general.nation = nation.nation WHERE nation.`level` = 0 AND general.`officer_level` = 12');
|
||||
|
||||
foreach (General::createGeneralObjListFromDB($wanderers) as $wanderer) {
|
||||
foreach (General::createObjListFromDB($wanderers) as $wanderer) {
|
||||
$wanderCmd = buildGeneralCommandClass('che_해산', $wanderer, $admin);
|
||||
if ($wanderCmd->hasFullConditionMet()) {
|
||||
$logger = $wanderer->getLogger();
|
||||
@@ -743,7 +743,7 @@ function checkEmperior()
|
||||
}
|
||||
|
||||
$inheritPointManager = InheritancePointManager::getInstance();
|
||||
$allUserGenerals = General::createGeneralObjListFromDB($db->queryFirstColumn('SELECT `no` FROM general WHERE npc < 2'));
|
||||
$allUserGenerals = General::createObjListFromDB($db->queryFirstColumn('SELECT `no` FROM general WHERE npc < 2'));
|
||||
foreach ($allUserGenerals as $genObj) {
|
||||
if ($genObj->getNationID() == $nationID) {
|
||||
if ($genObj->getVar('officer_level') > 4) {
|
||||
|
||||
@@ -364,7 +364,14 @@ function disaster(RandUtil $rng) {
|
||||
$logger->flush();
|
||||
|
||||
if (!$isGood) {
|
||||
$generalListByCity = Util::arrayGroupBy($db->query('SELECT no, name, nation, city, officer_level, injury, leadership, strength, intel, horse, weapon, book, item, crew, crewtype, atmos, train, special, special2 FROM general WHERE city IN %li', Util::squeezeFromArray($targetCityList, 'city')), 'city');
|
||||
[$queryColumns,,] = General::mergeQueryColumn();
|
||||
$generalListByCity = Util::arrayGroupBy(
|
||||
$db->query(
|
||||
'SELECT %l FROM general WHERE city IN %li',
|
||||
Util::formatListOfBackticks($queryColumns),
|
||||
Util::squeezeFromArray($targetCityList, 'city')
|
||||
),
|
||||
'city');
|
||||
//NOTE: 쿼리 1번이지만 복잡하기 vs 쿼리 여러번이지만 조금 더 깔끔하기
|
||||
foreach ($targetCityList as $city) {
|
||||
$affectRatio = Util::valueFit($city['secu'] / $city['secu_max'] / 0.8, 0, 1);
|
||||
|
||||
@@ -882,7 +882,7 @@ function setGift($tnmt_type, $tnmt, $phase)
|
||||
//포상 장수 이름, 금액
|
||||
$resultHelper[$generalID]['reward'] += $cost;
|
||||
$resultHelper[$generalID]['msg'] = "<span class='ev_highlight'>4강 진출</span>";
|
||||
General::createGeneralObjFromDB($generalID)->increaseInheritancePoint(InheritanceKey::tournament, 10);
|
||||
General::createObjFromDB($generalID)->increaseInheritancePoint(InheritanceKey::tournament, 10);
|
||||
}
|
||||
//결승자 명성 돈
|
||||
$cost = $admin['develcost'] * 6;
|
||||
@@ -946,7 +946,7 @@ function setGift($tnmt_type, $tnmt, $phase)
|
||||
$winnerLogger->pushGlobalHistoryLog("<B><b>【대회】</b></><C>{$tp}</> 대회에서 <Y>{$winner['name']}</>{$josaYiWinner} <C>우승</>, <Y>{$runnerUp['name']}</>{$josaYiRunnerUp} <C>준우승</>을 차지하여 천하에 이름을 떨칩니다!", ActionLogger::EVENT_YEAR_MONTH);
|
||||
$winnerLogger->pushGlobalHistoryLog("<B><b>【대회】</b></><C>{$tp}</> 대회의 <S>우승자</>에게는 <C>{$winnerRewardText}</>, <S>준우승자</>에겐 <C>{$runnerUpRewardText}</>의 <S>상금</>과 약간의 <S>명성</>이 주어집니다!", ActionLogger::EVENT_YEAR_MONTH);
|
||||
|
||||
$generalObjList = General::createGeneralObjListFromDB(array_keys($resultHelper));
|
||||
$generalObjList = General::createObjListFromDB(array_keys($resultHelper));
|
||||
|
||||
foreach ($resultHelper as $generalID => $general) {
|
||||
$rewardText = number_format($general['reward']);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
use sammo\Enums\GeneralLiteQueryMode;
|
||||
use sammo\Enums\GeneralQueryMode;
|
||||
use sammo\Enums\MessageType;
|
||||
|
||||
@@ -46,14 +47,14 @@ if($destGeneralID==0){
|
||||
$general->setVar('nation', $nationID);
|
||||
}
|
||||
else{
|
||||
$general = General::createGeneralObjFromDB($destGeneralID, [
|
||||
$general = GeneralLite::createObjFromDB($destGeneralID, [
|
||||
'name', 'leadership', 'strength', 'intel', 'gold','rice',
|
||||
'troop','officer_level','npc','picture','imgsvr',
|
||||
'permission','penalty','belong', 'crewtype',
|
||||
'experience', 'dedication', 'betray', 'dedlevel', 'explevel', 'makelimit', 'aux',
|
||||
], GeneralQueryMode::Lite);
|
||||
], GeneralLiteQueryMode::Lite);
|
||||
|
||||
if($general instanceof DummyGeneral){
|
||||
if($general instanceof DummyGeneralLite){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'올바르지 않은 장수입니다.'
|
||||
|
||||
@@ -36,7 +36,7 @@ if($tnmt < 0 || $tnmt > 1){
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$me = General::createGeneralObjFromDB($generalID);
|
||||
$me = General::createObjFromDB($generalID);
|
||||
|
||||
|
||||
if($defence_train !== $me->getVar('defence_train')){
|
||||
|
||||
@@ -66,7 +66,7 @@ if(!$ownerInfo){
|
||||
$info = Json::decode($info);
|
||||
|
||||
|
||||
$generalObj = General::createGeneralObjFromDB($generalID);
|
||||
$generalObj = General::createObjFromDB($generalID);
|
||||
$oldGeneralName = $generalObj->getName();
|
||||
$db->update('select_pool', [
|
||||
'general_id'=>-$generalID,
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ if ($limitState >= 2) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$generalObj = General::createGeneralObjFromDB($me['no'], null, GeneralQueryMode::FullWithAccessLog);
|
||||
$generalObj = General::createObjFromDB($me['no'], null, GeneralQueryMode::FullWithAccessLog);
|
||||
$generalObj->setRawCity($db->queryFirstRow('SELECT * FROM city WHERE city = %i', $generalObj->getCityID()));
|
||||
$scenario = $gameStor->scenario_text;
|
||||
|
||||
|
||||
+3
-3
@@ -38,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);
|
||||
$defenderGeneralList = General::createObjListFromDB($defenderIDList, null);
|
||||
|
||||
/** @var WarUnit[] */
|
||||
$defenderList = [];
|
||||
@@ -596,10 +596,10 @@ 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'], GeneralQueryMode::Lite)[0]),
|
||||
Util::formatListOfBackticks(General::mergeQueryColumn()[0]),
|
||||
$defenderNationID,
|
||||
12
|
||||
), null, null, $city, $loseNation, $year, $month, false);
|
||||
), null, null, $city, $loseNation, $year, $month);
|
||||
|
||||
$josaUl = JosaUtil::pick($defenderNationName, '을');
|
||||
$attackerLogger->pushNationalHistoryLog("<D><b>{$defenderNationName}</b></>{$josaUl} 정복");
|
||||
|
||||
@@ -39,7 +39,7 @@ class BidBuyRiceAuction extends \sammo\BaseAPI
|
||||
$amount = $this->args['amount'];
|
||||
|
||||
$generalID = $session->generalID;
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
$auction = new AuctionBuyRice($auctionID, $general);
|
||||
$result = $auction->bid($amount, true);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class BidSellRiceAuction extends \sammo\BaseAPI
|
||||
$amount = $this->args['amount'];
|
||||
|
||||
$generalID = $session->generalID;
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
$auction = new AuctionSellRice($auctionID, $general);
|
||||
$result = $auction->bid($amount, true);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class BidUniqueAuction extends \sammo\BaseAPI
|
||||
$tryExtendCloseDate = $this->args['extendCloseDate'] ?? false;
|
||||
|
||||
$generalID = $session->generalID;
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
$auction = new AuctionUniqueItem($auctionID, $general);
|
||||
$result = $auction->bid($amount, $tryExtendCloseDate);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class GetUniqueItemAuctionDetail extends \sammo\BaseAPI
|
||||
$inheritMgr = InheritancePointManager::getInstance();
|
||||
//preveious라서 column을 최대한 비울 수 있다.
|
||||
$remainPoint = $inheritMgr->getInheritancePoint(
|
||||
General::createGeneralObjFromDB($generalID, ['owner'], GeneralQueryMode::Core),
|
||||
General::createObjFromDB($generalID),
|
||||
InheritanceKey::previous
|
||||
);
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class OpenBuyRiceAuction extends \sammo\BaseAPI
|
||||
$finishBidAmount = $this->args['finishBidAmount'];
|
||||
$generalID = $session->generalID;
|
||||
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
@@ -66,7 +66,7 @@ class OpenSellRiceAuction extends \sammo\BaseAPI
|
||||
$finishBidAmount = $this->args['finishBidAmount'];
|
||||
$generalID = $session->generalID;
|
||||
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
@@ -57,7 +57,7 @@ class OpenUniqueAuction extends \sammo\BaseAPI
|
||||
$generalID = $session->generalID;
|
||||
|
||||
$itemObj = buildItemClass($itemID);
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
@@ -59,7 +59,7 @@ class BuildNationCandidate extends \sammo\BaseAPI
|
||||
|
||||
$env = $gameStor->getAll();
|
||||
|
||||
$generalObj = General::createGeneralObjFromDB($general['no']);
|
||||
$generalObj = General::createObjFromDB($general['no']);
|
||||
|
||||
$validCmd = false;
|
||||
foreach(GameConst::$availableGeneralCommand as $cmdList){
|
||||
|
||||
@@ -68,7 +68,7 @@ class DieOnPrestart extends \sammo\BaseAPI
|
||||
return "아직 삭제할 수 없습니다. {$targetTimeShort} 부터 가능합니다.";
|
||||
}
|
||||
|
||||
$generalObj = General::createGeneralObjFromDB($general['no']);
|
||||
$generalObj = General::createObjFromDB($general['no']);
|
||||
if ($generalObj instanceof DummyGeneral) {
|
||||
trigger_error("올바르지 않은 삭제 프로세스 $userID", E_USER_WARNING);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class DropItem extends \sammo\BaseAPI
|
||||
public function launch(Session $session, ?\DateTimeInterface $modifiedSince, ?string $reqEtag): null | string | array | APIRecoveryType
|
||||
{
|
||||
$generalID = $session->generalID;
|
||||
$me = General::createGeneralObjFromDB($generalID);
|
||||
$me = General::createObjFromDB($generalID);
|
||||
|
||||
$itemType = $this->args['itemType'];
|
||||
$item = $me->getItem($itemType);
|
||||
|
||||
@@ -21,7 +21,7 @@ class GetCommandTable extends \sammo\BaseAPI{
|
||||
public function launch(Session $session, ?\DateTimeInterface $modifiedSince, ?string $reqEtag): null | string | array | APIRecoveryType
|
||||
{
|
||||
$generalID = $session->generalID;
|
||||
$me = General::createGeneralObjFromDB($generalID);
|
||||
$me = General::createObjFromDB($generalID);
|
||||
$commandTable = getCommandTable($me);
|
||||
|
||||
return [
|
||||
|
||||
@@ -534,7 +534,7 @@ class GetFrontInfo extends \sammo\BaseAPI
|
||||
{
|
||||
$generalID = $session->generalID;
|
||||
//NOTE: 이 경우 staticNation 정보를 조회한다.
|
||||
$general = General::createGeneralObjFromDB($generalID, null, GeneralQueryMode::FullWithAccessLog);
|
||||
$general = General::createObjFromDB($generalID, null, GeneralQueryMode::FullWithAccessLog);
|
||||
$nationID = $general->getNationID();
|
||||
$cityID = $general->getCityID();
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class BuyHiddenBuff extends \sammo\BaseAPI
|
||||
$type = $this->args['type'];
|
||||
$level = $this->args['level'];
|
||||
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
if ($userID != $general->getVar('owner')) {
|
||||
return '로그인 상태가 이상합니다. 다시 로그인해 주세요.';
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class BuyRandomUnique extends \sammo\BaseAPI
|
||||
$userID = $session->userID;
|
||||
$generalID = $session->generalID;
|
||||
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
if($userID != $general->getVar('owner')){
|
||||
return '로그인 상태가 이상합니다. 다시 로그인해 주세요.';
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class ResetSpecialWar extends \sammo\BaseAPI
|
||||
$userID = $session->userID;
|
||||
$generalID = $session->generalID;
|
||||
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
if ($userID != $general->getVar('owner')) {
|
||||
return '로그인 상태가 이상합니다. 다시 로그인해 주세요.';
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class ResetTurnTime extends \sammo\BaseAPI
|
||||
$userID = $session->userID;
|
||||
$generalID = $session->generalID;
|
||||
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
if ($userID != $general->getVar('owner')) {
|
||||
return '로그인 상태가 이상합니다. 다시 로그인해 주세요.';
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class SetNextSpecialWar extends \sammo\BaseAPI
|
||||
|
||||
$type = $this->args['type'];
|
||||
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
if ($userID != $general->getVar('owner')) {
|
||||
return '로그인 상태가 이상합니다. 다시 로그인해 주세요.';
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@ namespace sammo\API\Nation;
|
||||
use ArrayObject;
|
||||
use sammo\DB;
|
||||
use sammo\Enums\APIRecoveryType;
|
||||
use sammo\Enums\GeneralLiteQueryMode;
|
||||
use sammo\Enums\GeneralQueryMode;
|
||||
use sammo\General;
|
||||
use sammo\GeneralLite;
|
||||
use sammo\Session;
|
||||
use sammo\Util;
|
||||
|
||||
@@ -165,7 +167,7 @@ class GeneralList extends \sammo\BaseAPI
|
||||
|
||||
|
||||
|
||||
[$queryColumns, $rankColumns, $accessLogColumns] = General::mergeQueryColumn(array_keys(static::$viewColumns), GeneralQueryMode::Lite);
|
||||
[$queryColumns, $rankColumns, $accessLogColumns] = GeneralLite::mergeQueryColumn(array_keys(static::$viewColumns), GeneralLiteQueryMode::Lite);
|
||||
|
||||
$rawGeneralList = Util::convertArrayToDict(
|
||||
$db->query(
|
||||
|
||||
@@ -58,7 +58,7 @@ class GetNationInfo extends \sammo\BaseAPI
|
||||
];
|
||||
}
|
||||
|
||||
$generalObj = General::createGeneralObjFromDB($session->generalID, null, GeneralQueryMode::FullWithoutIAction);
|
||||
$generalObj = General::createObjFromDB($session->generalID);
|
||||
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$gameEnv = $gameStor->getValues(['year', 'month', 'startyear']);
|
||||
|
||||
@@ -113,7 +113,7 @@ class GetReservedCommand extends \sammo\BaseAPI
|
||||
];
|
||||
}
|
||||
|
||||
$generalObj = General::createGeneralObjFromDB($session->generalID, null, GeneralQueryMode::FullWithoutIAction);
|
||||
$generalObj = General::createObjFromDB($session->generalID);
|
||||
|
||||
|
||||
return [
|
||||
|
||||
@@ -6,8 +6,10 @@ use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\DTO\VoteComment;
|
||||
use sammo\Enums\APIRecoveryType;
|
||||
use sammo\Enums\GeneralLiteQueryMode;
|
||||
use sammo\Enums\GeneralQueryMode;
|
||||
use sammo\General;
|
||||
use sammo\GeneralLite;
|
||||
use sammo\Session;
|
||||
use sammo\TimeUtil;
|
||||
use sammo\Validator;
|
||||
@@ -41,7 +43,7 @@ class AddComment extends \sammo\BaseAPI
|
||||
$text = mb_substr($this->args['text'], 0, 200);
|
||||
|
||||
$generalID = $session->generalID;
|
||||
$general = General::createGeneralObjFromDB($generalID, null, GeneralQueryMode::Core);
|
||||
$general = GeneralLite::createObjFromDB($generalID, null, GeneralLiteQueryMode::Core);
|
||||
$generalName = $general->getName();
|
||||
$nationID = $general->getNationID();
|
||||
$nationName = $general->getStaticNation()['name'];
|
||||
|
||||
@@ -106,7 +106,7 @@ class Vote extends \sammo\BaseAPI
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$voteReward = $gameStor->getValue('develcost') * 5;
|
||||
|
||||
$general = General::createGeneralObjFromDB($generalID, null, GeneralQueryMode::Full);
|
||||
$general = General::createObjFromDB($generalID, null, GeneralQueryMode::Full);
|
||||
$general->increaseVar('gold', $voteReward);
|
||||
$uniqueRng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
|
||||
UniqueConst::$hiddenSeed,
|
||||
|
||||
@@ -218,7 +218,7 @@ abstract class Auction
|
||||
if ($bidItem->generalID === $this->general->getID()) {
|
||||
$oldBidder = $this->general;
|
||||
} else {
|
||||
$oldBidder = General::createGeneralObjFromDB($bidItem->generalID);
|
||||
$oldBidder = General::createObjFromDB($bidItem->generalID);
|
||||
}
|
||||
|
||||
if ($this->info->reqResource === ResourceType::inheritancePoint) {
|
||||
@@ -485,7 +485,7 @@ abstract class Auction
|
||||
}
|
||||
}
|
||||
|
||||
$bidder = General::createGeneralObjFromDB($highestBid->generalID);
|
||||
$bidder = General::createObjFromDB($highestBid->generalID);
|
||||
$failReason = $this->finishAuction($highestBid, $bidder);
|
||||
if ($failReason === null) {
|
||||
$this->closeAuction();
|
||||
|
||||
@@ -116,7 +116,7 @@ abstract class AuctionBasicResource extends Auction
|
||||
} else if ($this->info->hostGeneralID == 0) {
|
||||
$auctionHost = $this->genDummy();
|
||||
} else {
|
||||
$auctionHost = General::createGeneralObjFromDB($this->info->hostGeneralID);
|
||||
$auctionHost = General::createObjFromDB($this->info->hostGeneralID);
|
||||
}
|
||||
|
||||
$hostRes = static::$hostRes;
|
||||
@@ -164,7 +164,7 @@ abstract class AuctionBasicResource extends Auction
|
||||
} else if ($this->info->hostGeneralID == 0) {
|
||||
$auctionHost = $this->genDummy();
|
||||
} else {
|
||||
$auctionHost = General::createGeneralObjFromDB($this->info->hostGeneralID);
|
||||
$auctionHost = General::createObjFromDB($this->info->hostGeneralID);
|
||||
}
|
||||
|
||||
$highestBid = $this->getHighestBid();
|
||||
@@ -175,7 +175,7 @@ abstract class AuctionBasicResource extends Auction
|
||||
if ($this->general->getID() === $highestBid->generalID) {
|
||||
$bidder = $this->general;
|
||||
} else {
|
||||
$bidder = General::createGeneralObjFromDB($highestBid->generalID);
|
||||
$bidder = General::createObjFromDB($highestBid->generalID);
|
||||
}
|
||||
|
||||
$hostRes = static::$hostRes;
|
||||
|
||||
@@ -91,7 +91,7 @@ class AutorunGeneralPolicy{
|
||||
|
||||
public array $priority;
|
||||
|
||||
function doNPCState(General $general){
|
||||
function doNPCState(GeneralBase $general){
|
||||
$npc = $general->getNPCType();
|
||||
$nationID = $general->getNationID();
|
||||
|
||||
@@ -115,7 +115,7 @@ class AutorunGeneralPolicy{
|
||||
|
||||
}
|
||||
|
||||
function __construct(General $general, $aiOptions, ?array $nationPolicy, ?array $serverPolicy, array $nation, array $env){
|
||||
function __construct(GeneralBase $general, $aiOptions, ?array $nationPolicy, ?array $serverPolicy, array $nation, array $env){
|
||||
$this->priority = static::$default_priority;
|
||||
|
||||
if($serverPolicy && key_exists('priority', $serverPolicy)){
|
||||
|
||||
@@ -179,7 +179,7 @@ class AutorunNationPolicy {
|
||||
'cureThreshold'=>10,
|
||||
];
|
||||
|
||||
function __construct(General $general, $aiOptions, ?array $nationPolicy, ?array $serverPolicy, array $nation, array $env)
|
||||
function __construct(GeneralBase $general, $aiOptions, ?array $nationPolicy, ?array $serverPolicy, array $nation, array $env)
|
||||
{
|
||||
foreach(static::$defaultPolicy as $policy=>$value){
|
||||
$this->{$policy} = $value;
|
||||
|
||||
@@ -402,7 +402,7 @@ class Betting
|
||||
$userLogger->flush();
|
||||
}
|
||||
} else {
|
||||
$generalList = General::createGeneralObjListFromDB(array_unique(Util::squeezeFromArray($rewardList, 'generalID')), ['gold', 'npc', 'betgold'], GeneralQueryMode::Lite);
|
||||
$generalList = General::createObjListFromDB(array_unique(Util::squeezeFromArray($rewardList, 'generalID')));
|
||||
foreach ($rewardList as $rewardItem) {
|
||||
$gambler = $generalList[$rewardItem['generalID']];
|
||||
$reward = Util::round($rewardItem['amount']);
|
||||
|
||||
@@ -7,11 +7,7 @@ use \sammo\{
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
GameUnitConst,
|
||||
Command,
|
||||
ScoutMessage
|
||||
};
|
||||
@@ -77,7 +73,7 @@ class che_등용 extends Command\GeneralCommand
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation', 'experience', 'dedication'], GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
@@ -68,7 +68,7 @@ class che_등용수락 extends Command\GeneralCommand{
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID'], null);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
$this->setDestNation($this->arg['destNationID'], ['gennum', 'scout']);
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class che_모반시도 extends Command\GeneralCommand{
|
||||
|
||||
$lordID = $db->queryFirstField('SELECT no FROM general WHERE nation = %i AND officer_level = 12', $nationID);
|
||||
|
||||
$lordGeneral = General::createGeneralObjFromDB($lordID);
|
||||
$lordGeneral = General::createObjFromDB($lordID);
|
||||
|
||||
$generalName = $general->getName();
|
||||
$lordName = $lordGeneral->getName();
|
||||
|
||||
@@ -66,7 +66,7 @@ class che_선양 extends Command\GeneralCommand
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'nation'], GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
|
||||
$this->fullConditionConstraints = [
|
||||
|
||||
@@ -84,7 +84,7 @@ class che_장수대상임관 extends Command\GeneralCommand{
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneralID = $this->arg['destGeneralID'];
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation'], GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($destGeneralID);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
$this->setDestNation($this->destGeneralObj->getVar('nation'), ['gennum', 'scout']);
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ class che_증여 extends Command\GeneralCommand
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'nation'], GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
|
||||
$this->fullConditionConstraints = [
|
||||
|
||||
@@ -269,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']);
|
||||
$destCityGeneralList = General::createObjListFromDB($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);
|
||||
|
||||
@@ -92,7 +92,7 @@ class che_몰수 extends Command\NationCommand
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'npc', 'nation', 'imgsvr', 'picture'], GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
|
||||
$env = $this->env;
|
||||
|
||||
@@ -72,7 +72,7 @@ class che_발령 extends Command\NationCommand
|
||||
{
|
||||
$this->setDestCity($this->arg['destCityID']);
|
||||
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
|
||||
if ($this->arg['destGeneralID'] == $this->getGeneral()->getID()) {
|
||||
|
||||
@@ -104,7 +104,7 @@ class che_불가침수락 extends Command\NationCommand
|
||||
$env = $this->env;
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
$this->setDestNation($this->arg['destNationID']);
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ class che_불가침파기수락 extends Command\NationCommand
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
$this->setDestNation($this->arg['destNationID']);
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ class che_종전수락 extends Command\NationCommand
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
$this->setDestNation($this->arg['destNationID']);
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ class che_포상 extends Command\NationCommand
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'nation'], GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
|
||||
if($this->arg['destGeneralID'] == $this->getGeneral()->getID()){
|
||||
|
||||
@@ -95,7 +95,7 @@ class che_필사즉생 extends Command\NationCommand{
|
||||
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <M>필사즉생</>을 발동하였습니다.";
|
||||
|
||||
$targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
||||
foreach(General::createGeneralObjListFromDB($targetGeneralList, ['train', 'atmos'], GeneralQueryMode::Lite) as $targetGeneral){
|
||||
foreach(General::createObjListFromDB($targetGeneralList) as $targetGeneral){
|
||||
$targetGeneral->getLogger()->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
||||
if($targetGeneral->getVar('train') < 100){
|
||||
$targetGeneral->setVar('train', 100);
|
||||
|
||||
@@ -163,7 +163,7 @@ class che_허보 extends Command\NationCommand
|
||||
$destNationCityList = $db->queryFirstColumn('SELECT city FROM city WHERE nation = %i AND supply = 1', $destNationID);
|
||||
|
||||
$targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND city=%i', $destNationID, $destCityID);
|
||||
foreach (General::createGeneralObjListFromDB($targetGeneralList) as $targetGeneralID => $targetGeneral) {
|
||||
foreach (General::createObjListFromDB($targetGeneralList) as $targetGeneralID => $targetGeneral) {
|
||||
$targetLogger = $targetGeneral->getLogger();
|
||||
$targetLogger->pushGeneralActionLog($destBroadcastMessage, ActionLogger::PLAIN);
|
||||
|
||||
|
||||
@@ -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, null, true);
|
||||
$generalObj = new General($this->general, null, null, null, null, 180, 1);
|
||||
|
||||
if($reqCrewType->id != $generalObj->getCrewTypeObj()->id){
|
||||
return true;
|
||||
|
||||
@@ -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::Lite);
|
||||
$destGeneralObj = General::createObjFromDB($this->dest->generalID);
|
||||
|
||||
$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::Lite);
|
||||
$destGeneralObj = General::createObjFromDB($this->dest->generalID);
|
||||
|
||||
$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::Lite);
|
||||
$destGeneralObj = General::createObjFromDB($this->dest->generalID);
|
||||
|
||||
$commandObj = buildNationCommandClass('che_종전수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [
|
||||
'destNationID'=>$this->src->nationID,
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
use sammo\Enums\InheritanceKey;
|
||||
|
||||
class DummyGeneralLite extends GeneralLite
|
||||
{
|
||||
public function __construct(bool $initLogger = true)
|
||||
{
|
||||
$raw = [
|
||||
'no' => 0,
|
||||
'name' => 'Dummy',
|
||||
'npc' => 3,
|
||||
'city' => 0,
|
||||
'nation' => 0,
|
||||
'officer_level' => 0,
|
||||
'crewtype' => -1,
|
||||
'turntime' => '2012-03-04 05:06:07.000000',
|
||||
'experience' => 0,
|
||||
'dedication' => 0,
|
||||
'gold' => 0,
|
||||
'rice' => 0,
|
||||
'leadership' => 10,
|
||||
'strength' => 10,
|
||||
'intel' => 10,
|
||||
'imgsvr' => 0,
|
||||
'picture' => 'default.jpg',
|
||||
];
|
||||
|
||||
$this->raw = $raw;
|
||||
|
||||
if ($initLogger) {
|
||||
$this->initLogger(1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function applyDB($db): bool
|
||||
{
|
||||
if ($this->logger) {
|
||||
$this->initLogger($this->logger->getYear(), $this->logger->getMonth());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Enums;
|
||||
|
||||
// mergeQueryColumn, createGeneralLiteObjListFromDB, createGeneralLiteObjFromDB 호출시 column 특수 모드 지정
|
||||
enum GeneralLiteQueryMode: int
|
||||
{
|
||||
/** 장수 식별을 위한 최소한의 정보, logger 초기화 없음 */
|
||||
case Core = 0;
|
||||
/** 게임 내에서 필수 이벤트 처리를 위한 정보 */
|
||||
case Lite = 1;
|
||||
/** 게임 내 모든 이벤트 처리를 위한 정보 */
|
||||
case Full = 2;
|
||||
}
|
||||
@@ -5,12 +5,6 @@ namespace sammo\Enums;
|
||||
// mergeQueryColumn, createGeneralObjListFromDB, createGeneralObjFromDB 호출시 column 특수 모드 지정
|
||||
enum GeneralQueryMode: int
|
||||
{
|
||||
/** 장수 식별을 위한 최소한의 정보, logger 초기화 없음 */
|
||||
case Core = 0;
|
||||
/** 게임 내에서 필수 이벤트 처리를 위한 정보, iAction 제외 */
|
||||
case Lite = 1;
|
||||
/** 게임 내 모든 이벤트 처리를 위한 정보, iAction 제외 */
|
||||
case FullWithoutIAction = 2;
|
||||
/** 게임 내 모든 이벤트 처리를 위한 정보, iAction 포함 */
|
||||
case Full = 3;
|
||||
/** 접속 정보를 포함한 모든 정보 */
|
||||
|
||||
@@ -28,7 +28,7 @@ class LostUniqueItem extends \sammo\Event\Action
|
||||
if (!$generalIDList) {
|
||||
return;
|
||||
}
|
||||
$generals = General::createGeneralObjListFromDB($generalIDList);
|
||||
$generals = General::createObjListFromDB($generalIDList);
|
||||
|
||||
$lostItems = [];
|
||||
$totalLostCnt = 0;
|
||||
|
||||
@@ -18,7 +18,7 @@ class MergeInheritPointRank extends \sammo\Event\Action
|
||||
{
|
||||
$db = DB::db();
|
||||
|
||||
$generals = General::createGeneralObjListFromDB(null, null);
|
||||
$generals = General::createObjListFromDB(null, null);
|
||||
|
||||
$points = new Map();
|
||||
$points->allocate(count($generals));
|
||||
|
||||
@@ -39,7 +39,11 @@ class ProcessIncome extends \sammo\Event\Action
|
||||
|
||||
$nationList = $db->query('SELECT name,nation,capital,gold,level,rate_tmp,bill,type from nation');
|
||||
$cityListByNation = Util::arrayGroupBy($db->query('SELECT * FROM city'), 'nation');
|
||||
$generalRawListByNation = Util::arrayGroupBy($db->query('SELECT no,name,nation,gold,officer_level,dedication,city FROM general WHERE npc != 5'), 'nation');
|
||||
//FIXME: factory 형태로 바꿔야함
|
||||
$generalRawListByNation = Util::arrayGroupBy($db->query(
|
||||
'SELECT %l FROM general WHERE npc != 5',
|
||||
Util::formatListOfBackticks(General::mergeQueryColumn()[0])
|
||||
), 'nation');
|
||||
|
||||
//국가별 처리
|
||||
foreach ($nationList as $nation) {
|
||||
@@ -119,7 +123,11 @@ class ProcessIncome extends \sammo\Event\Action
|
||||
|
||||
$nationList = $db->query('SELECT name,level,nation,capital,rice,rate_tmp,bill,type from nation');
|
||||
$cityListByNation = Util::arrayGroupBy($db->query('SELECT * FROM city'), 'nation');
|
||||
$generalRawListByNation = Util::arrayGroupBy($db->query('SELECT no,name,nation,rice,officer_level,dedication,city FROM general WHERE npc != 5'), 'nation');
|
||||
//FIXME: factory 형태로 바꿔야함
|
||||
$generalRawListByNation = Util::arrayGroupBy($db->query(
|
||||
'SELECT %l FROM general WHERE npc != 5',
|
||||
Util::formatListOfBackticks(General::mergeQueryColumn()[0])
|
||||
), 'nation');
|
||||
|
||||
//국가별 처리
|
||||
foreach ($nationList as $nation) {
|
||||
|
||||
@@ -84,7 +84,7 @@ class ProvideNPCTroopLeader extends \sammo\Event\Action
|
||||
'troop' => $npcID
|
||||
], 'no=%i', $npcID);
|
||||
|
||||
$cmd = buildGeneralCommandClass('che_집합', General::createGeneralObjFromDB($npcID), $env);
|
||||
$cmd = buildGeneralCommandClass('che_집합', General::createObjFromDB($npcID), $env);
|
||||
_setGeneralCommand($cmd, iterator_to_array(Util::range(GameConst::$maxTurn)));
|
||||
$NPCTroopLeaderCnt += 1;
|
||||
$gameStor->lastNPCTroopLeaderID = $lastNPCTroopLeaderID;
|
||||
|
||||
@@ -112,7 +112,12 @@ class RaiseDisaster extends \sammo\Event\Action
|
||||
$logger->flush();
|
||||
|
||||
if (!$isGood) {
|
||||
$generalListByCity = Util::arrayGroupBy($db->query('SELECT no, name, nation, city, officer_level, injury, leadership, strength, intel, horse, weapon, book, item, crew, crewtype, atmos, train, special, special2 FROM general WHERE city IN %li', Util::squeezeFromArray($targetCityList, 'city')), 'city');
|
||||
//FIXME: factory 형태로 바꿔야함
|
||||
$generalListByCity = Util::arrayGroupBy($db->query(
|
||||
'SELECT %l FROM general WHERE city IN %li',
|
||||
Util::formatListOfBackticks(General::mergeQueryColumn()[0]),
|
||||
Util::squeezeFromArray($targetCityList, 'city')),
|
||||
'city');
|
||||
//NOTE: 쿼리 1번이지만 복잡하기 vs 쿼리 여러번이지만 조금 더 깔끔하기
|
||||
foreach ($targetCityList as $city) {
|
||||
$affectRatio = Util::valueFit($city['secu'] / $city['secu_max'] / 0.8, 0, 1);
|
||||
|
||||
@@ -140,7 +140,7 @@ class UpdateNationLevel extends \sammo\Event\Action
|
||||
$nation['nation'],
|
||||
$targetKillTurn
|
||||
);
|
||||
$nationGenList = General::createGeneralObjListFromDB($nationGenIDList, ['belong', 'npc', 'aux']);
|
||||
$nationGenList = General::createObjListFromDB($nationGenIDList, ['belong', 'npc', 'aux']);
|
||||
$chiefID = null;
|
||||
|
||||
$uniqueLotteryWeightList = [];
|
||||
@@ -215,7 +215,7 @@ class UpdateNationLevel extends \sammo\Event\Action
|
||||
}
|
||||
|
||||
if ($chiefID) {
|
||||
$chiefObj = General::createGeneralObjFromDB($chiefID, ['belong', 'npc', 'aux'], GeneralQueryMode::Lite);
|
||||
$chiefObj = General::createObjFromDB($chiefID);
|
||||
$chiefObj->increaseInheritancePoint(InheritanceKey::unifier, 250 * $levelDiff);
|
||||
$chiefObj->applyDB($db);
|
||||
}
|
||||
|
||||
+23
-225
@@ -10,27 +10,20 @@ use sammo\Enums\InheritanceKey;
|
||||
use sammo\Enums\RankColumn;
|
||||
use sammo\WarUnitTrigger as WarUnitTrigger;
|
||||
|
||||
class General implements iAction
|
||||
class General extends GeneralBase implements iAction
|
||||
{
|
||||
use LazyVarUpdater;
|
||||
use LazyVarAndAuxUpdater;
|
||||
|
||||
protected $raw = [];
|
||||
protected $rawCity = null;
|
||||
|
||||
|
||||
/** @var Map<RankColumn,int|float> */
|
||||
/** @var Map<RankColumn,int> */
|
||||
protected Map $rankVarRead;
|
||||
/** @var Map<RankColumn,int|float> */
|
||||
/** @var Map<RankColumn,int> */
|
||||
protected Map $rankVarIncrease;
|
||||
/** @var Map<RankColumn,int|float> */
|
||||
/** @var Map<RankColumn,int> */
|
||||
protected Map $rankVarSet;
|
||||
|
||||
/** @var Map<GeneralAccessLogColumn,int|float> */
|
||||
/** @var Map<GeneralAccessLogColumn,int|float|string> */
|
||||
protected ?Map $accessLogRead;
|
||||
|
||||
/** @var \sammo\ActionLogger */
|
||||
protected $logger;
|
||||
|
||||
protected $activatedSkill = [];
|
||||
protected $logActivatedSkill = [];
|
||||
protected $isFinished = false;
|
||||
@@ -55,41 +48,17 @@ class General implements iAction
|
||||
protected $lastTurn = null;
|
||||
protected $resultTurn = null;
|
||||
|
||||
const TURNTIME_FULL_MS = -1;
|
||||
const TURNTIME_FULL = 0;
|
||||
const TURNTIME_HMS = 1;
|
||||
const TURNTIME_HM = 2;
|
||||
|
||||
protected $calcCache = [];
|
||||
|
||||
protected static $prohibitedDirectUpdateVars = [
|
||||
//Reason: iAction
|
||||
'leadership' => 1,
|
||||
'power' => 1,
|
||||
'intel' => 1,
|
||||
'nation' => 2,
|
||||
'officer_level' => 1,
|
||||
//NOTE: officerLevelObj로 인해 국가의 '레벨'이 바뀌는 것도 조심해야 하나, 국가 레벨의 변경은 월 초/말에만 일어남.
|
||||
'special' => 1,
|
||||
'special2' => 1,
|
||||
'personal' => 1,
|
||||
'horse' => 1,
|
||||
'weapon' => 1,
|
||||
'book' => 1,
|
||||
'item' => 1
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @param array $raw DB row값.
|
||||
* @param null|Map<RankColumn,int|float> $rawRank
|
||||
* @param null|Map<GeneralAccessLogColumn,int> $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 정도로 초기화 가능
|
||||
* @param int $year 게임 연도
|
||||
* @param int $month 게임 월
|
||||
*/
|
||||
public function __construct(array $raw, ?Map $rawRank, ?Map $rawAccessLog, ?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)
|
||||
{
|
||||
//TODO: 밖에서 가져오도록 하면 버그 확률이 높아짐. 필요한 raw 값을 직접 구해야함.
|
||||
|
||||
@@ -106,9 +75,7 @@ class General implements iAction
|
||||
$this->resultTurn = $this->lastTurn->duplicate();
|
||||
}
|
||||
|
||||
if ($year !== null && $month !== null) {
|
||||
$this->initLogger($year, $month);
|
||||
}
|
||||
|
||||
if ($rawRank) {
|
||||
$this->rankVarRead = $rawRank;
|
||||
@@ -122,10 +89,6 @@ class General implements iAction
|
||||
$this->rankVarIncrease = new Map();
|
||||
$this->rankVarSet = new Map();
|
||||
|
||||
if (!$fullConstruct) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->nationType = buildNationTypeClass($nation['type']);
|
||||
$this->officerLevelObj = new TriggerOfficerLevel($this->raw, $nation['level']);
|
||||
|
||||
@@ -141,42 +104,11 @@ class General implements iAction
|
||||
$this->itemObjs['book'] = buildItemClass($raw['book']);
|
||||
$this->itemObjs['item'] = buildItemClass($raw['item']);
|
||||
|
||||
if (key_exists('aux', $this->raw)) {
|
||||
$rawInheritBuff = $this->getAuxVar('inheritBuff');
|
||||
if ($rawInheritBuff !== null) {
|
||||
$this->inheritBuffObj = new TriggerInheritBuff($rawInheritBuff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initLogger(int $year, int $month)
|
||||
{
|
||||
$this->logger = new ActionLogger(
|
||||
$this->getVar('no'),
|
||||
$this->getVar('nation'),
|
||||
$year,
|
||||
$month,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
function getTurnTime(int $short = self::TURNTIME_FULL_MS)
|
||||
{
|
||||
return [
|
||||
self::TURNTIME_FULL_MS => function ($turntime) {
|
||||
return $turntime;
|
||||
},
|
||||
self::TURNTIME_FULL => function ($turntime) {
|
||||
return substr($turntime, 0, 19);
|
||||
},
|
||||
self::TURNTIME_HMS => function ($turntime) {
|
||||
return substr($turntime, 11, 8);
|
||||
},
|
||||
self::TURNTIME_HM => function ($turntime) {
|
||||
return substr($turntime, 11, 5);
|
||||
},
|
||||
][$short]($this->getVar('turntime'));
|
||||
}
|
||||
|
||||
function setItem(string $itemKey = 'item', ?string $itemCode)
|
||||
{
|
||||
@@ -200,11 +132,6 @@ class General implements iAction
|
||||
return $this->itemObjs[$itemKey];
|
||||
}
|
||||
|
||||
function getNPCType(): int
|
||||
{
|
||||
return $this->raw['npc'];
|
||||
}
|
||||
|
||||
/** @return BaseItem[] */
|
||||
function getItems(): array
|
||||
{
|
||||
@@ -281,48 +208,13 @@ class General implements iAction
|
||||
}
|
||||
}
|
||||
|
||||
function getName(): string
|
||||
{
|
||||
return $this->raw['name'];
|
||||
}
|
||||
|
||||
function getInfo(): string
|
||||
{
|
||||
//iAction용 info로는 적절하지 않음
|
||||
return '';
|
||||
}
|
||||
|
||||
function getID(): int
|
||||
{
|
||||
return $this->raw['no'];
|
||||
}
|
||||
|
||||
function getRawCity(): ?array
|
||||
{
|
||||
return $this->rawCity;
|
||||
}
|
||||
|
||||
function setRawCity(?array $city)
|
||||
{
|
||||
$this->rawCity = $city;
|
||||
}
|
||||
|
||||
function getCityID(): int
|
||||
{
|
||||
return $this->raw['city'];
|
||||
}
|
||||
|
||||
function getNationID(): int
|
||||
{
|
||||
return $this->raw['nation'];
|
||||
}
|
||||
|
||||
function getStaticNation(): array
|
||||
{
|
||||
return getNationStaticInfo($this->raw['nation']);
|
||||
}
|
||||
|
||||
function getLogger(): ?ActionLogger
|
||||
function getLogger(): ActionLogger
|
||||
{
|
||||
return $this->logger;
|
||||
}
|
||||
@@ -505,17 +397,6 @@ class General implements iAction
|
||||
return $this->getStatValue('intel', $withInjury, $withIActionObj, $withStatAdjust, $useFloor);
|
||||
}
|
||||
|
||||
function getDex(GameUnitDetail $crewType)
|
||||
{
|
||||
$armType = $crewType->armType;
|
||||
|
||||
if ($armType == GameUnitConst::T_CASTLE) {
|
||||
$armType = GameUnitConst::T_SIEGE;
|
||||
}
|
||||
|
||||
return $this->getVar("dex{$armType}");
|
||||
}
|
||||
|
||||
function addDex(GameUnitDetail $crewType, float $exp, bool $affectTrainAtmos = false)
|
||||
{
|
||||
$armType = $crewType->armType;
|
||||
@@ -593,8 +474,11 @@ class General implements iAction
|
||||
}
|
||||
}
|
||||
|
||||
function updateVar(string $key, $value)
|
||||
function updateVar(string|\BackedEnum $key, $value)
|
||||
{
|
||||
if($key instanceof \BackedEnum){
|
||||
$key = $key->value;
|
||||
}
|
||||
if (($this->raw[$key] ?? null) === $value) {
|
||||
return;
|
||||
}
|
||||
@@ -1032,86 +916,6 @@ class General implements iAction
|
||||
return $caller;
|
||||
}
|
||||
|
||||
static public function mergeQueryColumn(?array $reqColumns = null, GeneralQueryMode $queryMode = GeneralQueryMode::Full): array
|
||||
{
|
||||
$minimumColumn = ['no', 'name', 'owner', 'npc', 'city', 'nation', 'officer_level', 'officer_city'];
|
||||
$defaultEventColumn = [
|
||||
'no', 'name', 'npc', 'owner', 'city', 'nation', 'officer_level', 'officer_city',
|
||||
'special', 'special2', 'personal',
|
||||
'horse', 'weapon', 'book', 'item', 'last_turn', 'aux', 'turntime',
|
||||
];
|
||||
$fullColumn = [
|
||||
'no', 'name', 'owner', 'owner_name', 'picture', 'imgsvr', 'nation', 'city', 'troop', 'injury', 'affinity',
|
||||
'leadership', 'leadership_exp', 'strength', 'strength_exp', 'intel', 'intel_exp', 'weapon', 'book', 'horse', 'item',
|
||||
'experience', 'dedication', 'officer_level', 'officer_city', 'gold', 'rice', 'crew', 'crewtype', 'train', 'atmos', 'turntime',
|
||||
'makelimit', 'killturn', 'block', 'dedlevel', 'explevel', 'age', 'startage', 'belong',
|
||||
'personal', 'special', 'special2', 'defence_train', 'tnmt', 'npc', 'npc_org', 'deadyear', 'npcmsg',
|
||||
'dex1', 'dex2', 'dex3', 'dex4', 'dex5', 'betray',
|
||||
'recent_war', 'last_turn', 'myset',
|
||||
'specage', 'specage2', 'aux', 'permission', 'penalty',
|
||||
];
|
||||
$fullAcessLogColumn = [
|
||||
GeneralAccessLogColumn::refreshScore,
|
||||
GeneralAccessLogColumn::refreshScoreTotal,
|
||||
];
|
||||
|
||||
if ($reqColumns === null) {
|
||||
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[] */
|
||||
$rankColumn = [];
|
||||
$subColumn = [];
|
||||
$accessLogColumn = [];
|
||||
foreach ($reqColumns as $column) {
|
||||
if ($column instanceof RankColumn) {
|
||||
$rankColumn[] = $column;
|
||||
continue;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
switch ($queryMode) {
|
||||
case GeneralQueryMode::Core:
|
||||
return [array_unique(array_merge($minimumColumn, $subColumn)), $rankColumn, $accessLogColumn];
|
||||
case GeneralQueryMode::Lite:
|
||||
return [array_unique(array_merge($defaultEventColumn, $subColumn)), $rankColumn, $accessLogColumn];
|
||||
case GeneralQueryMode::FullWithoutIAction:
|
||||
case GeneralQueryMode::Full:
|
||||
return [array_unique(array_merge($fullColumn, $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');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ?int[] $generalIDList
|
||||
* @param null|array<string|RankColumn> $column
|
||||
@@ -1119,20 +923,15 @@ class General implements iAction
|
||||
* @return \sammo\General[]
|
||||
* @throws MustNotBeReachedException
|
||||
*/
|
||||
static public function createGeneralObjListFromDB(?array $generalIDList, ?array $column = null, GeneralQueryMode $queryMode = GeneralQueryMode::Full): array
|
||||
static public function createObjListFromDB(?array $generalIDList, ?array $column = null, GeneralQueryMode $queryMode = GeneralQueryMode::Full): array
|
||||
{
|
||||
if ($generalIDList === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
if ($queryMode->value > 0) {
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
|
||||
} else {
|
||||
$year = null;
|
||||
$month = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string[] $column
|
||||
@@ -1197,25 +996,24 @@ class General implements iAction
|
||||
$result[$generalID] = new DummyGeneral($queryMode->value > 0);
|
||||
continue;
|
||||
}
|
||||
if ($rawRanks->hasKey($generalID) && $rawRanks[$generalID]->count() !== count($rankColumn)) {
|
||||
/** @var Map<RankColumn,int|float> */
|
||||
$generalRankValues = $rawRanks[$generalID] ?? new Map();
|
||||
if ($generalRankValues->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->value);
|
||||
|
||||
$generalAccessLog = $rawAccessLogs[$generalID] ?? new Map();
|
||||
$result[$generalID] = new static($rawGenerals[$generalID], $generalRankValues, $generalAccessLog, null, null, $year, $month);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
static public function createGeneralObjFromDB(int $generalID, ?array $column = null, GeneralQueryMode $queryMode = GeneralQueryMode::Full): self
|
||||
static public function createObjFromDB(int $generalID, ?array $column = null, GeneralQueryMode $queryMode = GeneralQueryMode::Full): self
|
||||
{
|
||||
$db = DB::db();
|
||||
if ($queryMode->value > 0) {
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
|
||||
} else {
|
||||
$year = null;
|
||||
$month = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string[] $column
|
||||
@@ -1269,7 +1067,7 @@ class General implements iAction
|
||||
}
|
||||
|
||||
|
||||
$general = new static($rawGeneral, $rawRankValues, $rawAccessLog, null, null, $year, $month, $queryMode->value >= GeneralQueryMode::Full->value);
|
||||
$general = new static($rawGeneral, $rawRankValues, $rawAccessLog, null, null, $year, $month);
|
||||
|
||||
return $general;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
$nationGenerals = General::createObjListFromDB($generalIDList);
|
||||
|
||||
$lastWar = \PHP_INT_MAX;
|
||||
foreach ($nationGenerals as $nationGeneral) {
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
use Ds\Map;
|
||||
use sammo\Enums\GeneralAccessLogColumn;
|
||||
use sammo\Enums\GeneralLiteQueryMode;
|
||||
use sammo\Enums\GeneralQueryMode;
|
||||
use sammo\Enums\RankColumn;
|
||||
|
||||
abstract class GeneralBase
|
||||
{
|
||||
use LazyVarUpdater;
|
||||
|
||||
protected $raw = [];
|
||||
protected $rawCity = null;
|
||||
|
||||
/** @var Map<RankColumn,int> */
|
||||
protected Map $rankVarRead;
|
||||
|
||||
/** @var \sammo\ActionLogger */
|
||||
protected $logger;
|
||||
|
||||
const TURNTIME_FULL_MS = -1;
|
||||
const TURNTIME_FULL = 0;
|
||||
const TURNTIME_HMS = 1;
|
||||
const TURNTIME_HM = 2;
|
||||
|
||||
protected static $prohibitedDirectUpdateVars = [
|
||||
//Reason: iAction
|
||||
'leadership' => 1,
|
||||
'power' => 1,
|
||||
'intel' => 1,
|
||||
'nation' => 2,
|
||||
'officer_level' => 1,
|
||||
//NOTE: officerLevelObj로 인해 국가의 '레벨'이 바뀌는 것도 조심해야 하나, 국가 레벨의 변경은 월 초/말에만 일어남.
|
||||
'special' => 1,
|
||||
'special2' => 1,
|
||||
'personal' => 1,
|
||||
'horse' => 1,
|
||||
'weapon' => 1,
|
||||
'book' => 1,
|
||||
'item' => 1
|
||||
];
|
||||
|
||||
function initLogger(int $year, int $month)
|
||||
{
|
||||
$this->logger = new ActionLogger(
|
||||
$this->getVar('no'),
|
||||
$this->getVar('nation'),
|
||||
$year,
|
||||
$month,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
function getTurnTime(int $short = self::TURNTIME_FULL_MS): ?string
|
||||
{
|
||||
if(!key_exists('turntime', $this->raw)){
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
self::TURNTIME_FULL_MS => function ($turntime) {
|
||||
return $turntime;
|
||||
},
|
||||
self::TURNTIME_FULL => function ($turntime) {
|
||||
return substr($turntime, 0, 19);
|
||||
},
|
||||
self::TURNTIME_HMS => function ($turntime) {
|
||||
return substr($turntime, 11, 8);
|
||||
},
|
||||
self::TURNTIME_HM => function ($turntime) {
|
||||
return substr($turntime, 11, 5);
|
||||
},
|
||||
][$short]($this->getVar('turntime'));
|
||||
}
|
||||
|
||||
function getNPCType(): int
|
||||
{
|
||||
return $this->raw['npc'];
|
||||
}
|
||||
|
||||
function getName(): string
|
||||
{
|
||||
return $this->raw['name'];
|
||||
}
|
||||
|
||||
function getID(): int
|
||||
{
|
||||
return $this->raw['no'];
|
||||
}
|
||||
|
||||
function getRawCity(): ?array
|
||||
{
|
||||
return $this->rawCity;
|
||||
}
|
||||
|
||||
function setRawCity(?array $city)
|
||||
{
|
||||
$this->rawCity = $city;
|
||||
}
|
||||
|
||||
function getCityID(): int
|
||||
{
|
||||
return $this->raw['city'];
|
||||
}
|
||||
|
||||
function getNationID(): int
|
||||
{
|
||||
return $this->raw['nation'];
|
||||
}
|
||||
|
||||
function getStaticNation(): array
|
||||
{
|
||||
return getNationStaticInfo($this->raw['nation']);
|
||||
}
|
||||
|
||||
function getLogger(): ?ActionLogger
|
||||
{
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
function getDex(GameUnitDetail $crewType)
|
||||
{
|
||||
$armType = $crewType->armType;
|
||||
|
||||
if ($armType == GameUnitConst::T_CASTLE) {
|
||||
$armType = GameUnitConst::T_SIEGE;
|
||||
}
|
||||
|
||||
return $this->getVar("dex{$armType}");
|
||||
}
|
||||
|
||||
function getRankVar(RankColumn $key, $defaultValue = null): int
|
||||
{
|
||||
if (!$this->rankVarRead->hasKey($key)) {
|
||||
if ($defaultValue === null) {
|
||||
throw new \RuntimeException('인자가 없음 : ' . $key->value);
|
||||
}
|
||||
return $defaultValue;
|
||||
}
|
||||
|
||||
return $this->rankVarRead[$key];
|
||||
}
|
||||
|
||||
abstract function applyDB($db): bool;
|
||||
|
||||
static public function mergeQueryColumn(?array $reqColumns = null, GeneralQueryMode|GeneralLiteQueryMode $queryMode = GeneralQueryMode::Full): array
|
||||
{
|
||||
$minimumColumn = ['no', 'name', 'owner', 'npc', 'city', 'nation', 'officer_level', 'officer_city'];
|
||||
$defaultEventColumn = [
|
||||
'no', 'name', 'npc', 'owner', 'city', 'nation', 'officer_level', 'officer_city',
|
||||
'special', 'special2', 'personal',
|
||||
'horse', 'weapon', 'book', 'item', 'last_turn', 'aux', 'turntime',
|
||||
];
|
||||
$fullColumn = [
|
||||
'no', 'name', 'owner', 'owner_name', 'picture', 'imgsvr', 'nation', 'city', 'troop', 'injury', 'affinity',
|
||||
'leadership', 'leadership_exp', 'strength', 'strength_exp', 'intel', 'intel_exp', 'weapon', 'book', 'horse', 'item',
|
||||
'experience', 'dedication', 'officer_level', 'officer_city', 'gold', 'rice', 'crew', 'crewtype', 'train', 'atmos', 'turntime',
|
||||
'makelimit', 'killturn', 'block', 'dedlevel', 'explevel', 'age', 'startage', 'belong',
|
||||
'personal', 'special', 'special2', 'defence_train', 'tnmt', 'npc', 'npc_org', 'deadyear', 'npcmsg',
|
||||
'dex1', 'dex2', 'dex3', 'dex4', 'dex5', 'betray',
|
||||
'recent_war', 'last_turn', 'myset',
|
||||
'specage', 'specage2', 'aux', 'permission', 'penalty',
|
||||
];
|
||||
$fullAcessLogColumn = [
|
||||
GeneralAccessLogColumn::refreshScore,
|
||||
GeneralAccessLogColumn::refreshScoreTotal,
|
||||
];
|
||||
|
||||
if ($reqColumns === null) {
|
||||
switch ($queryMode) {
|
||||
case GeneralLiteQueryMode::Core:
|
||||
return [$minimumColumn, [], []];
|
||||
case GeneralLiteQueryMode::Lite:
|
||||
return [$defaultEventColumn, [], []];
|
||||
case GeneralLiteQueryMode::Full:
|
||||
case GeneralQueryMode::Full:
|
||||
return [$fullColumn, RankColumn::cases(), []];
|
||||
case GeneralQueryMode::FullWithAccessLog:
|
||||
return [$fullColumn, RankColumn::cases(), $fullAcessLogColumn];
|
||||
}
|
||||
}
|
||||
|
||||
/** @var RankColumn[] */
|
||||
$rankColumn = [];
|
||||
$subColumn = [];
|
||||
$accessLogColumn = [];
|
||||
foreach ($reqColumns as $column) {
|
||||
if ($column instanceof RankColumn) {
|
||||
$rankColumn[] = $column;
|
||||
continue;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
switch ($queryMode) {
|
||||
case GeneralLiteQueryMode::Core:
|
||||
return [array_unique(array_merge($minimumColumn, $subColumn)), $rankColumn, $accessLogColumn];
|
||||
case GeneralLiteQueryMode::Lite:
|
||||
return [array_unique(array_merge($defaultEventColumn, $subColumn)), $rankColumn, $accessLogColumn];
|
||||
case GeneralLiteQueryMode::Full:
|
||||
case GeneralQueryMode::Full:
|
||||
return [array_unique(array_merge($fullColumn, $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');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
use Ds\Map;
|
||||
use sammo\Enums\GeneralLiteQueryMode;
|
||||
use sammo\Enums\RankColumn;
|
||||
|
||||
class GeneralLite extends GeneralBase
|
||||
{
|
||||
/**
|
||||
* @param array $raw DB row값.
|
||||
* @param null|array $city DB city 테이블의 row값
|
||||
* @param int|null $year 게임 연도
|
||||
* @param int|null $month 게임 월
|
||||
*/
|
||||
public function __construct(array $raw, ?Map $rawRank, ?array $city, ?array $nation, ?int $year, ?int $month)
|
||||
{
|
||||
if ($nation === null) {
|
||||
$nation = getNationStaticInfo($raw['nation']);
|
||||
}
|
||||
|
||||
$this->raw = $raw;
|
||||
$this->rawCity = $city;
|
||||
|
||||
if ($year !== null && $month !== null) {
|
||||
$this->initLogger($year, $month);
|
||||
}
|
||||
|
||||
if ($rawRank) {
|
||||
$this->rankVarRead = $rawRank;
|
||||
} else {
|
||||
$this->rankVarRead = new Map();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MeekroDB $db
|
||||
*/
|
||||
function applyDB($db): bool
|
||||
{
|
||||
$updateVals = $this->getUpdatedValues();
|
||||
|
||||
|
||||
$generalID = $this->getID();
|
||||
$result = false;
|
||||
|
||||
if ($updateVals) {
|
||||
$db->update('general', $updateVals, 'no=%i', $generalID);
|
||||
$result = $result || $db->affectedRows() > 0;
|
||||
if (key_exists('nation', $updateVals)) {
|
||||
$db->update('rank_data', [
|
||||
'nation_id' => $updateVals['nation']
|
||||
], 'general_id = %i', $generalID);
|
||||
$result = true;
|
||||
}
|
||||
$this->flushUpdateValues();
|
||||
}
|
||||
|
||||
$this->getLogger()->flush();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ?int[] $generalIDList
|
||||
* @param null|array<string|RankColumn> $column
|
||||
* @param GeneralLiteQueryMode $queryMode
|
||||
* @return \sammo\GeneralLite[]
|
||||
* @throws MustNotBeReachedException
|
||||
*/
|
||||
static public function createObjListFromDB(?array $generalIDList, ?array $column = null, GeneralLiteQueryMode $queryMode = GeneralLiteQueryMode::Full): array
|
||||
{
|
||||
if ($generalIDList === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if($queryMode > GeneralLiteQueryMode::Full){
|
||||
throw new \InvalidArgumentException('지원하지 않는 queryMode:' . $queryMode->name);
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
if ($queryMode->value > 0) {
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
|
||||
} else {
|
||||
$year = null;
|
||||
$month = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string[] $column
|
||||
*/
|
||||
[$column, $rankColumn,] = static::mergeQueryColumn($column, $queryMode);
|
||||
|
||||
if ($generalIDList === null) {
|
||||
$rawGenerals = Util::convertArrayToDict(
|
||||
$db->query('SELECT %l FROM general WHERE 1', Util::formatListOfBackticks($column)),
|
||||
'no'
|
||||
);
|
||||
|
||||
$generalIDList = array_keys($rawGenerals);
|
||||
} else {
|
||||
$rawGenerals = Util::convertArrayToDict(
|
||||
$db->query('SELECT %l FROM general WHERE no IN %li', Util::formatListOfBackticks($column), $generalIDList),
|
||||
'no'
|
||||
);
|
||||
}
|
||||
|
||||
/** @var Map<int,Map<RankColumn,int|float>> */
|
||||
$rawRanks = new Map();
|
||||
if ($rankColumn) {
|
||||
$rawValue = $db->queryAllLists(
|
||||
'SELECT `general_id`, `type`, `value` FROM rank_data WHERE general_id IN %li AND `type` IN %ls',
|
||||
$generalIDList,
|
||||
array_map(fn (\BackedEnum $e) => $e->value, $rankColumn)
|
||||
);
|
||||
foreach ($rawValue as [$generalID, $rawRankType, $rankValue]) {
|
||||
if (!$rawRanks->hasKey($generalID)) {
|
||||
$rawRanks[$generalID] = new Map();
|
||||
}
|
||||
|
||||
$rankType = RankColumn::from($rawRankType);
|
||||
$rawRanks[$generalID][$rankType] = $rankValue;
|
||||
}
|
||||
}
|
||||
|
||||
$result = [];
|
||||
foreach ($generalIDList as $generalID) {
|
||||
if (!key_exists($generalID, $rawGenerals)) {
|
||||
$result[$generalID] = new DummyGeneral($queryMode->value > 0);
|
||||
continue;
|
||||
}
|
||||
$result[$generalID] = new static($rawGenerals[$generalID], $rawRanks[$generalID] ?? null, null, null, $year, $month);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
static public function createObjFromDB(int $generalID, ?array $column = null, GeneralLiteQueryMode $queryMode = GeneralLiteQueryMode::Full): self
|
||||
{
|
||||
$db = DB::db();
|
||||
if ($queryMode->value > 0) {
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
|
||||
} else {
|
||||
$year = null;
|
||||
$month = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string[] $column
|
||||
* @var RankColumn[] $rankColumn
|
||||
*/
|
||||
[$column, $rankColumn,] = static::mergeQueryColumn($column, $queryMode);
|
||||
|
||||
$rawGeneral = $db->queryFirstRow('SELECT %l FROM general WHERE no = %i', Util::formatListOfBackticks($column), $generalID);
|
||||
|
||||
if (!$rawGeneral) {
|
||||
return new DummyGeneralLite($queryMode->value > 0);
|
||||
}
|
||||
|
||||
$rawRankValues = new Map();
|
||||
if ($rankColumn) {
|
||||
$rawValue = $db->queryAllLists(
|
||||
'SELECT `type`, `value` FROM rank_data WHERE general_id = %i AND `type` IN %ls',
|
||||
$generalID,
|
||||
array_map(fn (\BackedEnum $e) => $e->value, $rankColumn)
|
||||
);
|
||||
foreach ($rawValue as [$rawRankType, $rankValue]) {
|
||||
$rankType = RankColumn::tryFrom($rawRankType);
|
||||
$rawRankValues->put($rankType, $rankValue);
|
||||
}
|
||||
}
|
||||
|
||||
$general = new static($rawGeneral, $rawRankValues, null, null, $year, $month);
|
||||
|
||||
return $general;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
trait LazyVarAndAuxUpdater{
|
||||
use LazyVarUpdater;
|
||||
|
||||
protected $auxVar = null;
|
||||
protected $auxUpdated = false;
|
||||
|
||||
function getRaw(bool $extractAux=false):array{
|
||||
if($extractAux){
|
||||
$this->getAuxVar('');
|
||||
|
||||
}
|
||||
return $this->raw;
|
||||
}
|
||||
|
||||
function unpackAux(){
|
||||
if(!key_exists('auxVar', $this->raw)){
|
||||
if(!key_exists('aux', $this->raw)){
|
||||
throw new \RuntimeException('aux is not set');
|
||||
}
|
||||
$this->raw['auxVar'] = Json::decode($this->raw['aux']??'{}');
|
||||
}
|
||||
}
|
||||
|
||||
function getAuxVar(string|\BackedEnum $key){
|
||||
if($key instanceof \BackedEnum){
|
||||
$key = $key->value;
|
||||
}
|
||||
$this->unpackAux();
|
||||
return $this->raw['auxVar'][$key]??null;
|
||||
}
|
||||
|
||||
function setAuxVar(string|\BackedEnum $key, $var){
|
||||
if($key instanceof \BackedEnum){
|
||||
$key = $key->value;
|
||||
}
|
||||
$oldVar = $this->getAuxVar($key);
|
||||
|
||||
if($oldVar === $var){
|
||||
return;
|
||||
}
|
||||
|
||||
if($var === null){
|
||||
unset($this->raw['auxVar'][$key]);
|
||||
$this->auxUpdated = true;
|
||||
return;
|
||||
}
|
||||
$this->raw['auxVar'][$key] = $var;
|
||||
$this->auxUpdated = true;
|
||||
}
|
||||
|
||||
function getUpdatedValues():array {
|
||||
if($this->auxUpdated){
|
||||
$this->setVar('aux', Json::encode($this->raw['auxVar']));
|
||||
$this->auxUpdated = false;
|
||||
}
|
||||
$updateVals = [];
|
||||
foreach(array_keys($this->updatedVar) as $key){
|
||||
$updateVals[$key] = $this->raw[$key];
|
||||
}
|
||||
return $updateVals;
|
||||
}
|
||||
|
||||
function flushUpdateValues():void {
|
||||
$this->updatedVar = [];
|
||||
if(key_exists('auxVar', $this->raw)){
|
||||
$this->auxUpdated = false;
|
||||
unset($this->raw['auxVar']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,8 @@ namespace sammo;
|
||||
trait LazyVarUpdater{
|
||||
protected $raw = [];
|
||||
protected $updatedVar = [];
|
||||
protected $auxVar = null;
|
||||
protected $auxUpdated = false;
|
||||
|
||||
function getRaw(bool $extractAux=false):array{
|
||||
if($extractAux){
|
||||
$this->getAuxVar('');
|
||||
|
||||
}
|
||||
function getRaw():array{
|
||||
return $this->raw;
|
||||
}
|
||||
|
||||
@@ -38,15 +32,6 @@ trait LazyVarUpdater{
|
||||
return true;
|
||||
}
|
||||
|
||||
function unpackAux(){
|
||||
if(!key_exists('auxVar', $this->raw)){
|
||||
if(!key_exists('aux', $this->raw)){
|
||||
throw new \RuntimeException('aux is not set');
|
||||
}
|
||||
$this->raw['auxVar'] = Json::decode($this->raw['aux']??'{}');
|
||||
}
|
||||
}
|
||||
|
||||
function setVar(string|\BackedEnum $key, $value){
|
||||
if($key instanceof \BackedEnum){
|
||||
$key = $key->value;
|
||||
@@ -54,33 +39,6 @@ trait LazyVarUpdater{
|
||||
return $this->updateVar($key, $value);
|
||||
}
|
||||
|
||||
function getAuxVar(string|\BackedEnum $key){
|
||||
if($key instanceof \BackedEnum){
|
||||
$key = $key->value;
|
||||
}
|
||||
$this->unpackAux();
|
||||
return $this->raw['auxVar'][$key]??null;
|
||||
}
|
||||
|
||||
function setAuxVar(string|\BackedEnum $key, $var){
|
||||
if($key instanceof \BackedEnum){
|
||||
$key = $key->value;
|
||||
}
|
||||
$oldVar = $this->getAuxVar($key);
|
||||
|
||||
if($oldVar === $var){
|
||||
return;
|
||||
}
|
||||
|
||||
if($var === null){
|
||||
unset($this->raw['auxVar'][$key]);
|
||||
$this->auxUpdated = true;
|
||||
return;
|
||||
}
|
||||
$this->raw['auxVar'][$key] = $var;
|
||||
$this->auxUpdated = true;
|
||||
}
|
||||
|
||||
function updateVar(string|\BackedEnum $key, $value){
|
||||
if($key instanceof \BackedEnum){
|
||||
$key = $key->value;
|
||||
@@ -160,10 +118,6 @@ trait LazyVarUpdater{
|
||||
}
|
||||
|
||||
function getUpdatedValues():array {
|
||||
if($this->auxUpdated){
|
||||
$this->setVar('aux', Json::encode($this->raw['auxVar']));
|
||||
$this->auxUpdated = false;
|
||||
}
|
||||
$updateVals = [];
|
||||
foreach(array_keys($this->updatedVar) as $key){
|
||||
$updateVals[$key] = $this->raw[$key];
|
||||
@@ -173,9 +127,5 @@ trait LazyVarUpdater{
|
||||
|
||||
function flushUpdateValues():void {
|
||||
$this->updatedVar = [];
|
||||
if(key_exists('auxVar', $this->raw)){
|
||||
$this->auxUpdated = false;
|
||||
unset($this->raw['auxVar']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ class RaiseInvaderMessage extends Message
|
||||
}
|
||||
|
||||
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
|
||||
$general = \sammo\General::createGeneralObjFromDB($receiverID);
|
||||
$general = \sammo\General::createObjFromDB($receiverID);
|
||||
|
||||
$logger = $general->getLogger();
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class ScoutMessage extends Message
|
||||
}
|
||||
|
||||
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
|
||||
$general = \sammo\General::createGeneralObjFromDB($receiverID);
|
||||
$general = \sammo\General::createObjFromDB($receiverID);
|
||||
|
||||
$logger = $general->getLogger();
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ class TurnExecutionHelper
|
||||
return [true, $currentTurn];
|
||||
}
|
||||
|
||||
$general = General::createGeneralObjFromDB($rawGeneral['no']);
|
||||
$general = General::createObjFromDB($rawGeneral['no']);
|
||||
$nationStor = KVStorage::getStorage($db, $general->getNationID(), 'nation_env');
|
||||
$turnObj = new static($general);
|
||||
|
||||
|
||||
@@ -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, null, $nation, $gameStor->year, $gameStor->month, false);
|
||||
$general = General::createObjFromDB($me['no']);
|
||||
|
||||
$rawServerPolicy = $gameStor->getValue('npc_nation_policy') ?? [];
|
||||
$rawNationPolicy = $nationStor->getValue('npc_nation_policy') ?? [];
|
||||
|
||||
@@ -7,7 +7,7 @@ include "func.php";
|
||||
//로그인 검사
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
$generalObj = General::createGeneralObjFromDB($session->generalID);
|
||||
$generalObj = General::createObjFromDB($session->generalID);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
@@ -14,7 +14,7 @@ $generalID = $session->generalID;
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
$me = General::createGeneralObjFromDB($generalID);
|
||||
$me = General::createObjFromDB($generalID);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ if ($isChiefTurn && !in_array($commandType, Util::array_flatten(GameConst::$avai
|
||||
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env')->turnOnCache();
|
||||
$env = $gameStor->getAll();
|
||||
$general = General::createGeneralObjFromDB($session->generalID);
|
||||
$general = General::createObjFromDB($session->generalID);
|
||||
|
||||
if (!$isChiefTurn) {
|
||||
$commandObj = buildGeneralCommandClass($commandType, $general, $env);
|
||||
|
||||
Reference in New Issue
Block a user