From c4fe77a5ba098d74dbd537a74f3528da034c32a1 Mon Sep 17 00:00:00 2001 From: hide_d Date: Wed, 22 Apr 2020 03:05:05 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Command/BaseCommand.php | 7 +--- hwe/sammo/Constraint/AllowJoinDestNation.php | 7 +--- hwe/sammo/GeneralAI.php | 44 ++++++++++++++++---- hwe/sammo/LazyVarUpdater.php | 2 +- 4 files changed, 39 insertions(+), 21 deletions(-) diff --git a/hwe/sammo/Command/BaseCommand.php b/hwe/sammo/Command/BaseCommand.php index d74cba25..1eab7808 100644 --- a/hwe/sammo/Command/BaseCommand.php +++ b/hwe/sammo/Command/BaseCommand.php @@ -258,11 +258,6 @@ abstract class BaseCommand{ } public function testReservable():?string{ - if(!$this->isArgValid()){ - $this->reasonNotReservable = '인자가 올바르지 않습니다.'; - $this->reservable = false; - return $this->reasonNotReservable; - } if($this->reservableConstraints === null){ return null; } @@ -271,6 +266,7 @@ abstract class BaseCommand{ return $this->reasonNotReservable; } + $this->generalObj->unpackAux(); $constraintInput = [ 'general'=>$this->generalObj->getRaw(), 'city'=>$this->city, @@ -305,6 +301,7 @@ abstract class BaseCommand{ return $this->reasonNotRunnable; } + $this->generalObj->unpackAux(); $constraintInput = [ 'general'=>$this->generalObj->getRaw(), 'city'=>$this->city, diff --git a/hwe/sammo/Constraint/AllowJoinDestNation.php b/hwe/sammo/Constraint/AllowJoinDestNation.php index 28d21de9..d0b0dcdb 100644 --- a/hwe/sammo/Constraint/AllowJoinDestNation.php +++ b/hwe/sammo/Constraint/AllowJoinDestNation.php @@ -19,11 +19,6 @@ class AllowJoinDestNation extends Constraint{ throw new \InvalidArgumentException("require auxVar in general"); } - if(!key_exists('joinedNations', $this->general['auxVar'])){ - if(!$throwExeception){return false; } - throw new \InvalidArgumentException("require joinedNations in general['auxVar']"); - } - if(!key_exists('scout', $this->destNation)){ if(!$throwExeception){return false; } throw new \InvalidArgumentException("require scout in nation"); @@ -55,7 +50,7 @@ class AllowJoinDestNation extends Constraint{ return false; } - $joinedNations = $this->general['auxVar']['joinedNations']; + $joinedNations = $this->general['auxVar']['joinedNations']??[]; if(in_array($this->destNation['nation'], $joinedNations)){ $this->reason = "이미 임관했었던 국가입니다."; return false; diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php index 2fa67e57..bff4fd7f 100644 --- a/hwe/sammo/GeneralAI.php +++ b/hwe/sammo/GeneralAI.php @@ -130,6 +130,7 @@ class GeneralAI $this->genType = $this->calcGenType($general); $this->calcDiplomacyState(); + LogText('전쟁상태', "{$this->general->getName()} {$this->nation['name']} {$this->dipState}"); } public function getGeneralObj(): General @@ -190,13 +191,15 @@ class GeneralAI $nationID ); - $onWar = false; + $onWar = 0; + $onWarReady = 0; $warTargetNation = []; foreach ($warTarget as [$warNationID, $warState]) { if ($warState == 0) { - $onWar = true; + $onWar += 1; $warTargetNation[$warNationID] = 2; } else { + $onWarReady += 1; $warTargetNation[$warNationID] = 1; } } @@ -221,10 +224,8 @@ class GeneralAI if ($this->attackable) { //전쟁으로 인한 attackable인가? - if ($onWar) { + if ($onWar || !$onWarReady) { $this->dipState = self::d전쟁; - } else { - $this->dipState = self::d징병; } } } @@ -1108,6 +1109,13 @@ class GeneralAI return null; } + if($this->nation['gold'] < $this->nationPolicy->reqNationGold){ + return null; + } + if($this->nation['rice'] < $this->nationPolicy->reqNationRice){ + return null; + } + $nation = $this->nation; $candidateArgs = []; $remainResource = [ @@ -1202,6 +1210,13 @@ class GeneralAI return null; } + if($this->nation['gold'] < $this->nationPolicy->reqNationGold){ + return null; + } + if($this->nation['rice'] < $this->nationPolicy->reqNationRice){ + return null; + } + $nation = $this->nation; $candidateArgs = []; @@ -1281,6 +1296,13 @@ class GeneralAI return null; } + if($this->nation['gold'] < $this->nationPolicy->reqNationGold){ + return null; + } + if($this->nation['rice'] < $this->nationPolicy->reqNationRice){ + return null; + } + $nation = $this->nation; $candidateArgs = []; @@ -2172,7 +2194,7 @@ class GeneralAI } } - if($train < $this->nationPolicy->properWarTrainAtmos){ + if($atmos < $this->nationPolicy->properWarTrainAtmos){ $cmd = buildGeneralCommandClass('che_사기진작', $general, $this->env); if($cmd->isRunnable()){ $cmdList[] = [$cmd, GameConst::$maxAtmosByCommand / Util::valueFit($atmos, 1)]; @@ -2213,6 +2235,10 @@ class GeneralAI return null; } + if($this->dipState !== self::d전쟁){ + return null; + } + $general = $this->getGeneralObj(); $city = $this->city; $nation = $this->nation; @@ -2233,13 +2259,13 @@ class GeneralAI return null; } - if ($city['front'] === 1 && $this->dipState === self::d전쟁) { + if ($city['front'] === 1) { return null; } $attackableNations = []; foreach ($this->warTargetNation as $targetNationID => $state) { - if ($this->dipState === self::d전쟁 && $state == 1) { + if ($state == 1) { continue; } $attackableNations[] = $targetNationID; @@ -2247,7 +2273,7 @@ class GeneralAI $nearCities = array_keys(CityConst::byID($cityID)->path); $attackableCities = $db->queryFirstColumn( - 'SELECT city FROM city WHERE nation IN %li AND city IN %li', + 'SELECT city, nation FROM city WHERE nation IN %li AND city IN %li', $attackableNations, $nearCities ); diff --git a/hwe/sammo/LazyVarUpdater.php b/hwe/sammo/LazyVarUpdater.php index ba65aa41..e89b7c40 100644 --- a/hwe/sammo/LazyVarUpdater.php +++ b/hwe/sammo/LazyVarUpdater.php @@ -31,7 +31,7 @@ trait LazyVarUpdater{ return true; } - protected function unpackAux(){ + function unpackAux(){ if($this->raw['auxVar']??null === null){ if(!key_exists('aux', $this->raw)){ throw new \RuntimeException('aux is not set');