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 "군주 및 수뇌부는 불가"; + } +}