diff --git a/hwe/a_kingdomList.php b/hwe/a_kingdomList.php
index be050a1a..412d428c 100644
--- a/hwe/a_kingdomList.php
+++ b/hwe/a_kingdomList.php
@@ -130,6 +130,14 @@ for($i=1; $i <= $count; $i++) {
elseif($level5['npc'] == 1) { $l5 = "{$level5['name']}"; }
else { $l5 = $level5['name']; }
+ $generals = $db->query('SELECT no,nation,npc,name,level,penalty,permission FROM general WHERE nation=%i ORDER BY no ASC', $nation['nation']);
+ $ambassadors = [];
+ foreach($generals as $general){
+ if(checkSecretPermission($general, false) == 4){
+ $ambassadors[] = $general['name'];
+ }
+ }
+
echo "
@@ -143,7 +151,7 @@ for($i=1; $i <= $count; $i++) {
| 국 력 |
{$nation['power']} |
장수 / 속령 |
- {$gencount} / {$citycount} |
+ ".count($generals)." / {$citycount} |
| ".getLevel(12, $nation['level'])." |
@@ -165,6 +173,11 @@ for($i=1; $i <= $count; $i++) {
".getLevel( 5, $nation['level'])." |
$l5 |
+
+ | 외교권자 | ";
+ echo join(', ', $ambassadors);
+ echo " |
+
| ";
if($nation['level'] > 0) {
@@ -190,8 +203,7 @@ for($i=1; $i <= $count; $i++) {
|
| 장수 일람 : ";
- for($j=0; $j < $gencount; $j++) {
- $general = MYDB_fetch_array($genresult);
+ foreach($generals as $general){
if($general['npc'] >= 2) { echo "{$general['name']}, "; }
elseif($general['npc'] == 1) { echo "{$general['name']}, "; }
else { echo "{$general['name']}, "; }
diff --git a/hwe/b_dipcenter.php b/hwe/b_dipcenter.php
index 8a9c53ec..482b37af 100644
--- a/hwe/b_dipcenter.php
+++ b/hwe/b_dipcenter.php
@@ -85,7 +85,6 @@ var scoutmsg = =Json::encode($nation['scoutmsg']??'')?>;
| 상태 |
기간 |
종 료 시 점 |
- 비 고 |
getValues(['year','month']);
diff --git a/hwe/b_myBossInfo.php b/hwe/b_myBossInfo.php
index c8eb0638..8fcdb324 100644
--- a/hwe/b_myBossInfo.php
+++ b/hwe/b_myBossInfo.php
@@ -35,8 +35,12 @@ if($meLevel == 0) {
=UniqueConst::$serverName?>: 인사부
=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
+=WebUtil::printJS('../e_lib/select2/select2.full.min.js')?>
=WebUtil::printJS('js/common.js')?>
+=WebUtil::printJS('js/bossInfo.js')?>
=WebUtil::printCSS('../e_lib/bootstrap.min.css')?>
+=WebUtil::printCSS('../e_lib/select2/select2.min.css')?>
+=WebUtil::printCSS('../e_lib/select2/select2-bootstrap4.css')?>
=WebUtil::printCSS('../d_shared/common.css')?>
=WebUtil::printCSS('css/common.css')?>
+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 71ad251b..5fee5268 100644
--- a/hwe/func.php
+++ b/hwe/func.php
@@ -395,6 +395,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() 함수에 필요한 인자가 부족');
@@ -416,16 +430,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_board_comment_add.php b/hwe/j_board_comment_add.php
index 42d56c20..9841e819 100644
--- a/hwe/j_board_comment_add.php
+++ b/hwe/j_board_comment_add.php
@@ -14,7 +14,7 @@ $text = Util::getReq('text');
increaseRefresh("회의실", 1);
-$me = $db->queryFirstRow('SELECT no, nation, level, permission, con, turntime, belong, penalty FROM general WHERE owner=%i', $userID);
+$me = $db->queryFirstRow('SELECT no, nation, name, level, permission, con, turntime, belong, penalty FROM general WHERE owner=%i', $userID);
$con = checkLimit($me['con']);
if ($con >= 2) {
diff --git a/hwe/j_board_get_articles.php b/hwe/j_board_get_articles.php
index 494c6fa3..c8fb0f85 100644
--- a/hwe/j_board_get_articles.php
+++ b/hwe/j_board_get_articles.php
@@ -62,7 +62,7 @@ foreach(
) as $comment
){
//TODO:아이콘 받아오기?
- $articles[$article['no']]['comment'] = $comment;
+ $articles[$comment['document_no']]['comment'][] = $comment;
}
Json::die([
diff --git a/hwe/j_general_set_permission.php b/hwe/j_general_set_permission.php
new file mode 100644
index 00000000..988ac22e
--- /dev/null
+++ b/hwe/j_general_set_permission.php
@@ -0,0 +1,80 @@
+setReadOnly();
+$userID = Session::getUserID();
+
+$db = DB::db();
+$gameStor = KVStorage::getStorage($db, 'game_env');
+
+$me = $db->queryFirstRow('SELECT no, level, nation FROM general WHERE owner = %i', $userID);
+
+if(!$me || $me['level'] != 12){
+ Json::die([
+ 'result'=>false,
+ 'reason'=>'군주가 아닙니다',
+ 'tmp'=>$me
+ ]);
+}
+
+$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);
+
+Json::die([
+ 'result'=>true,
+ 'reason'=>'success'
+]);
\ No newline at end of file
diff --git a/hwe/js/board.js b/hwe/js/board.js
index 459f2008..84260a74 100644
--- a/hwe/js/board.js
+++ b/hwe/js/board.js
@@ -48,7 +48,8 @@ function submitArticle(){
function submitComment(){
var $this = $(this);
- var $article = $this.parents('.article').eq(0);
+
+ var $article = $this.closest('.articleObj').eq(0);
var articleNo = $article.data('no');
var $text = $article.find('input.commentText');
var text = $.trim($text.val());
@@ -96,8 +97,8 @@ function drawArticle(idx, articleObj){
.data('no', articleObj.no)
.data('author', articleObj.general_no);
- console.log(articleObj);
-
+
+ $article.find('.articleNo').text(articleObj.no);
$article.find('.authorName').text(articleObj.author);
$article.find('.articleTitle').text(articleObj.title);
$article.find('.date').text(articleObj.date);
@@ -107,7 +108,7 @@ function drawArticle(idx, articleObj){
var $articleComment = $article.find('ul.commentList');
- $.each(articleObj.comment, function(commentObj){
+ $.each(articleObj.comment, function(_, commentObj){
var $comment = $commentFrame.clone();
$comment.find('.author').text(commentObj.author);
//$comment.find('.text').text(commentObj.text);
@@ -116,6 +117,8 @@ function drawArticle(idx, articleObj){
$articleComment.append($comment);
});
+ $article.find('.submitComment').click(submitComment);
+
var $board = $('#board');
$board.append($article);
@@ -150,7 +153,6 @@ function loadArticles(){
$(function(){
$('#submitArticle').click(submitArticle);
-$('.submitComment').click(submitComment);
loadArticles()
.then(drawArticles, errUnknown)
diff --git a/hwe/js/bossInfo.js b/hwe/js/bossInfo.js
new file mode 100644
index 00000000..391eb590
--- /dev/null
+++ b/hwe/js/bossInfo.js
@@ -0,0 +1,81 @@
+function changePermission(isAmbassador, rawGeneralList){
+ console.log(isAmbassador);
+ console.log(rawGeneralList);
+
+ var generalList = [];
+ $.each(rawGeneralList, function(idx, value){
+ generalList.push(parseInt(value.id));
+ })
+
+ $.post({
+ url:'j_general_set_permission.php',
+ dataType:'json',
+ data:{
+ isAmbassador:isAmbassador,
+ genlist:generalList
+ },
+ }).then(function(data){
+ if(!data){
+ alert('변경하지 못했습니다.');
+ return false;
+ }
+ if(!data.result){
+ alert('변경하지 못했습니다. : '+data.reason);
+ return false;
+ }
+ alert('변경했습니다.');
+ location.reload();
+ }, errUnknown);
+}
+
+$(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(){
+ if(!confirm('외교권자를 변경할까요?')){
+ return false;
+ }
+
+ changePermission(true, $('#selectAmbassador').select2('data'));
+ return false;
+ });
+
+ $('#changeAuditor').click(function(){
+ if(!confirm('조언자를 변경할까요?')){
+ return false;
+ }
+
+ changePermission(false, $('#selectAuditor').select2('data'));
+ return false;
+ })
+})
\ No newline at end of file
diff --git a/hwe/js/msg.js b/hwe/js/msg.js
index cf212e38..15d463c6 100644
--- a/hwe/js/msg.js
+++ b/hwe/js/msg.js
@@ -523,7 +523,7 @@ function activateMessageForm(){
jQuery(function($){
//tmp_template.html은 추후 msg.js에 통합될 수 있음
- var getTemplate = $.get('js/templates/message.html?9',function(obj){
+ var getTemplate = $.get('js/templates/message.html?10',function(obj){
messageTemplate = obj;
});
diff --git a/hwe/js/templates/message.html b/hwe/js/templates/message.html
index 5ed9d8b2..a319ee7c 100644
--- a/hwe/js/templates/message.html
+++ b/hwe/js/templates/message.html
@@ -12,7 +12,7 @@