diff --git a/hwe/sammo/Command/General/che_징병.php b/hwe/sammo/Command/General/che_징병.php index 0f604090..f74183aa 100644 --- a/hwe/sammo/Command/General/che_징병.php +++ b/hwe/sammo/Command/General/che_징병.php @@ -256,8 +256,11 @@ class che_징병 extends Command\GeneralCommand $ownCities = []; $ownRegions = []; - foreach (DB::db()->query('SELECT city, region from city where nation = %i', $general->getNationID()) as $city) { - $ownCities[$city['city']] = 1; + foreach (DB::db()->query('SELECT city, region, secu, level from city where nation = %i', $general->getNationID()) as $city) { + $ownCities[$city['city']] = [ + 'secu' => $city['secu'], + 'level' => $city['level'], + ]; $ownRegions[$city['region']] = 1; } @@ -278,8 +281,13 @@ class che_징병 extends Command\GeneralCommand $crewObj = new \stdClass; $crewObj->id = $unit->id; - $crewObj->reqTech = $unit->reqTech; - $crewObj->reqYear = $unit->reqYear; + /** @var ?\sammo\GameUnitConstraints\ReqTech */ + $reqTechObj = $unit->reqConstraints['reqTech'] ?? null; + $crewObj->reqTech = $reqTechObj ? $reqTechObj->reqTech : 0; + + /** @var ?\sammo\GameUnitConstraint\ReqMinRelYear */ + $reqMinRelYearObj = $unit->reqConstraints['reqMinRelYear'] ?? null; + $crewObj->reqYear = $reqMinRelYearObj ? $reqMinRelYearObj->reqMinRelYear : 0; /* if ($unit->reqTech == 0) { @@ -305,7 +313,7 @@ class che_징병 extends Command\GeneralCommand $crewObj->img = ServConfig::$gameImagePath . "/crewtype" . $unit->id . ".png"; } - $crewObj->info = $unit->info; + $crewObj->info = $unit->getInfo(); $armCrewType['values'][] = $crewObj; } diff --git a/hwe/sammo/GameUnitConstraint/ReqCities.php b/hwe/sammo/GameUnitConstraint/ReqCities.php index a213f325..667428b2 100644 --- a/hwe/sammo/GameUnitConstraint/ReqCities.php +++ b/hwe/sammo/GameUnitConstraint/ReqCities.php @@ -7,7 +7,7 @@ use sammo\General; class ReqCities extends BaseGameUnitConstraint { - public function __construct(protected array $reqCities) + public function __construct(public readonly array $reqCities) { } diff --git a/hwe/sammo/GameUnitConstraint/ReqMinRelYear.php b/hwe/sammo/GameUnitConstraint/ReqMinRelYear.php index d70444c6..836c4321 100644 --- a/hwe/sammo/GameUnitConstraint/ReqMinRelYear.php +++ b/hwe/sammo/GameUnitConstraint/ReqMinRelYear.php @@ -6,7 +6,7 @@ use sammo\General; class ReqMinRelYear extends BaseGameUnitConstraint { - public function __construct(protected int $reqMinRelYear) + public function __construct(public readonly int $reqMinRelYear) { } diff --git a/hwe/sammo/GameUnitConstraint/ReqRegions.php b/hwe/sammo/GameUnitConstraint/ReqRegions.php index 638b7059..da3b4456 100644 --- a/hwe/sammo/GameUnitConstraint/ReqRegions.php +++ b/hwe/sammo/GameUnitConstraint/ReqRegions.php @@ -7,7 +7,7 @@ use sammo\General; class ReqRegions extends BaseGameUnitConstraint { - public function __construct(protected array $reqRegions) + public function __construct(public readonly array $reqRegions) { } diff --git a/hwe/sammo/GameUnitConstraint/ReqTech.php b/hwe/sammo/GameUnitConstraint/ReqTech.php index e5d48319..2297bd59 100644 --- a/hwe/sammo/GameUnitConstraint/ReqTech.php +++ b/hwe/sammo/GameUnitConstraint/ReqTech.php @@ -7,7 +7,7 @@ use sammo\KVStorage; class ReqTech extends BaseGameUnitConstraint { - public function __construct(protected int $reqTech) + public function __construct(public readonly int $reqTech) { } diff --git a/hwe/sammo/GameUnitDetail.php b/hwe/sammo/GameUnitDetail.php index 9b2fcd57..0ab6fcc8 100644 --- a/hwe/sammo/GameUnitDetail.php +++ b/hwe/sammo/GameUnitDetail.php @@ -56,7 +56,11 @@ class GameUnitDetail implements iAction $this->magicCoef = $magicCoef; $this->cost = $cost; $this->rice = $rice; - $this->reqConstraints = $reqConstraints; + $this->reqConstraints = []; + foreach($reqConstraints as $constraint){ + $className = Util::getClassNameFromObj($constraint); + $this->reqConstraints[$className] = $constraint; + } $this->attackCoef = $attackCoef; $this->defenceCoef = $defenceCoef; $this->initSkillTrigger = $initSkillTrigger; @@ -205,36 +209,6 @@ class GameUnitDetail implements iAction } } - if ($tech < $this->reqTech) { - return false; - } - - if ($this->reqCities !== null) { - $valid = false; - foreach ($this->reqCities as $reqCity) { - if (\key_exists($reqCity, $ownCities)) { - $valid = true; - break; - } - } - if (!$valid) { - return false; - } - } - - if ($this->reqRegions !== null) { - $valid = false; - foreach ($this->reqRegions as $reqRegion) { - if (\key_exists($reqRegion, $ownRegions)) { - $valid = true; - break; - } - } - if (!$valid) { - return false; - } - } - return true; } diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php index f9848df9..c60bbb28 100644 --- a/hwe/sammo/GeneralAI.php +++ b/hwe/sammo/GeneralAI.php @@ -2558,8 +2558,11 @@ class GeneralAI $cities = []; $regions = []; - foreach ($db->queryAllLists('SELECT city, region FROM city WHERE nation = %i', $nationID) as [$cityID, $regionID]) { - $cities[$cityID] = true; + foreach ($db->queryAllLists('SELECT city, region, secu, level FROM city WHERE nation = %i', $nationID) as [$cityID, $regionID, $secu, $level]) { + $cities[$cityID] = [ + 'secu' => $secu, + 'level' => $level, + ]; $regions[$regionID] = true; } $relYear = Util::valueFit($env['year'] - $env['startyear'], 0); @@ -2582,11 +2585,15 @@ class GeneralAI if ($this->generalPolicy->can고급병종) { $currCrewType = $general->getCrewTypeObj(); if ($currCrewType->isValid($cities, $regions, $relYear, $tech)) { - if ($currCrewType->reqTech >= 2000) { - $type = $currCrewType->id; - } else if ($currCrewType->armType != $armType && $currCrewType->reqTech >= 1000) { - //굳이 뽑은 이유가 있겠지 - $type = $currCrewType->id; + $reqTechObj = $currCrewType->reqConstraints['reqTech'] ?? null; + if($reqTechObj){ + $reqTech = $reqTechObj->getValue($tech); + if ($reqTech >= 2000) { + $type = $currCrewType->id; + } else if ($currCrewType->armType != $armType && $reqTech >= 1000) { + //굳이 뽑은 이유가 있겠지 + $type = $currCrewType->id; + } } } }