nation_env 수정, $connect 일부 제거
This commit is contained in:
@@ -221,13 +221,9 @@ class che_임관 extends Command\GeneralCommand{
|
||||
$nationList = $db->query('SELECT nation,`name`,color,scout,gennum FROM nation');
|
||||
shuffle($nationList);
|
||||
$nationList = Util::convertArrayToDict($nationList, 'nation');
|
||||
$nationStor = KVStorage::getStorage($db, 'nation_env');
|
||||
//NOTE: join 안할것임
|
||||
$scoutMsgs = $nationStor->getValues(array_map(function($nationID){
|
||||
return "nation_scout_msg_{$nationID}";
|
||||
}, array_keys($nationList)));
|
||||
foreach($scoutMsgs as $nationIDPack=>$scoutMsg){
|
||||
$nationID = Util::toInt(Util::array_last(explode('_', $nationIDPack)));
|
||||
$scoutMsgs = KVStorage::getValuesFromInterNamespace($db, 'nation_env', 'scout_msg');
|
||||
foreach($scoutMsgs as $nationID=>$scoutMsg){
|
||||
$nationList[$nationID]['scoutmsg'] = $scoutMsg;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ use function sammo\buildNationTypeClass;
|
||||
use function sammo\refreshNationStaticInfo;
|
||||
use function sammo\GetNationColors;
|
||||
use function sammo\getAllNationStaticInfo;
|
||||
use function sammo\DeleteConflict;
|
||||
use function sammo\deleteNation;
|
||||
|
||||
|
||||
@@ -87,19 +86,20 @@ class che_해산 extends Command\GeneralCommand{
|
||||
$general->increaseVarWithLimit('gold', 0, 0, GameConst::$defaultGold);
|
||||
$general->increaseVarWithLimit('rice', 0, 0, GameConst::$defaultRice);
|
||||
|
||||
DeleteConflict($nationID);
|
||||
deleteNation($general);
|
||||
|
||||
refreshNationStaticInfo();
|
||||
|
||||
$logger = $general->getLogger();
|
||||
|
||||
$logger->pushGeneralActionLog("세력을 해산했습니다. <1>$date</>");
|
||||
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} 세력을 해산했습니다.");
|
||||
|
||||
$logger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>{$josaUl} 해산");
|
||||
|
||||
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
|
||||
$oldNationGenerals = deleteNation($general, false);
|
||||
foreach($oldNationGenerals as $oldGeneral){
|
||||
$oldGeneral->setVar('makelimit', 12);
|
||||
$oldGeneral->applyDB($db);
|
||||
}
|
||||
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -142,10 +142,11 @@ class che_천도 extends Command\NationCommand
|
||||
$lastTurn = $this->getLastTurn();
|
||||
$commandName = $this->getName();
|
||||
|
||||
$nationStor = \sammo\KVStorage::getStorage(DB::db(), 'nation_env');
|
||||
$general = $this->getGeneral();
|
||||
$nationID = $general->getNationID();
|
||||
$nationStor->setValue("last천도Trial_{$nationID}", [$general->getVar('officer_level'), $general->getTurnTime()]);
|
||||
$nationStor = \sammo\KVStorage::getStorage(DB::db(), $nationID, 'nation_env');
|
||||
|
||||
$nationStor->last천도Trial = [$general->getVar('officer_level'), $general->getTurnTime()];
|
||||
|
||||
if ($lastTurn->getCommand() != $commandName || $lastTurn->getArg() !== $this->arg) {
|
||||
$this->setResultTurn(new LastTurn(
|
||||
|
||||
@@ -1648,19 +1648,19 @@ class GeneralAI
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$nationStor = KVStorage::getStorage($db, 'nation_env');
|
||||
$nationStor = KVStorage::getStorage($db, $general->getNationID(), 'nation_env');
|
||||
$turnTerm = $this->env['turnterm'];
|
||||
|
||||
//천도를 한턴 넣었다면 계속 넣는다.
|
||||
if($lastTurn->getCommand() === '천도' && $lastTurn->getArg()['destCityID'] != $this->nation['capital']){
|
||||
$cmd = buildNationCommandClass('che_천도', $this->general, $this->env, $lastTurn, $lastTurn->getArg());
|
||||
if($cmd->hasFullConditionMet()){
|
||||
$nationStor->setValue("last천도Trial_{$this->nation['nation']}", [$general->getVar('officer_level'), $general->getTurnTime()]);
|
||||
$nationStor->last천도Trial = [$general->getVar('officer_level'), $general->getTurnTime()];
|
||||
return $cmd;
|
||||
}
|
||||
}
|
||||
|
||||
$lastTrial = $nationStor->getValue("last천도Trial_{$this->nation['nation']}");
|
||||
$lastTrial = $nationStor->last천도Trial;
|
||||
if($lastTrial){
|
||||
[$lastTrialLevel, $lastTrialTurnTime] = $lastTrial;
|
||||
$timeDiffSeconds = TimeUtil::DateIntervalToSeconds(
|
||||
@@ -1776,7 +1776,7 @@ class GeneralAI
|
||||
}
|
||||
|
||||
|
||||
$nationStor->setValue("last천도Trial_{$this->nation['nation']}", [$general->getVar('officer_level'), $general->getTurnTime()]);
|
||||
$nationStor->last천도Trial = [$general->getVar('officer_level'), $general->getTurnTime()];
|
||||
return $cmd;
|
||||
}
|
||||
|
||||
|
||||
+23
-11
@@ -15,18 +15,25 @@ class LastTurn{
|
||||
$this->setSeq($seq);
|
||||
}
|
||||
|
||||
static function fromRaw(?array $raw):self{
|
||||
if(!$raw){
|
||||
return new static();
|
||||
}
|
||||
$obj = new static(
|
||||
$raw['command']??null,
|
||||
$raw['arg']??null,
|
||||
$raw['term']??null,
|
||||
$raw['seq']??null
|
||||
);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
static function fromJson(?string $json):self{
|
||||
if($json === null || $json === ''){
|
||||
return new static();
|
||||
}
|
||||
$values = Json::decode($json);
|
||||
$obj = new static(
|
||||
$values['command']??null,
|
||||
$values['arg']??null,
|
||||
$values['term']??null,
|
||||
$values['seq']??null
|
||||
);
|
||||
return $obj;
|
||||
return static::fromRaw(Json::decode($json));
|
||||
|
||||
}
|
||||
|
||||
function setCommand(?string $command){
|
||||
@@ -64,7 +71,7 @@ class LastTurn{
|
||||
return $this->seq;
|
||||
}
|
||||
|
||||
function toJson():string{
|
||||
function toRaw():array{
|
||||
$result = [
|
||||
'command'=>$this->command
|
||||
];
|
||||
@@ -77,10 +84,15 @@ class LastTurn{
|
||||
if($this->seq !== null){
|
||||
$result['seq'] = $this->seq;
|
||||
}
|
||||
return Json::encode($result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function toJson():string{
|
||||
|
||||
return Json::encode($this->toRaw());
|
||||
}
|
||||
|
||||
function duplicate():LastTurn{
|
||||
return new static($this->command, $this->arg, $this->term);
|
||||
return new static($this->command, $this->arg, $this->term, $this->seq);
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,6 @@ class ResetHelper{
|
||||
}
|
||||
}
|
||||
|
||||
(KVStorage::getStorage($db, 'nation_env'))->resetValues();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$gameStor->resetValues();
|
||||
$gameStor->next_season_idx = $seasonIdx;
|
||||
|
||||
@@ -83,7 +83,7 @@ class Nation{
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$nationStor = KVStorage::getStorage($db, 'nation_env');
|
||||
$nationStor = KVStorage::getStorage($db, $this->id, 'nation_env');
|
||||
$otherNations = $db->queryFirstColumn('SELECT nation FROM nation');
|
||||
|
||||
$db->insert('nation', [
|
||||
@@ -111,8 +111,7 @@ class Nation{
|
||||
], 'city IN %li', $cities);
|
||||
}
|
||||
|
||||
$scoutKey = "nation_scout_msg_{$this->id}";
|
||||
$nationStor->{$scoutKey} = $this->infoText;
|
||||
$nationStor->scout_msg = $this->infoText;
|
||||
|
||||
|
||||
$diplomacy = [];
|
||||
|
||||
@@ -246,9 +246,8 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
|
||||
|
||||
$hasNationTurn = false;
|
||||
if($general->getVar('nation') != 0 && $general->getVar('officer_level') >= 5){
|
||||
$nationStor = KVStorage::getStorage($db, 'nation_env');
|
||||
$lastNationTurnKey = "turn_last_{$general->getVar('nation')}_{$general->getVar('officer_level')}";
|
||||
$lastNationTurn = $nationStor->getValue($lastNationTurnKey);
|
||||
$nationStor = KVStorage::getStorage($db, $general->getNationID(), 'nation_env');
|
||||
$lastNationTurnKey = "turn_last_{$general->getVar('officer_level')}";
|
||||
//수뇌 몇 없는데 매번 left join 하는건 낭비인것 같다.
|
||||
$rawNationTurn = $db->queryFirstRow(
|
||||
'SELECT action, arg FROM nation_turn WHERE nation_id = %i AND officer_level = %i AND turn_idx =0',
|
||||
@@ -258,7 +257,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
|
||||
$hasNationTurn = true;
|
||||
$nationCommand = $rawNationTurn['action']??null;
|
||||
$nationArg = Json::decode($rawNationTurn['arg']??null);
|
||||
$lastNationTurn = LastTurn::fromJson($lastNationTurn);
|
||||
$lastNationTurn = LastTurn::fromRaw($nationStor->getValue($lastNationTurnKey));
|
||||
$nationCommandObj = buildNationCommandClass($nationCommand, $general, $env, $lastNationTurn, $nationArg);
|
||||
}
|
||||
|
||||
@@ -279,7 +278,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
|
||||
$resultNationTurn = $turnObj->processNationCommand(
|
||||
$nationCommandObj
|
||||
);
|
||||
$nationStor->setValue($lastNationTurnKey, $resultNationTurn->toJson());
|
||||
$nationStor->setValue($lastNationTurnKey, $resultNationTurn->toRaw());
|
||||
}
|
||||
|
||||
if($ai){
|
||||
|
||||
Reference in New Issue
Block a user