diff --git a/hwe/b_myBossInfo.php b/hwe/b_myBossInfo.php index 95ff3730..a754da3e 100644 --- a/hwe/b_myBossInfo.php +++ b/hwe/b_myBossInfo.php @@ -35,8 +35,12 @@ if($meLevel == 0) { <?=UniqueConst::$serverName?>: 인사부 + + + + +query('SELECT no, name, level, penalty, permission FROM general WHERE permission = \'ambassador\' AND nation = %i', $nation['nation']); +$auditors = $db->query('SELECT no, name, level, penalty, permission FROM general WHERE permission = \'auditor\' AND nation = %i', $nation['nation']); +$candidateAmbassadors = []; +$candidateAuditors = []; +foreach($ambassadors as $ambassador){ + $candidateAmbassadors[] = $ambassador; +} +foreach($auditors as $auditor){ + $candidateAuditors[] = $auditor; +} +foreach($db->query('SELECT no, name, nation, level, penalty, permission FROM general WHERE nation = %i AND permission = \'normal\' AND level != 12', $nation['nation']) as $candidate){ + $maxPermission = checkSecretMaxPermission($candidate); + if($maxPermission == 4){ + $candidateAmbassadors[] = $candidate; + } + if($maxPermission >= 3){ + $candidateAuditors[] = $candidate; + } +} + +?> + + @@ -55,10 +104,6 @@ function out() { = 5) { $btn = "submit"; } else { $btn = "hidden"; } @@ -77,6 +122,7 @@ $tigerresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connec $query = "select name,picture,firenum from general where nation='{$nation['nation']}' order by firenum desc limit 7"; // 건안칠자 $eagleresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + echo " @@ -279,9 +325,35 @@ for($i=10; $i >= $lv; $i--) { echo "
빨간색은 현재 임명중인 장수, 노란색은 다른 관직에 임명된 장수, 하얀색은 일반 장수를 뜻합니다.
+ +"; + +if($meLevel == 12): +?> + + + + + + + + + +
외 교 권 자 임 명
외교권자 + + + 조언자 + + +
+ -"; += 5) { echo " diff --git a/hwe/func.php b/hwe/func.php index 54a58e22..3cc90380 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -399,6 +399,20 @@ function myNationInfo() { "; } +function checkSecretMaxPermission($me){ + $secretMax = 4; + if($penalty['noTopSecret']??false){ + $secretMax = 1; + } + else if($penalty['noChief']??false){ + $secretMax = 1; + } + else if($penalty['noAmbassador']??false){ + $secretMax = 2; + } + return $secretMax; +} + function checkSecretPermission($me, $checkSecretLimit=true){ if(!key_exists('penalty', $me) || !key_exists('permission', $me)){ trigger_error ('canAccessSecret() 함수에 필요한 인자가 부족'); @@ -420,16 +434,8 @@ function checkSecretPermission($me, $checkSecretLimit=true){ } $secretMin = 0; - $secretMax = 4; - if($penalty['noTopSecret']??false){ - $secretMax = 1; - } - else if($penalty['noChief']??false){ - $secretMax = 1; - } - else if($penalty['noAmbassador']??false){ - $secretMax = 2; - } + $secretMax = checkSecretMaxPermission($me); + if($me['level'] == 12){ $secretMin = 4; diff --git a/hwe/j_general_set_permission.php b/hwe/j_general_set_permission.php new file mode 100644 index 00000000..ad4569dc --- /dev/null +++ b/hwe/j_general_set_permission.php @@ -0,0 +1,81 @@ +setReadOnly(); +$userID = Session::getUserID(); + +$db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game_env'); + +$me = $db->query('SELECT no, level, nation FROM general WHERE owner = %i', $userID); + +if(!$me || $me['level'] != 12){ + Json::die([ + 'result'=>false, + 'reason'=>'군주가 아닙니다' + ]); +} + +$nationID = $me['nation']; + +if($isAmbassador){ + $targetType = 'ambassador'; + $targetLevel = 4; + if(count($genlist) > 2){ + Json::die([ + 'result'=>false, + 'reason'=>'외교권자는 최대 둘까지만 설정 가능합니다.' + ]); + } +} +else{ + $targetType = 'auditor'; + $targetLevel = 3; +} + +$db->update('general', [ + 'permission'=>'normal' +], 'nation = %i AND permission = %s', $nationID, $targetType); + +if(!$genlist){ + Json::die([ + 'result'=>true, + 'reason'=>'success' + ]); +} +$realCandidates = []; +foreach($db->query('SELECT no, nation, level, penalty, permission FROM general WHERE nation = %i AND level != 12 AND permission = \'normal\' AND no IN %li', $nationID, $genlist) as $candidate){ + $maxPermission = checkSecretMaxPermission($candidate); + if($maxPermission < $targetLevel){ + continue; + } + $realCandidates[] = $candidate['no']; +} + +if(!$realCandidates){ + Json::die([ + 'result'=>true, + 'reason'=>'success' + ]); +} + +$db->update('general', [ + 'permission'=>$targetType, +], 'no IN %li', $realCandidates); + +if(!$realCandidates){ + Json::die([ + 'result'=>true, + 'reason'=>'success' + ]); +} \ No newline at end of file diff --git a/hwe/js/bossInfo.js b/hwe/js/bossInfo.js new file mode 100644 index 00000000..e367bfff --- /dev/null +++ b/hwe/js/bossInfo.js @@ -0,0 +1,37 @@ +$(function(){ + $('#selectAmbassador').select2({ + theme: 'bootstrap4', + placeholder: "", + allowClear: true, + language: "ko", + width:300, + maximumSelectionLength: 2, + containerCss: { + display: "inline-block !important;", + color: 'white !important' + }, + data:candidateAmbassadors, + //containerCssClass: 'simple-select2-align-center bg-secondary text-secondary', + dropdownCssClass: 'simple-select2-align-center bg-secondary text-secondary', + }); + + $('#selectAuditor').select2({ + theme: 'bootstrap4', + placeholder: "", + allowClear: true, + language: "ko", + width:300, + maximumSelectionLength: 2, + containerCss: { + display: "inline-block !important;", + color: 'white !important' + }, + data:candidateAuditors, + //containerCssClass: 'simple-select2-align-center bg-secondary text-secondary', + dropdownCssClass: 'simple-select2-align-center bg-secondary text-secondary', + }); + + $('#changeAmbassador').click(function(){ + //TODO: 변경 코드 + }); +}) \ No newline at end of file
도 시 관 직 임 명