fix: div 0
This commit is contained in:
+76
-76
@@ -97,7 +97,7 @@ class GeneralAI
|
|||||||
else{
|
else{
|
||||||
$this->city = $general->getRawCity();
|
$this->city = $general->getRawCity();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->nation = $db->queryFirstRow(
|
$this->nation = $db->queryFirstRow(
|
||||||
'SELECT nation,name,color,capital,capset,gennum,gold,rice,bill,rate,rate_tmp,scout,war,strategic_cmd_limit,surlimit,tech,power,level,chief_set,type,aux FROM nation WHERE nation = %i',
|
'SELECT nation,name,color,capital,capset,gennum,gold,rice,bill,rate,rate_tmp,scout,war,strategic_cmd_limit,surlimit,tech,power,level,chief_set,type,aux FROM nation WHERE nation = %i',
|
||||||
$general->getNationID()
|
$general->getNationID()
|
||||||
@@ -144,7 +144,7 @@ class GeneralAI
|
|||||||
$this->fullStrength = $general->getStrength(false);
|
$this->fullStrength = $general->getStrength(false);
|
||||||
$this->fullIntel = $general->getIntel(false);
|
$this->fullIntel = $general->getIntel(false);
|
||||||
|
|
||||||
|
|
||||||
$this->genType = $this->calcGenType($general);
|
$this->genType = $this->calcGenType($general);
|
||||||
|
|
||||||
$this->calcDiplomacyState();
|
$this->calcDiplomacyState();
|
||||||
@@ -184,7 +184,7 @@ class GeneralAI
|
|||||||
$genType |= self::t통솔장;
|
$genType |= self::t통솔장;
|
||||||
}
|
}
|
||||||
return $genType;
|
return $genType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function calcDiplomacyState()
|
protected function calcDiplomacyState()
|
||||||
@@ -228,9 +228,9 @@ class GeneralAI
|
|||||||
if(!$onWar && !$onWarReady && !$onWarYet){
|
if(!$onWar && !$onWarReady && !$onWarYet){
|
||||||
$warTargetNation[0] = 1;
|
$warTargetNation[0] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->warTargetNation = $warTargetNation;
|
$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) {
|
||||||
@@ -271,7 +271,7 @@ class GeneralAI
|
|||||||
}
|
}
|
||||||
$this->calcWarRoute();
|
$this->calcWarRoute();
|
||||||
$troopCandidate = [];
|
$troopCandidate = [];
|
||||||
|
|
||||||
$chiefTurn = cutTurn($this->general->getTurnTime(), $this->env['turnterm']);
|
$chiefTurn = cutTurn($this->general->getTurnTime(), $this->env['turnterm']);
|
||||||
$yearMonth = Util::joinYearMonth($this->env['year'], $this->env['month']);
|
$yearMonth = Util::joinYearMonth($this->env['year'], $this->env['month']);
|
||||||
|
|
||||||
@@ -319,8 +319,8 @@ class GeneralAI
|
|||||||
$troopCandidate[] = [$leaderID, Util::choiceRandom($this->frontCities)['city']];
|
$troopCandidate[] = [$leaderID, Util::choiceRandom($this->frontCities)['city']];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//출발지가 아국땅이 아닌경우 수도->출발지
|
//출발지가 아국땅이 아닌경우 수도->출발지
|
||||||
if(!key_exists($fromCityID, $this->supplyCities)){
|
if(!key_exists($fromCityID, $this->supplyCities)){
|
||||||
$toCityID = $fromCityID;
|
$toCityID = $fromCityID;
|
||||||
@@ -377,7 +377,7 @@ class GeneralAI
|
|||||||
|
|
||||||
$chiefTurn = cutTurn($this->general->getTurnTime(), $this->env['turnterm']);
|
$chiefTurn = cutTurn($this->general->getTurnTime(), $this->env['turnterm']);
|
||||||
$yearMonth = Util::joinYearMonth($this->env['year'], $this->env['month']);
|
$yearMonth = Util::joinYearMonth($this->env['year'], $this->env['month']);
|
||||||
|
|
||||||
$troopCandidate = [];
|
$troopCandidate = [];
|
||||||
foreach($this->troopLeaders as $troopLeader){
|
foreach($this->troopLeaders as $troopLeader){
|
||||||
$leaderID = $troopLeader->getID();
|
$leaderID = $troopLeader->getID();
|
||||||
@@ -416,7 +416,7 @@ class GeneralAI
|
|||||||
if(!$troopCandidate){
|
if(!$troopCandidate){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($this->supplyCities) == 1){
|
if(count($this->supplyCities) == 1){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -485,7 +485,7 @@ class GeneralAI
|
|||||||
if(!$troopCandidate){
|
if(!$troopCandidate){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cityCandidates = [];
|
$cityCandidates = [];
|
||||||
|
|
||||||
foreach($this->frontCities as $city){
|
foreach($this->frontCities as $city){
|
||||||
@@ -679,7 +679,7 @@ class GeneralAI
|
|||||||
if($pop_ratio < $this->nationPolicy->safeRecruitCityPopulationRatio){
|
if($pop_ratio < $this->nationPolicy->safeRecruitCityPopulationRatio){
|
||||||
$pop_ratio /= 4;
|
$pop_ratio /= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
$recruitableCityList[$cityID] = $pop_ratio;
|
$recruitableCityList[$cityID] = $pop_ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -746,9 +746,9 @@ class GeneralAI
|
|||||||
$troopID = $lostGeneral->getVar('troop');
|
$troopID = $lostGeneral->getVar('troop');
|
||||||
if($troopID && key_exists($troopID, $this->troopLeaders)){
|
if($troopID && key_exists($troopID, $this->troopLeaders)){
|
||||||
$troopLeader = $this->troopLeaders[$troopID];
|
$troopLeader = $this->troopLeaders[$troopID];
|
||||||
|
|
||||||
if(
|
if(
|
||||||
key_exists($troopLeader->getCityID(), $this->supplyCities) &&
|
key_exists($troopLeader->getCityID(), $this->supplyCities) &&
|
||||||
$this->troopLeaders[$troopID]->getTurnTime() < $lostGeneral->getTurnTime()
|
$this->troopLeaders[$troopID]->getTurnTime() < $lostGeneral->getTurnTime()
|
||||||
){
|
){
|
||||||
//이미 탈출 가능한 부대를 탔다
|
//이미 탈출 가능한 부대를 탔다
|
||||||
@@ -770,10 +770,10 @@ class GeneralAI
|
|||||||
if(!$args){
|
if(!$args){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$arg = Util::choiceRandom($args);
|
$arg = Util::choiceRandom($args);
|
||||||
$cmd = buildNationCommandClass('che_발령', $this->general, $this->env, $lastTurn, $arg);
|
$cmd = buildNationCommandClass('che_발령', $this->general, $this->env, $lastTurn, $arg);
|
||||||
|
|
||||||
if(!$cmd->hasFullConditionMet()){
|
if(!$cmd->hasFullConditionMet()){
|
||||||
LogText('구출실패', [$arg, $cmd->getFailString()]);
|
LogText('구출실패', [$arg, $cmd->getFailString()]);
|
||||||
return null;
|
return null;
|
||||||
@@ -840,7 +840,7 @@ class GeneralAI
|
|||||||
|
|
||||||
return $cmd;
|
return $cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function do유저장내정발령(LastTurn $lastTurn): ?NationCommand
|
protected function do유저장내정발령(LastTurn $lastTurn): ?NationCommand
|
||||||
{
|
{
|
||||||
if(!$this->nation['capital']){
|
if(!$this->nation['capital']){
|
||||||
@@ -870,7 +870,7 @@ class GeneralAI
|
|||||||
if(!key_exists($cityID, $this->supplyCities)){
|
if(!key_exists($cityID, $this->supplyCities)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$city = $this->supplyCities[$cityID];
|
$city = $this->supplyCities[$cityID];
|
||||||
|
|
||||||
if($city['dev'] < 0.95){
|
if($city['dev'] < 0.95){
|
||||||
@@ -980,7 +980,7 @@ class GeneralAI
|
|||||||
if($pop_ratio < $this->nationPolicy->safeRecruitCityPopulationRatio){
|
if($pop_ratio < $this->nationPolicy->safeRecruitCityPopulationRatio){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$recruitableCityList[$cityID] = $pop_ratio;
|
$recruitableCityList[$cityID] = $pop_ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1227,7 +1227,7 @@ class GeneralAI
|
|||||||
$reqMoney = max($reqMoney, $reqHumanMinRes);
|
$reqMoney = max($reqMoney, $reqHumanMinRes);
|
||||||
}
|
}
|
||||||
$enoughMoney = $reqMoney * 1.1;
|
$enoughMoney = $reqMoney * 1.1;
|
||||||
|
|
||||||
if ($targetUserGeneral->getVar($resName) >= $reqMoney) {
|
if ($targetUserGeneral->getVar($resName) >= $reqMoney) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1257,9 +1257,9 @@ class GeneralAI
|
|||||||
if(!$candidateArgs){
|
if(!$candidateArgs){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmd = buildNationCommandClass(
|
$cmd = buildNationCommandClass(
|
||||||
'che_포상', $this->general, $this->env, $lastTurn,
|
'che_포상', $this->general, $this->env, $lastTurn,
|
||||||
Util::choiceRandomUsingWeightPair($candidateArgs)
|
Util::choiceRandomUsingWeightPair($candidateArgs)
|
||||||
);
|
);
|
||||||
if(!$cmd->hasFullConditionMet()){
|
if(!$cmd->hasFullConditionMet()){
|
||||||
@@ -1295,7 +1295,7 @@ class GeneralAI
|
|||||||
|
|
||||||
|
|
||||||
$userGenerals = $this->userGenerals;
|
$userGenerals = $this->userGenerals;
|
||||||
|
|
||||||
|
|
||||||
foreach($remainResource as $resName=>[$reqNationRes, $resVal,$reqHumanMinWarRes,$reqHumanMinDevelRes]){
|
foreach($remainResource as $resName=>[$reqNationRes, $resVal,$reqHumanMinWarRes,$reqHumanMinDevelRes]){
|
||||||
if($resVal < $reqNationRes){
|
if($resVal < $reqNationRes){
|
||||||
@@ -1333,7 +1333,7 @@ class GeneralAI
|
|||||||
$reqMoney = max($reqMoney, $reqHumanMinRes);
|
$reqMoney = max($reqMoney, $reqHumanMinRes);
|
||||||
}
|
}
|
||||||
$enoughMoney = $reqMoney * 1.2;
|
$enoughMoney = $reqMoney * 1.2;
|
||||||
|
|
||||||
if ($targetUserGeneral->getVar($resName) >= $reqMoney) {
|
if ($targetUserGeneral->getVar($resName) >= $reqMoney) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1360,13 +1360,13 @@ class GeneralAI
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$candidateArgs){
|
if(!$candidateArgs){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmd = buildNationCommandClass(
|
$cmd = buildNationCommandClass(
|
||||||
'che_포상', $this->general, $this->env, $lastTurn,
|
'che_포상', $this->general, $this->env, $lastTurn,
|
||||||
Util::choiceRandomUsingWeightPair($candidateArgs)
|
Util::choiceRandomUsingWeightPair($candidateArgs)
|
||||||
);
|
);
|
||||||
if(!$cmd->hasFullConditionMet()){
|
if(!$cmd->hasFullConditionMet()){
|
||||||
@@ -1422,7 +1422,7 @@ class GeneralAI
|
|||||||
$reqMoney = max($reqMoney, $reqNPCMinWarRes);
|
$reqMoney = max($reqMoney, $reqNPCMinWarRes);
|
||||||
}
|
}
|
||||||
$enoughMoney = $reqMoney * 1.2;
|
$enoughMoney = $reqMoney * 1.2;
|
||||||
|
|
||||||
if ($targetNPCGeneral->getVar($resName) >= $reqMoney) {
|
if ($targetNPCGeneral->getVar($resName) >= $reqMoney) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1453,9 +1453,9 @@ class GeneralAI
|
|||||||
if(!$candidateArgs){
|
if(!$candidateArgs){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmd = buildNationCommandClass(
|
$cmd = buildNationCommandClass(
|
||||||
'che_포상', $this->general, $this->env, $lastTurn,
|
'che_포상', $this->general, $this->env, $lastTurn,
|
||||||
Util::choiceRandomUsingWeightPair($candidateArgs)
|
Util::choiceRandomUsingWeightPair($candidateArgs)
|
||||||
);
|
);
|
||||||
if(!$cmd->hasFullConditionMet()){
|
if(!$cmd->hasFullConditionMet()){
|
||||||
@@ -1514,7 +1514,7 @@ class GeneralAI
|
|||||||
$reqMoney = max($reqMoney, $reqNPCMinWarRes);
|
$reqMoney = max($reqMoney, $reqNPCMinWarRes);
|
||||||
}
|
}
|
||||||
$enoughMoney = $reqMoney * 1.5;
|
$enoughMoney = $reqMoney * 1.5;
|
||||||
|
|
||||||
if ($targetNPCGeneral->getVar($resName) >= $reqMoney) {
|
if ($targetNPCGeneral->getVar($resName) >= $reqMoney) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1570,9 +1570,9 @@ class GeneralAI
|
|||||||
if(!$candidateArgs){
|
if(!$candidateArgs){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmd = buildNationCommandClass(
|
$cmd = buildNationCommandClass(
|
||||||
'che_포상', $this->general, $this->env, $lastTurn,
|
'che_포상', $this->general, $this->env, $lastTurn,
|
||||||
Util::choiceRandomUsingWeightPair($candidateArgs)
|
Util::choiceRandomUsingWeightPair($candidateArgs)
|
||||||
);
|
);
|
||||||
if(!$cmd->hasFullConditionMet()){
|
if(!$cmd->hasFullConditionMet()){
|
||||||
@@ -1654,14 +1654,14 @@ class GeneralAI
|
|||||||
return -($lhs->getVar($resName) <=> $rhs->getVar($resName));
|
return -($lhs->getVar($resName) <=> $rhs->getVar($resName));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach($npcWarGenerals as $idx=>$targetNPCGeneral){
|
foreach($npcWarGenerals as $idx=>$targetNPCGeneral){
|
||||||
if($willTakeSmallAmount){
|
if($willTakeSmallAmount){
|
||||||
if($targetNPCGeneral->getVar($resName) <= $reqNPCMinWarRes * 2){
|
if($targetNPCGeneral->getVar($resName) <= $reqNPCMinWarRes * 2){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if($targetNPCGeneral->getVar($resName) <= $reqNPCMinWarRes){
|
else if($targetNPCGeneral->getVar($resName) <= $reqNPCMinWarRes){
|
||||||
break;
|
break;
|
||||||
@@ -1700,9 +1700,9 @@ class GeneralAI
|
|||||||
if(!$candidateArgs){
|
if(!$candidateArgs){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmd = buildNationCommandClass(
|
$cmd = buildNationCommandClass(
|
||||||
'che_몰수', $this->general, $this->env, $lastTurn,
|
'che_몰수', $this->general, $this->env, $lastTurn,
|
||||||
Util::choiceRandomUsingWeightPair($candidateArgs)
|
Util::choiceRandomUsingWeightPair($candidateArgs)
|
||||||
);
|
);
|
||||||
if(!$cmd->hasFullConditionMet()){
|
if(!$cmd->hasFullConditionMet()){
|
||||||
@@ -1777,7 +1777,7 @@ class GeneralAI
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[$targetYear, $targetMonth] = Util::parseYearMonth($yearMonth + $diplomatMonth);
|
[$targetYear, $targetMonth] = Util::parseYearMonth($yearMonth + $diplomatMonth);
|
||||||
|
|
||||||
$cmd = buildNationCommandClass('che_불가침제의', $this->general, $this->env, $lastTurn, [
|
$cmd = buildNationCommandClass('che_불가침제의', $this->general, $this->env, $lastTurn, [
|
||||||
@@ -1788,10 +1788,10 @@ class GeneralAI
|
|||||||
if(!$cmd->hasFullConditionMet()){
|
if(!$cmd->hasFullConditionMet()){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$respAssistTry["n{$destNationID}"] = [$destNationID, $yearMonth];
|
$respAssistTry["n{$destNationID}"] = [$destNationID, $yearMonth];
|
||||||
$nationStor->setValue('resp_assist_try', $respAssistTry);
|
$nationStor->setValue('resp_assist_try', $respAssistTry);
|
||||||
|
|
||||||
return $cmd;
|
return $cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1900,7 +1900,7 @@ class GeneralAI
|
|||||||
else{
|
else{
|
||||||
$warNations[$destNationID] = 1 / sqrt($destNationPower + 1);
|
$warNations[$destNationID] = 1 / sqrt($destNationPower + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!$nations) {
|
if (!$nations) {
|
||||||
if(!$warNations){
|
if(!$warNations){
|
||||||
@@ -1964,7 +1964,7 @@ class GeneralAI
|
|||||||
|
|
||||||
|
|
||||||
//checkSupply()와 비슷하면서 다름
|
//checkSupply()와 비슷하면서 다름
|
||||||
|
|
||||||
$nationCityIDList = [];
|
$nationCityIDList = [];
|
||||||
$this->categorizeNationCities();
|
$this->categorizeNationCities();
|
||||||
foreach($this->nationCities as $city){
|
foreach($this->nationCities as $city){
|
||||||
@@ -1987,7 +1987,7 @@ class GeneralAI
|
|||||||
//수도와 연결된 도시 탐색
|
//수도와 연결된 도시 탐색
|
||||||
while(!$queue->isEmpty()){
|
while(!$queue->isEmpty()){
|
||||||
$cityID = $queue->dequeue();
|
$cityID = $queue->dequeue();
|
||||||
|
|
||||||
foreach(array_keys(CityConst::byID($cityID)->path) as $nextCityID){
|
foreach(array_keys(CityConst::byID($cityID)->path) as $nextCityID){
|
||||||
if(!key_exists($nextCityID, $nationCityIDList)){
|
if(!key_exists($nextCityID, $nationCityIDList)){
|
||||||
continue;
|
continue;
|
||||||
@@ -2049,7 +2049,7 @@ class GeneralAI
|
|||||||
}
|
}
|
||||||
$targetCityID = Util::choiceRandom($candidates);
|
$targetCityID = Util::choiceRandom($candidates);
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmd = buildNationCommandClass('che_천도', $this->general, $this->env, $lastTurn, [
|
$cmd = buildNationCommandClass('che_천도', $this->general, $this->env, $lastTurn, [
|
||||||
'destCityID'=>$targetCityID
|
'destCityID'=>$targetCityID
|
||||||
]);
|
]);
|
||||||
@@ -2058,7 +2058,7 @@ class GeneralAI
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$nationStor->last천도Trial = [$general->getVar('officer_level'), $general->getTurnTime()];
|
$nationStor->last천도Trial = [$general->getVar('officer_level'), $general->getTurnTime()];
|
||||||
return $cmd;
|
return $cmd;
|
||||||
}
|
}
|
||||||
@@ -2332,7 +2332,7 @@ class GeneralAI
|
|||||||
|
|
||||||
$absGold = $general->getVar('gold');
|
$absGold = $general->getVar('gold');
|
||||||
$absRice = $general->getVar('rice');
|
$absRice = $general->getVar('rice');
|
||||||
|
|
||||||
$relGold = $absGold;
|
$relGold = $absGold;
|
||||||
$relRice = $absRice * $deathRate;
|
$relRice = $absRice * $deathRate;
|
||||||
|
|
||||||
@@ -2374,7 +2374,7 @@ class GeneralAI
|
|||||||
{
|
{
|
||||||
$tryBuying = true;
|
$tryBuying = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if($relRice * 2 < $relGold && $relRice < $riceCost * 3)
|
if($relRice * 2 < $relGold && $relRice < $riceCost * 3)
|
||||||
@@ -2409,7 +2409,7 @@ class GeneralAI
|
|||||||
{
|
{
|
||||||
$trySelling = true;
|
$trySelling = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if($relGold * 2 < $relRice && $relGold < $goldCost * 3)
|
if($relGold * 2 < $relRice && $relGold < $goldCost * 3)
|
||||||
@@ -2433,7 +2433,7 @@ class GeneralAI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -2448,7 +2448,7 @@ class GeneralAI
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$general = $this->getGeneralObj();
|
$general = $this->getGeneralObj();
|
||||||
$city = $this->city;
|
$city = $this->city;
|
||||||
@@ -2470,7 +2470,7 @@ class GeneralAI
|
|||||||
(Util::randF($remainPop/$maxPop))){
|
(Util::randF($remainPop/$maxPop))){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$nationID = $general->getNationID();
|
$nationID = $general->getNationID();
|
||||||
@@ -2499,7 +2499,7 @@ class GeneralAI
|
|||||||
GameUnitConst::T_WIZARD => sqrt($general->getVar('dex4') + 500),
|
GameUnitConst::T_WIZARD => sqrt($general->getVar('dex4') + 500),
|
||||||
GameUnitConst::T_SIEGE => sqrt($general->getVar('dex5') + 500),
|
GameUnitConst::T_SIEGE => sqrt($general->getVar('dex5') + 500),
|
||||||
];
|
];
|
||||||
|
|
||||||
$availableArmType = [];
|
$availableArmType = [];
|
||||||
if($this->fullStrength > $this->fullIntel * 0.9){
|
if($this->fullStrength > $this->fullIntel * 0.9){
|
||||||
$availableArmType[GameUnitConst::T_FOOTMAN] = $dex[GameUnitConst::T_FOOTMAN] * $this->fullStrength;
|
$availableArmType[GameUnitConst::T_FOOTMAN] = $dex[GameUnitConst::T_FOOTMAN] * $this->fullStrength;
|
||||||
@@ -2548,7 +2548,7 @@ class GeneralAI
|
|||||||
//굳이 뽑은 이유가 있겠지
|
//굳이 뽑은 이유가 있겠지
|
||||||
$type = $currCrewType->id;
|
$type = $currCrewType->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//XXX: 훈련, 사기진작 금액을 하드코딩으로 계산중
|
//XXX: 훈련, 사기진작 금액을 하드코딩으로 계산중
|
||||||
@@ -2566,7 +2566,7 @@ class GeneralAI
|
|||||||
|
|
||||||
$riceCost = $crewType->riceWithTech(
|
$riceCost = $crewType->riceWithTech(
|
||||||
$this->nation['tech'],
|
$this->nation['tech'],
|
||||||
$this->fullLeadership*100 *
|
$this->fullLeadership*100 *
|
||||||
$general->getRankVar('killcrew')/max($general->getRankVar('deathcrew'),1)*1.2
|
$general->getRankVar('killcrew')/max($general->getRankVar('deathcrew'),1)*1.2
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2584,7 +2584,7 @@ class GeneralAI
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else if($gold < $cost && $gold * 2 >= $cost){
|
else if($gold < $cost && $gold * 2 >= $cost){
|
||||||
$crew *= 0.5;
|
$crew *= 0.5;
|
||||||
$riceCost *= 0.5;
|
$riceCost *= 0.5;
|
||||||
$crew = Util::round($crew-49, -2);
|
$crew = Util::round($crew-49, -2);
|
||||||
$cmd = buildGeneralCommandClass('che_징병', $general, $env, [
|
$cmd = buildGeneralCommandClass('che_징병', $general, $env, [
|
||||||
@@ -2597,7 +2597,7 @@ class GeneralAI
|
|||||||
//이 쌀도 없어?
|
//이 쌀도 없어?
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$cmd->hasFullConditionMet()){
|
if(!$cmd->hasFullConditionMet()){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -2749,7 +2749,7 @@ class GeneralAI
|
|||||||
|
|
||||||
foreach($resourceMap as [$resKey, $reqNation, $reqNPCWar, $reqNPCDevel]){
|
foreach($resourceMap as [$resKey, $reqNation, $reqNPCWar, $reqNPCDevel]){
|
||||||
$genRes = $general->getVar($resKey);
|
$genRes = $general->getVar($resKey);
|
||||||
|
|
||||||
if($this->genType & self::t통솔장){
|
if($this->genType & self::t통솔장){
|
||||||
$reqRes = $reqNPCWar;
|
$reqRes = $reqNPCWar;
|
||||||
}
|
}
|
||||||
@@ -2794,7 +2794,7 @@ class GeneralAI
|
|||||||
if($genRes < $reqRes * 1.5){
|
if($genRes < $reqRes * 1.5){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(!Util::randBool(($genRes / $reqRes)-0.5)){
|
if($reqRes > 0 && !Util::randBool(($genRes / $reqRes)-0.5)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$amount = $genRes - $reqRes;
|
$amount = $genRes - $reqRes;
|
||||||
@@ -2917,7 +2917,7 @@ class GeneralAI
|
|||||||
'optionText' => '순간이동',
|
'optionText' => '순간이동',
|
||||||
'destCityID' => Util::choiceRandomUsingWeight($recruitableCityList),
|
'destCityID' => Util::choiceRandomUsingWeight($recruitableCityList),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
if(!$cmd->hasFullConditionMet()){
|
if(!$cmd->hasFullConditionMet()){
|
||||||
LogText("{$this->general->getName()}, {$this->general->getID()} 후방워프 불가: 조건 불충족", $cmd->getArg());
|
LogText("{$this->general->getName()}, {$this->general->getID()} 후방워프 불가: 조건 불충족", $cmd->getArg());
|
||||||
@@ -2969,7 +2969,7 @@ class GeneralAI
|
|||||||
'optionText' => '순간이동',
|
'optionText' => '순간이동',
|
||||||
'destCityID' => Util::choiceRandomUsingWeight($candidateCities),
|
'destCityID' => Util::choiceRandomUsingWeight($candidateCities),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
if(!$cmd->hasFullConditionMet()){
|
if(!$cmd->hasFullConditionMet()){
|
||||||
return null;
|
return null;
|
||||||
@@ -2986,7 +2986,7 @@ class GeneralAI
|
|||||||
if(($this->genType & self::t통솔장)&&in_array($this->dipState, [self::d징병, self::d직전, self::d전쟁])){
|
if(($this->genType & self::t통솔장)&&in_array($this->dipState, [self::d징병, self::d직전, self::d전쟁])){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$city = $this->city;
|
$city = $this->city;
|
||||||
if(Util::randBool(0.6)){
|
if(Util::randBool(0.6)){
|
||||||
return null;
|
return null;
|
||||||
@@ -3028,9 +3028,9 @@ class GeneralAI
|
|||||||
$realDevelRate += $develVal;
|
$realDevelRate += $develVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$realDevelRate /= $availableTypeCnt;
|
$realDevelRate /= $availableTypeCnt;
|
||||||
|
|
||||||
if($realDevelRate >= 0.95){
|
if($realDevelRate >= 0.95){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -3158,7 +3158,7 @@ class GeneralAI
|
|||||||
|
|
||||||
$prop = Util::randF() * (GameConst::$defaultStatNPCMax + GameConst::$chiefStatMin) / 2;
|
$prop = Util::randF() * (GameConst::$defaultStatNPCMax + GameConst::$chiefStatMin) / 2;
|
||||||
$ratio = ($this->fullLeadership + $this->fullStrength + $this->fullIntel) / 3;
|
$ratio = ($this->fullLeadership + $this->fullStrength + $this->fullIntel) / 3;
|
||||||
|
|
||||||
|
|
||||||
if($prop >= $ratio){
|
if($prop >= $ratio){
|
||||||
return null;
|
return null;
|
||||||
@@ -3251,7 +3251,7 @@ class GeneralAI
|
|||||||
if ($nationCnt == 0 || $notFullNationCnt == 0) {
|
if ($nationCnt == 0 || $notFullNationCnt == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Util::randBool(pow(1 / ($nationCnt + 1) / pow($notFullNationCnt, 3), 1 / 4))) {
|
if (Util::randBool(pow(1 / ($nationCnt + 1) / pow($notFullNationCnt, 3), 1 / 4))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -3355,7 +3355,7 @@ class GeneralAI
|
|||||||
$nationID = $nation['nation'];
|
$nationID = $nation['nation'];
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$nationCities = [];
|
$nationCities = [];
|
||||||
$frontCities = [];
|
$frontCities = [];
|
||||||
$supplyCities = [];
|
$supplyCities = [];
|
||||||
@@ -3399,7 +3399,7 @@ class GeneralAI
|
|||||||
$userGenerals = [];
|
$userGenerals = [];
|
||||||
$userCivilGenerals = [];
|
$userCivilGenerals = [];
|
||||||
$userWarGenerals = [];
|
$userWarGenerals = [];
|
||||||
|
|
||||||
$lostGenerals = [];
|
$lostGenerals = [];
|
||||||
$npcCivilGenerals = [];
|
$npcCivilGenerals = [];
|
||||||
$npcWarGenerals = [];
|
$npcWarGenerals = [];
|
||||||
@@ -3541,7 +3541,7 @@ class GeneralAI
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->nationPolicy->priority as $actionName){
|
foreach($this->nationPolicy->priority as $actionName){
|
||||||
|
|
||||||
if(!property_exists($this->nationPolicy, 'can'.$actionName)){
|
if(!property_exists($this->nationPolicy, 'can'.$actionName)){
|
||||||
trigger_error ("can{$actionName}이 없음", E_USER_NOTICE );
|
trigger_error ("can{$actionName}이 없음", E_USER_NOTICE );
|
||||||
continue;
|
continue;
|
||||||
@@ -3625,7 +3625,7 @@ class GeneralAI
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($npcType == 5){
|
if($npcType == 5){
|
||||||
if($general->getNationID()==0){
|
if($general->getNationID()==0){
|
||||||
$general->setVar('killturn', 1);
|
$general->setVar('killturn', 1);
|
||||||
@@ -3765,10 +3765,10 @@ class GeneralAI
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$picked = false;
|
$picked = false;
|
||||||
foreach(Util::range(5) as $idx){
|
foreach(Util::range(5) as $idx){
|
||||||
|
|
||||||
/** @var General */
|
/** @var General */
|
||||||
if($this->npcWarGenerals){
|
if($this->npcWarGenerals){
|
||||||
$randGeneral = Util::choiceRandom($this->npcWarGenerals);
|
$randGeneral = Util::choiceRandom($this->npcWarGenerals);
|
||||||
@@ -3785,7 +3785,7 @@ class GeneralAI
|
|||||||
else{
|
else{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($randGeneral->getVar('officer_level') != 1){
|
if($randGeneral->getVar('officer_level') != 1){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -3864,7 +3864,7 @@ class GeneralAI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$minBelong = min($this->general->getVar('belong') - 1, 3);
|
$minBelong = min($this->general->getVar('belong') - 1, 3);
|
||||||
$updatedChiefSet = 0;
|
$updatedChiefSet = 0;
|
||||||
@@ -3910,7 +3910,7 @@ class GeneralAI
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach(Util::range(11, $minChiefLevel-1, -1) as $chiefLevel) {
|
foreach(Util::range(11, $minChiefLevel-1, -1) as $chiefLevel) {
|
||||||
if(isOfficerSet($nation['chief_set'], $chiefLevel)){
|
if(isOfficerSet($nation['chief_set'], $chiefLevel)){
|
||||||
continue;
|
continue;
|
||||||
@@ -3918,7 +3918,7 @@ class GeneralAI
|
|||||||
if($this->general->getVar('officer_level') === $chiefLevel){
|
if($this->general->getVar('officer_level') === $chiefLevel){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(key_exists($chiefLevel, $this->chiefGenerals)){
|
if(key_exists($chiefLevel, $this->chiefGenerals)){
|
||||||
$oldChief = $this->chiefGenerals[$chiefLevel];
|
$oldChief = $this->chiefGenerals[$chiefLevel];
|
||||||
if($oldChief->getNPCType() < 2 && $oldChief->getVar('killturn') >= $minChiefLevel){
|
if($oldChief->getNPCType() < 2 && $oldChief->getVar('killturn') >= $minChiefLevel){
|
||||||
@@ -3964,7 +3964,7 @@ class GeneralAI
|
|||||||
}
|
}
|
||||||
|
|
||||||
$newChief = $general;
|
$newChief = $general;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$newChief){
|
if(!$newChief){
|
||||||
|
|||||||
Reference in New Issue
Block a user