버그 수정

This commit is contained in:
2019-04-24 01:17:21 +09:00
parent 3f2cf23f47
commit 5d1b39ca49
29 changed files with 79 additions and 51 deletions
+3 -3
View File
@@ -1929,8 +1929,8 @@ function deleteNation(General $general) {
$josaUn = JosaUtil::pick($nationName, '은'); $josaUn = JosaUtil::pick($nationName, '은');
$logger->pushGlobalHistoryLog("<R><b>【멸망】</b></><D><b>{$nationName}</b></>{$josaUn} <R>멸망</>했습니다."); $logger->pushGlobalHistoryLog("<R><b>【멸망】</b></><D><b>{$nationName}</b></>{$josaUn} <R>멸망</>했습니다.");
$oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $general['nation']); $oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $nationID);
$oldNationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $general['nation']); $oldNationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nationID);
$oldNation['generals'] = $oldNationGenerals; $oldNation['generals'] = $oldNationGenerals;
$oldNation['aux'] = Json::decode($oldNation['aux']); $oldNation['aux'] = Json::decode($oldNation['aux']);
@@ -1963,7 +1963,7 @@ function deleteNation(General $general) {
$db->insert('ng_old_nations', [ $db->insert('ng_old_nations', [
'server_id'=>UniqueConst::$serverID, 'server_id'=>UniqueConst::$serverID,
'nation'=>$general['nation'], 'nation'=>$nationID,
'data'=>Json::encode($oldNation) 'data'=>Json::encode($oldNation)
]); ]);
$db->delete('nation', 'nation=%i', $nationID); $db->delete('nation', 'nation=%i', $nationID);
+4 -1
View File
@@ -1075,7 +1075,7 @@ function updateNationState() {
refreshNationStaticInfo(); refreshNationStaticInfo();
} }
$assemblerCnt = $assemblerCnt[$nation['nation']]??0; $assemblerCnt = $assemblerCnts[$nation['nation']]??0;
$maxAssemblerCnt = [ $maxAssemblerCnt = [
1=>0, 1=>0,
2=>1, 2=>1,
@@ -1105,6 +1105,9 @@ function updateNationState() {
'no'=>$npcID 'no'=>$npcID
]); ]);
$troopID = $db->insertId(); $troopID = $db->insertId();
$db->update('general', [
'troop'=>$troopID
], 'no=%i', $npcID);
//TODO: 5턴간 집합턴 입력 //TODO: 5턴간 집합턴 입력
$assemblerCnt += 1; $assemblerCnt += 1;
+1 -1
View File
@@ -123,7 +123,7 @@ function getGeneralIntel($general, $withInjury, $withItem, $withStatAdjust, $use
* *
* @return array 계산된 실패, 성공 확률 ('success' => 성공 확률, 'fail' => 실패 확률) * @return array 계산된 실패, 성공 확률 ('success' => 성공 확률, 'fail' => 실패 확률)
*/ */
function CriticalRatioDomestic(&$general, $type) { function CriticalRatioDomestic($general, $type) {
$leader = getGeneralLeadership($general, false, true, true, false); $leader = getGeneralLeadership($general, false, true, true, false);
$power = getGeneralPower($general, false, true, true, false); $power = getGeneralPower($general, false, true, true, false);
$intel = getGeneralIntel($general, false, true, true, false); $intel = getGeneralIntel($general, false, true, true, false);
+3 -1
View File
@@ -7,6 +7,8 @@ use \sammo\{
ActionLogger ActionLogger
}; };
use function \sammo\getNationStaticInfo;
use \sammo\Constraint\Constraint; use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper; use \sammo\Constraint\ConstraintHelper;
@@ -261,7 +263,7 @@ abstract class BaseCommand{
public function testRunnable():?string{ public function testRunnable():?string{
if(!$this->isArgValid()){ if(!$this->isArgValid()){
throw new \InvalidArgumentException('인자가 제대로 설정되지 않았습니다'); throw new \InvalidArgumentException('인자가 제대로 설정되지 않았습니다'.\sammo\Json::encode($this->arg));
} }
if($this->runnableConstraints === null){ if($this->runnableConstraints === null){
throw new \InvalidArgumentException('runnableConstraits가 제대로 설정되지 않았습니다'); throw new \InvalidArgumentException('runnableConstraits가 제대로 설정되지 않았습니다');
+3 -1
View File
@@ -29,7 +29,7 @@ class che_NPC능동 extends Command\GeneralCommand{
if(!key_exists('destCityID', $this->arg)){ if(!key_exists('destCityID', $this->arg)){
return false; return false;
} }
if(!key_exists($this->arg['destCityID'], CityConst::all())){ if(CityConst::byID($this->arg['destCityID']) === null){
return false; return false;
} }
$this->arg = [ $this->arg = [
@@ -45,6 +45,8 @@ class che_NPC능동 extends Command\GeneralCommand{
protected function init(){ protected function init(){
$general = $this->generalObj; $general = $this->generalObj;
$this->setNation();
$this->runnableConstraints=[ $this->runnableConstraints=[
ConstraintHelper::MustBeNPC() ConstraintHelper::MustBeNPC()
+1 -1
View File
@@ -113,7 +113,7 @@ class che_강행 extends Command\GeneralCommand{
if($generalList){ if($generalList){
$db->update('general', [ $db->update('general', [
'city'=>$destCityID 'city'=>$destCityID
], 'no IN %li', $generalList); ], 'no IN %li and nation=%i', $generalList, $general->getNationID());
} }
foreach($generalList as $targetGeneralID){ foreach($generalList as $targetGeneralID){
$targetGeneral = General::createGeneralObjFromDB($targetGeneralID, [], 1); $targetGeneral = General::createGeneralObjFromDB($targetGeneralID, [], 1);
+1 -1
View File
@@ -96,7 +96,7 @@ class che_거병 extends Command\GeneralCommand{
'bill'=>100, 'bill'=>100,
'strategic_cmd_limit'=>12, 'strategic_cmd_limit'=>12,
'surlimit'=>72, 'surlimit'=>72,
'type'=>0, 'type'=>GameConst::$neutralNationType,
'gennum'=>1 'gennum'=>1
]); ]);
$nationID = DB::db()->insertId(); $nationID = DB::db()->insertId();
+10 -10
View File
@@ -34,13 +34,13 @@ class che_건국 extends Command\GeneralCommand{
} }
$nationName = $this->arg['nationName']??null; $nationName = $this->arg['nationName']??null;
$nationType = $this->arg['nationType']??null; $nationType = $this->arg['nationType']??null;
$colorType = $this->arg['colorType']??null; $nationColor = $this->arg['nationColor']??null;
if($nationName === null || $nationType === null || $colorType === null){ if($nationName === null || $nationType === null || $nationColor === null){
return false; return false;
} }
if(!is_string($nationName) || !is_string($nationType) || !is_int($colorType)){ if(!is_string($nationName) || !is_string($nationType) || !is_int($nationColor)){
return false; return false;
} }
@@ -48,7 +48,7 @@ class che_건국 extends Command\GeneralCommand{
return false; return false;
} }
if(!key_exists($colorType, GetNationColors())){ if(!key_exists($nationColor, GetNationColors())){
return false; return false;
} }
@@ -62,7 +62,7 @@ class che_건국 extends Command\GeneralCommand{
$this->arg = [ $this->arg = [
'nationName'=>$nationName, 'nationName'=>$nationName,
'nationType'=>$nationType, 'nationType'=>$nationType,
'colorType'=>$colorType 'nationColor'=>$nationColor
]; ];
return true; return true;
@@ -75,10 +75,10 @@ class che_건국 extends Command\GeneralCommand{
$nationName = $this->arg['nationName']; $nationName = $this->arg['nationName'];
$nationType = $this->arg['nationType']; $nationType = $this->arg['nationType'];
$colorType = $this->arg['colorType']; $nationColor = $this->arg['nationColor'];
$this->setCity(); $this->setCity();
$this->setNation(); $this->setNation(['gennum']);
$relYear = $env['year'] - $env['startyear']; $relYear = $env['year'] - $env['startyear'];
@@ -120,7 +120,7 @@ class che_건국 extends Command\GeneralCommand{
$nationName = $this->arg['nationName']; $nationName = $this->arg['nationName'];
$nationType = $this->arg['nationType']; $nationType = $this->arg['nationType'];
$nationColor = GetNationColors()[$this->arg['colorType']]; $nationColor = GetNationColors()[$this->arg['nationColor']];
$cityName = $this->city['name']; $cityName = $this->city['name'];
@@ -152,10 +152,10 @@ class che_건국 extends Command\GeneralCommand{
$db->update('city', [ $db->update('city', [
'nation'=>$general->getNationID(), 'nation'=>$general->getNationID(),
'conflict'=>'{}' 'conflict'=>'{}'
], $general->getCityID()); ], 'city=%i', $general->getCityID());
$db->update('nation', [ $db->update('nation', [
'nation'=>$nationName, 'name'=>$nationName,
'color'=>$nationColor, 'color'=>$nationColor,
'level'=>1, 'level'=>1,
'type'=>$nationType, 'type'=>$nationType,
@@ -6,7 +6,7 @@ use \sammo\{
General, General,
ActionLogger, ActionLogger,
LastTurn, LastTurn,
Command Command, GameConst
}; };
use function sammo\{ use function sammo\{
@@ -201,15 +201,20 @@ class che_랜덤임관 extends Command\GeneralCommand{
$destNation = Util::choiceRandomUsingWeightPair($randVals); $destNation = Util::choiceRandomUsingWeightPair($randVals);
} }
$logger = $general->getLogger();
if(!$destNation){ if(!$destNation){
throw new MustNotBeReachedException(); //임관 가능한 국가가 없다!
$logger->pushGeneralActionLog("임관 가능한 국가가 없습니다. <1>$date</>");
$this->alternative = new che_요양($general, $this->env, null);
return false;
} }
$gennum = $destNation['gennum']; $gennum = $destNation['gennum'];
$destNationID = $destNation['nation']; $destNationID = $destNation['nation'];
$destNationName = $destNation['name']; $destNationName = $destNation['name'];
$logger = $general->getLogger();
$talkList = [ $talkList = [
'어쩌다 보니', '어쩌다 보니',
@@ -81,8 +81,8 @@ class che_인재탐색 extends Command\GeneralCommand{
$nationID = $general->getNationID(); $nationID = $general->getNationID();
$genCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc < 2', $nationID); $genCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc < 2', $nationID);
$npcCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc == 3', $nationID); $npcCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc = 3', $nationID);
$npcOtherCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation!=%i AND npc == 32', $nationID); $npcOtherCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation!=%i AND npc = 3', $nationID);
$genCount = Util::valueFit($genCount, 1); $genCount = Util::valueFit($genCount, 1);
@@ -84,7 +84,7 @@ class che_주민선정 extends Command\GeneralCommand{
$score *= getDomesticExpLevelBonus($general->getVar('explevel')); $score *= getDomesticExpLevelBonus($general->getVar('explevel'));
$score *= Util::randRange(0.8, 1.2); $score *= Util::randRange(0.8, 1.2);
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score); $score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
$score = Util::valutFit($score, 1); $score = Util::valueFit($score, 1);
return $score; return $score;
} }
+2
View File
@@ -92,6 +92,8 @@ class che_해산 extends Command\GeneralCommand{
refreshNationStaticInfo(); refreshNationStaticInfo();
$logger = $general->getLogger();
$logger->pushGeneralActionLog("세력을 해산했습니다. <1>$date</>"); $logger->pushGeneralActionLog("세력을 해산했습니다. <1>$date</>");
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} 세력을 해산했습니다."); $logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} 세력을 해산했습니다.");
+1 -2
View File
@@ -15,8 +15,7 @@ class 휴식 extends Command\GeneralCommand{
} }
protected function init(){ protected function init(){
$this->runnableConstraints=[ $this->runnableConstraints=[];
];
} }
public function getCost():array{ public function getCost():array{
+1 -1
View File
@@ -33,7 +33,7 @@ class che_발령 extends Command\NationCommand{
if(!key_exists('destCityID', $this->arg)){ if(!key_exists('destCityID', $this->arg)){
return false; return false;
} }
if(!key_exists($this->arg['destCityID'], CityConst::all())){ if(CityConst::byID($this->arg['destCityID']) === null){
return false; return false;
} }
$destGeneralID = $this->arg['destGeneralID']; $destGeneralID = $this->arg['destGeneralID'];
@@ -8,13 +8,15 @@ use \sammo\{
GameConst, GameConst,
LastTurn, LastTurn,
GameUnitConst, GameUnitConst,
Command Command,
Message, MessageTarget
}; };
use function \sammo\{ use function \sammo\{
getDomesticExpLevelBonus, getDomesticExpLevelBonus,
CriticalRatioDomestic, CriticalRatioDomestic,
CriticalScoreEx CriticalScoreEx,
GetImageURL
}; };
use \sammo\Constraint\Constraint; use \sammo\Constraint\Constraint;
+3 -1
View File
@@ -15,6 +15,8 @@ class 휴식 extends Command\NationCommand{
protected function init(){ protected function init(){
//아무것도 하지 않음 //아무것도 하지 않음
$this->runnableConstraints=[];
} }
public function getPreReqTurn():int{ public function getPreReqTurn():int{
@@ -24,7 +26,7 @@ class 휴식 extends Command\NationCommand{
public function getPostReqTurn():int{ public function getPostReqTurn():int{
return 0; return 0;
} }
public function getCost():array{ public function getCost():array{
return [0, 0]; return [0, 0];
} }
+1 -1
View File
@@ -45,7 +45,7 @@ class AllowJoinDestNation extends Constraint{
return false; return false;
} }
if($this->destNation['scout'] == 0){ if($this->destNation['scout'] == 1){
$this->reason = "임관이 금지되어 있습니다."; $this->reason = "임관이 금지되어 있습니다.";
return false; return false;
} }
@@ -4,6 +4,8 @@ namespace sammo\Constraint;
use \sammo\GameUnitConst; use \sammo\GameUnitConst;
use \sammo\DB; use \sammo\DB;
use \sammo\KVStorage;
use \sammo\CityConst;
class AvailableRecruitCrewType extends Constraint{ class AvailableRecruitCrewType extends Constraint{
const REQ_VALUES = Constraint::REQ_NATION|Constraint::REQ_INT_ARG; const REQ_VALUES = Constraint::REQ_NATION|Constraint::REQ_INT_ARG;
+1 -1
View File
@@ -22,7 +22,7 @@ class BeLord extends Constraint{
$this->checkInputValues(); $this->checkInputValues();
$this->tested = true; $this->tested = true;
if($this->general['level'] != 12){ if($this->general['level'] == 12){
return true; return true;
} }
-2
View File
@@ -193,9 +193,7 @@ abstract class Constraint{
/** @var \sammo\Constraint\Constraint $contraint */ /** @var \sammo\Constraint\Constraint $contraint */
$constraint = call_user_func($method,$input); $constraint = call_user_func($method,$input);
assert($constraint !== null);
assert($constraint instanceof Constraint); assert($constraint instanceof Constraint);
assert(count($constraintArgs) < 3);
if(count($constraintArgs) == 2){ if(count($constraintArgs) == 2){
$arg = $constraintArgs[1]; $arg = $constraintArgs[1];
+1 -1
View File
@@ -4,7 +4,7 @@ namespace sammo\Constraint;
use \sammo\JosaUtil; use \sammo\JosaUtil;
class RemainCityTrust extends Constraint{ class ReqCityTrust extends Constraint{
const REQ_VALUES = Constraint::REQ_CITY|Constraint::REQ_NUMERIC_ARG; const REQ_VALUES = Constraint::REQ_CITY|Constraint::REQ_NUMERIC_ARG;
protected $key; protected $key;
+1 -1
View File
@@ -22,7 +22,7 @@ class ReqGeneralGold extends Constraint{
$this->checkInputValues(); $this->checkInputValues();
$this->tested = true; $this->tested = true;
if($this->general['gold'] < $this->arg){ if($this->general['gold'] >= $this->arg){
return true; return true;
} }
+1 -1
View File
@@ -22,7 +22,7 @@ class ReqGeneralRice extends Constraint{
$this->checkInputValues(); $this->checkInputValues();
$this->tested = true; $this->tested = true;
if($this->general['rice'] < $this->arg){ if($this->general['rice'] >= $this->arg){
return true; return true;
} }
+1 -1
View File
@@ -22,7 +22,7 @@ class ReqNationGold extends Constraint{
$this->checkInputValues(); $this->checkInputValues();
$this->tested = true; $this->tested = true;
if($this->nation['gold'] < $this->arg){ if($this->nation['gold'] >= $this->arg){
return true; return true;
} }
+1 -1
View File
@@ -22,7 +22,7 @@ class ReqNationRice extends Constraint{
$this->checkInputValues(); $this->checkInputValues();
$this->tested = true; $this->tested = true;
if($this->nation['rice'] < $this->arg){ if($this->nation['rice'] >= $this->arg){
return true; return true;
} }
-2
View File
@@ -1,7 +1,6 @@
<?php <?php
namespace sammo; namespace sammo;
class DummyGeneral extends General{ class DummyGeneral extends General{
public function __construct(bool $initLogger=true){ public function __construct(bool $initLogger=true){
$raw = [ $raw = [
@@ -12,7 +11,6 @@ class DummyGeneral extends General{
'level'=>0, 'level'=>0,
]; ];
$staticNation = getNationStaticInfo($raw['nation']);
$this->raw = $raw; $this->raw = $raw;
$this->resultTurn = new LastTurn(); $this->resultTurn = new LastTurn();
+21 -9
View File
@@ -492,6 +492,10 @@ class GeneralAI{
return [$command, $arg]; return [$command, $arg];
} }
if($this->nation['level'] == 0){
return ['휴식', null];
}
if($generalObj->getVar('level') == 12 && $this->dipState == self::d평화 && !$this->attackable){ if($generalObj->getVar('level') == 12 && $this->dipState == self::d평화 && !$this->attackable){
$targetNationID = $this->findWarTarget(); $targetNationID = $this->findWarTarget();
if($targetNationID !== null){ if($targetNationID !== null){
@@ -537,6 +541,8 @@ class GeneralAI{
shuffle($frontCitiesID); shuffle($frontCitiesID);
shuffle($supplyCitiesID); shuffle($supplyCitiesID);
assert($supplyCitiesID);
$commandList = []; $commandList = [];
@@ -1281,10 +1287,13 @@ class GeneralAI{
$moveCities[$moveCityID] = $score; $moveCities[$moveCityID] = $score;
} }
return ['che_NPC능동', [ if($moveCities){
'optionText'=>'순간이동', return ['che_NPC능동', [
'destCityID'=>Util::choiceRandomUsingWeight($moveCities), 'optionText'=>'순간이동',
]]; 'destCityID'=>Util::choiceRandomUsingWeight($moveCities),
]];
}
} }
return $developTurn; return $developTurn;
@@ -1432,10 +1441,13 @@ class GeneralAI{
} }
} }
return ['che_NPC능동', [ if($attackableCities){
'optionText'=>'순간이동', return ['che_NPC능동', [
'destCityID'=>Util::choiceRandomUsingWeight($attackableCities), 'optionText'=>'순간이동',
]]; 'destCityID'=>Util::choiceRandomUsingWeight($attackableCities),
]];
}
} }
if($general->getVar('train') < 90){ if($general->getVar('train') < 90){
@@ -1509,7 +1521,7 @@ class GeneralAI{
} }
if($city['nation'] == 0 && ($city['level'] == 5 || $city['level'] == 6)) { if($city['nation'] == 0 && ($city['level'] == 5 || $city['level'] == 6)) {
$nationType = Util::choiceRandom(array_keys(getNationTypeList())); $nationType = Util::choiceRandom(GameConst::$availableNationType);
$nationColor = Util::choiceRandom(array_keys(GetNationColors())); $nationColor = Util::choiceRandom(array_keys(GetNationColors()));
return ['che_건국', [ return ['che_건국', [
'nationName'=>"".mb_substr($general->getName(), 1), 'nationName'=>"".mb_substr($general->getName(), 1),
+1
View File
@@ -152,6 +152,7 @@ class NPC{
$this->dex20 = $cavalry; $this->dex20 = $cavalry;
$this->dex30 = $wizard; $this->dex30 = $wizard;
$this->dex40 = $siege; $this->dex40 = $siege;
return $this;
} }
public function build($env=[]){ public function build($env=[]){