diff --git a/hwe/sammo/Event/Condition/RemainNation.php b/hwe/sammo/Event/Condition/RemainNation.php new file mode 100644 index 00000000..5488aa85 --- /dev/null +++ b/hwe/sammo/Event/Condition/RemainNation.php @@ -0,0 +1,50 @@ +true, + '!='=>true, + '<'=>true, + '>'=>true, + '<='=>true, + '>='=>true, + ]; + + private $cmp; + private $cnt; + + public function __construct(string $cmp, int $cnt){ + //Cmp('==', '!=', '<=', '>=', '<', '>'), Cnt + if(!array_key_exists($cmp, self::AVAILABLE_CMP)){ + throw new \InvalidArgumentException('올바르지 않은 비교연산자입니다'); + } + + $this->cmp = $cmp; + $this->cnt = $cnt; + } + + public function eval($env=null){ + $lhs = count(getAllNationStaticInfo()); + $rhs = $this->cnt; + + $value = false; + switch($this->cmp){ + case '==': $value = ($lhs == $rhs); break; + case '!=': $value = ($lhs != $rhs); break; + case '<=': $value = ($lhs <= $rhs); break; + case '>=': $value = ($lhs >= $rhs); break; + case '<': $value = ($lhs < $rhs); break; + case '>': $value = ($lhs > $rhs); break; + } + + return [ + 'value'=>$value, + 'chain'=>[__CLASS__] + ]; + + } +} \ No newline at end of file