diff --git a/hwe/a_kingdomList.php b/hwe/a_kingdomList.php index 1d713a53..824a7e80 100644 --- a/hwe/a_kingdomList.php +++ b/hwe/a_kingdomList.php @@ -9,13 +9,10 @@ $userID = Session::getUserID(); $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); -$connect=$db->get(); increaseRefresh("세력일람", 2); -$query = "select con,turntime from general where owner='{$userID}'"; -$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); -$me = MYDB_fetch_array($result); +$me = $db->queryFirstRow('SELECT con, turntime FROM general WHERE owner=%i', $userID); $con = checkLimit($me['con']); if($con >= 2) { printLimitMsg($me['turntime']); exit(); } @@ -43,97 +40,39 @@ if($con >= 2) { printLimitMsg($me['turntime']); exit(); }
| 장 수 | -{$gencount} | +".count($nations[0]['generals'])." | 속 령 | -{$citycount} | +".count($nations[0]['cities'])." | |
| 속령 일람 : "; -for($j=0; $j < $citycount; $j++) { - $city = MYDB_fetch_array($cityresult); - echo "{$city['name']}, "; +foreach($nations[0]['cities'] as $cityName) { + echo "{$cityName}, "; } echo" | ||||||
| 장수 일람 : "; - for($j=0; $j < $gencount; $j++) { - $general = MYDB_fetch_array($genresult); - if($general['npc'] >= 2) { echo "{$general['name']}, "; } - elseif($general['npc'] == 1) { echo "{$general['name']}, "; } - else { echo "{$general['name']}, "; } + foreach($nations[0]['generals'] as $general) { + $generalText = getColoredName($general['name'], $general['npc']); + echo "{$generalText}, "; } echo" | diff --git a/hwe/func.php b/hwe/func.php index 05849642..f317dd2c 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -36,6 +36,10 @@ function getNationStaticInfo($nationID, $forceRefresh=false) if ($nationID === null) { return null; } + if($nationID === -1 && $nationList !== null){ + return $nationList; + } + if($nationID === 0){ return [ 'nation'=>0, @@ -44,14 +48,18 @@ function getNationStaticInfo($nationID, $forceRefresh=false) 'type'=>GameConst::$neutralNationType, 'level'=>0, 'capital'=>0, - 'gennum'=>1 + 'gennum'=>1, + 'power'=>1 ]; } if($nationList === null){ - $nationAll = DB::db()->query("select nation, name, color, type, level, capital, gennum from nation"); + $nationAll = DB::db()->query("select nation, name, color, type, level, capital, gennum, power from nation"); $nationList = Util::convertArrayToDict($nationAll, "nation"); - $nationList[-1] = $nationAll; + } + + if($nationID === -1){ + return $nationList; } if(isset($nationList[$nationID])){ diff --git a/hwe/func_converter.php b/hwe/func_converter.php index 3b687d09..a75f3e05 100644 --- a/hwe/func_converter.php +++ b/hwe/func_converter.php @@ -638,12 +638,12 @@ function getNameColor(int $npcType):?string{ return null; } function getColoredName(string $name, int $npcType):string{ - $color = nameColor($npcType); + $color = getNameColor($npcType); if($color === null){ return $name; } //TODO: font 폐기. - return "{$name}"; + return "{$name}"; } function ConvertLog(?string $str, $type=1) : string { diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index fa7e4ca0..a1681ea3 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -518,6 +518,7 @@ function postUpdateMonthly() { } // 작위 업데이트 updateNationState(); + refreshNationStaticInfo(); // 천통여부 검사 checkEmperior(); //토너먼트 개시 @@ -942,8 +943,6 @@ function updateNationState() { } } $db->insertIgnore('nation_turn', $turnRows); - - refreshNationStaticInfo(); } $assemblerCnt = $assemblerCnts[$nation['nation']]??0; @@ -983,7 +982,6 @@ function updateNationState() { $assemblerCnt += 1; $gameStor->assembler_id = $lastAssemblerID; } - refreshNationStaticInfo(); } } @@ -1261,37 +1259,13 @@ function checkEmperior() { $poprate = round($city['totalpop']/$city['maxpop']*100, 2); $poprate .= " %"; - $query = "select name,picture,belong from general where nation='{$nation['nation']}' and level='12'"; - $genresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $level12 = MYDB_fetch_array($genresult); - - $query = "select name,picture,belong from general where nation='{$nation['nation']}' and level='11'"; - $genresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $level11 = MYDB_fetch_array($genresult); - - $query = "select name,picture,belong from general where nation='{$nation['nation']}' and level='10'"; - $genresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $level10 = MYDB_fetch_array($genresult); - - $query = "select name,picture,belong from general where nation='{$nation['nation']}' and level='9'"; - $genresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $level9 = MYDB_fetch_array($genresult); - - $query = "select name,picture,belong from general where nation='{$nation['nation']}' and level='8'"; - $genresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $level8 = MYDB_fetch_array($genresult); - - $query = "select name,picture,belong from general where nation='{$nation['nation']}' and level='7'"; - $genresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $level7 = MYDB_fetch_array($genresult); - - $query = "select name,picture,belong from general where nation='{$nation['nation']}' and level='6'"; - $genresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $level6 = MYDB_fetch_array($genresult); - - $query = "select name,picture,belong from general where nation='{$nation['nation']}' and level='5'"; - $genresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $level5 = MYDB_fetch_array($genresult); + $chiefs = Util::convertArrayToDict( + $db->query( + 'SELECT name,picture,belong,level FROM general WHERE nation=%i AND level >= 5', + $nation['nation'] + ), + 'level' + ); $oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $nation['nation']); $oldNationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nation['nation']); @@ -1407,22 +1381,22 @@ function checkEmperior() { 'poprate'=>$poprate, 'gold'=>$nation['gold'], 'rice'=>$nation['rice'], - 'l12name'=>$level12['name'], - 'l12pic'=>$level12['picture'], - 'l11name'=>$level11['name'], - 'l11pic'=>$level11['picture'], - 'l10name'=>$level10['name'], - 'l10pic'=>$level10['picture'], - 'l9name'=>$level9['name'], - 'l9pic'=>$level9['picture'], - 'l8name'=>$level8['name'], - 'l8pic'=>$level8['picture'], - 'l7name'=>$level7['name'], - 'l7pic'=>$level7['picture'], - 'l6name'=>$level6['name'], - 'l6pic'=>$level6['picture'], - 'l5name'=>$level5['name'], - 'l5pic'=>$level5['picture'], + 'l12name'=>$chiefs[12]['name'], + 'l12pic'=>$chiefs[12]['picture'], + 'l11name'=>$chiefs[11]['name'], + 'l11pic'=>$chiefs[11]['picture'], + 'l10name'=>$chiefs[10]['name'], + 'l10pic'=>$chiefs[10]['picture'], + 'l9name'=>$chiefs[9]['name'], + 'l9pic'=>$chiefs[9]['picture'], + 'l8name'=>$chiefs[8]['name'], + 'l8pic'=>$chiefs[8]['picture'], + 'l7name'=>$chiefs[7]['name'], + 'l7pic'=>$chiefs[7]['picture'], + 'l6name'=>$chiefs[6]['name'], + 'l6pic'=>$chiefs[6]['picture'], + 'l5name'=>$chiefs[5]['name'], + 'l5pic'=>$chiefs[5]['picture'], 'tiger'=>$tigerstr, 'eagle'=>$eaglestr, 'gen'=>$gen, diff --git a/hwe/func_time_event.php b/hwe/func_time_event.php index 5eba1e65..77822a27 100644 --- a/hwe/func_time_event.php +++ b/hwe/func_time_event.php @@ -14,25 +14,25 @@ function processSpring() { //인구 증가 popIncrease(); // 1월엔 무조건 내정 1% 감소 - $query = "update city set dead=0,agri=agri*0.99,comm=comm*0.99,secu=secu*0.99,def=def*0.99,wall=wall*0.99"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $db->update('city',[ + 'dead'=>0, + 'agri'=>$db->sqleval('agri * 0.99'), + 'comm'=>$db->sqleval('comm * 0.99'), + 'secu'=>$db->sqleval('secu * 0.99'), + 'def'=>$db->sqleval('def * 0.99'), + 'wall'=>$db->sqleval('wall * 0.99'), + ],true); + // > 10000 유지비 3%, > 1000 유지비 1% // 유지비 1% - $query = "update general set gold=gold*0.99 where gold>1000 and gold<=10000"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - // 유지비 3% - $query = "update general set gold=gold*0.97 where gold>10000"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $db->update('general', [ + 'gold'=>$db->sqleval('IF(gold > 10000, gold * 0.97, gold * 0.99)') + ], 'gold > 1000'); - // 유지비 1% - $query = "update nation set gold=gold*0.99 where gold>1000 and gold<=10000"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - // 유지비 3% - $query = "update nation set gold=gold*0.97 where gold>10000 and gold<=100000"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - // 유지비 5% - $query = "update nation set gold=gold*0.95 where gold>100000"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + // > 100000 유지비 5%, > 100000 유지비 3%, > 1000 유지비 1% + $db->update('nation', [ + 'gold'=>$db->sqleval('IF(gold > 100000, gold * 0.95, IF(gold > 10000, gold * 0.97, gold * 0.99))') + ], 'gold > 1000'); $admin = $gameStor->getValues(['year', 'month']);||||||