feat, refac(wip): 징병 기준을 GameUnitConstraint 기반으로 변경
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use sammo\General;
|
||||
|
||||
class ReqCities extends BaseGameUnitConstraint {
|
||||
|
||||
public function __construct(protected array $reqCities)
|
||||
public function __construct(public readonly array $reqCities)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use sammo\General;
|
||||
|
||||
class ReqMinRelYear extends BaseGameUnitConstraint {
|
||||
|
||||
public function __construct(protected int $reqMinRelYear)
|
||||
public function __construct(public readonly int $reqMinRelYear)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use sammo\General;
|
||||
|
||||
class ReqRegions extends BaseGameUnitConstraint {
|
||||
|
||||
public function __construct(protected array $reqRegions)
|
||||
public function __construct(public readonly array $reqRegions)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use sammo\KVStorage;
|
||||
|
||||
class ReqTech extends BaseGameUnitConstraint {
|
||||
|
||||
public function __construct(protected int $reqTech)
|
||||
public function __construct(public readonly int $reqTech)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+14
-7
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user