외교권자에게는 메시지를 보낼 수 없음

This commit is contained in:
2019-04-07 22:30:00 +09:00
parent 23c2a16286
commit f4d6803720
4 changed files with 37 additions and 12 deletions
+9 -6
View File
@@ -395,7 +395,7 @@ function myNationInfo() {
";
}
function checkSecretPermission($me){
function checkSecretPermission($me, $checkSecretLimit=true){
if(!key_exists('penalty', $me) || !key_exists('permission', $me)){
trigger_error ('canAccessSecret() 함수에 필요한 인자가 부족');
}
@@ -409,15 +409,14 @@ function checkSecretPermission($me){
if($me['level'] == 0){
return -1;
}
$secretLimit = $db->queryFirstField('SELECT secretlimit FROM nation WHERE nation = %i', $me['nation']);
if($pernalty['noSecret']??false){
return 0;
}
$secretMin = 0;
$secretMax = 3;
$secretMax = 4;
if($penalty['noTopSecret']??false){
$secretMax = 1;
}
@@ -443,8 +442,12 @@ function checkSecretPermission($me){
else if($me['level'] > 1){
$secretMin = 1;
}
else if($me['belong'] >= $secretLimit){
$secretMin = 1;
else if($checkSecretLimit){
$db = DB::db();
$secretLimit = $db->queryFirstField('SELECT secretlimit FROM nation WHERE nation = %i', $me['nation']);
if ($me['belong'] >= $secretLimit) {
$secretMin = 1;
}
}
return min($secretMin, $secretMax);
+8 -3
View File
@@ -5,14 +5,15 @@ function getMailboxList(){
$generalNations = [];
foreach(DB::db()->queryAllLists('select `no`, `name`, `nation`, `level`, `npc` from `general` where `npc` < 2') as $general)
foreach(DB::db()->query('select `no`, `name`, `nation`, `level`, `npc`, `permission`, `penalty` from `general` where `npc` < 2') as $general)
{
list($generalID, $generalName, $nationID, $level, $npc) = $general;
[$generalID, $generalName, $nationID, $level, $npc] = [$general['no'], $general['name'], $general['nation'], $general['level'], $general['npc']];
if(!isset($generalNations[$nationID])){
$generalNations[$nationID] = [];
}
$obj = [$generalID, $generalName, 0];
$permission = checkSecretPermission($general, false);
if($level == 12){
$obj[2] |= 1;
@@ -22,6 +23,10 @@ function getMailboxList(){
$obj[2] |= 2;
}
if($permission == 4){
$obj[2] |= 4;
}
$generalNations[$nationID][] = $obj;
}
@@ -37,7 +42,7 @@ function getMailboxList(){
"mailbox"=>$mailbox,
"name"=>$nationName,
"color"=>$color,
"general"=>$generals
"general"=>$generals,
];
}, array_merge([getNationStaticInfo(0)], getAllNationStaticInfo()));
+11 -2
View File
@@ -150,8 +150,8 @@ if($mailbox > 0) {
$session->lastMsg = $now->format('Y-m-d H:i:s');
$destUser = $db->queryFirstRow('SELECT `no`,`name`,`nation`,`con`,`picture`,`imgsvr` FROM general WHERE `no`=%i',$mailbox);
$destUser = $db->queryFirstRow('SELECT `no`,`name`,`nation`,`level`,`con`,`picture`,`imgsvr`,permission,penalty FROM general WHERE `no`=%i',$mailbox);
if(!$destUser){
Json::die([
'result' => false,
@@ -160,6 +160,15 @@ if($mailbox > 0) {
]);
}
$destPermission = checkSecretPermission($destUser, false);
if($permission == 4 && $destPermission == 4){
Json::die([
'result' => false,
'reason' => '외교권자끼리는 메시지를 보낼 수 없습니다.',
'msgID' => null
]);
}
$destNation = getNationStaticInfo($destUser['nation']);
$dest = new MessageTarget(
+9 -1
View File
@@ -376,6 +376,7 @@ function refreshMailboxList(obj){
var generalName = this[1];
var isNPC = !!(this[2] & 0x2);
var isRuler = !!(this[2] & 0x1);
var isAmbassador = !!(this[2] & 0x4);
@@ -387,6 +388,9 @@ function refreshMailboxList(obj){
if(isRuler){
textName = '*{0}*'.format(textName);
}
else if(isAmbassador){
textName = '#{0}#'.format(textName);
}
generalList[generalID] = {
id:generalID,
@@ -398,6 +402,10 @@ function refreshMailboxList(obj){
};
var $item = $('<option value="{0}">{1}</option>'.format(generalID, textName));
if(permissionLevel == 4 && isAmbassador){
$item.prop('disabled', true);
}
$optgroup.append($item);
});
@@ -460,7 +468,7 @@ function registerGlobal(basicInfo){
window.myGeneralID = basicInfo.generalID;
window.isChief = basicInfo.isChief;
window.myGeneralLevel = basicInfo.generalLevel;
window.permissionLevel = basicInfo.permissionLevel;
window.permissionLevel = basicInfo.permission;
}
function activateMessageForm(){