From 307d08d898d9898aa2f698bee257a46ad83cd934 Mon Sep 17 00:00:00 2001 From: hide_d Date: Mon, 24 Jan 2022 21:55:59 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20Event/Condition/RemainNation=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Event/Condition/RemainNation.php | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 hwe/sammo/Event/Condition/RemainNation.php 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