버그 수정

This commit is contained in:
2020-05-07 23:38:26 +09:00
parent e560bbdeb4
commit 7199a770c0
4 changed files with 38 additions and 37 deletions
+13 -13
View File
@@ -1635,8 +1635,8 @@ function deleteNation(General $lord, bool $applyDB):array
$db = DB::db(); $db = DB::db();
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env'); $nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
$oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $nationID); $nation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $nationID);
$nationName = $oldNation['name']; $nationName = $nation['name'];
$logger = $lord->getLogger(); $logger = $lord->getLogger();
@@ -1644,7 +1644,7 @@ function deleteNation(General $lord, bool $applyDB):array
$logger->pushGlobalHistoryLog("<R><b>【멸망】</b></><D><b>{$nationName}</b></>{$josaUn} <R>멸망</>했습니다."); $logger->pushGlobalHistoryLog("<R><b>【멸망】</b></><D><b>{$nationName}</b></>{$josaUn} <R>멸망</>했습니다.");
$oldNationGeneralList = General::createGeneralObjListFromDB( $nationGeneralList = General::createGeneralObjListFromDB(
$db->queryFirstColumn( $db->queryFirstColumn(
'SELECT `no` FROM general WHERE nation=%i AND no != %i', 'SELECT `no` FROM general WHERE nation=%i AND no != %i',
$nationID, $nationID,
@@ -1652,21 +1652,21 @@ function deleteNation(General $lord, bool $applyDB):array
), ),
['npc', 'gold', 'rice', 'experience', 'explevel', 'dedication', 'dedlevel', 'aux'], 1 ['npc', 'gold', 'rice', 'experience', 'explevel', 'dedication', 'dedlevel', 'aux'], 1
); );
$oldNationGeneralList[$lordID] = $lord; $nationGeneralList[$lordID] = $lord;
$oldNation['generals'] = array_keys($oldNationGeneralList); $nation['generals'] = array_keys($nationGeneralList);
$oldNation['aux'] = Json::decode($oldNation['aux']); $nation['aux'] = Json::decode($nation['aux']);
$oldNation['msg'] = $nationStor->notice; $nation['msg'] = $nationStor->notice;
$oldNation['scout_msg'] = $nationStor->scout_msg; $nation['scout_msg'] = $nationStor->scout_msg;
$oldNation['aux'] += $nationStor->max_power; $nation['aux'] += $nationStor->max_power;
$oldNation['history'] = getNationHistoryAll($nationID); $nation['history'] = getNationHistoryAll($nationID);
$josaYi = JosaUtil::pick($nationName, '이'); $josaYi = JosaUtil::pick($nationName, '이');
$destroyLog = "<D><b>{$nationName}</b></>{$josaYi} <R>멸망</>했습니다."; $destroyLog = "<D><b>{$nationName}</b></>{$josaYi} <R>멸망</>했습니다.";
$destroyHistoryLog = "<D><b>{$nationName}</b></>{$josaYi} <R>멸망</>"; $destroyHistoryLog = "<D><b>{$nationName}</b></>{$josaYi} <R>멸망</>";
// 전 장수 재야로 // 전 장수 재야로
foreach($oldNationGeneralList as $general){ foreach($nationGeneralList as $general){
$general->setVar('belong', 0); $general->setVar('belong', 0);
$general->setVar('troop', 0); $general->setVar('troop', 0);
$general->setVar('officer_level', 0); $general->setVar('officer_level', 0);
@@ -1694,7 +1694,7 @@ function deleteNation(General $lord, bool $applyDB):array
$db->insert('ng_old_nations', [ $db->insert('ng_old_nations', [
'server_id' => UniqueConst::$serverID, 'server_id' => UniqueConst::$serverID,
'nation' => $nationID, 'nation' => $nationID,
'data' => Json::encode($oldNation) 'data' => Json::encode($nation)
]); ]);
$db->delete('nation', 'nation=%i', $nationID); $db->delete('nation', 'nation=%i', $nationID);
$db->delete('nation_turn', 'nation_id=%i', $nationID); $db->delete('nation_turn', 'nation_id=%i', $nationID);
@@ -1706,7 +1706,7 @@ function deleteNation(General $lord, bool $applyDB):array
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env'); $nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
$nationStor->resetValues(); $nationStor->resetValues();
return $oldNationGeneralList; return $nationGeneralList;
} }
function nextRuler(General $general) function nextRuler(General $general)
+22 -21
View File
@@ -942,14 +942,13 @@ function checkEmperior()
return; return;
} }
$remainNationCnt = $db->queryFirstField('SELECT count(*) FROM nation WHERE level > 0'); $remainNations = $db->queryFirstColumn('SELECT nation FROM nation WHERE level > 0 LIMIT 2');
if ($remainNationCnt > 1) { if (!$remainNations || count($remainNations) != 1) {
return; return;
} }
$nation = $db->queryFirstRow('SELECT * FROM nation WHERE level > 0 LIMIT 1'); $nationID = $remainNations[0];
$nationID = $nation['nation'];
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env'); $nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
@@ -964,10 +963,13 @@ function checkEmperior()
checkStatistic(); checkStatistic();
$josaYi = JosaUtil::pick($nation['name'], '이'); $nation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $nationID);
$nationName = $nation['name'];
$josaYi = JosaUtil::pick($nationName, '이');
$nationLogger = new ActionLogger(0, $nationID, $admin['year'], $admin['month']); $nationLogger = new ActionLogger(0, $nationID, $admin['year'], $admin['month']);
$nationLogger->pushNationalHistoryLog("<D><b>{$nation['name']}</b></>{$josaYi} 전토를 통일"); $nationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>{$josaYi} 전토를 통일");
$gameStor->isunited = 2; $gameStor->isunited = 2;
$gameStor->conlimit = $gameStor->conlimit * 100; $gameStor->conlimit = $gameStor->conlimit * 100;
@@ -983,20 +985,19 @@ function checkEmperior()
$chiefs = Util::convertArrayToDict( $chiefs = Util::convertArrayToDict(
$db->query( $db->query(
'SELECT no,name,picture,belong,officer_level FROM general WHERE nation=%i AND officer_level >= 5', 'SELECT no,name,picture,belong,officer_level FROM general WHERE nation=%i AND officer_level >= 5',
$nation['nation'] $nationID
), ),
'officer_level' 'officer_level'
); );
$oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $nation['nation']); $nationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nationID);
$oldNationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nation['nation']); $nation['generals'] = $nationGenerals;
$oldNation['generals'] = $oldNationGenerals;
$tigers = $db->query( $tigers = $db->query(
'SELECT value, name 'SELECT value, name
FROM rank_data LEFT JOIN general ON rank_data.general_id = general.no FROM rank_data LEFT JOIN general ON rank_data.general_id = general.no
WHERE rank_data.nation_id = %i AND rank_data.type = "warnum" AND value > 0 ORDER BY value DESC LIMIT 5', WHERE rank_data.nation_id = %i AND rank_data.type = "warnum" AND value > 0 ORDER BY value DESC LIMIT 5',
$nation['nation'] $nationID
); // 오호장군 ); // 오호장군
$tigerstr = join(', ', array_map(function ($arr) { $tigerstr = join(', ', array_map(function ($arr) {
@@ -1008,7 +1009,7 @@ function checkEmperior()
'SELECT value, name 'SELECT value, name
FROM rank_data LEFT JOIN general ON rank_data.general_id = general.no FROM rank_data LEFT JOIN general ON rank_data.general_id = general.no
WHERE rank_data.nation_id = %i AND rank_data.type = "firenum" AND value > 0 ORDER BY value DESC LIMIT 7', WHERE rank_data.nation_id = %i AND rank_data.type = "firenum" AND value > 0 ORDER BY value DESC LIMIT 7',
$nation['nation'] $nationID
); // 건안칠자 ); // 건안칠자
$eaglestr = join(', ', array_map(function ($arr) { $eaglestr = join(', ', array_map(function ($arr) {
@@ -1019,7 +1020,7 @@ function checkEmperior()
$rawGeneralList = $db->query('SELECT no, name, npc, owner FROM general WHERE nation=%i ORDER BY dedication DESC', $nationID); $rawGeneralList = $db->query('SELECT no, name, npc, owner FROM general WHERE nation=%i ORDER BY dedication DESC', $nationID);
foreach ($rawGeneralList as $rawGeneral) { foreach ($rawGeneralList as $rawGeneral) {
$generalLogger = new ActionLogger($rawGeneral['no'], $nationID, $admin['year'], $admin['month']); $generalLogger = new ActionLogger($rawGeneral['no'], $nationID, $admin['year'], $admin['month']);
$generalLogger->pushGeneralActionLog("<D><b>{$nation['name']}</b></>{$josaYi} 전토를 통일하였습니다.", ActionLogger::YEAR_MONTH); $generalLogger->pushGeneralActionLog("<D><b>{$nationName}</b></>{$josaYi} 전토를 통일하였습니다.", ActionLogger::YEAR_MONTH);
$generalLogger->flush(); $generalLogger->flush();
} }
@@ -1034,13 +1035,13 @@ function checkEmperior()
$statNation = $db->queryFirstRow('SELECT nation_count,nation_name,nation_hist from statistic where nation_count=%i LIMIT 1', $stat['nc']); $statNation = $db->queryFirstRow('SELECT nation_count,nation_name,nation_hist from statistic where nation_count=%i LIMIT 1', $stat['nc']);
$statGeneral = $db->queryFirstRow('SELECT gen_count,personal_hist,special_hist,aux from statistic order by no desc LIMIT 1'); $statGeneral = $db->queryFirstRow('SELECT gen_count,personal_hist,special_hist,aux from statistic order by no desc LIMIT 1');
$oldNation = $nation; $nation = $nation;
$oldNation['generals'] = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nation['nation']); $nation['generals'] = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nation['nation']);
$oldNation['aux'] = Json::decode($oldNation['aux']); $nation['aux'] = Json::decode($nation['aux']);
$oldNation['msg'] = $nationStor->notice; $nation['msg'] = $nationStor->notice;
$oldNation['scout_msg'] = $nationStor->scout_msg; $nation['scout_msg'] = $nationStor->scout_msg;
$oldNation['aux'] += $nationStor->max_power; $nation['aux'] += $nationStor->max_power;
$oldNation['history'] = getNationHistoryAll($nation['nation']); $nation['history'] = getNationHistoryAll($nation['nation']);
storeOldGenerals(0, $admin['year'], $admin['month']); storeOldGenerals(0, $admin['year'], $admin['month']);
storeOldGenerals($nation['nation'], $admin['year'], $admin['month']); storeOldGenerals($nation['nation'], $admin['year'], $admin['month']);
@@ -1048,7 +1049,7 @@ function checkEmperior()
$db->insert('ng_old_nations', [ $db->insert('ng_old_nations', [
'server_id' => UniqueConst::$serverID, 'server_id' => UniqueConst::$serverID,
'nation' => $nation['nation'], 'nation' => $nation['nation'],
'data' => Json::encode($oldNation) 'data' => Json::encode($nation)
]); ]);
$noNationGeneral = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=0'); $noNationGeneral = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=0');
+1 -1
View File
@@ -4,7 +4,7 @@ namespace sammo;
include "lib.php"; include "lib.php";
include "func.php"; include "func.php";
$v = new Validator($_POST + $_GET); $v = new Validator($_POST);
$v $v
->rule('required', [ ->rule('required', [
'name', 'name',
+2 -2
View File
@@ -94,8 +94,8 @@ class che_해산 extends Command\GeneralCommand{
$logger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>{$josaUl} 해산"); $logger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>{$josaUl} 해산");
$general->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$oldNationGenerals = deleteNation($general, false); $nationGenerals = deleteNation($general, false);
foreach($oldNationGenerals as $oldGeneral){ foreach($nationGenerals as $oldGeneral){
$oldGeneral->setVar('makelimit', 12); $oldGeneral->setVar('makelimit', 12);
$oldGeneral->applyDB($db); $oldGeneral->applyDB($db);
} }