From 53b7dbfdd015254355ceeb3068ffec3aed4e0b86 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Wed, 22 Jan 2025 17:17:30 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=B3=91=EC=A2=85=20=EC=A7=95=EB=B3=91?= =?UTF-8?q?=20=EC=A1=B0=EA=B1=B4=20=EC=B6=94=EA=B0=80=20-=20=EA=B5=B0?= =?UTF-8?q?=EC=A3=BC=20=EB=B0=8F=20=EC=88=98=EB=87=8C=20-=20=EA=B5=B0?= =?UTF-8?q?=EC=A3=BC=20=EB=B0=8F=20=EC=88=98=EB=87=8C=20=EC=95=84=EB=8B=98?= =?UTF-8?q?=20-=20=EB=8F=84=EC=8B=9C=EC=9D=98=20=EA=B7=9C=EB=AA=A8=20?= =?UTF-8?q?=EC=9A=94=EA=B5=AC=20-=20=ED=8A=B9=EC=A0=95=20Nation=20Aux=20?= =?UTF-8?q?=EA=B0=92=20=EC=9A=94=EA=B5=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Enums/NationUpgradeKey.php | 2 - hwe/sammo/GameUnitConstraint/ReqChief.php | 26 ++++ .../ReqCitiesWithCityLevel.php | 48 +++++++ hwe/sammo/GameUnitConstraint/ReqNationAux.php | 122 ++++++++++++++++++ hwe/sammo/GameUnitConstraint/ReqNotChief.php | 26 ++++ 5 files changed, 222 insertions(+), 2 deletions(-) create mode 100644 hwe/sammo/GameUnitConstraint/ReqChief.php create mode 100644 hwe/sammo/GameUnitConstraint/ReqCitiesWithCityLevel.php create mode 100644 hwe/sammo/GameUnitConstraint/ReqNationAux.php create mode 100644 hwe/sammo/GameUnitConstraint/ReqNotChief.php diff --git a/hwe/sammo/Enums/NationUpgradeKey.php b/hwe/sammo/Enums/NationUpgradeKey.php index 2ba31569..3a68912f 100644 --- a/hwe/sammo/Enums/NationUpgradeKey.php +++ b/hwe/sammo/Enums/NationUpgradeKey.php @@ -23,6 +23,4 @@ enum NationAuxKey: string case can_음귀병사용 = 'can_음귀병사용'; case can_무희사용 = 'can_무희사용'; case can_흑병사용 = 'can_흑병사용'; - - } \ No newline at end of file diff --git a/hwe/sammo/GameUnitConstraint/ReqChief.php b/hwe/sammo/GameUnitConstraint/ReqChief.php new file mode 100644 index 00000000..517d26a4 --- /dev/null +++ b/hwe/sammo/GameUnitConstraint/ReqChief.php @@ -0,0 +1,26 @@ +getVar('officer_level') >= 5){ + return true; + } + + return false; + } + + public function getInfo(): string + { + return "군주 및 수뇌부만 가능"; + } +} diff --git a/hwe/sammo/GameUnitConstraint/ReqCitiesWithCityLevel.php b/hwe/sammo/GameUnitConstraint/ReqCitiesWithCityLevel.php new file mode 100644 index 00000000..055acd63 --- /dev/null +++ b/hwe/sammo/GameUnitConstraint/ReqCitiesWithCityLevel.php @@ -0,0 +1,48 @@ +reqCities = []; + return; + } + + foreach ($reqCities as $city) { + $dstReqCities[CityConst::byName($city)->id] = $city; + } + $this->reqCities = $dstReqCities; + } + + public function test(General $general, array $ownCities, array $ownRegions, int $relativeYear, int $tech, array $nationAux): bool + { + foreach ($this->reqCities as $cityID => $cityName) { + if (!key_exists($cityID, $ownCities)) { + continue; + } + + if($ownCities[$cityID]['level'] >= $this->reqCityLevel) { + return true; + } + } + + return false; + } + + public function getInfo(): string + { + $cityNameText = implode(', ', $this->reqCities); + return "{$cityNameText} 소유시 가능"; + } +} diff --git a/hwe/sammo/GameUnitConstraint/ReqNationAux.php b/hwe/sammo/GameUnitConstraint/ReqNationAux.php new file mode 100644 index 00000000..f6b2eca2 --- /dev/null +++ b/hwe/sammo/GameUnitConstraint/ReqNationAux.php @@ -0,0 +1,122 @@ + true, + '!=' => true, + '<' => true, + '>' => true, + '<=' => true, + '>=' => true, + ]; + + public function __construct( + public readonly NationAuxKey $reqNationAuxKey, + public readonly string $cmp, + public readonly int|float $value + ) { + if (!array_key_exists($cmp, self::AVAILABLE_CMP)) { + throw new \InvalidArgumentException('올바르지 않은 비교연산자입니다'); + } + } + + public function test(General $general, array $ownCities, array $ownRegions, int $relativeYear, int $tech, array $nationAux): bool + { + + $lhs = $nationAux[$this->reqNationAuxKey->value] ?? 0; + $rhs = $this->value; + + $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; + } + + public function getInfo(): string + { + //Enum별 특수한 경우 + switch ($this->reqNationAuxKey) { + case NationAuxKey::can_대검병사용: + if ($this->cmp == "==" && $this->value == 1) return "대검병 연구 시 가능"; + break; + case NationAuxKey::can_극병사용: + if ($this->cmp == "==" && $this->value == 1) return "극병 연구 시 가능"; + break; + case NationAuxKey::can_화시병사용: + if ($this->cmp == "==" && $this->value == 1) return "화시병 연구 시 가능"; + break; + case NationAuxKey::can_원융노병사용: + if ($this->cmp == "==" && $this->value == 1) return "원융노병 연구 시 가능"; + break; + case NationAuxKey::can_산저병사용: + if ($this->cmp == "==" && $this->value == 1) return "산저병 연구 시 가능"; + break; + case NationAuxKey::can_상병사용: + if ($this->cmp == "==" && $this->value == 1) return "상병 연구 시 가능"; + break; + case NationAuxKey::can_음귀병사용: + if ($this->cmp == "==" && $this->value == 1) return "음귀병 연구 시 가능"; + break; + case NationAuxKey::can_무희사용: + if ($this->cmp == "==" && $this->value == 1) return "무희 연구 시 가능"; + break; + case NationAuxKey::can_흑병사용: + if ($this->cmp == "==" && $this->value == 1) return "흑병 연구 시 가능"; + break; + case NationAuxKey::did_특성초토화: + if ($this->cmp == ">=" && $this->value == 1) return "특성 초토화 시 가능"; + break; + } + + //범용 + switch ($this->cmp) { + case '==': { + if ($this->value == 0) { + return "{$this->reqNationAuxKey->value} 없을 때"; + } + if ($this->value == 1) { + return "{$this->reqNationAuxKey->value} 있을 때"; + } + return "{$this->reqNationAuxKey->value} = {$this->value} 일 때"; + }; + case '!=': { + if ($this->value == 0) { + return "{$this->reqNationAuxKey->value} 없을 때"; + } + if ($this->value == 1) { + return "{$this->reqNationAuxKey->value} 있을 때"; + } + return "{$this->reqNationAuxKey->value} != {$this->value} 일 때"; + }; + default: + return "{$this->reqNationAuxKey->value} {$this->cmp} {$this->value} 일 때"; + } + } +} diff --git a/hwe/sammo/GameUnitConstraint/ReqNotChief.php b/hwe/sammo/GameUnitConstraint/ReqNotChief.php new file mode 100644 index 00000000..04447974 --- /dev/null +++ b/hwe/sammo/GameUnitConstraint/ReqNotChief.php @@ -0,0 +1,26 @@ +getVar('officer_level') < 5){ + return true; + } + + return false; + } + + public function getInfo(): string + { + return "군주 및 수뇌부는 불가"; + } +}