버그 수정
This commit is contained in:
@@ -151,7 +151,7 @@ function _setNationCommand(int $nationID, int $level, array $turnList, string $c
|
|||||||
$db->update('nation_turn', [
|
$db->update('nation_turn', [
|
||||||
'action'=>$command,
|
'action'=>$command,
|
||||||
'arg'=>Json::encode($arg, JSON::EMPTY_ARRAY_IS_DICT)
|
'arg'=>Json::encode($arg, JSON::EMPTY_ARRAY_IS_DICT)
|
||||||
], 'nation_id = %i AND level = %i AND turn_idx IN %li', $generalID, $level, $turnList);
|
], 'nation_id = %i AND level = %i AND turn_idx IN %li', $nationID, $level, $turnList);
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkCommandArg(?array $arg):?string{
|
function checkCommandArg(?array $arg):?string{
|
||||||
@@ -221,7 +221,7 @@ function setGeneralCommand(int $generalID, array $turnList, string $command, ?ar
|
|||||||
$general = General::createGeneralObjFromDB($generalID);
|
$general = General::createGeneralObjFromDB($generalID);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$commandObj = buildGeneralCommandClass($action, $general, $env, $arg);
|
$commandObj = buildGeneralCommandClass($command, $general, $env, $arg);
|
||||||
}
|
}
|
||||||
catch (\InvalidArgumentException $e){
|
catch (\InvalidArgumentException $e){
|
||||||
return [
|
return [
|
||||||
@@ -292,7 +292,7 @@ function setNationCommand(int $generalID, array $turnList, string $command, ?arr
|
|||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$commandObj = buildNationCommandClass($action, $general, $env, $arg);
|
$commandObj = buildNationCommandClass($command, $general, $env, $general->getLastTurn(), $arg);
|
||||||
}
|
}
|
||||||
catch (\InvalidArgumentException $e){
|
catch (\InvalidArgumentException $e){
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ abstract class BaseCommand{
|
|||||||
'destNation'=>$this->destNation,
|
'destNation'=>$this->destNation,
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->reasonNotReservable = Constraint::testAll($this->reservableConstraints, $constraintInput);
|
$this->reasonNotReservable = Constraint::testAll($this->reservableConstraints??[], $constraintInput);
|
||||||
$this->reservable = $this->reasonNotReservable === null;
|
$this->reservable = $this->reasonNotReservable === null;
|
||||||
return $this->reasonNotReservable;
|
return $this->reasonNotReservable;
|
||||||
}
|
}
|
||||||
@@ -289,7 +289,7 @@ abstract class BaseCommand{
|
|||||||
'destNation'=>$this->destNation,
|
'destNation'=>$this->destNation,
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->reasonNotRunnable = Constraint::testAll($this->runnableConstraints, $constraintInput);
|
$this->reasonNotRunnable = Constraint::testAll($this->runnableConstraints??[], $constraintInput);
|
||||||
$this->runnable = $this->reasonNotRunnable === null;
|
$this->runnable = $this->reasonNotRunnable === null;
|
||||||
return $this->reasonNotRunnable;
|
return $this->reasonNotRunnable;
|
||||||
|
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ class che_강행 extends Command\GeneralCommand{
|
|||||||
$general->checkStatChange();
|
$general->checkStatChange();
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ class che_건국 extends Command\GeneralCommand{
|
|||||||
'level'=>1,
|
'level'=>1,
|
||||||
'type'=>$nationType,
|
'type'=>$nationType,
|
||||||
'capital'=>$general->getCityID()
|
'capital'=>$general->getCityID()
|
||||||
], 'nation=%i', $destNationID);
|
], 'nation=%i', $general->getNationID());
|
||||||
|
|
||||||
refreshNationStaticInfo();
|
refreshNationStaticInfo();
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace sammo\Command\General;
|
|||||||
use \sammo\Command;
|
use \sammo\Command;
|
||||||
use \sammo\Util;
|
use \sammo\Util;
|
||||||
use \sammo\JosaUtil;
|
use \sammo\JosaUtil;
|
||||||
|
use \sammo\LastTurn;
|
||||||
|
|
||||||
class 휴식 extends Command\GeneralCommand{
|
class 휴식 extends Command\GeneralCommand{
|
||||||
static protected $actionName = '휴식';
|
static protected $actionName = '휴식';
|
||||||
@@ -13,7 +14,8 @@ class 휴식 extends Command\GeneralCommand{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function init(){
|
protected function init(){
|
||||||
//아무것도 하지 않음
|
$this->runnableConstraints=[
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost():array{
|
public function getCost():array{
|
||||||
|
|||||||
+44
-45
@@ -66,12 +66,12 @@ class GeneralAI{
|
|||||||
'name'=>'재야',
|
'name'=>'재야',
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->calcGenType();
|
|
||||||
|
|
||||||
$this->leadership = $general->getLeadership(true, true, true, true);
|
$this->leadership = $general->getLeadership(true, true, true, true);
|
||||||
$this->power = $general->getPower(true, true, true, true);
|
$this->power = $general->getPower(true, true, true, true);
|
||||||
$this->intel = $general->getIntel(true, true, true, true);
|
$this->intel = $general->getIntel(true, true, true, true);
|
||||||
|
|
||||||
|
$this->calcGenType();
|
||||||
|
|
||||||
$this->calcDiplomacyState();
|
$this->calcDiplomacyState();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ class GeneralAI{
|
|||||||
//지장
|
//지장
|
||||||
} else {
|
} else {
|
||||||
$genType = self::t지장;
|
$genType = self::t지장;
|
||||||
if ($power >= $intel * 0.8 && Util::randBol(0.2)) { //지무장
|
if ($power >= $intel * 0.8 && Util::randBool(0.2)) { //지무장
|
||||||
if(Util::randBool($power / $intel / 2)){
|
if(Util::randBool($power / $intel / 2)){
|
||||||
$genType |= self::t무장;
|
$genType |= self::t무장;
|
||||||
}
|
}
|
||||||
@@ -545,9 +545,9 @@ class GeneralAI{
|
|||||||
$npcCivilGenerals = [];
|
$npcCivilGenerals = [];
|
||||||
$npcWarGenerals = [];
|
$npcWarGenerals = [];
|
||||||
|
|
||||||
foreach($db->query('SELECT `no`, nation, city, npc, `gold`, `rice`, leader, `power`, intel, killturn, crew, train, atmos, `level`, troop FROM general WHERE nation = %i', $nationID) as $nationGeneral) {
|
foreach($db->query('SELECT `no`, nation, city, npc, `gold`, `rice`, leader, `power`, intel, killturn, crew, train, atmos, `level`, troop FROM general WHERE nation = %i', $nationID) as $rawNationGeneral) {
|
||||||
|
|
||||||
$nationGeneralObj = (object)$nationGeneral;
|
$nationGeneral = (object)$rawNationGeneral;
|
||||||
$cityID = $nationGeneral->city;
|
$cityID = $nationGeneral->city;
|
||||||
$generalID = $nationGeneral->no;
|
$generalID = $nationGeneral->no;
|
||||||
|
|
||||||
@@ -556,24 +556,24 @@ class GeneralAI{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(key_exists($cityID, $nationCities)){
|
if(key_exists($cityID, $nationCities)){
|
||||||
$nationCities[$cityID]['generals'][] = $nationGeneralObj;
|
$nationCities[$cityID]['generals'][] = $nationGeneral;
|
||||||
if(!$nationCities[$cityID]['supply']){
|
if(!$nationCities[$cityID]['supply']){
|
||||||
$lostGenerals[] = $nationGeneralObj;
|
$lostGenerals[] = $nationGeneral;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$lostGenerals[] = $nationGeneralObj;
|
$lostGenerals[] = $nationGeneral;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($nationGeneral['npc']<2 && $nationGeneral['killturn'] >= 5){
|
if($nationGeneral->npc<2 && $nationGeneral->killturn >= 5){
|
||||||
$userGenerals[] = $nationGeneralObj;
|
$userGenerals[] = $nationGeneral;
|
||||||
}
|
}
|
||||||
else if($nationGeneral['leader']>=40 && $nationGeneral['killturn'] >= 5){
|
else if($nationGeneral->leader>=40 && $nationGeneral->killturn >= 5){
|
||||||
$npcWarGenerals[] = $nationGeneralObj;
|
$npcWarGenerals[] = $nationGeneral;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
//삭턴이 몇 안남은 장수는 '내정장 npc'로 처리
|
//삭턴이 몇 안남은 장수는 '내정장 npc'로 처리
|
||||||
$npcCivilGenerals[] = $nationGeneralObj;
|
$npcCivilGenerals[] = $nationGeneral;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nationGenerals[$generalID] = $nationGeneral;
|
$nationGenerals[$generalID] = $nationGeneral;
|
||||||
@@ -609,15 +609,15 @@ class GeneralAI{
|
|||||||
|
|
||||||
$resName = Util::choiceRandom(['gold', 'rice']);
|
$resName = Util::choiceRandom(['gold', 'rice']);
|
||||||
|
|
||||||
usort($this->userGenerals, function($lhs, $rhs) use ($nationGenerals, $resName){
|
usort($userGenerals, function($lhs, $rhs) use ($resName){
|
||||||
return $lhs->$resName <=> $rhs->$resName;
|
return $lhs->$resName <=> $rhs->$resName;
|
||||||
});
|
});
|
||||||
|
|
||||||
usort($npcWarGeneralsID, function($lhs, $rhs) use ($nationGenerals, $resName){
|
usort($npcWarGenerals, function($lhs, $rhs) use ($resName){
|
||||||
return $lhs->$resName <=> $rhs->$resName;
|
return $lhs->$resName <=> $rhs->$resName;
|
||||||
});
|
});
|
||||||
|
|
||||||
usort($npcCivilGeneralsID, function($lhs, $rhs) use ($nationGenerals, $resName){
|
usort($npcCivilGenerals, function($lhs, $rhs) use ($resName){
|
||||||
return $lhs->$resName <=> $rhs->$resName;
|
return $lhs->$resName <=> $rhs->$resName;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -628,16 +628,16 @@ class GeneralAI{
|
|||||||
$avgUserRes /= max(1, count($userGenerals));
|
$avgUserRes /= max(1, count($userGenerals));
|
||||||
|
|
||||||
$avgNpcWarRes = 0;
|
$avgNpcWarRes = 0;
|
||||||
foreach ($npcWarGeneralsID as $id){
|
foreach ($npcWarGenerals as $npcWarGeneral){
|
||||||
$avgNpcWarRes += $nationGenerals[$id][$resName];
|
$avgNpcWarRes += $npcWarGeneral->$resName;
|
||||||
}
|
}
|
||||||
$avgNpcWarRes /= max(1, count($npcWarGeneralsID));
|
$avgNpcWarRes /= max(1, count($npcWarGenerals));
|
||||||
|
|
||||||
$avgNpcCivilRes = 0;
|
$avgNpcCivilRes = 0;
|
||||||
foreach ($npcCivilGeneralsID as $id){
|
foreach ($npcCivilGenerals as $npcCivilGeneral){
|
||||||
$avgNpcCivilRes += $nationGenerals[$id][$resName];
|
$avgNpcCivilRes += $npcCivilGeneral->$resName;
|
||||||
}
|
}
|
||||||
$avgNpcCivilRes /= max(1, count($npcCivilGeneralsID));
|
$avgNpcCivilRes /= max(1, count($npcCivilGenerals));
|
||||||
|
|
||||||
//금쌀이 부족한 '유저장' 먼저 포상
|
//금쌀이 부족한 '유저장' 먼저 포상
|
||||||
while ($nation[$resName] > ($resName=='gold'?1:2)*3000 && $userGenerals) {
|
while ($nation[$resName] > ($resName=='gold'?1:2)*3000 && $userGenerals) {
|
||||||
@@ -727,29 +727,28 @@ class GeneralAI{
|
|||||||
|
|
||||||
}
|
}
|
||||||
} else{ // 포상
|
} else{ // 포상
|
||||||
$compNpcWar = $npcWarGeneralsID?$nationGenerals[$npcWarGeneralsID[0]]:null;
|
$compNpcWar = Util::array_fist($npcWarGenerals);
|
||||||
$compNpcCivil = null;
|
$compNpcCivil = null;
|
||||||
foreach($npcCivilGeneralsID??[] as $npcCivilID){
|
foreach($npcCivilGenerals as $npcCivil){
|
||||||
$npcCivil = $nationGenerals[$npcCivilID];
|
if($npcCivil->npc == 5){
|
||||||
if($npcCivil['npc'] == 5){
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$compNpcCivil = $npcCivil;
|
$compNpcCivil = $npcCivil;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($compNpcWar && $compNpcWar[$resName] < 21000){
|
if($compNpcWar && $compNpcWar->$resName < 21000){
|
||||||
$amount = min(100, intdiv(($nation[$resName]-($resName=='rice'?(GameConst::$baserice):(GameConst::$basegold))), 5000)*10 + 10);
|
$amount = min(100, intdiv(($nation[$resName]-($resName=='rice'?(GameConst::$baserice):(GameConst::$basegold))), 5000)*10 + 10);
|
||||||
$commandList[] = [['che_몰수', [
|
$commandList[] = [['che_몰수', [
|
||||||
'destGeneralID'=>$compNpcWar['no'],
|
'destGeneralID'=>$compNpcWar->no,
|
||||||
'isGold'=>$resName=='gold',
|
'isGold'=>$resName=='gold',
|
||||||
'amount'=>$amount
|
'amount'=>$amount
|
||||||
]], 3];
|
]], 3];
|
||||||
}
|
}
|
||||||
if($compNpcCivil && $compNpcCivil[$resName] < $minRes){
|
if($compNpcCivil && $compNpcCivil->$resName < $minRes){
|
||||||
$amount = intdiv($minRes+99, 100);
|
$amount = intdiv($minRes+99, 100);
|
||||||
$commandList[] = [['che_몰수', [
|
$commandList[] = [['che_몰수', [
|
||||||
'destGeneralID'=>$compNpcCivil['no'],
|
'destGeneralID'=>$compNpcCivil->no,
|
||||||
'isGold'=>$resName=='gold',
|
'isGold'=>$resName=='gold',
|
||||||
'amount'=>$amount
|
'amount'=>$amount
|
||||||
]], 2];
|
]], 2];
|
||||||
@@ -758,7 +757,7 @@ class GeneralAI{
|
|||||||
|
|
||||||
//고립 도시 장수 발령
|
//고립 도시 장수 발령
|
||||||
foreach($lostGenerals as $lostGeneral){
|
foreach($lostGenerals as $lostGeneral){
|
||||||
if($lostGeneral['npc']<2){
|
if($lostGeneral->npc<2){
|
||||||
//고립 유저 장수는 이미 세팅했음
|
//고립 유저 장수는 이미 세팅했음
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -864,29 +863,29 @@ class GeneralAI{
|
|||||||
if($frontCitiesID){
|
if($frontCitiesID){
|
||||||
$workRemain = 3;
|
$workRemain = 3;
|
||||||
foreach($nationGenerals as $nationGeneral){
|
foreach($nationGenerals as $nationGeneral){
|
||||||
$generalCity = $nationCities[$nationGeneral['city']]??null;
|
$generalCity = $nationCities[$nationGeneral->city]??null;
|
||||||
if(!$generalCity){
|
if(!$generalCity){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if($nationGeneral['crew'] < 2000){
|
if($nationGeneral->crew < 2000){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if($nationGeneral['rice'] < 700 * $tech){
|
if($nationGeneral->rice < 700 * $tech){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if($generalCity['front']){
|
if($generalCity->front){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if($nationGeneral['train'] * $nationGeneral['atmos'] < 75 * 75){
|
if($nationGeneral->train * $nationGeneral->atmos < 75 * 75){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($nationGeneral['troop'] != 0){
|
if($nationGeneral->troop != 0){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$score = 5;
|
$score = 5;
|
||||||
if($nationGeneral['npc']<2){
|
if($nationGeneral->npc<2){
|
||||||
$score *= 4;
|
$score *= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -898,7 +897,7 @@ class GeneralAI{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$command = [['che_발령', [
|
$command = [['che_발령', [
|
||||||
'destGeneralID'=>$nationGeneral['no'],
|
'destGeneralID'=>$nationGeneral->no,
|
||||||
'destCityID'=>$targetCityID
|
'destCityID'=>$targetCityID
|
||||||
]], 5];
|
]], 5];
|
||||||
|
|
||||||
@@ -959,15 +958,15 @@ class GeneralAI{
|
|||||||
|
|
||||||
|
|
||||||
$command = [['che_발령', [
|
$command = [['che_발령', [
|
||||||
'destGeneralID'=>$nationGeneral['no'],
|
'destGeneralID'=>$nationGeneral->no,
|
||||||
'destCityID'=>$targetCity['city']
|
'destCityID'=>$targetCity['city']
|
||||||
]], 5];
|
]], 5];
|
||||||
|
|
||||||
if($nationGeneral['npc']<2 && ($workRemain&2)){
|
if($nationGeneral->npc<2 && ($workRemain&2)){
|
||||||
$workRemain ^= 2;
|
$workRemain ^= 2;
|
||||||
$commandList[] = [$command, $score];
|
$commandList[] = [$command, $score];
|
||||||
}
|
}
|
||||||
else if($nationGeneral['npc']>=2 && ($workRemain&1)){
|
else if($nationGeneral->npc>=2 && ($workRemain&1)){
|
||||||
$workRemain ^= 1;
|
$workRemain ^= 1;
|
||||||
$commandList[] = [$command, $score];
|
$commandList[] = [$command, $score];
|
||||||
}
|
}
|
||||||
@@ -1606,7 +1605,7 @@ class GeneralAI{
|
|||||||
$nationID = $this->nation['nation'];
|
$nationID = $this->nation['nation'];
|
||||||
|
|
||||||
$this->devRate = $db->queryFirstRow(
|
$this->devRate = $db->queryFirstRow(
|
||||||
'SELECT sum(pop)/sum(pop2)*100 as pop,(sum(agri)+sum(comm)+sum(secu)+sum(def)+sum(wall))/(sum(agri2)+sum(comm2)+sum(secu2)+sum(def2)+sum(wall2))*100 as all from city where nation=%i',
|
'SELECT sum(pop)/sum(pop2)*100 as pop_p,(sum(agri)+sum(comm)+sum(secu)+sum(def)+sum(wall))/(sum(agri2)+sum(comm2)+sum(secu2)+sum(def2)+sum(wall2))*100 as all_p from city where nation=%i',
|
||||||
$nationID
|
$nationID
|
||||||
);
|
);
|
||||||
return $this->devRate;
|
return $this->devRate;
|
||||||
@@ -1626,7 +1625,7 @@ class GeneralAI{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$devRate = $this->getNationDevelopedRate();
|
$devRate = $this->getNationDevelopedRate();
|
||||||
if(($devRate['pop'] + $devRate['all']) / 2 < 80){
|
if(($devRate['pop_p'] + $devRate['all_p']) / 2 < 80){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1770,7 +1769,7 @@ class GeneralAI{
|
|||||||
} else {
|
} else {
|
||||||
$devRate = $this->getNationDevelopedRate();
|
$devRate = $this->getNationDevelopedRate();
|
||||||
|
|
||||||
$avg = ($devRate['pop'] + $devRate['all']) / 2;
|
$avg = ($devRate['pop_p'] + $devRate['all_p']) / 2;
|
||||||
|
|
||||||
if($avg > 95) $rate = 25;
|
if($avg > 95) $rate = 25;
|
||||||
elseif($avg > 70) $rate = 20;
|
elseif($avg > 70) $rate = 20;
|
||||||
|
|||||||
Reference in New Issue
Block a user