diff --git a/hwe/a_emperior.php b/hwe/a_emperior.php index 75feafeb..7f4b5c3a 100644 --- a/hwe/a_emperior.php +++ b/hwe/a_emperior.php @@ -224,7 +224,10 @@ if($serverID){ else{ $nation['generalsFull'] = []; } - + + if(key_exists('aux', $nation)){ + $nation += $nation['aux']; + } echo $templates->render('oldNation', $nation); } diff --git a/hwe/func.php b/hwe/func.php index 98635b2c..a5d0afb9 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -2455,6 +2455,7 @@ function deleteNation($general) { $oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $general['nation']); $oldNationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $general['nation']); $oldNation['generals'] = $oldNationGenerals; + $oldNation['aux'] = Json::decode($oldNation['aux']); // 전 장수 재야로 // 전 장수 소속 무소속으로 $query = "update general set belong=0,troop=0,level=0,nation=0,makelimit=12 where nation='{$general['nation']}'"; diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index 6c93881e..bb9db7ac 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -427,6 +427,15 @@ function postUpdateMonthly() { $history = []; + //도시 수 측정 + $cityNations = []; + foreach($db->queryAllLists('SELECT city, name, nation FROM city') as [$cityID, $cityName, $cityNation]){ + if(!key_exists($cityNation, $cityNations)){ + $cityNations[$cityNation] = []; + } + $cityNations[$cityNation][] = $cityName; + } + //각 국가 전월 장수수 대비 당월 장수수로 단합도 산정 //각 국가 장수수를 구하고 국력 산정 // $query = "select nation,gennum from nation where level>0"; @@ -438,34 +447,33 @@ function postUpdateMonthly() { // 접속률 // 숙련도 // 명성,공헌 - $query = " -select -A.nation, -A.gennum, A.gennum2, A.chemi, -round(( - round(((A.gold+A.rice)+(select sum(gold+rice) from general where nation=A.nation))/100) - +A.tech - +if(A.level=0,0,( - select round( - sum(pop)*sum(pop+agri+comm+secu+wall+def)/sum(pop2+agri2+comm2+secu2+wall2+def2)/100 - ) from city where nation=A.nation and supply=1 - )) - +(select sum(leader+power+intel) from general where nation=A.nation) - +(select round(sum(dex0+dex10+dex20+dex30+dex40)/1000) from general where nation=A.nation) - +(select round(sum(experience+dedication)/100) from general where nation=A.nation) - +(select round(avg(connect)) from general where nation=A.nation) -)/10) -as power -from nation A -group by A.nation -"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $nationCount = MYDB_num_rows($result); - $genNum = []; - for($i=0; $i < $nationCount; $i++) { - $nation = MYDB_fetch_array($result); + $nations = $db->query('SELECT + A.nation, + A.gennum, A.gennum2, A.chemi, A.aux, + round(( + round(((A.gold+A.rice)+(select sum(gold+rice) from general where nation=A.nation))/100) + +A.tech + +if(A.level=0,0,( + select round( + sum(pop)*sum(pop+agri+comm+secu+wall+def)/sum(pop2+agri2+comm2+secu2+wall2+def2)/100 + ) from city where nation=A.nation and supply=1 + )) + +(select sum(leader+power+intel) from general where nation=A.nation) + +(select round(sum(dex0+dex10+dex20+dex30+dex40)/1000) from general where nation=A.nation) + +(select round(sum(experience+dedication)/100) from general where nation=A.nation) + +(select round(avg(connect)) from general where nation=A.nation) + )/10) + as power, + (select sum(crew) from general where nation=A.nation) as totalCrew + from nation A + group by A.nation'); + foreach($nations as $nation) { $genNum[$nation['nation']] = $nation['gennum']; + $aux = Json::decode($nation['aux']); + + + if($nation['gennum'] > $nation['gennum2']) { // 장수가 증가했을때 $nation['chemi'] -= ceil(($nation['gennum'] - $nation['gennum2']) / $nation['gennum'] * 100); @@ -479,9 +487,21 @@ group by A.nation if($nation['chemi'] > 100) { $nation['chemi'] = 100; } //약간의 랜덤치 부여 (95% ~ 105%) + $nation['power'] = Util::round($nation['power'] * (rand()%101 + 950) / 1000); - $query = "update nation set power='{$nation['power']}',gennum2='{$nation['gennum']}',chemi='{$nation['chemi']}' where nation='{$nation['nation']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $aux['maxPower'] = max($aux['maxPower']??0, $nation['power']); + $aux['maxCrew'] = max($aux['maxCrew']??0, Util::toInt($nation['totalCrew'])); + + if(count($cityNations[$nation['nation']]??[]) > count($aux['maxCities']??[])){ + $aux['maxCities'] = $cityNations[$nation['nation']]; + } + + $db->update('nation', [ + 'power'=>$nation['power'], + 'gennum2'=>$nation['gennum'], + 'chemi'=>$nation['chemi'], + 'aux'=>Json::encode($aux) + ], 'nation=%i', $nation['nation']); } // 전쟁기한 세팅 @@ -690,6 +710,7 @@ function checkMerge() { $oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $me['nation']); $oldNationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $me['nation']); $oldNation['generals'] = $oldNationGenerals; + $oldNation['aux'] = Json::decode($oldNation['aux']); // 자금 통합, 외교제한 5년, 기술유지 $query = "update nation set name='{$you['makenation']}',gold=gold+'{$mynation['gold']}',rice=rice+'{$mynation['rice']}',surlimit='24',totaltech='$newTotalTech',tech='$newTech',gennum='{$newGenCount}' where nation='{$younation['nation']}'"; @@ -820,6 +841,7 @@ function checkSurrender() { $oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $me['nation']); $oldNationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $me['nation']); $oldNation['generals'] = $oldNationGenerals; + $oldNation['aux'] = Json::decode($oldNation['aux']); $newGenCount = $gencount + $gencount2; if($newGenCount < GameConst::$initialNationGenLimit) { $newGenCount = GameConst::$initialNationGenLimit; } @@ -1332,6 +1354,7 @@ function checkEmperior() { $oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $nation['nation']); $oldNation['generals'] = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nation['nation']); + $oldNation['aux'] = Json::decode($oldNation['aux']); storeOldGenerals(0, $admin['year'], $admin['month']); storeOldGenerals($nation['nation'], $admin['year'], $admin['month']); diff --git a/hwe/process_war.php b/hwe/process_war.php index b8f31378..711813c9 100644 --- a/hwe/process_war.php +++ b/hwe/process_war.php @@ -1816,6 +1816,7 @@ function ConquerCity($admin, $general, $city, $nation, $destnation) { //다른 코드와는 다르게 공용으로 쓰므로 남겨둠 return $gen['no']; }, $oldNationGenerals); + $oldNation['aux'] = Json::decode($oldNation['aux']); foreach($oldNationGenerals as $gen){ diff --git a/hwe/templates/oldNation.php b/hwe/templates/oldNation.php index c2de9f36..46f445e3 100644 --- a/hwe/templates/oldNation.php +++ b/hwe/templates/oldNation.php @@ -32,15 +32,15 @@