diff --git a/hwe/j_msg_get_recent.php b/hwe/j_msg_get_recent.php index e3001cf6..ee76a7a8 100644 --- a/hwe/j_msg_get_recent.php +++ b/hwe/j_msg_get_recent.php @@ -37,19 +37,21 @@ if($delayTime){ $session->setReadOnly(); -list($generalID, $nationID, $generalName) = DB::db()->queryFirstList( - 'select `no`, `nation`, `name` from `general` where owner = %i', - $userID -); +$db = DB::db(); +$me = $db->queryFirstRow('SELECT `no`,`name`,`nation`,`level`,`con`,`picture`,`imgsvr`,penalty,permission FROM general WHERE `owner`=%i', $userID); - -if($nationID === null){ +if($me === null){ Json::die([ 'result'=>false, 'reason'=>'장수가 사망했습니다.' ]); } +$generalID = $me['no']; +$nationID = $me['nation']; +$generalName = $me['name']; +$permission = checkSecretPermission($me); + $result = []; $result['result'] = true; $result['keepRecent'] = false; @@ -90,12 +92,20 @@ $result['national'] = array_map(function(Message $msg)use (&$nextSequence, &$min return $msg->toArray(); }, Message::getMessagesFromMailBox(Message::MAILBOX_NATIONAL + $nationID, Message::MSGTYPE_NATIONAL, 40, $reqSequence)); -$result['diplomacy']= array_map(function(Message $msg)use (&$nextSequence, &$minSequence, &$lastType){ +$result['diplomacy']= array_map(function(Message $msg)use (&$nextSequence, &$minSequence, &$lastType, $permission){ if($msg->id > $nextSequence){ $nextSequence = $msg->id; } - return $msg->toArray(); -}, Message::getMessagesFromMailBox(Message::MAILBOX_NATIONAL + $nationID, Message::MSGTYPE_DIPLOMACY, 10, 0)); + if($msg->id <= $minSequence){ + $minSequence = $msg->id; + $lastType = 'diplomacy'; + } + $values = $msg->toArray(); + if($permission < 3){ + $values['text'] = '(외교 문서입니다)';//TODO: 외교서신이라 읽을 수 없음을 보여줘야함 + } + return $values; +}, Message::getMessagesFromMailBox(Message::MAILBOX_NATIONAL + $nationID, Message::MSGTYPE_DIPLOMACY, 40, $reqSequence)); if($lastType !== null){ array_pop($result[$lastType]); diff --git a/hwe/j_msg_submit.php b/hwe/j_msg_submit.php index eae1f9f0..5a099d80 100644 --- a/hwe/j_msg_submit.php +++ b/hwe/j_msg_submit.php @@ -99,19 +99,26 @@ if($mailbox == Message::MAILBOX_PUBLIC) { // 국가 메세지 if($mailbox >= Message::MAILBOX_NATIONAL) { - if($me < 3){ + if($permission < 4){ $destNationID = $me['nation']; } else{ $destNationID = $mailbox - Message::MAILBOX_NATIONAL; } + if($destNationID == $me['nation']){ + $msgType = Message::MSGTYPE_NATIONAL; + } + else{ + $msgType = Message::MSGTYPE_DIPLOMACY; + } + $destNation = getNationStaticInfo($destNationID); $dest = new MessageTarget(0, '', $destNation['nation'], $destNation['name'], $destNation['color']); $msg = new Message( - Message::MSGTYPE_NATIONAL, + $msgType, $src, $dest, $text, diff --git a/hwe/js/msg.js b/hwe/js/msg.js index e60e4fe1..99a6f288 100644 --- a/hwe/js/msg.js +++ b/hwe/js/msg.js @@ -126,7 +126,7 @@ function redrawMsg(deferred, addFront){ return t; } lastSequence = Math.max(lastSequence, obj.sequence); - $.each(['public', 'private', 'national'], function (_, msgType) { + $.each(['public', 'private', 'national', 'diplomacy'], function (_, msgType) { var msgList = obj[msgType]; if(msgList === undefined || msgList.length == 0){ return true; @@ -420,7 +420,7 @@ function refreshMailboxList(obj){ $favorite.append($lastContact); //TODO:운영자를 추가하는 코드도 넣을 것. - if(myGeneralLevel >= 5){ + if(permissionLevel >= 4){ $.each(obj.nation, function(){ var nation = this; //console.log(nation); @@ -514,7 +514,7 @@ function activateMessageForm(){ jQuery(function($){ //tmp_template.html은 추후 msg.js에 통합될 수 있음 - var getTemplate = $.get('js/templates/message.html?8',function(obj){ + var getTemplate = $.get('js/templates/message.html?9',function(obj){ messageTemplate = obj; }); diff --git a/hwe/js/templates/message.html b/hwe/js/templates/message.html index 70f5ff5d..c05945c1 100644 --- a/hwe/js/templates/message.html +++ b/hwe/js/templates/message.html @@ -12,7 +12,7 @@
- <%if(msgType != 'diplomacy' && msgType != 'diplomacy' && src.id == myGeneralID && now <= last5min && invalidType == 'msg_valid'){%> + <%if(!this.option && !this.option.action && src.id == myGeneralID && now <= last5min && invalidType == 'msg_valid'){%> <%}%> <%if(msgType == 'private') {%> diff --git a/hwe/sammo/DiplomaticMessage.php b/hwe/sammo/DiplomaticMessage.php index 99db2e99..9541072e 100644 --- a/hwe/sammo/DiplomaticMessage.php +++ b/hwe/sammo/DiplomaticMessage.php @@ -64,8 +64,10 @@ class DiplomaticMessage extends Message{ return [self::INVALID, '송신자가 외교서신을 처리할 수 없습니다.']; } - if(!$general || $general['level'] < 5){ - return [self::INVALID, '해당 국가의 수뇌가 아닙니다.']; + $permission = checkSecretPermission($general); + + if(!$general || $permission < 4){ + return [self::INVALID, '해당 국가의 외교권자 아닙니다.']; } return [self::ACCEPTED, '']; @@ -271,7 +273,7 @@ class DiplomaticMessage extends Message{ $gameStor = KVStorage::getStorage($db, 'game_env'); $general = $db->queryFirstRow( - 'SELECT `name`, `level` FROM general WHERE `no`=%i AND nation=%i', + 'SELECT `name`, `level`, `permission`, `penalty` FROM general WHERE `no`=%i AND nation=%i', $receiverID, $this->dest->nationID ); diff --git a/hwe/sammo/Message.php b/hwe/sammo/Message.php index 9774af59..35c85666 100644 --- a/hwe/sammo/Message.php +++ b/hwe/sammo/Message.php @@ -149,7 +149,7 @@ class Message ]; $action = Util::array_get($option['action'], null); - if ($msgType === self::MSGTYPE_DIPLOMACY) { + if ($msgType === self::MSGTYPE_DIPLOMACY && $action !== null) { $objMessage = new DiplomaticMessage(...$args); } elseif ($action === 'scout') { $objMessage = new ScoutMessage(...$args);