feat,refac: GameUnitConstraint 개념 추가
- GameUnitDetail의 요구 기술, 지역, 도시, 연도를 GameUnitConstraint로 통합 - GameUnitConstraint는 조건 검사, 설명 제공 - 병종 정의를 GameUnitConstraint 이용 재정의 - test 함수에 General 객체 요구, - test 함수의 ownCities에 단순 도시 외 도시 정보 추가 - 변경된 값에 맞게 호출 함수 변경
This commit is contained in:
+16
-9
@@ -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);
|
||||
@@ -2567,7 +2570,7 @@ class GeneralAI
|
||||
|
||||
$types = [];
|
||||
foreach (GameUnitConst::byType($armType) as $crewtype) {
|
||||
if ($crewtype->isValid($cities, $regions, $relYear, $tech)) {
|
||||
if ($crewtype->isValid($general, $cities, $regions, $relYear, $tech)) {
|
||||
$score = $crewtype->pickScore($tech);
|
||||
$types[$crewtype->id] = $score;
|
||||
}
|
||||
@@ -2581,12 +2584,16 @@ 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;
|
||||
if ($currCrewType->isValid($general, $cities, $regions, $relYear, $tech)) {
|
||||
$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