버그 수정

This commit is contained in:
2019-04-21 15:41:02 +09:00
parent 2765e1c923
commit 9ad8d70cf7
9 changed files with 32 additions and 14 deletions
+1 -1
View File
@@ -118,7 +118,7 @@ function pullNationCommand(int $nationID, int $level, int $turnCnt=1){
$db = DB::db(); $db = DB::db();
$db->update('general_turn', [ $db->update('nation_turn', [
'turn_idx'=>$db->sqleval('turn_idx + %i', GameConst::$maxChiefTurn), 'turn_idx'=>$db->sqleval('turn_idx + %i', GameConst::$maxChiefTurn),
'action'=>'휴식', 'action'=>'휴식',
'arg'=>'{}' 'arg'=>'{}'
+1 -1
View File
@@ -1059,7 +1059,7 @@ function updateNationState() {
], 'nation=%i', $nation['nation']); ], 'nation=%i', $nation['nation']);
$turnRows = []; $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){ foreach(range(0, GameConst::$maxChiefTurn - 1) as $turnIdx){
$turnRows[] = [ $turnRows[] = [
'nation_id'=>$nation['nation'], 'nation_id'=>$nation['nation'],
+1 -1
View File
@@ -142,7 +142,7 @@ class che_몰수 extends Command\NationCommand{
Message::MSGTYPE_PUBLIC, Message::MSGTYPE_PUBLIC,
$src, $src,
$src, $src,
$str, $text,
new \DateTime(), new \DateTime(),
new \DateTime('9999-12-31'), new \DateTime('9999-12-31'),
[] []
+2
View File
@@ -1,5 +1,7 @@
<?php <?php
namespace sammo\Command; namespace sammo\Command;
use \sammo\General;
use \sammo\LastTurn;
abstract class NationCommand extends BaseCommand{ abstract class NationCommand extends BaseCommand{
protected $lastTurn; protected $lastTurn;
+1 -1
View File
@@ -27,7 +27,7 @@ class NearCity extends Constraint{
$this->tested = true; $this->tested = true;
$dist = \sammo\searchDistance($this->general['city'], $this->arg, false); $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; return true;
} }
+2 -2
View File
@@ -727,7 +727,7 @@ class GeneralAI{
} }
} else{ // 포상 } else{ // 포상
$compNpcWar = Util::array_fist($npcWarGenerals); $compNpcWar = Util::array_first($npcWarGenerals);
$compNpcCivil = null; $compNpcCivil = null;
foreach($npcCivilGenerals as $npcCivil){ foreach($npcCivilGenerals as $npcCivil){
if($npcCivil->npc == 5){ if($npcCivil->npc == 5){
@@ -1733,7 +1733,7 @@ class GeneralAI{
$iterCurrentType = ($cheifLevel % 2 == 0)?$iterCandChiefPower:$iterCandChiefIntel; $iterCurrentType = ($cheifLevel % 2 == 0)?$iterCandChiefPower:$iterCandChiefIntel;
$candidate = $iterCurrentType->current(); $candidate = $iterCurrentType->current();
while(key_exist($candidate, $promoted)){ while(key_exists($candidate, $promoted)){
$iterCurrentType->next(); $iterCurrentType->next();
} }
+4 -1
View File
@@ -13,7 +13,10 @@ class LastTurn{
$this->setTerm($term); $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); $values = Json::decode($json);
$obj = new static( $obj = new static(
$values['command']??null, $values['command']??null,
+16
View File
@@ -1,6 +1,8 @@
<?php <?php
namespace sammo\Scenario; namespace sammo\Scenario;
use \sammo\DB; use \sammo\DB;
use \sammo\GameConst;
use function \sammo\getNationChiefLevel;
class Nation{ class Nation{
private $id; private $id;
@@ -146,6 +148,20 @@ class Nation{
$newRuler = $db->queryFirstField('SELECT `no` FROM general WHERE nation=%i ORDER BY leader+power+intel DESC LIMIT 1', $this->id); $newRuler = $db->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); $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(){ public function getBrief(){
+4 -7
View File
@@ -65,10 +65,7 @@ class TurnExecutionHelper
return true; return true;
} }
public function processNationCommand(string $commandClassName, array $commandArg, LastTurn $commandLast):LastTurn{ public function processNationCommand(string $commandClassName, ?array $commandArg, LastTurn $commandLast):LastTurn{
if(!$this->nationTurn){
throw new \InvalidArgumentException('nationTurn이 없음');
}
$general = $this->getGeneral(); $general = $this->getGeneral();
$db = DB::db(); $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){ if($general->getVar('nation') != 0 && $general->getVar('level') >= 5){
$nationStor = KVStorage::getStorage($db, 'nation_env'); $nationStor = KVStorage::getStorage($db, 'nation_env');
$lastNationTurnKey = "turn_last_{$general->getVar('nation')}_{$general->getVar('level')}"; $lastNationTurnKey = "turn_last_{$general->getVar('nation')}_{$general->getVar('level')}";
$lastNationTurn = $nationStor->getValue($lastNationTurnKey)??[]; $lastNationTurn = $nationStor->getValue($lastNationTurnKey);
//수뇌 몇 없는데 매번 left join 하는건 낭비인것 같다. //수뇌 몇 없는데 매번 left join 하는건 낭비인것 같다.
$rawNationTurn = Json::decode($db->queryFirstRow( $rawNationTurn = Json::decode($db->queryFirstRow(
'SELECT action, arg FROM nation_turn WHERE nation_id = %i AND level = %i AND turn_idx =0', '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; $hasNationTurn = true;
$nationCommand = $rawNationTurn['action']; $nationCommand = $rawNationTurn['action'];
$nationArg = Json::decode($rawNationTurn['arg']); $nationArg = Json::decode($rawNationTurn['arg']??null);
} }
if($general->getVar('npc') >= 2){ if($general->getVar('npc') >= 2){
@@ -261,7 +258,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
$resultNationTurn = $turnObj->processNationCommand( $resultNationTurn = $turnObj->processNationCommand(
$nationCommand, $nationCommand,
$nationArg, $nationArg,
$lastNationTurn LastTurn::fromJson($lastNationTurn)
); );
$nationStor->setValue($lastNationTurnKey, $resultNationTurn->toJson()); $nationStor->setValue($lastNationTurnKey, $resultNationTurn->toJson());
} }