[f8bb7aaf30]ng_diplomacy 적용
This commit is contained in:
+10
-4
@@ -132,10 +132,15 @@ for($i=1; $i <= $count; $i++) {
|
||||
|
||||
$generals = $db->query('SELECT no,nation,npc,name,level,penalty,permission FROM general WHERE nation=%i ORDER BY no ASC', $nation['nation']);
|
||||
$ambassadors = [];
|
||||
$auditors = [];
|
||||
foreach($generals as $general){
|
||||
if(checkSecretPermission($general, false) == 4){
|
||||
$generalPermission = checkSecretPermission($general, false);
|
||||
if($generalPermission == 4){
|
||||
$ambassadors[] = $general['name'];
|
||||
}
|
||||
else if($generalPermission == 3){
|
||||
$auditors[] = $general['name'];
|
||||
}
|
||||
}
|
||||
|
||||
echo "
|
||||
@@ -174,10 +179,11 @@ for($i=1; $i <= $count; $i++) {
|
||||
<td align=center>$l5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center id=bg1>외교권자</td><td colspan=7>";
|
||||
<td align=center id=bg1>외교권자</td><td colspan=5>";
|
||||
echo join(', ', $ambassadors);
|
||||
echo "</td>
|
||||
</tr>
|
||||
echo "</td><td align=center id=bg1>조언자</td><td align=center >";
|
||||
echo count($auditors).'명';
|
||||
echo "</td></tr>
|
||||
<tr>
|
||||
<td colspan=8>";
|
||||
if($nation['level'] > 0) {
|
||||
|
||||
@@ -33,7 +33,7 @@ $query = "select nation from general where no='$gen'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
|
||||
$general = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select no,nation,level,con,turntime,belong from general where owner='{$userID}'";
|
||||
$query = "select no,nation,level,con,turntime,belong,permission,penalty from general where owner='{$userID}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
@@ -161,7 +161,7 @@ for ($i=0; $i < $gencount; $i++) {
|
||||
<?=getBatResRecent($gen, 24)?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if($npc > 1 || $meLevel >= 5): ?>
|
||||
<?php if($npc > 1 || $permission >= 2): ?>
|
||||
<tr>
|
||||
<td align=center id=bg1><font color=orange size=3>개인 기록</font></td>
|
||||
<td align=center id=bg1><font color=orange size=3> </font></td>
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ $connect=$db->get();
|
||||
|
||||
increaseRefresh("내무부", 1);
|
||||
|
||||
$me = $db->queryFirstRow('SELECT no, nation, level, con, turntime, belong FROM general WHERE owner=%i', $userID);
|
||||
$me = $db->queryFirstRow('SELECT no, nation, level, con, turntime, belong, permission, penalty FROM general WHERE owner=%i', $userID);
|
||||
|
||||
$nation = $db->queryFirstRow('SELECT msg, scoutmsg FROM nation WHERE nation = %i', $me['nation']);
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ $connect=$db->get();
|
||||
|
||||
increaseRefresh("암행부", 1);
|
||||
|
||||
$query = "select no,nation,level,con,turntime,belong from general where owner='{$userID}'";
|
||||
$query = "select no,nation,level,con,turntime,belong,permission,penalty from general where owner='{$userID}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
|
||||
@@ -467,7 +467,7 @@ if($meLevel >= 5) {
|
||||
</form>
|
||||
<form method=post action=c_myBossInfo.php>
|
||||
<tr>
|
||||
<td colspan=3 align=right id=bg2>시 중 임 명</td>
|
||||
<td colspan=3 align=right id=bg2>종 사 임 명</td>
|
||||
<td colspan=2>
|
||||
<select name=citylist size=1 style=color:white;background-color:black;>
|
||||
";
|
||||
@@ -527,7 +527,7 @@ echo "
|
||||
<td width=158 align=center id=bg1 colspan=2><font size=4>도 시</font></td>
|
||||
<td width=278 align=center id=bg1><font size=4>태 수 (사관) 【현재도시】</font></td>
|
||||
<td width=278 align=center id=bg1><font size=4>군 사 (사관) 【현재도시】</font></td>
|
||||
<td width=278 align=center id=bg1><font size=4>시 중 (사관) 【현재도시】</font></td>
|
||||
<td width=278 align=center id=bg1><font size=4>종 사 (사관) 【현재도시】</font></td>
|
||||
</tr>
|
||||
";
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ $userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$me = $db->queryFirstRow('SELECT `no`,nation,`level` FROM general WHERE `owner`=%i', $userID);
|
||||
$me = $db->queryFirstRow('SELECT `no`,nation,`level`,permission,penalty FROM general WHERE `owner`=%i', $userID);
|
||||
|
||||
//내가 수뇌부이어야함
|
||||
$permission = checkSecretPermission($me);
|
||||
|
||||
@@ -150,6 +150,7 @@ if($btn == "추방") {
|
||||
'level'=>0,
|
||||
'nation'=>0,
|
||||
'belong'=>0,
|
||||
'permission'=>'normal',
|
||||
], 'no=%i', $general['no']);
|
||||
}
|
||||
else{
|
||||
|
||||
+3
-1
@@ -12,7 +12,9 @@ $gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
$killturn = $gameStor->killturn;
|
||||
|
||||
$db->update('general', ['killturn'=>$killturn*3], 'owner=%i', $userID);
|
||||
$db->update('general', [
|
||||
'killturn'=>$killturn*3,
|
||||
], 'owner=%i', $userID);
|
||||
|
||||
|
||||
header('location:b_myPage.php');
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#newArticle{
|
||||
width:1000px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.titleInput{
|
||||
width:100%;
|
||||
color:white;
|
||||
background-color:transparent;
|
||||
border:none;
|
||||
margin:1px 5px;
|
||||
}
|
||||
|
||||
.contentInput{
|
||||
width:100%;
|
||||
min-height:3em;
|
||||
color:white;
|
||||
background-color:transparent;
|
||||
border:none;
|
||||
padding:1px 5px;
|
||||
}
|
||||
|
||||
.articleFrame{
|
||||
width:1000px;
|
||||
margin: 20px auto;
|
||||
}
|
||||
|
||||
.commentText{
|
||||
width:100%;
|
||||
}
|
||||
|
||||
.authorName, .comment .author{
|
||||
width:110px;
|
||||
font-size:85%;
|
||||
}
|
||||
|
||||
.date{
|
||||
width:125px;
|
||||
font-size:85%;
|
||||
}
|
||||
|
||||
.text{
|
||||
text-align:left;
|
||||
padding:1px 5px;
|
||||
}
|
||||
|
||||
.submitComment{
|
||||
width:100%;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
#newLetter {
|
||||
width:1000px;
|
||||
margin: 10px auto;
|
||||
}
|
||||
|
||||
#newLetter th{
|
||||
width:20ch;
|
||||
}
|
||||
|
||||
#newLetter textarea{
|
||||
width:100%;
|
||||
min-height:3em;
|
||||
color:white;
|
||||
background-color:transparent;
|
||||
border:none;
|
||||
}
|
||||
|
||||
.letterFrame{
|
||||
width:1000px;
|
||||
margin: 10px auto;
|
||||
}
|
||||
|
||||
.letterFrame th{
|
||||
width:20ch;
|
||||
}
|
||||
|
||||
.letterHeader{
|
||||
position: relative;
|
||||
font-size:200%;
|
||||
}
|
||||
|
||||
.letterDate{
|
||||
position: absolute;
|
||||
right:1ch;
|
||||
bottom:0.2em;
|
||||
font-size:50%;
|
||||
|
||||
}
|
||||
|
||||
.letterBrief, .letterDetail{
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.letterSignerPlate{
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.letterSrc, .letterDest{
|
||||
display:inline-block;
|
||||
margin: 0 10px;
|
||||
border: 1px solid gray;
|
||||
width:110px;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.signerNation, .signerName{
|
||||
border-top: 1px solid gray;
|
||||
}
|
||||
|
||||
@@ -1942,6 +1942,7 @@ function deleteNation(General $general) {
|
||||
'level'=>0,
|
||||
'nation'=>0,
|
||||
'makelimit'=>12,
|
||||
'permission'=>'normal',
|
||||
], 'nation=%i', $nationID);
|
||||
// 도시 공백지로
|
||||
$db->update('city', [
|
||||
|
||||
@@ -788,6 +788,7 @@ function checkMerge() {
|
||||
|
||||
$db->update('general', [
|
||||
'nation'=>0,
|
||||
'permission'=>'normal',
|
||||
], 'nation=%i AND npc = 5', $me['nation']);
|
||||
|
||||
$query = "delete from nation where nation='{$me['nation']}'";
|
||||
@@ -944,6 +945,7 @@ function checkSurrender() {
|
||||
|
||||
$db->update('general', [
|
||||
'nation'=>0,
|
||||
'permission'=>'normal',
|
||||
], 'nation=%i AND npc = 5', $me['nation']);
|
||||
|
||||
$query = "delete from nation where nation='{$me['nation']}'";
|
||||
|
||||
@@ -243,6 +243,7 @@ function process_25(&$general) {
|
||||
'nation'=>$nation['nation'],
|
||||
'nations'=>Json::encode($joinedNations),
|
||||
'level'=>1,
|
||||
'permission'=>'normal',
|
||||
'experience'=>$db->sqleval('experience + %i', $exp),
|
||||
'city'=>$king['city'],
|
||||
'belong'=>1
|
||||
|
||||
@@ -163,7 +163,8 @@ function commandButton() {
|
||||
'fgColor'=>$fgColor,
|
||||
'meLevel'=>$me['level'],
|
||||
'nationLevel'=>$nation['level'],
|
||||
'showSecret'=>$showSecret
|
||||
'showSecret'=>$showSecret,
|
||||
'permission'=>$permission,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -333,7 +333,7 @@ if ($con == 1) {
|
||||
MessageBox("접속제한이 얼마 남지 않았습니다!");
|
||||
}
|
||||
if ($me['newmsg'] == 1) {
|
||||
MessageBox("개인 서신이 도착했습니다!");
|
||||
MessageBox("새로운 서신이 도착했습니다!");
|
||||
}
|
||||
if ($me['newvote'] == 1) {
|
||||
$develcost = $gameStor->develcost*5;
|
||||
|
||||
@@ -15,7 +15,7 @@ $text = Util::getReq('text');
|
||||
|
||||
increaseRefresh("회의실", 1);
|
||||
|
||||
$me = $db->queryFirstRow('SELECT no, nation, name, 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, `picture`,`imgsvr` FROM general WHERE owner=%i', $userID);
|
||||
|
||||
$con = checkLimit($me['con']);
|
||||
if ($con >= 2) {
|
||||
@@ -57,12 +57,15 @@ else if ($isSecretBoard && $permission < 2) {
|
||||
]);
|
||||
}
|
||||
|
||||
$icon = GetImageURL($me['imgsvr'], $me['picture']);
|
||||
|
||||
$db->insert('board', [
|
||||
'nation_no'=>$me['nation'],
|
||||
'is_secret'=>$isSecretBoard,
|
||||
'date'=>TimeUtil::DatetimeNow(),
|
||||
'general_no'=>$me['no'],
|
||||
'author'=>$me['name'],
|
||||
'author_icon'=>$icon,
|
||||
'title'=>$title,
|
||||
'text'=>$text
|
||||
]);
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
//로그인 검사
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$letterNo = Util::getReq('letterNo', 'int');
|
||||
|
||||
increaseRefresh("외교부", 1);
|
||||
|
||||
$me = $db->queryFirstRow('SELECT no, name, nation, level, permission, con, turntime, belong, penalty, picture, imgsvr FROM general WHERE owner=%i', $userID);
|
||||
|
||||
$con = checkLimit($me['con']);
|
||||
if ($con >= 2) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'접속 제한입니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
if($letterNo === null){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'올바르지 않은 입력입니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$permission = checkSecretPermission($me);
|
||||
if ($permission < 4) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'권한이 부족합니다. 수뇌부가 아닙니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
$letter = $db->queryFirstRow('SELECT * FROM ng_diplomacy WHERE no=%i AND (src_nation_id = %i OR dest_nation_id = %i) AND state = \'activated\'', $letterNo, $me['nation'], $me['nation']);
|
||||
if(!$letter){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'서신이 없습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$aux = Json::decode($letter['aux']);
|
||||
|
||||
|
||||
$stateOpt = $aux['state_opt']??null;
|
||||
|
||||
if(($stateOpt == 'try_destroy_src' && $letter['src_nation_id'] == $me['nation'])||
|
||||
($stateOpt == 'try_destroy_dest' && $letter['dest_nation_id'] == $me['nation'])){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'이미 파기 신청을 했습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
$srcNation = getNationStaticInfo($letter['src_nation_id']);
|
||||
$destNation = getNationStaticInfo($letter['dest_nation_id']);
|
||||
$me['icon'] = GetImageURL($me['imgsvr'], $me['picture']);
|
||||
|
||||
|
||||
if($letter['src_nation_id'] == $me['nation']){
|
||||
$src = new MessageTarget($me['no'], $me['name'], $srcNation['nation'], $srcNation['name'], $srcNation['color'], $me['icon']);
|
||||
$dest = new MessageTarget(0, '', $destNation['nation'], $destNation['name'], $destNation['color']);
|
||||
}
|
||||
else{
|
||||
$src = new MessageTarget($me['no'], $me['name'], $destNation['nation'], $destNation['name'], $destNation['color'], $me['icon']);
|
||||
$dest = new MessageTarget(0, '', $srcNation['nation'], $srcNation['name'], $srcNation['color']);
|
||||
}
|
||||
|
||||
|
||||
$now = new \DateTime();
|
||||
$unlimited = new \DateTime('9999-12-31');
|
||||
|
||||
if(in_array($stateOpt, ['try_destroy_src', 'try_destroy_dest'])){
|
||||
$deleteLetterNo = $letterNo;
|
||||
$db->update('ng_diplomacy', [
|
||||
'state'=>'cancelled',
|
||||
'aux'=>Json::encode($aux)
|
||||
], 'no=%i', $letterNo);
|
||||
while(true){
|
||||
$deleteLetter = $db->queryFirstRow('SELECT prev_no, aux FROM ng_diplomacy WHERE no = %i AND state = \'replaced\'', $currentLetterNo);
|
||||
if(!$deleteLetter){
|
||||
break;
|
||||
}
|
||||
$deleteAux = Json::decode($deleteLetter['aux']);
|
||||
$deleteLetterNo = $deleteLetter['prev_no'];
|
||||
$deleteAux['reason'] = [
|
||||
'who'=>$me['no'],
|
||||
'action'=>'destroy',
|
||||
'reason'=>'파기'
|
||||
];
|
||||
}
|
||||
$msgText = "외교 서신 #{$letterNo}를 파기했습니다.";
|
||||
$lastState = 'cancelled';
|
||||
}
|
||||
else{
|
||||
if ($letter['src_nation_id'] == $me['nation']) {
|
||||
$aux['state_opt'] = 'try_destroy_src';
|
||||
}
|
||||
else{
|
||||
$aux['state_opt'] = 'try_destroy_dest';
|
||||
}
|
||||
$db->update('ng_diplomacy', [
|
||||
'aux'=>Json::encode($aux)
|
||||
], 'no=%i', $letterNo);
|
||||
|
||||
$msgText = "외교 서신 #{$letterNo}를 파기 요청합니다.";
|
||||
$lastState = 'activated';
|
||||
}
|
||||
|
||||
$msg = new Message(
|
||||
Message::MSGTYPE_DIPLOMACY,
|
||||
$src,
|
||||
$dest,
|
||||
$msgText,
|
||||
$now,
|
||||
$unlimited,
|
||||
['invalid' => true]
|
||||
);
|
||||
$msgID = $msg->send();
|
||||
|
||||
Json::die([
|
||||
'result'=>true,
|
||||
'reason'=>'success',
|
||||
'state'=>$lastState
|
||||
]);
|
||||
@@ -38,17 +38,32 @@ $letters = [];
|
||||
|
||||
foreach(
|
||||
$db->query(
|
||||
'SELECT * FROM ng_diplomacy WHERE src_nation_id = %i OR dest_nation_id = %i ORDER BY date desc',
|
||||
'SELECT * FROM ng_diplomacy WHERE (src_nation_id = %i OR dest_nation_id = %i) AND state != \'cancelled\' ORDER BY date desc',
|
||||
$me['nation'], $me['nation']
|
||||
) as $letter
|
||||
){
|
||||
|
||||
if($permission < 3){
|
||||
if($permission < 3 && $letter['detail']){
|
||||
$letter['detail'] = '(권한이 부족합니다)';
|
||||
}
|
||||
$letter['comment'] = [];
|
||||
$letter['aux'] = Json::decode($letter['aux']);
|
||||
$letters[$letter['no']] = $letter;
|
||||
$letter['src'] = $letter['aux']['src'];
|
||||
$letter['dest'] = $letter['aux']['dest'];
|
||||
|
||||
$letter['src']['nationID'] = $letter['src_nation_id'];
|
||||
$letter['dest']['nationID'] = $letter['dest_nation_id'];
|
||||
|
||||
$letters[$letter['no']] = [
|
||||
'no'=>$letter['no'],
|
||||
'src'=>$letter['src'],
|
||||
'dest'=>$letter['dest'],
|
||||
'prev_no'=>$letter['prev_no'],
|
||||
'state'=>$letter['state'],
|
||||
'state_opt'=>($letter['aux']['state_opt']??null),
|
||||
'brief'=>$letter['text_brief'],
|
||||
'detail'=>$letter['text_detail'],
|
||||
'date'=>$letter['date']
|
||||
];
|
||||
}
|
||||
|
||||
$nations = [];
|
||||
@@ -63,6 +78,7 @@ Json::die([
|
||||
'result'=>true,
|
||||
'nations'=>$nations,
|
||||
'letters'=>$letters,
|
||||
'myNationID'=>$me['nation'],
|
||||
'reason'=>'success'
|
||||
]);
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ $reason = Util::getReq('reason', 'string', '');
|
||||
|
||||
|
||||
|
||||
increaseRefresh("회의실", 1);
|
||||
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, name, nation, level, permission, con, turntime, belong, penalty, picture, imgsvr FROM general WHERE owner=%i', $userID);
|
||||
|
||||
$con = checkLimit($me['con']);
|
||||
if ($con >= 2) {
|
||||
@@ -35,7 +35,6 @@ if($letterNo === null){
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$permission = checkSecretPermission($me);
|
||||
if ($permission < 4) {
|
||||
Json::die([
|
||||
@@ -55,15 +54,36 @@ if(!$letter){
|
||||
}
|
||||
|
||||
$aux = Json::decode($letter['aux']);
|
||||
$me['icon'] = GetImageURL($me['imgsvr'], $me['picture']);
|
||||
|
||||
$srcNation = getNationStaticInfo($letter['src_nation_id']);
|
||||
$destNation = getNationStaticInfo($letter['dest_nation_id']);
|
||||
|
||||
$src = new MessageTarget($me['no'], $me['name'], $destNation['nation'], $destNation['name'], $destNation['color'], $me['icon']);
|
||||
$dest = new MessageTarget(0, '', $srcNation['nation'], $srcNation['name'], $srcNation['color']);
|
||||
|
||||
$now = new \DateTime();
|
||||
$unlimited = new \DateTime('9999-12-31');
|
||||
|
||||
if($isAgree){
|
||||
$aux['dest']['generalName'] = $me['name'];
|
||||
$aux['dest']['generalIcon'] = $me['icon'];
|
||||
|
||||
$db->update('ng_diplomacy', [
|
||||
'state'=>'activated',
|
||||
'dest_signer'=>$me['no'],
|
||||
'aux'=>Json::encode($aux)
|
||||
], 'no=%i', $letterNo);
|
||||
//TODO: 외교 서신에 대한 메시지를 양국에 발송해야함
|
||||
|
||||
$prevLetterNo = $letter['prev_no'];
|
||||
while($prevLetterNo !== null){
|
||||
$db->update('ng_diplomacy', [
|
||||
'state'=>'replaced',
|
||||
], 'no=%i', $prevLetterNo);
|
||||
$prevLetterNo = $db->queryFirstField('SELECT prev_no FROM ng_diplomacy WHERE state != \'cancelled\' AND no = %i', $prevLetterNo);
|
||||
}
|
||||
$msgText = "외교 서신 #{$letterNo}가 승인되었습니다.";
|
||||
}
|
||||
else{
|
||||
$aux['reason'] = [
|
||||
@@ -74,10 +94,24 @@ else{
|
||||
$db->update('ng_diplomacy', [
|
||||
'state'=>'cancelled',
|
||||
'aux'=>Json::encode($aux)
|
||||
]);
|
||||
//TODO: 외교 서신에 대한 메시지를 양국에 발송해야함
|
||||
], 'no=%i', $letterNo);
|
||||
$msgText = "외교 서신 #{$letterNo}가 거부되었습니다.";
|
||||
if($reason){
|
||||
$msgText .= ' 이유 : '.$reason;
|
||||
}
|
||||
}
|
||||
|
||||
$msg = new Message(
|
||||
Message::MSGTYPE_DIPLOMACY,
|
||||
$src,
|
||||
$dest,
|
||||
$msgText,
|
||||
$now,
|
||||
$unlimited,
|
||||
['invalid' => true]
|
||||
);
|
||||
$msgID = $msg->send();
|
||||
|
||||
Json::die([
|
||||
'result'=>true,
|
||||
'reason'=>'success'
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
//로그인 검사
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$letterNo = Util::getReq('letterNo', 'int');
|
||||
|
||||
increaseRefresh("외교부", 1);
|
||||
|
||||
$me = $db->queryFirstRow('SELECT no, name, nation, level, permission, con, turntime, belong, penalty, picture, imgsvr FROM general WHERE owner=%i', $userID);
|
||||
|
||||
$con = checkLimit($me['con']);
|
||||
if ($con >= 2) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'접속 제한입니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
if($letterNo === null){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'올바르지 않은 입력입니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$permission = checkSecretPermission($me);
|
||||
if ($permission < 4) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'권한이 부족합니다. 수뇌부가 아닙니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
$reason = trim($reason);
|
||||
|
||||
$letter = $db->queryFirstRow('SELECT * FROM ng_diplomacy WHERE no=%i AND src_nation_id = %i AND state = \'proposed\'', $letterNo, $me['nation']);
|
||||
if(!$letter){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'서신이 없습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
$aux = Json::decode($letter['aux']);
|
||||
$me['icon'] = GetImageURL($me['imgsvr'], $me['picture']);
|
||||
|
||||
$srcNation = getNationStaticInfo($letter['src_nation_id']);
|
||||
$destNation = getNationStaticInfo($letter['dest_nation_id']);
|
||||
|
||||
$src = new MessageTarget($me['no'], $me['name'], $srcNation['nation'], $srcNation['name'], $srcNation['color'], $me['icon']);
|
||||
$dest = new MessageTarget(0, '', $destNation['nation'], $destNation['name'], $destNation['color']);
|
||||
|
||||
$now = new \DateTime();
|
||||
$unlimited = new \DateTime('9999-12-31');
|
||||
|
||||
$aux['reason'] = [
|
||||
'who'=>$me['no'],
|
||||
'action'=>'cancelled',
|
||||
'reason'=>$reason
|
||||
];
|
||||
$db->update('ng_diplomacy', [
|
||||
'state'=>'cancelled',
|
||||
'aux'=>Json::encode($aux)
|
||||
], 'no=%i', $letterNo);
|
||||
$msgText = "외교 서신 #{$letterNo}가 회수되었습니다.";
|
||||
|
||||
$msg = new Message(
|
||||
Message::MSGTYPE_DIPLOMACY,
|
||||
$src,
|
||||
$dest,
|
||||
$msgText,
|
||||
$now,
|
||||
$unlimited,
|
||||
['invalid' => true]
|
||||
);
|
||||
$msgID = $msg->send();
|
||||
|
||||
Json::die([
|
||||
'result'=>true,
|
||||
'reason'=>'success'
|
||||
]);
|
||||
@@ -11,8 +11,8 @@ $db = DB::db();
|
||||
|
||||
$destNationNo = Util::getReq('destNation', 'int', 0);
|
||||
$prevNo = Util::getReq('prevNo', 'int', null);
|
||||
$textBrief = Util::getReq('textBrief');
|
||||
$textDetail = Util::getReq('textDetail');
|
||||
$textBrief = Util::getReq('brief');
|
||||
$textDetail = Util::getReq('detail');
|
||||
|
||||
increaseRefresh("외교부", 1);
|
||||
|
||||
@@ -20,7 +20,7 @@ if($prevNo < 1){
|
||||
$prevNo = null;
|
||||
}
|
||||
|
||||
$me = $db->queryFirstRow('SELECT no, nation, level, permission, con, turntime, belong, penalty FROM general WHERE owner=%i', $userID);
|
||||
$me = $db->queryFirstRow('SELECT no, name, nation, level, permission, con, turntime, belong, penalty, picture, imgsvr FROM general WHERE owner=%i', $userID);
|
||||
|
||||
$con = checkLimit($me['con']);
|
||||
if ($con >= 2) {
|
||||
@@ -65,18 +65,10 @@ if ($permission < 4) {
|
||||
|
||||
$srcNationNo = $me['nation'];
|
||||
|
||||
$nations = $db->query('SELECT nation, name, color FROM nation WHERE nation IN (%i, %i)', $srcNationNo, $destNationNo);
|
||||
if(count($nations) != 2){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'올바르지 않은 국가입니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
if($prevNo !== null){
|
||||
//state는 체크하지 않는걸로 하자. 파기한 것을 재 송신하는 경우도 있을 수 있음.
|
||||
$prevLetter = $db->queryFirstRow(
|
||||
'SELECT no, state, aux FROM ng_diplomacy WHERE no = %i AND src_nation_id IN (%i, %i) AND dest_nation_id IN (%i, %i)',
|
||||
'SELECT no, src_nation_id, dest_nation_id, state, aux FROM ng_diplomacy WHERE no = %i AND src_nation_id IN (%i, %i) AND dest_nation_id IN (%i, %i)',
|
||||
$prevNo,
|
||||
$srcNationNo, $destNationNo,
|
||||
$srcNationNo, $destNationNo
|
||||
@@ -89,6 +81,24 @@ if($prevNo !== null){
|
||||
]);
|
||||
}
|
||||
|
||||
//새로 나온 문서가 있는지 확인하자
|
||||
$newerLetter = $db->queryFirstField(
|
||||
'SELECT count(no) FROM ng_diplomacy WHERE prev_no = %i AND state != \'cancelled\'', $prevNo
|
||||
);
|
||||
if($newerLetter){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'해당 문서에 대한 새로운 문서가 이미 있습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
if($prevLetter['src_nation_id'] != $srcNationNo){
|
||||
$destNationNo = $prevLetter['src_nation_id'];
|
||||
}
|
||||
else{
|
||||
$destNationNo = $prevLetter['dest_nation_id'];
|
||||
}
|
||||
|
||||
if($prevLetter['state'] == 'proposed'){
|
||||
$prevAux = Json::decode($prevLetter['aux']);
|
||||
$prevAux['reason'] = [
|
||||
@@ -97,12 +107,20 @@ if($prevNo !== null){
|
||||
'reason'=>'new_letter'
|
||||
];
|
||||
$db->update('ng_diplomacy', [
|
||||
'state'=>'cancelled',
|
||||
'state'=>'replaced',
|
||||
'aux'=>Json::encode($prevAux)
|
||||
], 'no=%i', $prevNo);
|
||||
}
|
||||
}
|
||||
|
||||
$nations = $db->query('SELECT nation, name, color FROM nation WHERE nation IN (%i, %i)', $srcNationNo, $destNationNo);
|
||||
if(count($nations) != 2){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'올바르지 않은 국가입니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
if($nations[0]['nation'] == $me['nation']){
|
||||
//index 순서에 따라 또 모름.
|
||||
$srcNation = $nations[0];
|
||||
@@ -113,6 +131,8 @@ else{
|
||||
$destNation = $nations[0];
|
||||
}
|
||||
|
||||
$me['icon'] = GetImageURL($me['imgsvr'], $me['picture']);
|
||||
|
||||
$db->insert('ng_diplomacy', [
|
||||
'src_nation_id'=>$srcNation['nation'],
|
||||
'dest_nation_id'=>$destNation['nation'],
|
||||
@@ -127,7 +147,8 @@ $db->insert('ng_diplomacy', [
|
||||
'src'=>[
|
||||
'nationName'=>$srcNation['name'],
|
||||
'nationColor'=>$srcNation['color'],
|
||||
'generalName'=>$me['name']
|
||||
'generalName'=>$me['name'],
|
||||
'generalIcon'=>$me['icon']
|
||||
],
|
||||
'dest'=>[
|
||||
'nationName'=>$destNation['name'],
|
||||
@@ -135,9 +156,33 @@ $db->insert('ng_diplomacy', [
|
||||
]
|
||||
]),
|
||||
]);
|
||||
$newLetterNo = $db->insertId();
|
||||
|
||||
$src = new MessageTarget($me['no'], $me['name'], $srcNation['nation'], $srcNation['name'], $srcNation['color'], $me['icon']);
|
||||
$dest = new MessageTarget(0, '', $destNation['nation'], $destNation['name'], $destNation['color']);
|
||||
|
||||
$now = new \DateTime();
|
||||
$unlimited = new \DateTime('9999-12-31');
|
||||
|
||||
$josaYi = JosaUtil::pick($newLetterNo, '이');
|
||||
if($prevNo){
|
||||
$msgText = "문서 #{$prevNo}의 새로운 외교 문서 #{$newLetterNo}{$josaYi} 준비되었습니다. 외교부에서 확인해주세요.";
|
||||
}
|
||||
else{
|
||||
$msgText = "새로운 외교 문서 #{$newLetterNo}{$josaYi} 준비되었습니다. 외교부에서 확인해주세요.";
|
||||
}
|
||||
|
||||
|
||||
//TODO: 외교 서신에 대한 메시지를 양국에 발송해야함
|
||||
$msg = new Message(
|
||||
Message::MSGTYPE_DIPLOMACY,
|
||||
$src,
|
||||
$dest,
|
||||
$msgText,
|
||||
$now,
|
||||
$unlimited,
|
||||
['invalid' => true]
|
||||
);
|
||||
$msgID = $msg->send();
|
||||
|
||||
Json::die([
|
||||
'result'=>true,
|
||||
|
||||
@@ -101,8 +101,9 @@ $result['diplomacy']= array_map(function(Message $msg)use (&$nextSequence, &$min
|
||||
$lastType = 'diplomacy';
|
||||
}
|
||||
$values = $msg->toArray();
|
||||
if($permission < 3){
|
||||
$values['text'] = '(외교 문서입니다)';//TODO: 외교서신이라 읽을 수 없음을 보여줘야함
|
||||
if($msg->dest->nationID != 0 && $permission < 3){
|
||||
$values['text'] = '(외교 메시지입니다)';//TODO: 외교서신이라 읽을 수 없음을 보여줘야함
|
||||
$values['option']['invalid'] = true;
|
||||
}
|
||||
return $values;
|
||||
}, Message::getMessagesFromMailBox(Message::MAILBOX_NATIONAL + $nationID, Message::MSGTYPE_DIPLOMACY, 20, $reqSequence));
|
||||
|
||||
@@ -77,6 +77,7 @@ $db->update('general', [
|
||||
'npc'=>1,
|
||||
'killturn'=>6,
|
||||
'mode'=>2,
|
||||
'permission'=>'normal',
|
||||
'owner'=>$userID,
|
||||
], 'owner <= 0 AND npc = 2 AND no = %i', $pick);
|
||||
|
||||
|
||||
+14
-4
@@ -90,7 +90,7 @@ function submitComment(){
|
||||
|
||||
function drawArticle(idx, articleObj){
|
||||
var $articleFrame = $('#articleTemplate > .articleFrame');
|
||||
var $commentFrame = $('#commentTemplate > .comment');
|
||||
var $commentFrame = $($('#commentTemplate').prop('content'));
|
||||
|
||||
var $article = $articleFrame.clone();
|
||||
$article.addClass('articleObj')
|
||||
@@ -102,11 +102,14 @@ function drawArticle(idx, articleObj){
|
||||
$article.find('.authorName').text(articleObj.author);
|
||||
$article.find('.articleTitle').text(articleObj.title);
|
||||
$article.find('.date').text(articleObj.date);
|
||||
if(articleObj.author_icon){
|
||||
$article.find('.authorIcon').attr('src', articleObj.author_icon);
|
||||
}
|
||||
//$article.find('.text').text(articleObj.text);
|
||||
$article.find('.text').html(nl2br(escapeHtml(articleObj.text)));
|
||||
//TODO: 바꿀 것
|
||||
|
||||
var $articleComment = $article.find('ul.commentList');
|
||||
var $articleComment = $article.find('.commentList');
|
||||
|
||||
$.each(articleObj.comment, function(_, commentObj){
|
||||
var $comment = $commentFrame.clone();
|
||||
@@ -121,7 +124,7 @@ function drawArticle(idx, articleObj){
|
||||
|
||||
var $board = $('#board');
|
||||
|
||||
$board.append($article);
|
||||
$board.prepend($article);
|
||||
}
|
||||
|
||||
function drawArticles(articlesObj){
|
||||
@@ -150,8 +153,15 @@ function loadArticles(){
|
||||
});
|
||||
}
|
||||
|
||||
$(function(){
|
||||
function resizeTextarea($obj){
|
||||
$obj.height(1).height($obj.prop('scrollHeight')+12 );
|
||||
}
|
||||
|
||||
$(function(){
|
||||
$('textarea.autosize').on('keydown keyup', function(){
|
||||
resizeTextarea($(this));
|
||||
})
|
||||
|
||||
$('#submitArticle').click(submitArticle);
|
||||
|
||||
loadArticles()
|
||||
|
||||
@@ -124,6 +124,27 @@ String.prototype.format = function() {
|
||||
};
|
||||
|
||||
|
||||
function hexToRgb(hex) {
|
||||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||
return result ? {
|
||||
r: parseInt(result[1], 16),
|
||||
g: parseInt(result[2], 16),
|
||||
b: parseInt(result[3], 16)
|
||||
} : null;
|
||||
}
|
||||
|
||||
|
||||
function isBrightColor(color){
|
||||
color = hexToRgb(color);
|
||||
if ((color.r*0.299 + color.g*0.587 + color.b*0.114) > 140){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 게임내에서 지원하는 color type만 선택할 수 있도록 해주는 함수
|
||||
* @param {string} color #AAAAAA 또는 AAAAAA 형태로 작성된 RGB hex color string
|
||||
|
||||
+312
-39
@@ -1,11 +1,10 @@
|
||||
|
||||
|
||||
function submitLetter(){
|
||||
var $letter = $('#newLetter');
|
||||
var $brief = $letter.find('input.briefInput');
|
||||
var $detail = $letter.find('input.detailInput');
|
||||
var $prevNo = $letter.find('input.prevNo');
|
||||
var $destNation = $letter.find('input.destNation');
|
||||
var $brief = $('#inputBrief');
|
||||
var $detail = $('#inputDetail');
|
||||
var $prevNo = $('#inputPrevNo');
|
||||
var $destNation = $('#inputDestNation');
|
||||
var brief = $.trim($brief.val());
|
||||
var detail = $.trim($detail.val());
|
||||
var prevNo = parseInt($prevNo.val());
|
||||
@@ -15,7 +14,7 @@ function submitLetter(){
|
||||
prevNo = null;
|
||||
}
|
||||
|
||||
|
||||
console.log(brief);
|
||||
if(!brief){
|
||||
return false;
|
||||
}
|
||||
@@ -34,18 +33,18 @@ function submitLetter(){
|
||||
}
|
||||
}).then(function(data){
|
||||
if(!data){
|
||||
$title.val(title);
|
||||
$text.val(text);
|
||||
alert()
|
||||
$brief.val(brief);
|
||||
$detail.val(detail);
|
||||
return quickReject('외교 서신을 보내는데 실패했습니다.');
|
||||
}
|
||||
if(!data.result){
|
||||
$title.val(title);
|
||||
$text.val(text);
|
||||
$brief.val(brief);
|
||||
$detail.val(detail);
|
||||
return quickReject('외교 서신을 보내는데 실패했습니다. : '+data.reason);
|
||||
}
|
||||
|
||||
return loadLetters().done(drawLetters);
|
||||
alert('전송했습니다.');
|
||||
location.reload();
|
||||
|
||||
}, errUnknown)
|
||||
.fail(function(reason){
|
||||
@@ -55,31 +54,33 @@ function submitLetter(){
|
||||
return false;
|
||||
}
|
||||
|
||||
function repondLetter(isAgree){
|
||||
var $this = $(this);
|
||||
var $letter = $this.parents('.letter').eq(0);
|
||||
var letterNo = $letter.data('no');
|
||||
|
||||
function repondLetter(letterNo, isAgree, reason){
|
||||
$.post({
|
||||
url:'j_diplomacy_respond_letter.php',
|
||||
dataType:'json',
|
||||
data:{
|
||||
letterNo:letterNo,
|
||||
isAgree:isAgree,
|
||||
reason:'', //TODO: reason 받기
|
||||
reason:reason,
|
||||
}
|
||||
}).then(function(data){
|
||||
if(!data){
|
||||
$text.val(text);
|
||||
alert()
|
||||
return quickReject('응답을 실패했습니다.');
|
||||
}
|
||||
if(!data.result){
|
||||
$text.val(text);
|
||||
return quickReject('응답을 실패했습니다. : '+data.reason);
|
||||
}
|
||||
|
||||
return loadArticles().done(drawLetters);
|
||||
if(isAgree){
|
||||
alert('승인했습니다.');
|
||||
}
|
||||
else{
|
||||
alert('거부했습니다.');
|
||||
}
|
||||
|
||||
location.reload();
|
||||
return false;
|
||||
|
||||
}, errUnknown)
|
||||
.fail(function(reason){
|
||||
@@ -89,22 +90,276 @@ function repondLetter(isAgree){
|
||||
return false;
|
||||
}
|
||||
|
||||
function drawLetter(letterObj){
|
||||
function rollbackLetter(letterNo){
|
||||
$.post({
|
||||
url:'j_diplomacy_rollback_letter.php',
|
||||
dataType:'json',
|
||||
data:{
|
||||
letterNo:letterNo,
|
||||
}
|
||||
}).then(function(data){
|
||||
if(!data){
|
||||
alert()
|
||||
return quickReject('회수를 실패했습니다.');
|
||||
}
|
||||
if(!data.result){
|
||||
return quickReject('회수를 실패했습니다. : '+data.reason);
|
||||
}
|
||||
|
||||
alert('회수 했습니다.');
|
||||
|
||||
location.reload();
|
||||
return false;
|
||||
|
||||
}, errUnknown)
|
||||
.fail(function(reason){
|
||||
alert(reason);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function destroyLetter(letterNo){
|
||||
$.post({
|
||||
url:'j_diplomacy_destroy_letter.php',
|
||||
dataType:'json',
|
||||
data:{
|
||||
letterNo:letterNo,
|
||||
}
|
||||
}).then(function(data){
|
||||
if(!data){
|
||||
alert()
|
||||
return quickReject('파기를 실패했습니다.');
|
||||
}
|
||||
if(!data.result){
|
||||
return quickReject('파기를 실패했습니다. : '+data.reason);
|
||||
}
|
||||
|
||||
if(data.state == 'activated'){
|
||||
alert('파기를 요청 했습니다.');
|
||||
}
|
||||
else{
|
||||
alert('파기 되었습니다.');
|
||||
}
|
||||
|
||||
location.reload();
|
||||
return false;
|
||||
|
||||
}, errUnknown)
|
||||
.fail(function(reason){
|
||||
alert(reason);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function drawLetter(idx, letterObj){
|
||||
|
||||
if(letterObj.state == 'cancelled'){
|
||||
//TODO: 취소되거나, 대체된 문서도 보여줄 방법을 찾아볼 것
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(letterObj);
|
||||
|
||||
var $letterFrame = $('#letterTemplate > .letterFrame');
|
||||
|
||||
var srcColorFormat = {
|
||||
'background-color':letterObj.src.nationColor,
|
||||
'color':isBrightColor(letterObj.src.nationColor)?'#000000':'#ffffff'
|
||||
};
|
||||
|
||||
var destColorFormat = {
|
||||
'background-color':letterObj.dest.nationColor,
|
||||
'color':isBrightColor(letterObj.dest.nationColor)?'#000000':'#ffffff'
|
||||
};
|
||||
|
||||
var targetNation = letterObj.src.nationID==myNationID?letterObj.dest:letterObj.src;
|
||||
var targetColor = letterObj.src.nationID==myNationID?destColorFormat:srcColorFormat;
|
||||
|
||||
var $letter = $letterFrame.clone();
|
||||
|
||||
if(letterObj.state == 'replaced'){
|
||||
$letter.hide();
|
||||
}
|
||||
|
||||
$letter.addClass('letterObj')
|
||||
.data('no', letterObj.no)
|
||||
.data('brief', letterObj.brief)
|
||||
.data('detail', letterObj.detail)
|
||||
.attr('id', 'letter_'+letterObj.no);
|
||||
|
||||
//TODO: 국가명, 수뇌명 입력
|
||||
$letter.find('.date').text(letterObj.date);
|
||||
$letter.find('.letterHeader').css(targetColor);
|
||||
$letter.find('.letterNationName').text(targetNation.nationName);
|
||||
$letter.find('.letterDate').text(letterObj.date);
|
||||
$letter.find('.letterNo').text('#'+letterObj.no);
|
||||
$letter.find('.srcNation').text(letterObj.aux[''])
|
||||
$letter.find('.brief').html(nl2br(escapeHtml(letterObj.brief)));
|
||||
$letter.find('.detail').html(nl2br(escapeHtml(letterObj.detail)));
|
||||
//TODO: 바꿀 것
|
||||
|
||||
$('#board').append($letter);
|
||||
var stateText = {
|
||||
'proposed':'제안됨',
|
||||
'activated':'승인됨',
|
||||
'cancelled':'거부됨',
|
||||
'replaced':'대체됨',
|
||||
};
|
||||
|
||||
var stateOptionText = {
|
||||
'try_destroy_src':'송신측의 파기 요청',
|
||||
'try_destroy_dest':'수신측의 파기 요청',
|
||||
}
|
||||
$letter.find('.letterStatus').text(stateText[letterObj.state]);
|
||||
|
||||
if(letterObj.state_opt !== null){
|
||||
$letter.find('.letterStatusOpt').text('('+stateOptionText[letterObj.state_opt]+')');
|
||||
}
|
||||
if(letterObj.prev_no !== null){
|
||||
var $showPrev = $('<a href="#">#{0}</a>'.format(letterObj.prev_no));
|
||||
$showPrev.click(function(){
|
||||
$('#letter_'+letterObj.prev_no).toggle();
|
||||
})
|
||||
$letter.find('.letterPrevNo').html($showPrev);
|
||||
}
|
||||
else{
|
||||
$letter.find('.letterPrevNo').text('신규');
|
||||
}
|
||||
$letter.find('.letterBrief').html(nl2br(escapeHtml(letterObj.brief)));
|
||||
$letter.find('.letterDetail').html(nl2br(escapeHtml(letterObj.detail)));
|
||||
|
||||
$letter.find('.letterSrc .signerImg img.generalIcon').attr('src', letterObj.src.generalIcon);
|
||||
$letter.find('.letterSrc .signerNation').text(letterObj.src.nationName).css(srcColorFormat);
|
||||
$letter.find('.letterSrc .signerName').text(letterObj.src.generalName).css(srcColorFormat);
|
||||
|
||||
if(letterObj.dest.generalName){
|
||||
$letter.find('.letterDest .signerImg img.generalIcon').attr('src', letterObj.dest.generalIcon);
|
||||
$letter.find('.letterDest .signerNation').text(letterObj.dest.nationName).css(destColorFormat);
|
||||
$letter.find('.letterDest .signerName').text(letterObj.dest.generalName).css(destColorFormat);
|
||||
}
|
||||
|
||||
if(letterObj.state == 'proposed' && letterObj.src.nationID != myNationID){
|
||||
$letter.find('.btnAgree').show().click(function(){
|
||||
if(!confirm('승인하시겠습니까?')){
|
||||
return false;
|
||||
}
|
||||
return repondLetter(letterObj.no, true, null);
|
||||
});
|
||||
$letter.find('.btnDisagree').show().click(function(){
|
||||
var reason = prompt('거부하시겠습니까? (이유 [최대 50자])');
|
||||
if(reason === null){
|
||||
return false;
|
||||
}
|
||||
reason = substr.substr(0, 50);
|
||||
return repondLetter(letterObj.no, false, reason);
|
||||
});
|
||||
}
|
||||
|
||||
if(letterObj.state == 'proposed' && letterObj.src.nationID == myNationID){
|
||||
$letter.find('.btnRollback').show().click(function(){
|
||||
if(!confirm('회수하시겠습니까?')){
|
||||
return false;
|
||||
}
|
||||
return rollbackLetter(letterObj.no);
|
||||
});
|
||||
}
|
||||
|
||||
if(letterObj.state == 'activated'){
|
||||
var $btnDestroy = $letter.find('.btnDestroy');
|
||||
if((letterObj.src.nationID==myNationID && letterObj.state_opt == 'try_destroy_src') ||
|
||||
(letterObj.dest.nationID==myNationID && letterObj.state_opt == 'try_destroy_dest')){
|
||||
$btnDestroy.show().prop('disabled', true);
|
||||
}
|
||||
else{
|
||||
$btnDestroy.show().click(function(){
|
||||
if(!confirm('본 문서를 파기하겠습니까? (상호 동의 필요)')){
|
||||
return false;
|
||||
}
|
||||
return destroyLetter(letterObj.no);
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$letter.find('.btnRenew').click(function(){
|
||||
var $inputPrevNo = $('#inputPrevNo');
|
||||
$inputPrevNo.val(letterObj.no);
|
||||
$inputPrevNo.trigger('change');
|
||||
})
|
||||
|
||||
|
||||
$('#letters').prepend($letter);
|
||||
}
|
||||
|
||||
function initNewLetterForm(lettersObj){
|
||||
console.log(lettersObj);
|
||||
var nationList = [];
|
||||
$.each(lettersObj.nations, function(idx, nation){
|
||||
nation.id = nation.nation;
|
||||
nation.text = nation.name;
|
||||
nationList.push(nation);
|
||||
})
|
||||
|
||||
var $destNation = $('#inputDestNation').select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: "",
|
||||
language: "ko",
|
||||
width:300,
|
||||
containerCss: {
|
||||
display: "inline-block !important;",
|
||||
color: 'white !important'
|
||||
},
|
||||
data:nationList,
|
||||
templateResult: colorNation,
|
||||
containerCssClass: 'simple-select2-align-center bg-secondary text-secondary',
|
||||
dropdownCssClass: 'simple-select2-align-center bg-secondary text-secondary',
|
||||
});
|
||||
|
||||
|
||||
var prevNoList = [{
|
||||
id:0,
|
||||
text:'-새 문서-',
|
||||
nation:null,
|
||||
}];
|
||||
|
||||
$.each(lettersObj.letters, function(idx, letterObj){
|
||||
if(letterObj.state == 'replaced' || letterObj.state == 'cancelled'){
|
||||
return true;
|
||||
}
|
||||
var targetNation = letterObj.src.nationID==myNationID?letterObj.dest:letterObj.src;
|
||||
prevNoList.push({
|
||||
id:letterObj.no,
|
||||
text:'#{0} <{1}>'.format(letterObj.no, targetNation.nationName),
|
||||
nation:targetNation.nationID
|
||||
});
|
||||
});
|
||||
|
||||
var $inputPrevNo = $('#inputPrevNo').select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: "",
|
||||
language: "ko",
|
||||
width:300,
|
||||
containerCss: {
|
||||
display: "inline-block !important;",
|
||||
color: 'white !important'
|
||||
},
|
||||
data:prevNoList,
|
||||
containerCssClass: 'simple-select2-align-center bg-secondary text-secondary',
|
||||
dropdownCssClass: 'simple-select2-align-center bg-secondary text-secondary',
|
||||
});
|
||||
$inputPrevNo.on('change', function(e){
|
||||
var data = $inputPrevNo.select2('data')[0];
|
||||
console.log(data);
|
||||
if(data.nation == null){
|
||||
$destNation.prop("disabled", false);
|
||||
}
|
||||
else{
|
||||
$destNation.val(data.nation).prop("disabled", true);
|
||||
var $targetLetter = $('#letter_'+data.id);
|
||||
resizeTextarea($('#inputBrief').val($targetLetter.data('brief')));
|
||||
resizeTextarea($('#inputDetail').val($targetLetter.data('detail')));
|
||||
}
|
||||
});
|
||||
|
||||
$('#btnSend').click(submitLetter);
|
||||
|
||||
$('#newLetter').show();
|
||||
}
|
||||
|
||||
function drawLetters(lettersObj){
|
||||
@@ -113,12 +368,17 @@ function drawLetters(lettersObj){
|
||||
return quickReject('받아오는데 실패했습니다.');
|
||||
}
|
||||
|
||||
//TODO: 국가 리스트 출력
|
||||
|
||||
if(!lettersObj.result){
|
||||
return quickReject('에러가 발생했습니다. : '+lettersObj.reason);
|
||||
}
|
||||
|
||||
window.myNationID = lettersObj.myNationID;
|
||||
|
||||
if(permissionLevel == 4){
|
||||
initNewLetterForm(lettersObj);
|
||||
$('.letterActionPlate').show();
|
||||
}
|
||||
|
||||
$('.letterObj').detach();//첫 버전이니까 일괄 삭제 일괄 로드
|
||||
$.each(lettersObj.letters, drawLetter);
|
||||
return true;
|
||||
@@ -126,22 +386,35 @@ function drawLetters(lettersObj){
|
||||
|
||||
function loadLetters(){
|
||||
return $.post({
|
||||
url:'j_diplomacy_get_letters.php',
|
||||
url:'j_diplomacy_get_letter.php',
|
||||
dataType:'json', //첫 버전이니까 전체 다 불러오자
|
||||
data:{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function colorNation(nationInfo){
|
||||
if(!nationInfo.color){
|
||||
return nationInfo.text;
|
||||
}
|
||||
|
||||
var fgColor = isBrightColor(nationInfo.color)?'#000000':'#ffffff';
|
||||
var $nationForm = $('<div>'+nationInfo.text+'</div>').css({
|
||||
'color':fgColor,
|
||||
'background-color':nationInfo.color
|
||||
});
|
||||
return $nationForm;
|
||||
}
|
||||
|
||||
function resizeTextarea($obj){
|
||||
$obj.height(1).height($obj.prop('scrollHeight')+12 );
|
||||
}
|
||||
|
||||
$(function(){
|
||||
|
||||
$('#submitLetter').click(submitLetter);
|
||||
$('.respondAgree').click(function(){
|
||||
return repondLetter(true);
|
||||
});
|
||||
$('.respondDisagree').click(function(){
|
||||
return repondLetter(false);
|
||||
});
|
||||
$('textarea.autosize').on('keydown keyup', function(){
|
||||
resizeTextarea($(this));
|
||||
})
|
||||
|
||||
loadLetters()
|
||||
.then(drawLetters, errUnknown)
|
||||
|
||||
@@ -1,24 +1,5 @@
|
||||
|
||||
|
||||
function hexToRgb(hex) {
|
||||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||
return result ? {
|
||||
r: parseInt(result[1], 16),
|
||||
g: parseInt(result[2], 16),
|
||||
b: parseInt(result[3], 16)
|
||||
} : null;
|
||||
}
|
||||
|
||||
|
||||
function isBrightColor(color){
|
||||
color = hexToRgb(color);
|
||||
if ((color.r*0.299 + color.g*0.587 + color.b*0.114) > 140){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var messageTemplate = '';
|
||||
var myGeneralID=null;
|
||||
|
||||
@@ -64,7 +64,7 @@ class DiplomaticMessage extends Message{
|
||||
return [self::INVALID, '송신자가 외교서신을 처리할 수 없습니다.'];
|
||||
}
|
||||
|
||||
$permission = checkSecretPermission($general);
|
||||
$permission = checkSecretPermission($general, false);
|
||||
|
||||
if(!$general || $permission < 4){
|
||||
return [self::INVALID, '해당 국가의 외교권자 아닙니다.'];
|
||||
@@ -273,7 +273,7 @@ class DiplomaticMessage extends Message{
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
$general = $db->queryFirstRow(
|
||||
'SELECT `name`, `level`, `permission`, `penalty` FROM general WHERE `no`=%i AND nation=%i',
|
||||
'SELECT `name`, nation, `level`, `permission`, `penalty` FROM general WHERE `no`=%i AND nation=%i',
|
||||
$receiverID,
|
||||
$this->dest->nationID
|
||||
);
|
||||
|
||||
+11
-1
@@ -387,7 +387,17 @@ class Message
|
||||
return $this->sendRaw($this->dest->generalID);
|
||||
}
|
||||
|
||||
if($this->msgType === self::MSGTYPE_NATIONAL || $this->msgType === self::MSGTYPE_DIPLOMACY){
|
||||
if($this->msgType === self::MSGTYPE_NATIONAL){
|
||||
return $this->sendRaw($this->dest->nationID + self::MAILBOX_NATIONAL);
|
||||
}
|
||||
|
||||
if($this->msgType === self::MSGTYPE_DIPLOMACY){
|
||||
if(!($this->msgOption['silence']??false)){
|
||||
//XXX: 알림을 이런식으로 보내는게 맞는가에 대한 의문 있음
|
||||
DB::db()->update('general', [
|
||||
'newmsg'=>1
|
||||
], 'nation = %i AND (level = 12 OR permission IN (\'ambassador\', \'auditor\')) ',$this->dest->nationID);
|
||||
}
|
||||
return $this->sendRaw($this->dest->nationID + self::MAILBOX_NATIONAL);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -215,6 +215,7 @@ CREATE TABLE `board` (
|
||||
`date` DATETIME NOT NULL,
|
||||
`general_no` INT(11) NOT NULL,
|
||||
`author` VARCHAR(32) NOT NULL,
|
||||
`author_icon` VARCHAR(128) NULL DEFAULT NULL,
|
||||
`title` TEXT NOT NULL,
|
||||
`text` TEXT NOT NULL,
|
||||
PRIMARY KEY (`no`),
|
||||
@@ -458,7 +459,7 @@ CREATE TABLE `ng_diplomacy` (
|
||||
`src_nation_id` INT(11) NOT NULL,
|
||||
`dest_nation_id` INT(11) NOT NULL,
|
||||
`prev_no` INT(11) NULL DEFAULT NULL,
|
||||
`state` ENUM('proposed','activated','cancelled') NOT NULL DEFAULT 'proposed',
|
||||
`state` ENUM('proposed','activated','cancelled','replaced') NOT NULL DEFAULT 'proposed',
|
||||
`text_brief` TEXT NOT NULL,
|
||||
`text_detail` TEXT NOT NULL,
|
||||
`date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
+40
-29
@@ -63,44 +63,55 @@ var isSecretBoard = <?=($isSecretBoard?'true':'false')?>; //
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id='newArticle'>
|
||||
<div><span class='articleTitle'>제목</span><input class='titleInput' type='text' maxlength='250'></input></div>
|
||||
<div class='boardArticle'>
|
||||
<textarea class="contentInput" rows="10" cols="50"></textarea>
|
||||
</div>
|
||||
<table id='newArticle' class='bg0'>
|
||||
<thead>
|
||||
<tr><td colspan='2' class='newArticleHeader bg2'>새 게시물 작성</td>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><th class='bg1' style='width:66px;'><span class='articleTitle'>제목</span></th><td><input class='titleInput' type='text' maxlength='250' placeholder='제목'></input></td></tr>
|
||||
<tr><th class='bg1'>내용</th><td class='boardArticle'>
|
||||
<textarea class="contentInput autosize" placeholder='내용'></textarea>
|
||||
</td></tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr><td colspan="2">
|
||||
<button type='button' id='submitArticle'>등록</button>
|
||||
</div>
|
||||
</td></tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
<div id="board">
|
||||
</div>
|
||||
|
||||
<!-- 설계미스. template와 shadowdom으로 변경 -->
|
||||
<div id='articleTemplate' style='display:none;'>
|
||||
<div class='articleFrame'>
|
||||
<div>#<span class='articleNo'></span> <span class='articleTitle'></span></div>
|
||||
<div class='authorPlate'><span class='authorIcon'></span><span class='authorName'></span><span class='date'></span></div>
|
||||
<div class='text'>
|
||||
|
||||
</div>
|
||||
<div class='commentFrame'>
|
||||
<ul class='commentList'>
|
||||
|
||||
</ul>
|
||||
<div>
|
||||
<input class='commentText' type='text' maxlength='250'>
|
||||
<button type='button' class='submitComment'>등록</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<table class='articleFrame bg0'>
|
||||
<thead>
|
||||
<tr class='bg1'>
|
||||
<th class='authorName'></th><th class='articleTitle'></th><th class='date'></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><img class='authorIcon generalIcon' width='64' height='64'></td>
|
||||
<td class='text' colspan='2'></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody class='commentList'>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr><td class='bg2'>댓글 달기</td><td><input class='commentText' type='text' maxlength='250'></td><td><button type='button' class='submitComment'>등록</button></td></tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id='commentTemplate' style='display:none;'>
|
||||
<li class='comment'>
|
||||
<span class='author'></span>
|
||||
<span class='text'></span>
|
||||
<span class='date'></span>
|
||||
</li>
|
||||
</div>
|
||||
<template id='commentTemplate' style='display:none;'>
|
||||
<tr class='comment'>
|
||||
<th class='author'></th>
|
||||
<td class='text'></td>
|
||||
<td class='date'></td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<div style='width=1000px;' class='tb_layout bg0'>
|
||||
<?=backButton()?><br>
|
||||
|
||||
+64
-12
@@ -36,6 +36,8 @@ if ($permission < 1) {
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=1024" />
|
||||
<?=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('../e_lib/tui.editor/tui-editor.min.css')?>-->
|
||||
<!--<?=WebUtil::printCSS('../e_lib/tui.editor/tui-editor-contents.min.css')?>-->
|
||||
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
||||
@@ -48,27 +50,77 @@ var permissionLevel = <?=$permission?>; //
|
||||
<?=WebUtil::printJS('../d_shared/common_path.js')?>
|
||||
<?=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('../e_lib/tui.editor/tui-editor-Editor-all.min.js')?>-->
|
||||
<?=WebUtil::printJS('js/common.js')?>
|
||||
<?=WebUtil::printJS('js/board.js')?>
|
||||
<?=WebUtil::printJS('js/diplomacy.js')?>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<table style='width:1000px;margin:auto;' class='tb_layout bg0'>
|
||||
<tr><td style='text-align:left;'>외 교 부<br><?=backButton()?></td></tr>
|
||||
</table>
|
||||
|
||||
<template id='diplomacyTemplate'>
|
||||
<div class='diplomacyFrame'>
|
||||
<div><span class='articleTitle'></span></div>
|
||||
<div class='authorPlate'><span class='authorIcon'></span><span class='authorName'><span><span class='date'></span></div>
|
||||
<div class='boardArticle'>
|
||||
<table id='newLetter' class='bg0' style='display:none;'>
|
||||
<thead>
|
||||
<tr><td colspan='2' class='newLetterHeader'>새 외교문서 작성</td>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><th class='bg1'>이전 문서</th><td><select id='inputPrevNo'></select></td></tr>
|
||||
<tr><th class='bg1'>대상 국가</th><td><select id='inputDestNation'></select></td></tr>
|
||||
<tr><th class='bg1'>내용(국가 내 공개)</th><td><textarea id='inputBrief' class='autosize'></textarea></td></tr>
|
||||
<tr><th class='bg1'>내용(외교권자 전용)</th><td><textarea id='inputDetail' class='autosize'></textarea></td></tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class='letterActionPlate'><th class='bg1'>동작</th><td>
|
||||
<button type='button' id='btnSend'>전송</button>
|
||||
</td></tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div id='letters'></div>
|
||||
|
||||
<div style='width=1000px;' class='tb_layout bg0'>
|
||||
<!-- 설계미스. template와 shadowdom으로 변경 -->
|
||||
<div id='letterTemplate' style='display:none;'>
|
||||
<table class='letterFrame bg0'>
|
||||
<thead>
|
||||
<tr><td colspan='2' class='letterHeader'><span class='letterNationName'></span>국과의 외교 문서<span class='letterDate'>2099-12-31 23:59:59</span></td>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><th class='bg1'>문서 번호</th><td><span class='letterNo'></span></td></tr>
|
||||
<tr><th class='bg1'>이전 문서</th><td><span class='letterPrevNo'></span></td></tr>
|
||||
<tr><th class='bg1'>상태</th><td><span class='letterStatus'></span><span class='letterStatusOpt'></span></td></tr>
|
||||
<tr><th class='bg1'>내용(국가 내 공개)</th><td><div class='letterBrief'></div></td></tr>
|
||||
<tr><th class='bg1'>내용(외교권자 전용)</th><td><div class='letterDetail'></div></td></tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr><th class='bg1'>서명인</th><td class='letterSignerPlate'>
|
||||
<div class='letterSrc'>
|
||||
<div class="signerImg"><img class='generalIcon' width='64px' height='64px'></div>
|
||||
<div class="signerNation"> </div>
|
||||
<div class="signerName"> </div>
|
||||
</div><div class='letterDest'>
|
||||
<div class="signerImg"><img class='generalIcon' width='64px' height='64px'></div>
|
||||
<div class="signerNation"> </div>
|
||||
<div class="signerName"> </div>
|
||||
</div>
|
||||
</td></tr>
|
||||
<tr class='letterActionPlate' style='display:none;'><th class='bg1'>동작</th><td>
|
||||
<button type='button' class='btnAgree' style='display:none;'>승인</button>
|
||||
<button type='button' class='btnDisagree' style='display:none;'>거부</button>
|
||||
<button type='button' class='btnRollback' style='display:none;'>회수</button>
|
||||
<button type='button' class='btnDestroy' style='display:none;'>파기</button>
|
||||
<button type='button' class='btnRenew'>추가 문서 작성</button>
|
||||
</td></tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<table style='width:1000px;margin:auto;' class='tb_layout bg0'>
|
||||
<tr><td style='text-align:left;'>
|
||||
<?=backButton()?><br>
|
||||
<?=banner()?>
|
||||
</div>
|
||||
</td></tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class='buttonPlate bg2'>
|
||||
<div>
|
||||
<a href='t_board.php'><button type="button" class='commandButton' <?=$meLevel>=1?'':'disabled'?> style='background-color:<?=$bgColor?>;color:<?=$fgColor?>;'>회 의 실</button></a>
|
||||
<a href='t_board.php?isSecret=true'><button type="button" class='commandButton' <?=$meLevel>=5?'':'disabled'?> style='background-color:<?=$bgColor?>;color:<?=$fgColor?>;'>기 밀 실</button></a>
|
||||
<a href='t_board.php?isSecret=true'><button type="button" class='commandButton' <?=$permission>=2?'':'disabled'?> style='background-color:<?=$bgColor?>;color:<?=$fgColor?>;'>기 밀 실</button></a>
|
||||
<a href='b_troop.php'><button type="button" class='commandButton' <?=($meLevel>=1&&$nationLevel>=1)?'':'disabled'?> style='background-color:<?=$bgColor?>;color:<?=$fgColor?>;'>부대 편성</button></a>
|
||||
<a href='t_diplomacy.php'><button type="button" class='commandButton' <?=$meLevel>=1?'':'disabled'?> style='background-color:<?=$bgColor?>;color:<?=$fgColor?>;'>외 교 부</button></a>
|
||||
<a href='b_myBossInfo.php'><button type="button" class='commandButton' <?=$meLevel>=1?'':'disabled'?> style='background-color:<?=$bgColor?>;color:<?=$fgColor?>;'>인 사 부</button></a>
|
||||
|
||||
Reference in New Issue
Block a user