전투 턴 관련 등록
This commit is contained in:
+94
-20
@@ -16,6 +16,7 @@ class GeneralAI{
|
|||||||
protected $intel;
|
protected $intel;
|
||||||
|
|
||||||
protected $dipState;
|
protected $dipState;
|
||||||
|
protected $warTargetNation;
|
||||||
protected $attackable;
|
protected $attackable;
|
||||||
protected $onGame;
|
protected $onGame;
|
||||||
|
|
||||||
@@ -109,6 +110,18 @@ class GeneralAI{
|
|||||||
// 공격가능도시 있으면
|
// 공격가능도시 있으면
|
||||||
$this->attackable = ($frontStatus !== null)?$frontStatus:false;
|
$this->attackable = ($frontStatus !== null)?$frontStatus:false;
|
||||||
|
|
||||||
|
$warTarget = $db->queryAllLists(
|
||||||
|
'SELECT you, state WHERE me = %i AND (state = 1 OR (state = 0 AND term < 5))',
|
||||||
|
$nationID
|
||||||
|
);
|
||||||
|
|
||||||
|
$warTargetNation = [];
|
||||||
|
foreach($warTarget as [$warNationID, $warState]){
|
||||||
|
$warTargetNation[$warNationID] = $warState==0?2:1;
|
||||||
|
}
|
||||||
|
$warTargetNation[0] = 0;
|
||||||
|
$this->warTargetNation = $warTargetNation;
|
||||||
|
|
||||||
|
|
||||||
$minWarTerm = $db->queryFirstField('SELECT min(term) FROM diplomacy WHERE me = %i AND state=1', $nationID);
|
$minWarTerm = $db->queryFirstField('SELECT min(term) FROM diplomacy WHERE me = %i AND state=1', $nationID);
|
||||||
if($minWarTerm === null){
|
if($minWarTerm === null){
|
||||||
@@ -655,6 +668,8 @@ class GeneralAI{
|
|||||||
$general = $this->getGeneralObj();
|
$general = $this->getGeneralObj();
|
||||||
$city = $this->city;
|
$city = $this->city;
|
||||||
$nation = $this->nation;
|
$nation = $this->nation;
|
||||||
|
$cityID = $city['city'];
|
||||||
|
$nationID = $nation['nation'];
|
||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
|
|
||||||
$baseArmCost = GameUnitConst::byID(GameUnitConst::DEFAULT_CREWTYPE)->costWithTech(
|
$baseArmCost = GameUnitConst::byID(GameUnitConst::DEFAULT_CREWTYPE)->costWithTech(
|
||||||
@@ -680,8 +695,36 @@ class GeneralAI{
|
|||||||
return ['che_주민선정', null];
|
return ['che_주민선정', null];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($general->getVar('crew') < 1000){
|
||||||
|
if ($general->getVar('gold') <= $baseArmCost) {
|
||||||
|
//반징도 불가? 내정
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sumLeadershipInCity = $db->queryFirstField('SELECT sum(leader) FROM general WHERE nation = %i AND city = %i AND leader > 40', $nationID, $cityID);
|
||||||
|
if(
|
||||||
|
$city['pop'] > 30000 + $general->getLeadership(false) * 100 * 1.3 &&
|
||||||
|
Util::bool(($city['pop'] - 30000) / $sumLeadershipInCity * 100)
|
||||||
|
){
|
||||||
|
return $this->chooseRecruitCrewType();
|
||||||
|
}
|
||||||
|
|
||||||
|
$recruitableCityList = $db->queryAllLists(
|
||||||
|
'SELECT city, (pop - 30000) as relPop FROM city WHERE nation = %i AND pop > %i AND supply = 1',
|
||||||
|
$nationID,
|
||||||
|
30000 + $general->getLeadership(false) * 100
|
||||||
|
);
|
||||||
|
|
||||||
|
if(!$recruitableCityList){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return ['che_NPC능동', [
|
||||||
|
'optionText'=>'순간이동',
|
||||||
|
'destCityID'=>Util::choiceRandomUsingWeightPair($recruitableCityList),
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
if(
|
if(
|
||||||
$general->getVar('crew') >= 1000 &&
|
|
||||||
$general->getVar('train') >= 90 &&
|
$general->getVar('train') >= 90 &&
|
||||||
$general->getVar('atmos') >= 90
|
$general->getVar('atmos') >= 90
|
||||||
){
|
){
|
||||||
@@ -693,27 +736,59 @@ class GeneralAI{
|
|||||||
){
|
){
|
||||||
return $this->processAttack();
|
return $this->processAttack();
|
||||||
}
|
}
|
||||||
|
if($city['front'] > 0){
|
||||||
|
//전방에 훈사까지 완료되어있으면 내정을 해야..
|
||||||
|
return null;
|
||||||
|
}
|
||||||
//TODO: 전방으로
|
//TODO: 전방으로
|
||||||
}
|
$frontCities = $db->queryFirstColumn('SELECT city FROM city WHERE nation=%i AND front > 0');
|
||||||
|
$nearCities = [];
|
||||||
|
foreach($frontCities as $frontCity){
|
||||||
|
foreach(array_keys(CityConst::byID($frontCity)->path) as $nearCity){
|
||||||
if($general->getVar('crew') >= 1000){
|
if(!key_exists($nearCity, $nearCities)){
|
||||||
if($general->getVar('train') < 90){
|
$nearCities[$nearCity] = [$frontCity];
|
||||||
$turnObj = buildGeneralCommandClass('che_훈련', $general, $env, null);
|
}
|
||||||
[$reqGold, $reqRice] = $turnObj->getCost();
|
else{
|
||||||
if($general->getVar('gold') >= $reqGold && $general->getVar('rice') >= $reqRice){
|
$nearCities[$nearCity][] = $frontCity;
|
||||||
return ['che_훈련', null];
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$attackableCities = [];
|
||||||
|
foreach($db->queryFirstColumn(
|
||||||
|
'SELECT city FROM city WHERE nation IN %li',
|
||||||
|
array_keys($this->warTargetNation)
|
||||||
|
) as $targetCity){
|
||||||
|
foreach($nearCities[$targetCity] as $attackableCity){
|
||||||
|
if(!key_exists($attackableCity, $attackableCities)){
|
||||||
|
$attackableCities[$attackableCity] = 1;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$attackableCities[$attackableCity] += 1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($general->getVar('rice') < 90){
|
return ['che_NPC능동', [
|
||||||
$turnObj = buildGeneralCommandClass('che_사기진작', $general, $env, null);
|
'optionText'=>'순간이동',
|
||||||
[$reqGold, $reqRice] = $turnObj->getCost();
|
'destCityID'=>Util::choiceRandomUsingWeight($attackableCities),
|
||||||
if($general->getVar('gold') >= $reqGold && $general->getVar('rice') >= $reqRice){
|
]];
|
||||||
return ['che_사기진작', null];
|
}
|
||||||
}
|
|
||||||
|
if($general->getVar('train') < 90){
|
||||||
|
$turnObj = buildGeneralCommandClass('che_훈련', $general, $env, null);
|
||||||
|
[$reqGold, $reqRice] = $turnObj->getCost();
|
||||||
|
if($general->getVar('gold') >= $reqGold && $general->getVar('rice') >= $reqRice){
|
||||||
|
return ['che_훈련', null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($general->getVar('rice') < 90){
|
||||||
|
$turnObj = buildGeneralCommandClass('che_사기진작', $general, $env, null);
|
||||||
|
[$reqGold, $reqRice] = $turnObj->getCost();
|
||||||
|
if($general->getVar('gold') >= $reqGold && $general->getVar('rice') >= $reqRice){
|
||||||
|
return ['che_사기진작', null];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -721,8 +796,7 @@ class GeneralAI{
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$recruitCommand = $this->chooseRecruitCrewType();
|
|
||||||
//TODO: 징병 가능한 도시인가? 불가능하다면?
|
|
||||||
return $recruitCommand;
|
return $recruitCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user