feat: 병종 징병 조건 추가

- 군주 및 수뇌
- 군주 및 수뇌 아님
- 도시의 규모 요구
- 특정 Nation Aux 값 요구
This commit is contained in:
2025-01-22 17:17:30 +00:00
parent fd14c5403b
commit 53b7dbfdd0
5 changed files with 222 additions and 2 deletions
-2
View File
@@ -23,6 +23,4 @@ enum NationAuxKey: string
case can_음귀병사용 = 'can_음귀병사용'; case can_음귀병사용 = 'can_음귀병사용';
case can_무희사용 = 'can_무희사용'; case can_무희사용 = 'can_무희사용';
case can_흑병사용 = 'can_흑병사용'; case can_흑병사용 = 'can_흑병사용';
} }
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace sammo\GameUnitConstraint;
use sammo\General;
class ReqChief extends BaseGameUnitConstraint
{
public function __construct()
{
}
public function test(General $general, array $ownCities, array $ownRegions, int $relativeYear, int $tech, array $nationAux): bool
{
if($general->getVar('officer_level') >= 5){
return true;
}
return false;
}
public function getInfo(): string
{
return "군주 및 수뇌부만 가능";
}
}
@@ -0,0 +1,48 @@
<?php
namespace sammo\GameUnitConstraint;
use sammo\CityConst;
use sammo\General;
class ReqCitiesWithCityLevel extends BaseGameUnitConstraint
{
public readonly array $reqCities;
public function __construct(
public readonly int $reqCityLevel,
...$reqCities)
{
$dstReqCities = [];
if (count($reqCities) == 0) {
$this->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} 소유시 가능";
}
}
@@ -0,0 +1,122 @@
<?php
namespace sammo\GameUnitConstraint;
use sammo\CityConst;
use sammo\Enums\NationAuxKey;
use sammo\General;
class ReqNationAux extends BaseGameUnitConstraint
{
const AVAILABLE_CMP = [
'==' => 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} 일 때";
}
}
}
@@ -0,0 +1,26 @@
<?php
namespace sammo\GameUnitConstraint;
use sammo\General;
class ReqNotChief extends BaseGameUnitConstraint
{
public function __construct()
{
}
public function test(General $general, array $ownCities, array $ownRegions, int $relativeYear, int $tech, array $nationAux): bool
{
if($general->getVar('officer_level') < 5){
return true;
}
return false;
}
public function getInfo(): string
{
return "군주 및 수뇌부는 불가";
}
}