버그 수정

This commit is contained in:
2019-04-21 15:41:02 +09:00
parent 45a4ca5298
commit f8bcfba90e
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->update('general_turn', [
$db->update('nation_turn', [
'turn_idx'=>$db->sqleval('turn_idx + %i', GameConst::$maxChiefTurn),
'action'=>'휴식',
'arg'=>'{}'
+1 -1
View File
@@ -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'],
+1 -1
View File
@@ -142,7 +142,7 @@ class che_몰수 extends Command\NationCommand{
Message::MSGTYPE_PUBLIC,
$src,
$src,
$str,
$text,
new \DateTime(),
new \DateTime('9999-12-31'),
[]
+2
View File
@@ -1,5 +1,7 @@
<?php
namespace sammo\Command;
use \sammo\General;
use \sammo\LastTurn;
abstract class NationCommand extends BaseCommand{
protected $lastTurn;
+1 -1
View File
@@ -27,7 +27,7 @@ class NearCity extends Constraint{
$this->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;
}
+2 -2
View File
@@ -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();
}
+4 -1
View File
@@ -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,
+16
View File
@@ -1,6 +1,8 @@
<?php
namespace sammo\Scenario;
use \sammo\DB;
use \sammo\GameConst;
use function \sammo\getNationChiefLevel;
class Nation{
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);
$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(){
+4 -7
View File
@@ -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());
}