건국 조건 설정

This commit is contained in:
Hide_D committed 2018-10-29 03:14:03 +09:00
1 parent a3dc250698
commit fd734fadbc
5 files changed
+160 -5

No files matched your search

@@ -0,0 +1,46 @@
<?php
namespace sammo\Constraint;
class ConstructableCity extends Constraint{
const REQ_VALUES = Constraint::REQ_CITY;
protected $relYear;
public function checkInputValues(bool $throwExeception=true){
if(!parent::checkInputValues($throwExeception) && !$throwException){
return false;
}
if(!key_exists('nation', $this->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;
}
}