diff --git a/hwe/sammo/Command/General/che_건국.php b/hwe/sammo/Command/General/che_건국.php index 4b033f02..304b9fa1 100644 --- a/hwe/sammo/Command/General/che_건국.php +++ b/hwe/sammo/Command/General/che_건국.php @@ -37,7 +37,7 @@ class che_건국 extends Command\GeneralCommand{ return false; } - if(mb_strwidth($nationName) > 18){ + if(mb_strwidth($nationName) > 18 || $nationName == ''){ return false; } @@ -62,6 +62,10 @@ class che_건국 extends Command\GeneralCommand{ $general = $this->generalObj; $env = $this->env; + $nationName = $this->arg['nationName']; + $nationType = $this->arg['nationType']; + $colorType = $this->arg['colorType']; + $this->setCity(); $this->setNation(); @@ -78,10 +82,13 @@ class che_건국 extends Command\GeneralCommand{ $relYear = $env['year'] - $env['startyear']; $this->runnableConstraints=[ - ['BeNeutral'], - ['ExistsDestNation'], - ['AllowJoinDestNation', $relYear], - ['AllowJoinAction'] + ['ReqNationValue', 'gennum', '수하 장수', '>=', 2], + ['BeOpeningPart'], + ['WanderingNation'], + ['CheckNationNameDuplicate', $nationName], + ['BeLord'], + ['AllowJoinAction'], + ['ConstructableCity'] ]; } diff --git a/hwe/sammo/Constraint/BeOpeningPart.php b/hwe/sammo/Constraint/BeOpeningPart.php new file mode 100644 index 00000000..cec24aaa --- /dev/null +++ b/hwe/sammo/Constraint/BeOpeningPart.php @@ -0,0 +1,31 @@ +relYear = $this->arg; + + return true; + } + + public function test():bool{ + $this->checkInputValues(); + $this->tested = true; + + if($relYear < GameConst::$openingPartYear){ + return true; + } + + $this->reason = "초반이 지났습니다."; + return false; + } +} \ No newline at end of file diff --git a/hwe/sammo/Constraint/CheckNationNameDuplicate.php b/hwe/sammo/Constraint/CheckNationNameDuplicate.php new file mode 100644 index 00000000..9487f195 --- /dev/null +++ b/hwe/sammo/Constraint/CheckNationNameDuplicate.php @@ -0,0 +1,39 @@ +nation)){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("require nation in nation"); + } + + return true; + } + + public function test():bool{ + $this->checkInputValues(); + $this->tested = true; + + $db = DB::db(); + + $exists = $db->queryFirstField('SELECT count(*) FROM nation WHERE name = %s AND nation != %i', $this->arg, $this->nation['nation']); + + if($exists == 0){ + return true; + } + + $this->reason = '존재하는 국가명입니다.'; + return false; + } +} \ No newline at end of file diff --git a/hwe/sammo/Constraint/ConstructableCity.php b/hwe/sammo/Constraint/ConstructableCity.php new file mode 100644 index 00000000..026cd8cc --- /dev/null +++ b/hwe/sammo/Constraint/ConstructableCity.php @@ -0,0 +1,46 @@ +city)){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("require nation in city"); + } + + if(!key_exists('level', $this->city)){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("require nation in city"); + } + + return true; + } + + public function test():bool{ + $this->checkInputValues(); + $this->tested = true; + + $city = $this->city(); + + if($city['nation'] != 0){ + $this->reason = '공백지가 아닙니다.'; + return false; + } + + if(!in_array($city['level'], [5, 6])){ + $this->reason = '중, 소 도시에만 가능합니다.'; + return false; + } + + return true; + } +} \ No newline at end of file diff --git a/hwe/sammo/Constraint/WanderingNation.php b/hwe/sammo/Constraint/WanderingNation.php new file mode 100644 index 00000000..2ead535c --- /dev/null +++ b/hwe/sammo/Constraint/WanderingNation.php @@ -0,0 +1,32 @@ +nation)){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("require level in nation"); + } + + return true; + } + + public function test():bool{ + $this->checkInputValues(); + $this->tested = true; + + if($this->nation['level'] == 0){ + return true; + } + + $this->reason = "방랑군이어야 합니다"; + return false; + } +} \ No newline at end of file