From 674018d2fc332fbc15b09b32d0e304e896c6eaf4 Mon Sep 17 00:00:00 2001 From: hide_d Date: Thu, 16 Apr 2020 02:37:36 +0900 Subject: [PATCH] =?UTF-8?q?=ED=86=B5=ED=95=A9=20=EC=84=B8=EB=A0=A5?= =?UTF-8?q?=EC=9E=A5=EC=88=98,=EC=95=94=ED=96=89=EB=B6=80=20query?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/b_myBossInfo.php | 19 +--- hwe/j_get_nation_general_list.php | 161 ++++++++++++++++++++++++++++++ hwe/sammo/General.php | 5 +- 3 files changed, 167 insertions(+), 18 deletions(-) create mode 100644 hwe/j_get_nation_general_list.php diff --git a/hwe/b_myBossInfo.php b/hwe/b_myBossInfo.php index 772e168a..d920ba43 100644 --- a/hwe/b_myBossInfo.php +++ b/hwe/b_myBossInfo.php @@ -137,14 +137,14 @@ $eaglestr = join(', ', array_map(function($arr){ return "{$arr['name']}【{$number}】"; }, $eagles)); -echo " +?> - -"; += $lv; $i-=2) { $i1 = $i; $i2 = $i - 1; $imageTemp1 = GetImageURL($level[$i1]['imgsvr']??0); @@ -172,7 +172,6 @@ for($i=12; $i >= $lv; $i-=2) {
+ ; bgcolor=' colspan=6> 【 {$nation['name']} 】
- @@ -208,7 +207,6 @@ $general = MYDB_fetch_array($result); echo " -
추 방
@@ -217,7 +215,6 @@ echo " - - "; @@ -271,7 +267,6 @@ for($i=10; $i >= $lv; $i--) { if($i % 2 == 0) { echo ""; } echo " -"; + echo ""; if($i % 2 == 1) { echo ""; } } echo " @@ -345,7 +340,6 @@ endif; if($meLevel >= 5) { echo " - - - - - - "; } echo " diff --git a/hwe/j_get_nation_general_list.php b/hwe/j_get_nation_general_list.php new file mode 100644 index 00000000..cf6528bc --- /dev/null +++ b/hwe/j_get_nation_general_list.php @@ -0,0 +1,161 @@ +setReadOnly(); +$userID = Session::getUserID(); + +$db = DB::db(); +$reqType = Util::getReq('req', 'int', 1); +$reqForce = Util::getReq('force', 'bool', false); +$gameStor = KVStorage::getStorage($db, 'game_env'); + +increaseRefresh("세력장수", 1); + +$me = $db->queryFirstRow('SELECT con, turntime, nation, level, permission, penalty FROM general WHERE owner=%i', $userID); +$con = checkLimit($me['con']); +if ($con >= 2) { + Json::die([ + 'result'=>false, + 'reason'=>'접속 제한중입니다. 1턴 이내에 너무 많은 갱신을 하셨습니다.' + ]); +} + +$nationID = $me['nation']; +$permission = checkSecretPermission($me, true); +if($reqForce && $reqType > $permission){ + Json::die([ + 'result'=>false, + 'reason'=>'권한이 부족합니다.' + ]); +} +$permission = min($reqType, $permission); +$nationArr = getNationStaticInfo($nationID); +$viewColumns = [ + 'no'=>1, + 'name'=>1, + 'owner_name'=>9, + 'nation'=>1, + 'city'=>1, + 'level'=>1, + 'npc'=>1, + 'defence_train'=>2, + 'troop'=>2, + 'injury'=>1, + 'leadership'=>1, + 'strength'=>1, + 'intel'=>1, + 'experience'=>1, + 'explevel'=>1, + 'dedication'=>1, + 'dedlevel'=>1, + 'gold'=>1, + 'rice'=>1, + 'crewtype'=>2, + 'crew'=>2, + 'train'=>2, + 'atmos'=>2, + 'killturn'=>1, + 'turntime'=>2, + 'picture'=>1, + 'imgsvr'=>1, + 'age'=>1, + 'special'=>1, + 'special2'=>1, + 'personal'=>1, + 'horse'=>3, + 'weapon'=>3, + 'book'=>3, + 'item'=>3, + 'connect'=>1 +]; + +$customViewColumns = [ + 'lbonus'=>1, + 'ownerName'=>1, + 'levelText'=>1, + 'honorText'=>1, + 'expLevelText'=>1, +]; + +$specialViewFilter = [ + 'special'=>function($rawGeneral){ + return getGeneralSpecialDomesticName($rawGeneral['special']); + }, + 'special2'=>function($rawGeneral){ + return getGeneralSpecialWarName($rawGeneral['special2']); + }, + 'personal'=>function($rawGeneral){ + return getGenChar($rawGeneral['personal']); + }, + 'lbonus'=>function($rawGeneral)use($nationArr){ + return calcLeadershipBonus($rawGeneral['level'], $nationArr['level']); + }, + 'ownerName'=>function($rawGeneral){ + if($rawGeneral['npc']!=1){ + return null; + } + return $rawGeneral['owner_name']; + }, + 'levelText'=>function($rawGeneral)use($nationArr){ + return getLevelText($rawGeneral['level'], $nationArr['level']); + }, + 'honorText'=>function($rawGeneral){ + return getHonor($rawGeneral['experience']); + }, + 'dedLevelText'=>function($rawGeneral){ + return getDedLevelText($rawGeneral['dedLevel']); + }, + 'turntime'=>function($rawGeneral){ + //'0000-00-00 11:23'; + return substr($rawGeneral['turntime'], 11, 5); + } + +]; + +$queryColumns = General::mergeQueryColumn(array_keys($viewColumns), 1); + +$rawGeneralList = Util::convertArrayToDict($db->queryAllLists('SELECT %lb from general WHERE nation = %i', $queryColumns, $nationID), 'no'); + +$resultColumns = []; +foreach($viewColumns as $column=>$reqPermission){ + if($reqPermission > $permission){ + continue; + } + $resultColumns[] = $column; +} + +foreach($customViewColumns as $column=>$reqPermission){ + if($reqPermission > $permission){ + continue; + } + $resultColumns[] = $column; +} + +foreach($rawGeneralList as $rawGeneral){ + //General 생성? + + $item = []; + foreach($resultColumns as $column){ + $value = $rawGeneral[$column]; + if(key_exists($column, $specialViewFilter)){ + $value = $specialViewFilter[$column]($rawGeneral); + } + $item[] = $value; + } + + $generalList[] = $item; +} + +$result = [ + 'result'=>true, + 'column'=>$resultColumns, + 'list'=>$generalList, +]; + +Json::die($result); diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index a9fdeab6..9fe79d92 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -874,9 +874,7 @@ class General implements iAction{ return $caller; } - //TODO:createGeneralObjListFromDB로, 조건으로 select query나 generalIDList가 들어가는 녀석이 필요할 수 있음 - - static private function mergeQueryColumn(?array $reqColumns=null, int $constructMode=2):array{ + static public function mergeQueryColumn(?array $reqColumns=null, int $constructMode=2):array{ $minimumColumn = ['no', 'name', 'city', 'nation', 'level']; $defaultEventColumn = [ 'no', 'name', 'city', 'nation', 'level', @@ -1052,6 +1050,7 @@ class General implements iAction{ * @return GeneralCommand[][] */ static public function getReservedTurnListByGeneralList(array $generalList, int $turnIdxFrom, int $turnIdxTo, array $env){ + //XXX: static인데 return값이 General이 아니라고?? GeneralCommandHelper같은게 있어야하지 않을까? if(!$generalList){ return []; }
".getLevelText(12, $nation['level'])." {$general['name']} 【".CityConst::byID($general['city'])->name."】 ".getLevelText(11, $nation['level'])."
"; @@ -255,7 +252,6 @@ if($meLevel >= 5 && $nation['l11set'] == 0) { } echo "
".getLevelText($i, $nation['level'])."
"; @@ -307,7 +302,7 @@ for($i=10; $i >= $lv; $i--) { echo "{$general['name']} 【".CityConst::byID($general['city'])->name."】"; } } - echo "
도 시 관 직 임 명
태 수 임 명 @@ -398,8 +392,6 @@ if($meLevel >= 5) {
군 사 임 명 @@ -452,8 +444,6 @@ if($meLevel >= 5) {
종 사 임 명 @@ -507,7 +497,6 @@ if($meLevel >= 5) {
빨간색은 현재 임명중인 장수, 노란색은 다른 관직에 임명된 장수, 하얀색은 일반 장수를 뜻합니다.