diff --git a/hwe/func.php b/hwe/func.php index 062ff7c8..d92ad463 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1929,8 +1929,8 @@ function deleteNation(General $general) { $josaUn = JosaUtil::pick($nationName, '은'); $logger->pushGlobalHistoryLog("【멸망】{$nationName}{$josaUn} 멸망했습니다."); - $oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $general['nation']); - $oldNationGenerals = $db->queryFirstColumn('SELECT `no` FROM general 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', $nationID); $oldNation['generals'] = $oldNationGenerals; $oldNation['aux'] = Json::decode($oldNation['aux']); @@ -1963,7 +1963,7 @@ function deleteNation(General $general) { $db->insert('ng_old_nations', [ 'server_id'=>UniqueConst::$serverID, - 'nation'=>$general['nation'], + 'nation'=>$nationID, 'data'=>Json::encode($oldNation) ]); $db->delete('nation', 'nation=%i', $nationID); diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index e660ad34..f7db7dfa 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -1075,7 +1075,7 @@ function updateNationState() { refreshNationStaticInfo(); } - $assemblerCnt = $assemblerCnt[$nation['nation']]??0; + $assemblerCnt = $assemblerCnts[$nation['nation']]??0; $maxAssemblerCnt = [ 1=>0, 2=>1, @@ -1105,6 +1105,9 @@ function updateNationState() { 'no'=>$npcID ]); $troopID = $db->insertId(); + $db->update('general', [ + 'troop'=>$troopID + ], 'no=%i', $npcID); //TODO: 5턴간 집합턴 입력 $assemblerCnt += 1; diff --git a/hwe/func_process.php b/hwe/func_process.php index bc354339..4a955f1a 100644 --- a/hwe/func_process.php +++ b/hwe/func_process.php @@ -123,7 +123,7 @@ function getGeneralIntel($general, $withInjury, $withItem, $withStatAdjust, $use * * @return array 계산된 실패, 성공 확률 ('success' => 성공 확률, 'fail' => 실패 확률) */ -function CriticalRatioDomestic(&$general, $type) { +function CriticalRatioDomestic($general, $type) { $leader = getGeneralLeadership($general, false, true, true, false); $power = getGeneralPower($general, false, true, true, false); $intel = getGeneralIntel($general, false, true, true, false); diff --git a/hwe/sammo/Command/BaseCommand.php b/hwe/sammo/Command/BaseCommand.php index 9ae0b1e5..0207096f 100644 --- a/hwe/sammo/Command/BaseCommand.php +++ b/hwe/sammo/Command/BaseCommand.php @@ -7,6 +7,8 @@ use \sammo\{ ActionLogger }; +use function \sammo\getNationStaticInfo; + use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; @@ -261,7 +263,7 @@ abstract class BaseCommand{ public function testRunnable():?string{ if(!$this->isArgValid()){ - throw new \InvalidArgumentException('인자가 제대로 설정되지 않았습니다'); + throw new \InvalidArgumentException('인자가 제대로 설정되지 않았습니다'.\sammo\Json::encode($this->arg)); } if($this->runnableConstraints === null){ throw new \InvalidArgumentException('runnableConstraits가 제대로 설정되지 않았습니다'); diff --git a/hwe/sammo/Command/General/che_NPC능동.php b/hwe/sammo/Command/General/che_NPC능동.php index 831f18c2..79a623c4 100644 --- a/hwe/sammo/Command/General/che_NPC능동.php +++ b/hwe/sammo/Command/General/che_NPC능동.php @@ -29,7 +29,7 @@ class che_NPC능동 extends Command\GeneralCommand{ if(!key_exists('destCityID', $this->arg)){ return false; } - if(!key_exists($this->arg['destCityID'], CityConst::all())){ + if(CityConst::byID($this->arg['destCityID']) === null){ return false; } $this->arg = [ @@ -45,6 +45,8 @@ class che_NPC능동 extends Command\GeneralCommand{ protected function init(){ $general = $this->generalObj; + $this->setNation(); + $this->runnableConstraints=[ ConstraintHelper::MustBeNPC() diff --git a/hwe/sammo/Command/General/che_강행.php b/hwe/sammo/Command/General/che_강행.php index 031c3aea..3739a416 100644 --- a/hwe/sammo/Command/General/che_강행.php +++ b/hwe/sammo/Command/General/che_강행.php @@ -113,7 +113,7 @@ class che_강행 extends Command\GeneralCommand{ if($generalList){ $db->update('general', [ 'city'=>$destCityID - ], 'no IN %li', $generalList); + ], 'no IN %li and nation=%i', $generalList, $general->getNationID()); } foreach($generalList as $targetGeneralID){ $targetGeneral = General::createGeneralObjFromDB($targetGeneralID, [], 1); diff --git a/hwe/sammo/Command/General/che_거병.php b/hwe/sammo/Command/General/che_거병.php index d119ca68..214cd827 100644 --- a/hwe/sammo/Command/General/che_거병.php +++ b/hwe/sammo/Command/General/che_거병.php @@ -96,7 +96,7 @@ class che_거병 extends Command\GeneralCommand{ 'bill'=>100, 'strategic_cmd_limit'=>12, 'surlimit'=>72, - 'type'=>0, + 'type'=>GameConst::$neutralNationType, 'gennum'=>1 ]); $nationID = DB::db()->insertId(); diff --git a/hwe/sammo/Command/General/che_건국.php b/hwe/sammo/Command/General/che_건국.php index 85a441f4..aff1bbea 100644 --- a/hwe/sammo/Command/General/che_건국.php +++ b/hwe/sammo/Command/General/che_건국.php @@ -34,13 +34,13 @@ class che_건국 extends Command\GeneralCommand{ } $nationName = $this->arg['nationName']??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; } - if(!is_string($nationName) || !is_string($nationType) || !is_int($colorType)){ + if(!is_string($nationName) || !is_string($nationType) || !is_int($nationColor)){ return false; } @@ -48,7 +48,7 @@ class che_건국 extends Command\GeneralCommand{ return false; } - if(!key_exists($colorType, GetNationColors())){ + if(!key_exists($nationColor, GetNationColors())){ return false; } @@ -62,7 +62,7 @@ class che_건국 extends Command\GeneralCommand{ $this->arg = [ 'nationName'=>$nationName, 'nationType'=>$nationType, - 'colorType'=>$colorType + 'nationColor'=>$nationColor ]; return true; @@ -75,10 +75,10 @@ class che_건국 extends Command\GeneralCommand{ $nationName = $this->arg['nationName']; $nationType = $this->arg['nationType']; - $colorType = $this->arg['colorType']; + $nationColor = $this->arg['nationColor']; $this->setCity(); - $this->setNation(); + $this->setNation(['gennum']); $relYear = $env['year'] - $env['startyear']; @@ -120,7 +120,7 @@ class che_건국 extends Command\GeneralCommand{ $nationName = $this->arg['nationName']; $nationType = $this->arg['nationType']; - $nationColor = GetNationColors()[$this->arg['colorType']]; + $nationColor = GetNationColors()[$this->arg['nationColor']]; $cityName = $this->city['name']; @@ -152,10 +152,10 @@ class che_건국 extends Command\GeneralCommand{ $db->update('city', [ 'nation'=>$general->getNationID(), 'conflict'=>'{}' - ], $general->getCityID()); + ], 'city=%i', $general->getCityID()); $db->update('nation', [ - 'nation'=>$nationName, + 'name'=>$nationName, 'color'=>$nationColor, 'level'=>1, 'type'=>$nationType, diff --git a/hwe/sammo/Command/General/che_기술연구.php b/hwe/sammo/Command/General/che_기술연구.php index a13e927e..be602de2 100644 --- a/hwe/sammo/Command/General/che_기술연구.php +++ b/hwe/sammo/Command/General/che_기술연구.php @@ -6,7 +6,7 @@ use \sammo\{ General, ActionLogger, LastTurn, - Command + Command, GameConst }; use function sammo\{ diff --git a/hwe/sammo/Command/General/che_랜덤임관.php b/hwe/sammo/Command/General/che_랜덤임관.php index 6ae4a011..c8f52c7e 100644 --- a/hwe/sammo/Command/General/che_랜덤임관.php +++ b/hwe/sammo/Command/General/che_랜덤임관.php @@ -201,15 +201,20 @@ class che_랜덤임관 extends Command\GeneralCommand{ $destNation = Util::choiceRandomUsingWeightPair($randVals); } + $logger = $general->getLogger(); + if(!$destNation){ - throw new MustNotBeReachedException(); + //임관 가능한 국가가 없다! + $logger->pushGeneralActionLog("임관 가능한 국가가 없습니다. <1>$date"); + $this->alternative = new che_요양($general, $this->env, null); + return false; } $gennum = $destNation['gennum']; $destNationID = $destNation['nation']; $destNationName = $destNation['name']; - $logger = $general->getLogger(); + $talkList = [ '어쩌다 보니', diff --git a/hwe/sammo/Command/General/che_인재탐색.php b/hwe/sammo/Command/General/che_인재탐색.php index a0a7b0c4..81d3929b 100644 --- a/hwe/sammo/Command/General/che_인재탐색.php +++ b/hwe/sammo/Command/General/che_인재탐색.php @@ -81,8 +81,8 @@ class che_인재탐색 extends Command\GeneralCommand{ $nationID = $general->getNationID(); $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); - $npcOtherCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation!=%i AND npc == 32', $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 = 3', $nationID); $genCount = Util::valueFit($genCount, 1); diff --git a/hwe/sammo/Command/General/che_주민선정.php b/hwe/sammo/Command/General/che_주민선정.php index 64409a74..4f569734 100644 --- a/hwe/sammo/Command/General/che_주민선정.php +++ b/hwe/sammo/Command/General/che_주민선정.php @@ -84,7 +84,7 @@ class che_주민선정 extends Command\GeneralCommand{ $score *= getDomesticExpLevelBonus($general->getVar('explevel')); $score *= Util::randRange(0.8, 1.2); $score = $general->onCalcDomestic(static::$actionKey, 'score', $score); - $score = Util::valutFit($score, 1); + $score = Util::valueFit($score, 1); return $score; } diff --git a/hwe/sammo/Command/General/che_해산.php b/hwe/sammo/Command/General/che_해산.php index e27f959b..d154db72 100644 --- a/hwe/sammo/Command/General/che_해산.php +++ b/hwe/sammo/Command/General/che_해산.php @@ -92,6 +92,8 @@ class che_해산 extends Command\GeneralCommand{ refreshNationStaticInfo(); + $logger = $general->getLogger(); + $logger->pushGeneralActionLog("세력을 해산했습니다. <1>$date"); $logger->pushGlobalActionLog("{$generalName}{$josaYi} 세력을 해산했습니다."); diff --git a/hwe/sammo/Command/General/휴식.php b/hwe/sammo/Command/General/휴식.php index eaa586a6..68241f4c 100644 --- a/hwe/sammo/Command/General/휴식.php +++ b/hwe/sammo/Command/General/휴식.php @@ -15,8 +15,7 @@ class 휴식 extends Command\GeneralCommand{ } protected function init(){ - $this->runnableConstraints=[ - ]; + $this->runnableConstraints=[]; } public function getCost():array{ diff --git a/hwe/sammo/Command/Nation/che_발령.php b/hwe/sammo/Command/Nation/che_발령.php index 2ae08558..d2c8e599 100644 --- a/hwe/sammo/Command/Nation/che_발령.php +++ b/hwe/sammo/Command/Nation/che_발령.php @@ -33,7 +33,7 @@ class che_발령 extends Command\NationCommand{ if(!key_exists('destCityID', $this->arg)){ return false; } - if(!key_exists($this->arg['destCityID'], CityConst::all())){ + if(CityConst::byID($this->arg['destCityID']) === null){ return false; } $destGeneralID = $this->arg['destGeneralID']; diff --git a/hwe/sammo/Command/Nation/che_선전포고.php b/hwe/sammo/Command/Nation/che_선전포고.php index 1dd60120..6c490d7a 100644 --- a/hwe/sammo/Command/Nation/che_선전포고.php +++ b/hwe/sammo/Command/Nation/che_선전포고.php @@ -8,13 +8,15 @@ use \sammo\{ GameConst, LastTurn, GameUnitConst, - Command + Command, + Message, MessageTarget }; use function \sammo\{ getDomesticExpLevelBonus, CriticalRatioDomestic, - CriticalScoreEx + CriticalScoreEx, + GetImageURL }; use \sammo\Constraint\Constraint; diff --git a/hwe/sammo/Command/Nation/휴식.php b/hwe/sammo/Command/Nation/휴식.php index 5c81af4c..c125d4ab 100644 --- a/hwe/sammo/Command/Nation/휴식.php +++ b/hwe/sammo/Command/Nation/휴식.php @@ -15,6 +15,8 @@ class 휴식 extends Command\NationCommand{ protected function init(){ //아무것도 하지 않음 + $this->runnableConstraints=[]; + } public function getPreReqTurn():int{ @@ -24,7 +26,7 @@ class 휴식 extends Command\NationCommand{ public function getPostReqTurn():int{ return 0; } - + public function getCost():array{ return [0, 0]; } diff --git a/hwe/sammo/Constraint/AllowJoinDestNation.php b/hwe/sammo/Constraint/AllowJoinDestNation.php index e7420cd5..5efc2268 100644 --- a/hwe/sammo/Constraint/AllowJoinDestNation.php +++ b/hwe/sammo/Constraint/AllowJoinDestNation.php @@ -45,7 +45,7 @@ class AllowJoinDestNation extends Constraint{ return false; } - if($this->destNation['scout'] == 0){ + if($this->destNation['scout'] == 1){ $this->reason = "임관이 금지되어 있습니다."; return false; } diff --git a/hwe/sammo/Constraint/AvailableRecruitCrewType.php b/hwe/sammo/Constraint/AvailableRecruitCrewType.php index 2486d46b..b083a39a 100644 --- a/hwe/sammo/Constraint/AvailableRecruitCrewType.php +++ b/hwe/sammo/Constraint/AvailableRecruitCrewType.php @@ -4,6 +4,8 @@ namespace sammo\Constraint; use \sammo\GameUnitConst; use \sammo\DB; +use \sammo\KVStorage; +use \sammo\CityConst; class AvailableRecruitCrewType extends Constraint{ const REQ_VALUES = Constraint::REQ_NATION|Constraint::REQ_INT_ARG; diff --git a/hwe/sammo/Constraint/BeLord.php b/hwe/sammo/Constraint/BeLord.php index ba2756ae..8bee0b87 100644 --- a/hwe/sammo/Constraint/BeLord.php +++ b/hwe/sammo/Constraint/BeLord.php @@ -22,7 +22,7 @@ class BeLord extends Constraint{ $this->checkInputValues(); $this->tested = true; - if($this->general['level'] != 12){ + if($this->general['level'] == 12){ return true; } diff --git a/hwe/sammo/Constraint/Constraint.php b/hwe/sammo/Constraint/Constraint.php index 5ce12d7f..44e8280e 100644 --- a/hwe/sammo/Constraint/Constraint.php +++ b/hwe/sammo/Constraint/Constraint.php @@ -193,9 +193,7 @@ abstract class Constraint{ /** @var \sammo\Constraint\Constraint $contraint */ $constraint = call_user_func($method,$input); - assert($constraint !== null); assert($constraint instanceof Constraint); - assert(count($constraintArgs) < 3); if(count($constraintArgs) == 2){ $arg = $constraintArgs[1]; diff --git a/hwe/sammo/Constraint/ReqCityTrust.php b/hwe/sammo/Constraint/ReqCityTrust.php index a719d0dd..67f5a0b3 100644 --- a/hwe/sammo/Constraint/ReqCityTrust.php +++ b/hwe/sammo/Constraint/ReqCityTrust.php @@ -4,7 +4,7 @@ namespace sammo\Constraint; use \sammo\JosaUtil; -class RemainCityTrust extends Constraint{ +class ReqCityTrust extends Constraint{ const REQ_VALUES = Constraint::REQ_CITY|Constraint::REQ_NUMERIC_ARG; protected $key; diff --git a/hwe/sammo/Constraint/ReqGeneralGold.php b/hwe/sammo/Constraint/ReqGeneralGold.php index aa6fdff0..4d8450cb 100644 --- a/hwe/sammo/Constraint/ReqGeneralGold.php +++ b/hwe/sammo/Constraint/ReqGeneralGold.php @@ -22,7 +22,7 @@ class ReqGeneralGold extends Constraint{ $this->checkInputValues(); $this->tested = true; - if($this->general['gold'] < $this->arg){ + if($this->general['gold'] >= $this->arg){ return true; } diff --git a/hwe/sammo/Constraint/ReqGeneralRice.php b/hwe/sammo/Constraint/ReqGeneralRice.php index 9308cdb4..f6ef0fdc 100644 --- a/hwe/sammo/Constraint/ReqGeneralRice.php +++ b/hwe/sammo/Constraint/ReqGeneralRice.php @@ -22,7 +22,7 @@ class ReqGeneralRice extends Constraint{ $this->checkInputValues(); $this->tested = true; - if($this->general['rice'] < $this->arg){ + if($this->general['rice'] >= $this->arg){ return true; } diff --git a/hwe/sammo/Constraint/ReqNationalGold.php b/hwe/sammo/Constraint/ReqNationalGold.php index ed01d856..6bb6b875 100644 --- a/hwe/sammo/Constraint/ReqNationalGold.php +++ b/hwe/sammo/Constraint/ReqNationalGold.php @@ -22,7 +22,7 @@ class ReqNationGold extends Constraint{ $this->checkInputValues(); $this->tested = true; - if($this->nation['gold'] < $this->arg){ + if($this->nation['gold'] >= $this->arg){ return true; } diff --git a/hwe/sammo/Constraint/ReqNationalRice.php b/hwe/sammo/Constraint/ReqNationalRice.php index 449529f3..43b1c73a 100644 --- a/hwe/sammo/Constraint/ReqNationalRice.php +++ b/hwe/sammo/Constraint/ReqNationalRice.php @@ -22,7 +22,7 @@ class ReqNationRice extends Constraint{ $this->checkInputValues(); $this->tested = true; - if($this->nation['rice'] < $this->arg){ + if($this->nation['rice'] >= $this->arg){ return true; } diff --git a/hwe/sammo/DummyGeneral.php b/hwe/sammo/DummyGeneral.php index b962eaa1..5489176b 100644 --- a/hwe/sammo/DummyGeneral.php +++ b/hwe/sammo/DummyGeneral.php @@ -1,7 +1,6 @@ 0, ]; - $staticNation = getNationStaticInfo($raw['nation']); $this->raw = $raw; $this->resultTurn = new LastTurn(); diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php index e7bbf4b9..f5665084 100644 --- a/hwe/sammo/GeneralAI.php +++ b/hwe/sammo/GeneralAI.php @@ -492,6 +492,10 @@ class GeneralAI{ return [$command, $arg]; } + if($this->nation['level'] == 0){ + return ['휴식', null]; + } + if($generalObj->getVar('level') == 12 && $this->dipState == self::d평화 && !$this->attackable){ $targetNationID = $this->findWarTarget(); if($targetNationID !== null){ @@ -537,6 +541,8 @@ class GeneralAI{ shuffle($frontCitiesID); shuffle($supplyCitiesID); + assert($supplyCitiesID); + $commandList = []; @@ -1281,10 +1287,13 @@ class GeneralAI{ $moveCities[$moveCityID] = $score; } - return ['che_NPC능동', [ - 'optionText'=>'순간이동', - 'destCityID'=>Util::choiceRandomUsingWeight($moveCities), - ]]; + if($moveCities){ + return ['che_NPC능동', [ + 'optionText'=>'순간이동', + 'destCityID'=>Util::choiceRandomUsingWeight($moveCities), + ]]; + } + } return $developTurn; @@ -1432,10 +1441,13 @@ class GeneralAI{ } } - return ['che_NPC능동', [ - 'optionText'=>'순간이동', - 'destCityID'=>Util::choiceRandomUsingWeight($attackableCities), - ]]; + if($attackableCities){ + return ['che_NPC능동', [ + 'optionText'=>'순간이동', + 'destCityID'=>Util::choiceRandomUsingWeight($attackableCities), + ]]; + } + } if($general->getVar('train') < 90){ @@ -1509,7 +1521,7 @@ class GeneralAI{ } 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())); return ['che_건국', [ 'nationName'=>"㉿".mb_substr($general->getName(), 1), diff --git a/hwe/sammo/Scenario/NPC.php b/hwe/sammo/Scenario/NPC.php index e1622a63..3b7d8a0c 100644 --- a/hwe/sammo/Scenario/NPC.php +++ b/hwe/sammo/Scenario/NPC.php @@ -152,6 +152,7 @@ class NPC{ $this->dex20 = $cavalry; $this->dex30 = $wizard; $this->dex40 = $siege; + return $this; } public function build($env=[]){