diff --git a/hwe/func_command.php b/hwe/func_command.php index 9e065f25..b161a75e 100644 --- a/hwe/func_command.php +++ b/hwe/func_command.php @@ -118,7 +118,7 @@ function pullNationCommand(int $nationID, int $level, int $turnCnt=1){ $db = DB::db(); - $db->update('general_turn', [ + $db->update('nation_turn', [ 'turn_idx'=>$db->sqleval('turn_idx + %i', GameConst::$maxChiefTurn), 'action'=>'휴식', 'arg'=>'{}' diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index e1a90502..e660ad34 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -1059,7 +1059,7 @@ function updateNationState() { ], 'nation=%i', $nation['nation']); $turnRows = []; - foreach(range(getNationChiefLevel($oldLevel) - 1, getNationChiefLevel($nation['level']), -1) as $chiefLevel){ + foreach(range(12, getNationChiefLevel($nation['level']), -1) as $chiefLevel){ foreach(range(0, GameConst::$maxChiefTurn - 1) as $turnIdx){ $turnRows[] = [ 'nation_id'=>$nation['nation'], diff --git a/hwe/sammo/Command/Nation/che_몰수.php b/hwe/sammo/Command/Nation/che_몰수.php index 633079af..f2e760de 100644 --- a/hwe/sammo/Command/Nation/che_몰수.php +++ b/hwe/sammo/Command/Nation/che_몰수.php @@ -142,7 +142,7 @@ class che_몰수 extends Command\NationCommand{ Message::MSGTYPE_PUBLIC, $src, $src, - $str, + $text, new \DateTime(), new \DateTime('9999-12-31'), [] diff --git a/hwe/sammo/Command/NationCommand.php b/hwe/sammo/Command/NationCommand.php index 0ecab883..433a1005 100644 --- a/hwe/sammo/Command/NationCommand.php +++ b/hwe/sammo/Command/NationCommand.php @@ -1,5 +1,7 @@ tested = true; $dist = \sammo\searchDistance($this->general['city'], $this->arg, false); - if(key_exist($this->destCity['city'], $dist)){ + if(key_exists($this->destCity['city'], $dist)){ return true; } diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php index 8440a1ea..803ce154 100644 --- a/hwe/sammo/GeneralAI.php +++ b/hwe/sammo/GeneralAI.php @@ -727,7 +727,7 @@ class GeneralAI{ } } else{ // 포상 - $compNpcWar = Util::array_fist($npcWarGenerals); + $compNpcWar = Util::array_first($npcWarGenerals); $compNpcCivil = null; foreach($npcCivilGenerals as $npcCivil){ if($npcCivil->npc == 5){ @@ -1733,7 +1733,7 @@ class GeneralAI{ $iterCurrentType = ($cheifLevel % 2 == 0)?$iterCandChiefPower:$iterCandChiefIntel; $candidate = $iterCurrentType->current(); - while(key_exist($candidate, $promoted)){ + while(key_exists($candidate, $promoted)){ $iterCurrentType->next(); } diff --git a/hwe/sammo/LastTurn.php b/hwe/sammo/LastTurn.php index f95de1bd..fb4d3eb3 100644 --- a/hwe/sammo/LastTurn.php +++ b/hwe/sammo/LastTurn.php @@ -13,7 +13,10 @@ class LastTurn{ $this->setTerm($term); } - static function fromJson(string $json):self{ + static function fromJson(?string $json):self{ + if($json === null || $json === ''){ + return new static(); + } $values = Json::decode($json); $obj = new static( $values['command']??null, diff --git a/hwe/sammo/Scenario/Nation.php b/hwe/sammo/Scenario/Nation.php index 169a1862..de862e96 100644 --- a/hwe/sammo/Scenario/Nation.php +++ b/hwe/sammo/Scenario/Nation.php @@ -1,6 +1,8 @@ queryFirstField('SELECT `no` FROM general WHERE nation=%i ORDER BY leader+power+intel DESC LIMIT 1', $this->id); $db->update('general',['level'=>12], 'no=%i', $newRuler); } + + $turnRows = []; + foreach(range(getNationChiefLevel(0) - 1, getNationChiefLevel($this->nationLevel), -1) as $chiefLevel){ + foreach(range(0, GameConst::$maxChiefTurn - 1) as $turnIdx){ + $turnRows[] = [ + 'nation_id'=>$nation['nation'], + 'level'=>$chiefLevel, + 'turn_idx'=>$turnIdx, + 'action'=>'휴식', + 'arg'=>null, + ]; + } + } + $db->insertIgnore('nation_turn', $turnRows); } public function getBrief(){ diff --git a/hwe/sammo/TurnExecutionHelper.php b/hwe/sammo/TurnExecutionHelper.php index d358a66a..deb8ae02 100644 --- a/hwe/sammo/TurnExecutionHelper.php +++ b/hwe/sammo/TurnExecutionHelper.php @@ -65,10 +65,7 @@ class TurnExecutionHelper return true; } - public function processNationCommand(string $commandClassName, array $commandArg, LastTurn $commandLast):LastTurn{ - if(!$this->nationTurn){ - throw new \InvalidArgumentException('nationTurn이 없음'); - } + public function processNationCommand(string $commandClassName, ?array $commandArg, LastTurn $commandLast):LastTurn{ $general = $this->getGeneral(); $db = DB::db(); @@ -233,7 +230,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC', if($general->getVar('nation') != 0 && $general->getVar('level') >= 5){ $nationStor = KVStorage::getStorage($db, 'nation_env'); $lastNationTurnKey = "turn_last_{$general->getVar('nation')}_{$general->getVar('level')}"; - $lastNationTurn = $nationStor->getValue($lastNationTurnKey)??[]; + $lastNationTurn = $nationStor->getValue($lastNationTurnKey); //수뇌 몇 없는데 매번 left join 하는건 낭비인것 같다. $rawNationTurn = Json::decode($db->queryFirstRow( 'SELECT action, arg FROM nation_turn WHERE nation_id = %i AND level = %i AND turn_idx =0', @@ -242,7 +239,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC', ))??[]; $hasNationTurn = true; $nationCommand = $rawNationTurn['action']; - $nationArg = Json::decode($rawNationTurn['arg']); + $nationArg = Json::decode($rawNationTurn['arg']??null); } if($general->getVar('npc') >= 2){ @@ -261,7 +258,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC', $resultNationTurn = $turnObj->processNationCommand( $nationCommand, $nationArg, - $lastNationTurn + LastTurn::fromJson($lastNationTurn) ); $nationStor->setValue($lastNationTurnKey, $resultNationTurn->toJson()); }