From 88c78ec892daec491c96b10d95f5ca7d9cbe353a Mon Sep 17 00:00:00 2001 From: Hide_D Date: Thu, 1 Sep 2022 02:49:20 +0900 Subject: [PATCH] =?UTF-8?q?game,=20misc:=20=EC=9E=91=EC=9C=84=20=EC=83=81?= =?UTF-8?q?=EC=8A=B9=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func_gamerule.php | 87 +++++++++++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 33 deletions(-) diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index 6c296a68..681ce19b 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -554,32 +554,39 @@ function updateNationState() $startYear = $admin['startyear']; $assemblerCnts = []; + + $nationCityCounts = []; + foreach($db->queryAllLists('SELECT nation, count(*) FROM city WHERE LEVEL>=4 GROUP BY nation') as [$nationID, $cityCnt]){ + $nationCityCounts[$nationID] = $cityCnt; + } + foreach ($db->queryAllLists('SELECT nation,count(no) FROM general WHERE npc = 5 GROUP BY nation') as [$nationID, $assemblerCnt]) { $assemblerCnts[$nationID] = $assemblerCnt; }; + $nationLevelByCityCnt = [ + 0, //방랑군 + 1, //호족 + 2, //군벌 + 5, //주자사 + 8, //주목 + 11, //공 + 16, //왕 + 21, //황제 + ]; + foreach ($db->query('SELECT nation,name,level,tech,aux FROM nation') as $nation) { //TODO: level이 진관수이소중대특 체계를 벗어날 수 있음 $nationID = $nation['nation']; - $citycount = $db->queryFirstField('SELECT count(*) FROM city WHERE nation=%i AND level>=4', $nationID); + $cityCnt = $nationCityCounts[$nationID] ?? 0; - - if ($citycount == 0) { - $nationlevel = 0; // 방랑군 - } elseif ($citycount == 1) { - $nationlevel = 1; // 호족 - } elseif ($citycount <= 4) { - $nationlevel = 2; // 군벌 - } elseif ($citycount <= 7) { - $nationlevel = 3; // 주자사 - } elseif ($citycount <= 10) { - $nationlevel = 4; // 주목 - } elseif ($citycount <= 15) { - $nationlevel = 5; // 공 - } elseif ($citycount <= 20) { - $nationlevel = 6; // 왕 - } else { - $nationlevel = 7; // 황제 + /** @var int */ + $nationlevel = 0; + foreach($nationLevelByCityCnt as $cmpNationLevel => $cmpCityCnt){ + if($cityCnt < $cmpCityCnt){ + break; + } + $nationlevel = $cmpNationLevel; } if ($nationlevel > $nation['level']) { @@ -593,33 +600,47 @@ function updateNationState() 'rice' => $db->sqleval('rice + %i', $nationlevel * 1000), ]; + $nationName = $nation['name']; + $lordName = $db->queryFirstField('SELECT name FROM general WHERE nation = %i AND officer_level = 12', $nationID); + + $oldNationLevelText = getNationLevel($oldLevel); + $nationLevelText = getNationLevel($nationlevel); + + $logger = new ActionLogger(0, $nationID, $year, $month, false); + $josaYi = JosaUtil::pick($lordName, '이'); + switch ($nationlevel) { - case 7: - $josaUl = JosaUtil::pick(getNationLevel($nationlevel), '을'); - $history[] = "●{$year}년 {$month}월:【작위】{$nation['name']}의 군주가 " . getNationLevel($nationlevel) . "{$josaUl} 자칭하였습니다."; - pushNationHistoryLog($nation['nation'], ["●{$year}년 {$month}월:{$nation['name']}의 군주가 " . getNationLevel($nationlevel) . "{$josaUl} 자칭"]); + case 7: //황제 + $josaRo = JosaUtil::pick($nationLevelText, '로'); + $logger->pushGlobalHistoryLog("【작위】{$nationName} {$oldNationLevelText} {$lordName}{$josaYi} {$nationLevelText}{$josaRo} 옹립되었습니다."); + $logger->pushNationalHistoryLog("{$nationName} {$oldNationLevelText} {$lordName}{$josaYi} {$nationLevelText}{$josaRo} 옹립"); $auxVal = Json::decode($nation['aux']); $auxVal['can_국기변경'] = 1; $auxVal['can_국호변경'] = 1; $updateVals['aux'] = Json::encode($auxVal); break; - case 6: - $history[] = "●{$year}년 {$month}월:【작위】{$nation['name']}의 군주가 " . getNationLevel($nationlevel) . "에 등극하였습니다."; - pushNationHistoryLog($nation['nation'], ["●{$year}년 {$month}월:{$nation['name']}의 군주가 " . getNationLevel($nationlevel) . "에 등극"]); + case 6: //왕 + $josaRo = JosaUtil::pick($nationLevelText, '로'); + $logger->pushGlobalHistoryLog("【작위】{$nationName}{$lordName}{$josaYi} $nationLevelText{$josaRo} 책봉되었습니다."); + $logger->pushNationalHistoryLog("{$nationName}{$lordName}{$josaYi} $nationLevelText{$josaRo} 책봉"); break; - case 5: - case 4: - case 3: - $history[] = "●{$year}년 {$month}월:【작위】{$nation['name']}의 군주가 " . getNationLevel($nationlevel) . "에 임명되었습니다."; - pushNationHistoryLog($nation['nation'], ["●{$year}년 {$month}월:{$nation['name']}의 군주가 " . getNationLevel($nationlevel) . "에 임명됨"]); + case 5: //공 + case 4: //주목 + case 3: //주자사 + $josaRo = JosaUtil::pick($nationLevelText, '로'); + $logger->pushGlobalHistoryLog("【작위】{$nationName}{$lordName}{$josaYi} $nationLevelText{$josaRo} 임명되었습니다."); + $logger->pushNationalHistoryLog("{$nationName}{$lordName}{$josaYi} $nationLevelText{$josaRo} 임명됨"); break; - case 2: - $history[] = "●{$year}년 {$month}월:【작위】{$nation['name']}의 군주가 독립하여 " . getNationLevel($nationlevel) . "로 나섰습니다."; - pushNationHistoryLog($nation['nation'], ["●{$year}년 {$month}월:{$nation['name']}의 군주가 " . getNationLevel($nationlevel) . "로 나서다"]); + case 2: //군벌 + $josaRa = JosaUtil::pick($nationName, '라'); + $josaRo = JosaUtil::pick($nationLevelText, '로'); + $logger->pushGlobalHistoryLog("【작위】{$lordName}{$josaYi} 독립하여 {$nationName}{$josaRa}는 $nationLevelText{$josaRo} 나섰습니다."); + $logger->pushNationalHistoryLog("{$lordName}{$josaYi} 독립하여 {$nationName}{$josaRa}는 $nationLevelText{$josaRo} 나서다"); break; } $db->update('nation', $updateVals, 'nation=%i', $nation['nation']); + $logger->flush(); $turnRows = []; foreach (Util::range(getNationChiefLevel($nation['level']), 12) as $chiefLevel) {