국메 처리 방식을 변경. 국가간 메시지는 외교권자만 가능

This commit is contained in:
2019-04-07 22:27:14 +09:00
parent 408b1f76e4
commit 06fcc383ce
6 changed files with 38 additions and 19 deletions
+19 -9
View File
@@ -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]);
+9 -2
View File
@@ -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,
+3 -3
View File
@@ -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;
});
+1 -1
View File
@@ -12,7 +12,7 @@
</div>
<div class="msg_body">
<div class="msg_header">
<%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'){%>
<button type="button" data-erase_until="<%last5min%>" class="btn btn btn-outline-warning btn-sm btn-delete-msg" style='float:right'></button>
<%}%>
<%if(msgType == 'private') {%>
+5 -3
View File
@@ -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
);
+1 -1
View File
@@ -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);