버그 수정
This commit is contained in:
+3
-3
@@ -144,12 +144,12 @@ foreach(getAllNationStaticInfo() as $staticNation):
|
||||
$cityList = $db->query('SELECT * FROM city WHERE nation=%i', $nationID);
|
||||
$dedicationList = $db->query('SELECT dedication FROM general WHERE nation=%i AND npc!=5', $nationID);
|
||||
|
||||
$goldIncome = getGoldIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$goldIncome = getGoldIncome($nation['nation'], $nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$warIncome = getWarGoldIncome($nation['type'], $cityList);
|
||||
$totalGoldIncome = $goldIncome + $warIncome;
|
||||
|
||||
$riceIncome = getRiceIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$wallIncome = getWallIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$riceIncome = getRiceIncome($nation['nation'], $nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$wallIncome = getWallIncome($nation['nation'], $nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$totalRiceIncome = $riceIncome + $wallIncome;
|
||||
|
||||
$outcome = getOutcome($nation['bill'], $dedicationList);
|
||||
|
||||
@@ -64,12 +64,12 @@ foreach($cityList as $city){
|
||||
[$currCrew, $maxCrew] = $db->queryFirstList('SELECT sum(crew), sum(leadership)*100 FROM general WHERE nation=%i AND npc != 5', $nation['nation']);
|
||||
$dedicationList = $db->query('SELECT dedication FROM general WHERE nation=%i AND npc!=5', $nationID);
|
||||
|
||||
$goldIncome = getGoldIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$goldIncome = getGoldIncome($nation['nation'], $nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$warIncome = getWarGoldIncome($nation['type'], $cityList);
|
||||
$totalGoldIncome = $goldIncome + $warIncome;
|
||||
|
||||
$riceIncome = getRiceIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$wallIncome = getWallIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$riceIncome = getRiceIncome($nation['nation'], $nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$wallIncome = getWallIncome($nation['nation'], $nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$totalRiceIncome = $riceIncome + $wallIncome;
|
||||
|
||||
$outcome = getOutcome($nation['bill'], $dedicationList);
|
||||
|
||||
+24
-12
@@ -46,7 +46,7 @@ function processGoldIncome() {
|
||||
$adminLog = [];
|
||||
|
||||
|
||||
$nationList = $db->query('SELECT name,nation,capital,gold,rate_tmp,bill,type from nation');
|
||||
$nationList = $db->query('SELECT name,nation,capital,gold,level,rate_tmp,bill,type from nation');
|
||||
$cityListByNation = Util::arrayGroupBy($db->query('SELECT * FROM city'), 'nation');
|
||||
$generalRawListByNation = Util::arrayGroupBy($db->query('SELECT no,name,nation,gold,level,dedication,city FROM general'), 'nation');
|
||||
|
||||
@@ -55,7 +55,7 @@ function processGoldIncome() {
|
||||
$nationID = $nation['nation'];
|
||||
|
||||
$generalRawList = $generalRawListByNation[$nationID];
|
||||
$income = getGoldIncome($nation['level'], $nation['type'], $nation['rate_tmp'], $nation['capital'], $cityListByNation[$nationID]);
|
||||
$income = getGoldIncome($nationID, $nation['level'], $nation['rate_tmp'], $nation['capital'], $nation['type'], $cityListByNation[$nationID]??[]);
|
||||
$originoutcome = getOutcome(100, $generalRawList);
|
||||
$outcome= Util::round($nation['bill'] / 100 * $originoutcome);
|
||||
|
||||
@@ -219,11 +219,15 @@ function calcCityWallRiceIncome(array $rawCity, int $officerCnt, bool $isCapital
|
||||
return $wallIncome;
|
||||
}
|
||||
|
||||
function getGoldIncome(int $nationLevel, string $nationType, float $taxRate, int $capitalID, array $cityList){
|
||||
function getGoldIncome(int $nationID, int $nationLevel, float $taxRate, int $capitalID, string $nationType, ?array $cityList){
|
||||
if(!$cityList){
|
||||
return 0;
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$officers = [];
|
||||
foreach($db->queryAllLists('SELECT no, city FROM general WHERE nation = %i AND level IN (2,3,4)') as [$genID, $cityID]){
|
||||
foreach($db->queryAllLists('SELECT no, city FROM general WHERE nation = %i AND level IN (2,3,4)', $nationID) as [$genID, $cityID]){
|
||||
$officers[$genID] = $cityID;
|
||||
}
|
||||
|
||||
@@ -320,7 +324,7 @@ function processRiceIncome() {
|
||||
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
|
||||
$adminLog = [];
|
||||
|
||||
$nationList = $db->query('SELECT name,nation,capital,rice,rate_tmp,bill,type from nation');
|
||||
$nationList = $db->query('SELECT name,level,nation,capital,rice,rate_tmp,bill,type from nation');
|
||||
$cityListByNation = Util::arrayGroupBy($db->query('SELECT * FROM city'), 'nation');
|
||||
$generalRawListByNation = Util::arrayGroupBy($db->query('SELECT no,name,nation,rice,level,dedication,city FROM general'), 'nation');
|
||||
|
||||
@@ -329,8 +333,8 @@ function processRiceIncome() {
|
||||
$nationID = $nation['nation'];
|
||||
|
||||
$generalRawList = $generalRawListByNation[$nationID];
|
||||
$income = getRiceIncome($nation['level'], $nation['type'], $nation['rate_tmp'], $nation['capital'], $cityListByNation[$nationID]);
|
||||
$income += getWallIncome($nation['level'], $nation['type'], $nation['rate_tmp'], $nation['capital'], $cityListByNation[$nationID]);
|
||||
$income = getRiceIncome($nation['nation'], $nation['level'], $nation['rate_tmp'], $nation['capital'], $nation['type'], $cityListByNation[$nationID]??[]);
|
||||
$income += getWallIncome($nation['nation'], $nation['level'], $nation['rate_tmp'], $nation['capital'], $nation['type'], $cityListByNation[$nationID]??[]);
|
||||
$originoutcome = getOutcome(100, $generalRawList);
|
||||
$outcome= Util::round($nation['bill'] / 100 * $originoutcome);
|
||||
|
||||
@@ -388,11 +392,15 @@ function processRiceIncome() {
|
||||
pushAdminLog($adminLog);
|
||||
}
|
||||
|
||||
function getRiceIncome(int $nationLevel, string $nationType, float $taxRate, int $capitalID, array $cityList) {
|
||||
function getRiceIncome(int $nationID, int $nationLevel, float $taxRate, int $capitalID, string $nationType, ?array $cityList) {
|
||||
if(!$cityList){
|
||||
return 0;
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$officers = [];
|
||||
foreach($db->queryAllLists('SELECT no, city FROM general WHERE nation = %i AND level IN (2,3,4)') as [$genID, $cityID]){
|
||||
foreach($db->queryAllLists('SELECT no, city FROM general WHERE nation = %i AND level IN (2,3,4)', $nationID) as [$genID, $cityID]){
|
||||
$officers[$genID] = $cityID;
|
||||
}
|
||||
|
||||
@@ -403,7 +411,7 @@ function getRiceIncome(int $nationLevel, string $nationType, float $taxRate, int
|
||||
$cityID = $rawCity['city'];
|
||||
foreach ([2,3,4] as $officerLevel) {
|
||||
$officerCnt = 0;
|
||||
if($officers[$rawCity['officer'.$officerLevel]] == $cityID){
|
||||
if($officers[$rawCity['officer'.$officerLevel]]??0 == $cityID){
|
||||
$officerCnt += 1;
|
||||
}
|
||||
}
|
||||
@@ -416,11 +424,15 @@ function getRiceIncome(int $nationLevel, string $nationType, float $taxRate, int
|
||||
return $cityIncome;
|
||||
}
|
||||
|
||||
function getWallIncome(int $nationLevel, string $nationType, float $taxRate, int $capitalID, array $cityList) {
|
||||
function getWallIncome(int $nationID, int $nationLevel, float $taxRate, int $capitalID, string $nationType, ?array $cityList) {
|
||||
if(!$cityList){
|
||||
return 0;
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$officers = [];
|
||||
foreach($db->queryAllLists('SELECT no, city FROM general WHERE nation = %i AND level IN (2,3,4)') as [$genID, $cityID]){
|
||||
foreach($db->queryAllLists('SELECT no, city FROM general WHERE nation = %i AND level IN (2,3,4)', $nationID) as [$genID, $cityID]){
|
||||
$officers[$genID] = $cityID;
|
||||
}
|
||||
|
||||
|
||||
+14
-4
@@ -53,7 +53,7 @@ class GeneralAI{
|
||||
}
|
||||
$this->city = $general->getRawCity();
|
||||
$this->nation = $db->queryFirstRow(
|
||||
'SELECT nation,level,tech,gold,rice,rate,type,color,name,war FROM nation WHERE nation = %i',
|
||||
'SELECT nation,level,capital,tech,gold,rice,rate,type,color,name,war FROM nation WHERE nation = %i',
|
||||
$general->getNationID()
|
||||
)??[
|
||||
'nation'=>0,
|
||||
@@ -1865,9 +1865,14 @@ class GeneralAI{
|
||||
$nationID = $nation['nation'];
|
||||
|
||||
$cityList = $db->query('SELECT * FROM city WHERE nation=%i', $nationID);
|
||||
|
||||
if(!$cityList){
|
||||
return 20;
|
||||
}
|
||||
|
||||
$dedicationList = $db->query('SELECT dedication FROM general WHERE nation=%i AND npc!=5', $nationID);
|
||||
|
||||
$goldIncome = getGoldIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$goldIncome = getGoldIncome($nation['nation'], $nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$warIncome = getWarGoldIncome($nation['type'], $cityList);
|
||||
$income = $goldIncome + $warIncome;
|
||||
|
||||
@@ -1893,10 +1898,15 @@ class GeneralAI{
|
||||
$nationID = $nation['nation'];
|
||||
|
||||
$cityList = $db->query('SELECT * FROM city WHERE nation=%i', $nationID);
|
||||
|
||||
if(!$cityList){
|
||||
return 20;
|
||||
}
|
||||
|
||||
$dedicationList = $db->query('SELECT dedication FROM general WHERE nation=%i AND npc!=5', $nationID);
|
||||
|
||||
$riceIncome = getRiceIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$wallIncome = getWallIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$riceIncome = getRiceIncome($nation['nation'], $nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$wallIncome = getWallIncome($nation['nation'], $nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$income = $riceIncome + $wallIncome;
|
||||
|
||||
$outcome = getOutcome(100, $dedicationList);
|
||||
|
||||
Reference in New Issue
Block a user