diff --git a/hwe/sammo/Command/BaseCommand.php b/hwe/sammo/Command/BaseCommand.php index f6093005..19090ff8 100644 --- a/hwe/sammo/Command/BaseCommand.php +++ b/hwe/sammo/Command/BaseCommand.php @@ -145,14 +145,14 @@ abstract class BaseCommand{ $db = DB::db(); - $destNation = $db->queryFirstRow('SELECT %l FROM nation WHERE nation=%i', Util::formatListOfBackticks($args), $nationID); - if($destNation === null){ - $destNation = []; + $nation = $db->queryFirstRow('SELECT %l FROM nation WHERE nation=%i', Util::formatListOfBackticks($args), $nationID); + if($nation === null){ + $nation = []; foreach($args as $arg){ - $destNation[$arg] = $defaultValues[$arg]; + $nation[$arg] = $defaultValues[$arg]; } } - $this->destNation = $destNation; + $this->nation = $nation; } protected function setDestGeneral(General $destGeneralObj){ @@ -246,7 +246,7 @@ abstract class BaseCommand{ 'general'=>$this->generalObj->getRaw(), 'city'=>$this->city, 'nation'=>$this->nation, - 'arg'=>$this->arg, + 'cmd_arg'=>$this->arg, 'destGeneral'=>$this->destGeneralObj->getRaw(), 'destCity'=>$this->destCity, @@ -282,7 +282,7 @@ abstract class BaseCommand{ 'general'=>$this->generalObj->getRaw(), 'city'=>$this->city, 'nation'=>$this->nation, - 'arg'=>$this->arg, + 'cmd_arg'=>$this->arg, 'destGeneral'=>$this->destGeneralObj?$this->destGeneralObj->getRaw():null, 'destCity'=>$this->destCity, diff --git a/hwe/sammo/Command/General/che_인재탐색.php b/hwe/sammo/Command/General/che_인재탐색.php index 3d219a5c..a0a7b0c4 100644 --- a/hwe/sammo/Command/General/che_인재탐색.php +++ b/hwe/sammo/Command/General/che_인재탐색.php @@ -191,6 +191,8 @@ class che_인재탐색 extends Command\GeneralCommand{ $isOurNation = $this->nation['scout'] == 0; + $age = $env['year'] - 20; + $newNPC = new \sammo\Scenario\NPC( Util::randRangeInt(1, 150), \sammo\getRandGenName(), @@ -201,7 +203,7 @@ class che_인재탐색 extends Command\GeneralCommand{ $power, $intel, $isOurNation?1:0, - $env['year'] - 20, + $age, $env['year'] + Util::randRangeInt(10, 50), null, null diff --git a/hwe/sammo/Command/General/che_징병.php b/hwe/sammo/Command/General/che_징병.php index e5cbdd0d..e5e5693d 100644 --- a/hwe/sammo/Command/General/che_징병.php +++ b/hwe/sammo/Command/General/che_징병.php @@ -57,14 +57,15 @@ class che_징병 extends Command\GeneralCommand{ if(!is_int($crewType)){ return false; } - if(!is_int($amount)){ + if(!is_numeric($amount)){ return false; } + $amount = (int)$amount; if(GameUnitConst::byID($crewType) === null){ return false; } - if($amount < 100){ + if($amount < 0){ return false; } $this->arg = [ diff --git a/hwe/sammo/Command/Nation/che_불가침제의.php b/hwe/sammo/Command/Nation/che_불가침제의.php index d91f4ca0..83af5128 100644 --- a/hwe/sammo/Command/Nation/che_불가침제의.php +++ b/hwe/sammo/Command/Nation/che_불가침제의.php @@ -157,14 +157,14 @@ class che_불가침제의 extends Command\NationCommand{ $now = new \DateTime($date); $validUntil = new \DateTime($date); - $validMinutes = max(30, $turnterm*3); + $validMinutes = max(30, $env['turnterm']*3); $validUntil->add(new \DateInterval("PT{$validMinutes}M")); $msg = new DiplomaticMessage( Message::MSGTYPE_DIPLOMACY, $src, $dest, - "{$srcNation['name']}의 {$year}년 {$month}까지 불가침 제의 서신", + "{$nationName}의 {$year}년 {$month}까지 불가침 제의 서신", $now, $validUntil, [ @@ -177,7 +177,7 @@ class che_불가침제의 extends Command\NationCommand{ $general->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->applyDB($db); - $destGeneral->applyDB($db); + $destLogger->flush(); return true; } diff --git a/hwe/sammo/Command/Nation/che_선전포고.php b/hwe/sammo/Command/Nation/che_선전포고.php index 492ac3b7..1dd60120 100644 --- a/hwe/sammo/Command/Nation/che_선전포고.php +++ b/hwe/sammo/Command/Nation/che_선전포고.php @@ -134,7 +134,7 @@ class che_선전포고 extends Command\NationCommand{ ], '(me=%i AND you=%i) OR (me=%i AND you=%i)', $nationID, $destNationID, $destNationID, $nationID); //국메로 저장 - $text = "【외교】{$env['year']}년 {$env['month']}월:{$nationNation}에서 {$destNationName}에 선전포고"; + $text = "【외교】{$env['year']}년 {$env['month']}월:{$nationName}에서 {$destNationName}에 선전포고"; $src = new MessageTarget( $general->getID(), @@ -164,7 +164,7 @@ class che_선전포고 extends Command\NationCommand{ $general->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->applyDB($db); - $destGeneral->applyDB($db); + $destLogger->flush(); return true; } diff --git a/hwe/sammo/Command/Nation/휴식.php b/hwe/sammo/Command/Nation/휴식.php index e489e468..5c81af4c 100644 --- a/hwe/sammo/Command/Nation/휴식.php +++ b/hwe/sammo/Command/Nation/휴식.php @@ -16,6 +16,15 @@ class 휴식 extends Command\NationCommand{ protected function init(){ //아무것도 하지 않음 } + + public function getPreReqTurn():int{ + return 0; + } + + public function getPostReqTurn():int{ + return 0; + } + public function getCost():array{ return [0, 0]; } diff --git a/hwe/sammo/Constraint/BeOpeningPart.php b/hwe/sammo/Constraint/BeOpeningPart.php index b649600b..febbc51d 100644 --- a/hwe/sammo/Constraint/BeOpeningPart.php +++ b/hwe/sammo/Constraint/BeOpeningPart.php @@ -1,6 +1,7 @@ general = $general; $this->tested = false; $this->reason = null; } - public function city(array $city){ + public function setCity(array $city){ $this->city = $city; $this->tested = false; $this->reason = null; } - public function nation(array $nation){ + public function setNation(array $nation){ $this->nation = $nation; $this->tested = false; $this->reason = null; } - public function arg($arg){ + public function setArg($arg){ $this->arg = $arg; $this->tested = false; $this->reason = null; } + public function setCmdArg($cmd_arg){ + $this->cmd_arg = $cmd_arg; + $this->tested = false; + $this->reason = null; + } - public function destGeneral(array $general){ + public function setDestGeneral(array $general){ $this->destGeneral = $general; $this->tested = false; $this->reason = null; } - public function destCity(array $city){ + public function setDestCity(array $city){ $this->destCity = $city; $this->tested = false; $this->reason = null; } - public function destNation(array $nation){ + public function setDestNation(array $nation){ $this->destNation = $nation; $this->tested = false; $this->reason = null; @@ -84,14 +91,14 @@ abstract class Constraint{ continue; } switch($key){ - case 'general': $self->general($value); break; - case 'city': $self->city($value); break; - case 'nation': $self->nation($value); break; - case 'arg': $self->arg($value); break; + case 'general': $self->setGeneral($value); break; + case 'city': $self->setCity($value); break; + case 'nation': $self->setNation($value); break; + case 'cmd_arg': $self->setCmdArg($value); break; - case 'destGeneral': $self->destGeneral($value); break; - case 'destCity': $self->destCity($value); break; - case 'destNation': $self->destNation($value); break; + case 'destGeneral': $self->setDestGeneral($value); break; + case 'destCity': $self->setDestCity($value); break; + case 'destNation': $self->setDestNation($value); break; } } @@ -169,7 +176,7 @@ abstract class Constraint{ } public function reason():?string{ - if(!$this->tested === false){ + if($this->tested === false){ throw new \RuntimeException(get_class($this).'::test가 실행되지 않음'); } return $this->reason; @@ -186,11 +193,13 @@ 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) > 1){ + if(count($constraintArgs) == 2){ $arg = $constraintArgs[1]; - $constraint->arg($arg); + $constraint->setArg($arg); } diff --git a/hwe/sammo/Constraint/ConstraintHelper.php b/hwe/sammo/Constraint/ConstraintHelper.php index 0307d3ff..fb319e5a 100644 --- a/hwe/sammo/Constraint/ConstraintHelper.php +++ b/hwe/sammo/Constraint/ConstraintHelper.php @@ -69,11 +69,11 @@ class ConstraintHelper{ } static function DisallowDiplomacyStatus(int $nationID, array $disallowList):array{ - return [__FUNCTION__, $nationID, $disallowList]; + return [__FUNCTION__, [$nationID, $disallowList]]; } static function ExistsAllowJoinNation(int $relYear, array $excludeNationList):array{ - return [__FUNCTION__, $relYear, $excludeNationList]; + return [__FUNCTION__, [$relYear, $excludeNationList]]; } static function ExistsDestGeneral():array{ @@ -145,7 +145,7 @@ class ConstraintHelper{ } static function RemainCityCapacity($key, string $actionName):array{ - return [__FUNCTION__, $key, $actionName]; + return [__FUNCTION__, [$key, $actionName]]; } static function RemainCityTrust(string $actionName):array{ @@ -153,7 +153,7 @@ class ConstraintHelper{ } static function ReqCityCapacity($key, string $keyNick, $reqVal):array{ - return [__FUNCTION__, $key, $keyNick, $reqVal]; + return [__FUNCTION__, [$key, $keyNick, $reqVal]]; } static function ReqCityTrust(float $minTrust):array{ @@ -165,7 +165,7 @@ class ConstraintHelper{ } static function ReqEnvValue($key, string $keyNick, string $comp, $reqVal, string $failMessage):array{ - return [__FUNCTION__, $key, $keyNick, $comp, $reqVal, $failMessage]; + return [__FUNCTION__, [$key, $keyNick, $comp, $reqVal, $failMessage]]; } static function ReqGeneralAtmosMargin(int $maxAtmos):array{ @@ -193,7 +193,7 @@ class ConstraintHelper{ } static function ReqGeneralValue($key, string $keyNick, string $comp, $reqVal):array{ - return [__FUNCTION__, $key, $keyNick, $comp, $reqVal]; + return [__FUNCTION__, [$key, $keyNick, $comp, $reqVal]]; } static function ReqNationGold(int $reqGold):array{ @@ -205,7 +205,7 @@ class ConstraintHelper{ } static function ReqNationValue($key, string $keyNick, string $comp, $reqVal):array{ - return [__FUNCTION__, $key, $keyNick, $comp, $reqVal]; + return [__FUNCTION__, [$key, $keyNick, $comp, $reqVal]]; } static function ReqTroopMembers():array{ diff --git a/hwe/sammo/Constraint/NotOpeningPart.php b/hwe/sammo/Constraint/NotOpeningPart.php index 0b23e754..1a0022f2 100644 --- a/hwe/sammo/Constraint/NotOpeningPart.php +++ b/hwe/sammo/Constraint/NotOpeningPart.php @@ -1,6 +1,7 @@ getGeneralObj(); $city = $this->city; $nation = $this->nation; @@ -374,7 +374,9 @@ class GeneralAI{ $cost = $general->onCalcDomestic('징병', 'cost', $cost); $crew = intdiv($gold, $cost); - if($leadership < $crew) { $crew = $leadership; } + if($leadership*100 < $crew) { $crew = $leadership; } + $crew *= 100; + $arg = [ 'crewType'=>$type, 'amountCrew'=>$crew diff --git a/hwe/sammo/TextDecoration/SightseeingMessage.php b/hwe/sammo/TextDecoration/SightseeingMessage.php index 4f3599a4..83c3b340 100644 --- a/hwe/sammo/TextDecoration/SightseeingMessage.php +++ b/hwe/sammo/TextDecoration/SightseeingMessage.php @@ -104,7 +104,7 @@ class SightseeingMessage{ } public function pickAction():array{ - [$type, $texts] = Util::choiceRandomUsingWeightPair(static::$messages); + [$type, $texts] = Util::choiceRandomUsingWeightPair(static::$messages??[]); $text = Util::choiceRandom($texts); return [$type, $text];