Files
core/hwe/sammo/Constraint/ReqNationRice.php
2019-10-09 03:19:50 +09:00

32 lines
817 B
PHP

<?php
namespace sammo\Constraint;
class ReqNationRice extends Constraint{
const REQ_VALUES = Constraint::REQ_NATION|Constraint::REQ_NUMERIC_ARG;
public function checkInputValues(bool $throwExeception=true):bool{
if(!parent::checkInputValues($throwExeception) && !$throwExeception){
return false;
}
if(!key_exists('rice', $this->nation)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require rice in nation");
}
return true;
}
public function test():bool{
$this->checkInputValues();
$this->tested = true;
if($this->nation['rice'] >= $this->arg){
return true;
}
$this->reason = "병량이 부족합니다.";
return false;
}
}