메시지 시스템 외부로 연결중.
This commit is contained in:
+125
@@ -0,0 +1,125 @@
|
||||
@charset "UTF-8";
|
||||
|
||||
/*임시용 */
|
||||
|
||||
#container{
|
||||
width:1000px;
|
||||
margin:auto;
|
||||
font-size:13px;
|
||||
}
|
||||
/*임시용 끝*/
|
||||
|
||||
#message_board section{
|
||||
width:498px;
|
||||
}
|
||||
|
||||
.msg_plate{
|
||||
width:100%;
|
||||
border:groove 0.1em;
|
||||
height:64px;
|
||||
font-size:12px;
|
||||
word-break:break-all;
|
||||
color:white;
|
||||
}
|
||||
|
||||
.msg_plate_private{
|
||||
background-color:#5d1e1a;
|
||||
}
|
||||
|
||||
.msg_plate_public{
|
||||
background-color:#141c65;
|
||||
|
||||
}
|
||||
|
||||
.msg_plate_national, .msg_plate_diplomacy{
|
||||
background-color:#00582c;
|
||||
|
||||
}
|
||||
|
||||
.msg_icon{
|
||||
float:left;
|
||||
width:64px;
|
||||
height:64px;
|
||||
border-right:groove 0.1em;
|
||||
}
|
||||
|
||||
.msg_time{
|
||||
font-size:0.75em;
|
||||
font-weight:normal;
|
||||
}
|
||||
|
||||
.msg_header{
|
||||
font-weight: bold;
|
||||
margin-bottom:3px;
|
||||
color:white;
|
||||
}
|
||||
|
||||
#msg_input{
|
||||
color:white;
|
||||
background-color:black;
|
||||
font-size:12px;
|
||||
width:720px;
|
||||
height:15px;
|
||||
}
|
||||
|
||||
#mailbox_list{
|
||||
color:white;
|
||||
background-color:black;
|
||||
font-size:12px;
|
||||
}
|
||||
|
||||
.board_header{
|
||||
color:white;
|
||||
border:groove 0.1em;
|
||||
}
|
||||
|
||||
.board_side{
|
||||
width:50%;
|
||||
float:left;
|
||||
}
|
||||
|
||||
.msg_body{
|
||||
padding-left:64px;
|
||||
}
|
||||
|
||||
.msg_target{
|
||||
margin:2px 2px 0 2px;
|
||||
padding:2px 3px;
|
||||
display:inline-block;
|
||||
box-shadow: 2px 2px black;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/*
|
||||
.public_message .msg_target{
|
||||
box-shadow: 2px 2px darkslategrey;
|
||||
}
|
||||
*/
|
||||
|
||||
.msg_target.msg_bright{
|
||||
color:black;
|
||||
}
|
||||
|
||||
.msg_target.msg_dark{
|
||||
color:white;
|
||||
}
|
||||
|
||||
.msg_from_to{
|
||||
display:inline-block;
|
||||
}
|
||||
|
||||
.msg_content{
|
||||
margin-left:10px;
|
||||
margin-right:5px;
|
||||
}
|
||||
|
||||
.msg_prompt{
|
||||
text-align:right;
|
||||
margin-top:5px;
|
||||
margin-right:5px;
|
||||
}
|
||||
|
||||
#mailbox_list option{
|
||||
color:white;
|
||||
background-color:black;
|
||||
}
|
||||
-134
@@ -1,134 +0,0 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
|
||||
$ok = Util::getReq('ok');
|
||||
$when = Util::getReq('when', 'int');
|
||||
$gen = Util::getReq('gen', 'int'); //XXX: -_-;;;;;;;;;;;;
|
||||
|
||||
extractMissingPostToGlobals();
|
||||
|
||||
//로그인 검사
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
//FIXME: 망했음. CriticalFailure. 재 구현.
|
||||
|
||||
$db = DB::db();
|
||||
$connect=$db->get();
|
||||
|
||||
//$when = ($when + 1) * 2;
|
||||
|
||||
$query = "select year,month from game limit 1";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$admin = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select no,name,nation,level,picture,imgsvr from general where owner='{$userID}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select no,nation,name from general where no='$gen'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$you = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select name,surlimit,color from nation where nation='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$younation = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select name,gold,rice,surlimit,color,dip{$num} as dipmsg from nation where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$mynation = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select pop from city where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$citycount = MYDB_num_rows($result);
|
||||
|
||||
$query = "select city from city where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$losecitynum = MYDB_num_rows($result);
|
||||
|
||||
$query = "select city from city where nation='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$wincitynum = MYDB_num_rows($result);
|
||||
|
||||
//아국과의 관계
|
||||
$query = "select state,term from diplomacy where me='{$me['nation']}' and you='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$dip = MYDB_fetch_array($result);
|
||||
|
||||
//상대국의 제의조건
|
||||
$query = "select reserved from diplomacy where me='{$you['nation']}' and you='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$dip2 = MYDB_fetch_array($result);
|
||||
|
||||
$mylog = [];
|
||||
$youlog = [];
|
||||
|
||||
if($ok == "수락") {
|
||||
// 서신 보낸 후 멸망,선양 등 했을때.
|
||||
if($me['level'] < 5) {
|
||||
$mylog[] = "<C>●</>수뇌부가 아니므로 불가능합니다. 불가침 실패.";
|
||||
} elseif($dip['term'] == $when*12 && $dip['state'] == 7) {
|
||||
$mylog[] = "<C>●</>이미 수락했습니다. 불가침 실패.";
|
||||
} elseif($losecitynum == 0) {
|
||||
$mylog[] = "<C>●</>방랑군이므로 불가능합니다. 불가침 실패.";
|
||||
} elseif($wincitynum == 0) {
|
||||
$mylog[] = "<C>●</>상대가 방랑군이므로 불가능합니다. 불가침 실패.";
|
||||
} elseif($dip['state'] == 0) {
|
||||
$mylog[] = "<C>●</>아국과 교전중입니다. 불가침 실패.";
|
||||
} elseif($dip['state'] == 1) {
|
||||
$mylog[] = "<C>●</>아국과 선포중입니다. 불가침 실패.";
|
||||
} elseif($dip['state'] == 3 || $dip['state'] == 4) {
|
||||
$mylog[] = "<C>●</>아국과 합병중입니다. 불가침 실패.";
|
||||
} elseif($mynation['dipmsg'] == "") {
|
||||
$mylog[] = "<C>●</>이미 거절했습니다. 불가침 실패.";
|
||||
} else {
|
||||
// $alllog[] = "<C>●</>{$admin['month']}월:<Y>{$me['name']}</>(이)가 <D><b>{$younation['name']}</b></>(와)과 <M>불가침</>에 합의.";
|
||||
// $history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【불가침】</b></><D><b>{$mynation['name']}</b></>(이)가 <D><b>{$younation['name']}</b></>(와)과 불가침 조약을 체결했습니다.";
|
||||
|
||||
$youlog[] = "<C>●</><D><b>{$mynation['name']}</b></>(와)과 <C>$when</>년 불가침에 성공했습니다.";
|
||||
$mylog[] = "<C>●</><D><b>{$younation['name']}</b></>(와)과 <C>$when</>년 불가침에 합의했습니다.";
|
||||
pushGeneralHistory($you, "<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$mynation['name']}</b></>(와)과 {$when}년 불가침 성공");
|
||||
pushGeneralHistory($me, "<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$younation['name']}</b></>(와)과 {$when}년 불가침 수락");
|
||||
|
||||
//국메로 저장
|
||||
$msg = "【외교】{$admin['year']}년 {$admin['month']}월:{$younation['name']}(와)과 {$when}년 불가침 합의, 비고: {$dip2['reserved']}";
|
||||
$youmsg = "【외교】{$admin['year']}년 {$admin['month']}월:{$mynation['name']}(와)과 {$when}년 불가침 합의, 비고: {$dip2['reserved']}";
|
||||
|
||||
PushMsg(2, $me['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:{$mynation['name']}▶", $mynation['color'], $younation['name'], $younation['color'], $msg);
|
||||
PushMsg(3, $you['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:{$mynation['name']}▶", $mynation['color'], $younation['name'], $younation['color'], $youmsg);
|
||||
|
||||
$when = $when * 12;
|
||||
//외교 변경
|
||||
$query = "update diplomacy set state='7',term='$when',fixed='{$dip2['reserved']}' where me='{$me['nation']}' and you='{$you['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$query = "update diplomacy set state='7',term='$when',fixed='{$dip2['reserved']}' where me='{$you['nation']}' and you='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
}
|
||||
|
||||
//조건 지움
|
||||
$query = "update diplomacy set reserved='' where me='{$you['nation']}' and you='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
//현 메세지 지움
|
||||
$query = "update nation set dip{$num}='',dip{$num}_who='0',dip{$num}_when='' where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} else {
|
||||
$youlog[] = "<C>●</><Y>{$mynation['name']}</>(이)가 불가침을 거부했습니다.";
|
||||
$mylog[] = "<C>●</><D>{$younation['name']}</>(와)과 불가침을 거부했습니다.";
|
||||
|
||||
//조건 지움
|
||||
$query = "update diplomacy set reserved='' where me='{$you['nation']}' and you='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
//현 메세지 지움
|
||||
$query = "update nation set dip{$num}='',dip{$num}_who='0',dip{$num}_when='' where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
}
|
||||
|
||||
pushGenLog($me, $mylog);
|
||||
pushGenLog($you, $youlog);
|
||||
//pushGeneralPublicRecord($alllog, $admin['year'], $admin['month']);
|
||||
//pushWorldHistory($history, $admin['year'], $admin['month']);
|
||||
|
||||
header('location:msglist.php');
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
|
||||
$ok = Util::getReq('ok');
|
||||
$gen = Util::getReq('gen', 'int'); //XXX: -_-;;;;;;;;;;;;
|
||||
|
||||
extractMissingPostToGlobals();
|
||||
|
||||
//로그인 검사
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
//FIXME: 망했음. CriticalFailure. 재 구현.
|
||||
|
||||
$db = DB::db();
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select year,month from game limit 1";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$admin = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select no,name,nation,level,picture,imgsvr from general where owner='{$userID}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select no,nation from general where no='$gen'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$you = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select name,surlimit,color from nation where nation='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$younation = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select name,gold,rice,surlimit,color,dip{$num} as dipmsg from nation where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$mynation = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select pop from city where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$citycount = MYDB_num_rows($result);
|
||||
|
||||
$query = "select city from city where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$losecitynum = MYDB_num_rows($result);
|
||||
|
||||
$query = "select city from city where nation='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$wincitynum = MYDB_num_rows($result);
|
||||
|
||||
//아국과의 관계
|
||||
$query = "select state from diplomacy where me='{$me['nation']}' and you='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$dip = MYDB_fetch_array($result);
|
||||
|
||||
$mylog = [];
|
||||
$youlog = [];
|
||||
$alllog = [];
|
||||
$history = [];
|
||||
|
||||
if($ok == "수락") {
|
||||
// 서신 보낸 후 멸망,선양 등 했을때.
|
||||
if($me['level'] < 5) {
|
||||
$mylog[] = "<C>●</>수뇌부가 아니므로 불가능합니다. 파기 실패.";
|
||||
} elseif($losecitynum == 0) {
|
||||
$mylog[] = "<C>●</>방랑군이므로 불가능합니다. 파기 실패.";
|
||||
} elseif($wincitynum == 0) {
|
||||
$mylog[] = "<C>●</>상대가 방랑군이므로 불가능합니다. 파기 실패.";
|
||||
} elseif($dip['state'] != 7) {
|
||||
$mylog[] = "<C>●</>아국과 불가침중이 아닙니다. 파기 실패.";
|
||||
} elseif($mynation['dipmsg'] == "") {
|
||||
$mylog[] = "<C>●</>이미 거절했습니다. 파기 실패.";
|
||||
} else {
|
||||
$alllog[] = "<C>●</>{$admin['month']}월:<Y>{$me['name']}</>(이)가 <D><b>{$younation['name']}</b></>(와)과 <M>조약 파기</>에 합의.";
|
||||
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【파기】</b></><D><b>{$mynation['name']}</b></>(이)가 <D><b>{$younation['name']}</b></>(와)과 불가침을 파기 하였습니다.";
|
||||
$youlog[] = "<C>●</><D><b>{$mynation['name']}</b></>(와)과 파기에 성공했습니다.";
|
||||
$mylog[] = "<C>●</><D><b>{$younation['name']}</b></>(와)과 파기에 합의했습니다.";
|
||||
pushGeneralHistory($you, "<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$mynation['name']}</b></>(와)과 파기 성공");
|
||||
pushGeneralHistory($me, "<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$younation['name']}</b></>(와)과 파기 수락");
|
||||
|
||||
//외교 변경
|
||||
$query = "update diplomacy set state='2',term='0' where me='{$me['nation']}' and you='{$you['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$query = "update diplomacy set state='2',term='0' where me='{$you['nation']}' and you='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
|
||||
//국메로 저장
|
||||
$msg = "【외교】{$admin['year']}년 {$admin['month']}월:{$younation['name']}(와)과 불가침 파기 동의";
|
||||
$youmsg = "【외교】{$admin['year']}년 {$admin['month']}월:{$mynation['name']}(와)과 불가침 파기 동의";
|
||||
|
||||
PushMsg(2, $me['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:{$mynation['name']}▶", $mynation['color'], $younation['name'], $younation['color'], $msg);
|
||||
PushMsg(3, $you['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:{$mynation['name']}▶", $mynation['color'], $younation['name'], $younation['color'], $youmsg);
|
||||
}
|
||||
|
||||
//현 메세지 지움
|
||||
$query = "update nation set dip{$num}='',dip{$num}_who='0',dip{$num}_when='' where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} else {
|
||||
$youlog[] = "<C>●</><Y>{$mynation['name']}</>(이)가 파기를 거부했습니다.";
|
||||
$mylog[] = "<C>●</><D>{$younation['name']}</>(와)과 파기를 거부했습니다.";
|
||||
|
||||
//현 메세지 지움
|
||||
$query = "update nation set dip{$num}='',dip{$num}_who='0',dip{$num}_when='' where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
}
|
||||
|
||||
pushGenLog($me, $mylog);
|
||||
pushGenLog($you, $youlog);
|
||||
pushGeneralPublicRecord($alllog, $admin['year'], $admin['month']);
|
||||
pushWorldHistory($history, $admin['year'], $admin['month']);
|
||||
|
||||
header('location:msglist.php');
|
||||
-119
@@ -1,119 +0,0 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
|
||||
$ok = Util::getReq('ok');
|
||||
$gen = Util::getReq('gen', 'int'); //XXX: -_-;;;;;;;;;;;;
|
||||
|
||||
extractMissingPostToGlobals();
|
||||
|
||||
//로그인 검사
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
//FIXME: 망했음. CriticalFailure. 재 구현.
|
||||
|
||||
$db = DB::db();
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select year,month from game limit 1";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$admin = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select no,name,nation,level,picture,imgsvr from general where owner='{$userID}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select no,nation from general where no='$gen'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$you = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select nation,name,surlimit,color from nation where nation='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$younation = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select nation,name,gold,rice,surlimit,color,dip{$num} as dipmsg from nation where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$mynation = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select pop from city where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$citycount = MYDB_num_rows($result);
|
||||
|
||||
$query = "select city from city where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$losecitynum = MYDB_num_rows($result);
|
||||
|
||||
$query = "select city from city where nation='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$wincitynum = MYDB_num_rows($result);
|
||||
|
||||
//아국과의 관계
|
||||
$query = "select state from diplomacy where me='{$me['nation']}' and you='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$dip = MYDB_fetch_array($result);
|
||||
|
||||
$mylog = [];
|
||||
$youlog = [];
|
||||
$alllog = [];
|
||||
$history = [];
|
||||
|
||||
if($ok == "수락") {
|
||||
// 서신 보낸 후 멸망,선양 등 했을때.
|
||||
if($me['level'] < 5) {
|
||||
$mylog[] = "<C>●</>수뇌부가 아니므로 불가능합니다. 종전 실패.";
|
||||
} elseif($losecitynum == 0) {
|
||||
$mylog[] = "<C>●</>방랑군이므로 불가능합니다. 종전 실패.";
|
||||
} elseif($wincitynum == 0) {
|
||||
$mylog[] = "<C>●</>상대가 방랑군이므로 불가능합니다. 종전 실패.";
|
||||
} elseif($dip['state'] != 0 && $dip['state'] != 1) {
|
||||
$mylog[] = "<C>●</>아국과 교전중이 아닙니다. 종전 실패.";
|
||||
} elseif($mynation['dipmsg'] == "") {
|
||||
$mylog[] = "<C>●</>이미 거절했습니다. 불가침 실패.";
|
||||
} else {
|
||||
$alllog[] = "<C>●</>{$admin['month']}월:<Y>{$me['name']}</>(이)가 <D><b>{$younation['name']}</b></>(와)과 <M>종전 합의</> 하였습니다.";
|
||||
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【종전】</b></><D><b>{$mynation['name']}</b></>(이)가 <D><b>{$younation['name']}</b></>(와)과 <M>종전 합의</> 하였습니다.";
|
||||
$youlog[] = "<C>●</><D><b>{$mynation['name']}</b></>(와)과 종전에 성공했습니다.";
|
||||
$mylog[] = "<C>●</><D><b>{$younation['name']}</b></>(와)과 종전에 합의했습니다.";
|
||||
pushGeneralHistory($you, "<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$mynation['name']}</b></>(와)과 종전 성공");
|
||||
pushGeneralHistory($me, "<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$younation['name']}</b></>(와)과 종전 수락");
|
||||
|
||||
//외교 변경
|
||||
$query = "update diplomacy set state='2',term='0' where me='{$mynation['nation']}' and you='{$younation['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$query = "update diplomacy set state='2',term='0' where me='{$younation['nation']}' and you='{$mynation['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
//외교제한
|
||||
$query = "update nation set surlimit=24 where nation='{$mynation['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$query = "update nation set surlimit=24 where nation='{$younation['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
|
||||
//국메로 저장
|
||||
$msg = "【외교】{$admin['year']}년 {$admin['month']}월:{$younation['name']}(와)과 종전 동의";
|
||||
$youmsg = "【외교】{$admin['year']}년 {$admin['month']}월:{$mynation['name']}(와)과 종전 동의";
|
||||
|
||||
PushMsg(2, $mynation['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:{$mynation['name']}▶", $mynation['color'], $younation['name'], $younation['color'], $msg);
|
||||
PushMsg(3, $younation['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:{$mynation['name']}▶", $mynation['color'], $younation['name'], $younation['color'], $youmsg);
|
||||
}
|
||||
|
||||
//현 메세지 지움
|
||||
$query = "update nation set dip{$num}='',dip{$num}_who='0',dip{$num}_when='' where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} else {
|
||||
$youlog[] = "<C>●</><Y>{$mynation['name']}</>(이)가 종전을 거부했습니다.";
|
||||
$mylog[] = "<C>●</><D>{$younation['name']}</>(와)과 종전을 거부했습니다.";
|
||||
|
||||
//현 메세지 지움
|
||||
$query = "update nation set dip{$num}='',dip{$num}_who='0',dip{$num}_when='' where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
}
|
||||
|
||||
pushGenLog($me, $mylog);
|
||||
pushGenLog($you, $youlog);
|
||||
pushGeneralPublicRecord($alllog, $admin['year'], $admin['month']);
|
||||
pushWorldHistory($history, $admin['year'], $admin['month']);
|
||||
|
||||
header('location:msglist.php');
|
||||
-154
@@ -1,154 +0,0 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
|
||||
$ok = Util::getReq('ok');
|
||||
$gen = Util::getReq('gen', 'int'); //XXX: -_-;;;;;;;;;;;;
|
||||
|
||||
extractMissingPostToGlobals();
|
||||
|
||||
//로그인 검사
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$connect=$db->get();
|
||||
|
||||
//FIXME: 망했음. CriticalFailure. 재 구현.
|
||||
|
||||
$query = "select year,month from game limit 1";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$admin = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select no,name,nation,level,picture,imgsvr from general where owner='{$userID}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select no,name,nation from general where no='$gen'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$you = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select round(avg(power)) as power,round(avg(gennum)) as gennum from nation where level>=1";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$avgnation = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select round(std(power)) as power,round(std(gennum)) as gennum from nation where level>=1";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$stdnation = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select nation,name,gennum,power,surlimit,color from nation where nation='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$younation = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select nation,name,gennum,power,gold,rice,surlimit,color,dip{$num} as dipmsg from nation where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$mynation = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select city from city where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$losecitynum = MYDB_num_rows($result);
|
||||
|
||||
$query = "select city from city where nation='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$wincitynum = MYDB_num_rows($result);
|
||||
|
||||
//아국과의 관계
|
||||
$query = "select state from diplomacy where me='{$me['nation']}' and you='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$dip = MYDB_fetch_array($result);
|
||||
//대상국이 외교 진행중(선포중,교전중,합병수락중,통합수락중)일때
|
||||
$query = "select state from diplomacy where me='{$you['nation']}' and (state='0' or state='1' or state='3' or state='5')";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$dipcount = MYDB_num_rows($result);
|
||||
//대상국B이 아국C과 교전중인 국가A와 불가침중일때 불가(A=B 불가침, A=C(아국) 교전, B<-C(아국) 항복)
|
||||
$query = "select you,state from diplomacy where me='{$me['nation']}' and (state='0' or state='1')";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$warcount = MYDB_num_rows($result);
|
||||
// 아국과 교전중인 국가 골라냄
|
||||
$valid = 1;
|
||||
for($i=0; $i < $warcount; $i++) {
|
||||
$acdip = MYDB_fetch_array($result);
|
||||
//교전중 국가A와 대상국B 외교 확인
|
||||
$query = "select state from diplomacy where me='{$acdip['you']}' and you='{$you['nation']}'";
|
||||
$dipresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$abdip = MYDB_fetch_array($dipresult);
|
||||
|
||||
if($abdip['state'] == 7) {
|
||||
$valid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$mylog = [];
|
||||
$youlog = [];
|
||||
$alllog = [];
|
||||
$history = [];
|
||||
|
||||
if($ok == "수락") {
|
||||
// 서신 보낸 후 멸망 했을때.
|
||||
if($me['level'] < 5) {
|
||||
$mylog[] = "<C>●</>수뇌부가 아니므로 불가능합니다. 통합 실패.";
|
||||
} elseif($mynation['surlimit'] > 0) {
|
||||
$mylog[] = "<C>●</>본국이 외교제한이 지나지 않았습니다. 통합 실패.";
|
||||
} elseif($younation['surlimit'] > 0) {
|
||||
$mylog[] = "<C>●</>상대국이 외교제한이 지나지 않았습니다. 통합 실패.";
|
||||
} elseif($losecitynum == 0) {
|
||||
$mylog[] = "<C>●</>방랑군이므로 불가능합니다. 통합 실패.";
|
||||
} elseif($wincitynum == 0) {
|
||||
$mylog[] = "<C>●</>상대가 방랑군이므로 불가능합니다. 통합 실패.";
|
||||
} elseif($mynation['power']+$younation['power'] > $avgnation['power']+$stdnation['power']) {
|
||||
$mylog[] = "<C>●</>양국 국력이 너무 높습니다. 통합 실패.";
|
||||
} elseif($mynation['gennum']+$younation['gennum'] > $avgnation['gennum']+$stdnation['gennum']) {
|
||||
$mylog[] = "<C>●</>양국 장수가 많습니다. 통합 실패.";
|
||||
} elseif(!isClose($younation['nation'], $mynation['nation'])) {
|
||||
$mylog[] = "<C>●</>인접한 국가가 아니므로 불가능합니다. 통합 실패.";
|
||||
} elseif($dip['state'] == 0) {
|
||||
$mylog[] = "<C>●</>아국과 교전중입니다. 통합 실패.";
|
||||
} elseif($dipcount != 0) {
|
||||
$mylog[] = "<C>●</>상대국이 외교 진행중입니다. 통합 실패.";
|
||||
} elseif($valid == 0) {
|
||||
$mylog[] = "<C>●</>상대국이 아국의 교전국과 불가침중입니다. 통합 실패.";
|
||||
} elseif($mynation['dipmsg'] == "") {
|
||||
$mylog[] = "<C>●</>이미 거절했습니다. 불가침 실패.";
|
||||
} else {
|
||||
$youlog[] = "<C>●</><D><b>{$mynation['name']}</b></>(이)가 통합에 동의했습니다.";
|
||||
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【통합시도】</b></><D><b>{$mynation['name']}</b></>(와)과 <D><b>{$younation['name']}</b></>(이)가 통합을 시도합니다.";
|
||||
$mylog[] = "<C>●</><D><b>{$younation['name']}</b></>(와)과 통합에 동의했습니다.";
|
||||
$alllog[] = "<C>●</>{$admin['month']}월:<Y>{$me['name']}</>(이)가 <D><b>{$younation['name']}</b></>(와)과 <M>통합</>에 동의하였습니다.";
|
||||
pushGeneralHistory($you, "<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$mynation['name']}</b></>(와)과 통합 시도");
|
||||
pushGeneralHistory($me, "<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$younation['name']}</b></>(와)과 통합 시도");
|
||||
|
||||
//외교 변경
|
||||
$query = "update diplomacy set state='3',term='24' where me='{$mynation['nation']}' and you='{$younation['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$query = "update diplomacy set state='4',term='24' where me='{$younation['nation']}' and you='{$mynation['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
|
||||
//국메로 저장
|
||||
$msg = "【외교】{$admin['year']}년 {$admin['month']}월:{$younation['name']}(와)과 통합에 합의";
|
||||
$youmsg = "【외교】{$admin['year']}년 {$admin['month']}월:{$mynation['name']}(와)과 통합에 합의";
|
||||
|
||||
PushMsg(2, $mynation['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:{$mynation['name']}▶", $mynation['color'], $younation['name'], $younation['color'], $msg);
|
||||
PushMsg(3, $younation['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:{$mynation['name']}▶", $mynation['color'], $younation['name'], $younation['color'], $youmsg);
|
||||
}
|
||||
|
||||
//현 메세지 지움
|
||||
$query = "update nation set dip{$num}='',dip{$num}_who='0',dip{$num}_when='' where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} else {
|
||||
$youlog[] = "<C>●</><Y>{$mynation['name']}</>(이)가 항복을 거부했습니다.";
|
||||
$mylog[] = "<C>●</><D>{$younation['name']}</>(으)로 항복을 거부했습니다.";
|
||||
|
||||
//현 메세지 지움
|
||||
$query = "update nation set dip{$num}='',dip{$num}_who='0',dip{$num}_when='' where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
}
|
||||
|
||||
pushGenLog($me, $mylog);
|
||||
pushGenLog($you, $youlog);
|
||||
pushGeneralPublicRecord($alllog, $admin['year'], $admin['month']);
|
||||
pushWorldHistory($history, $admin['year'], $admin['month']);
|
||||
|
||||
header('location:msglist.php');
|
||||
|
||||
-181
@@ -1,181 +0,0 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
//TODO: 등용장 재 디자인.
|
||||
//xxx: 일단 비활성화
|
||||
header('Location:msglist.php');
|
||||
die();
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
//로그인 검사
|
||||
|
||||
$gen = Util::getReq('gen', 'int');
|
||||
|
||||
extractMissingPostToGlobals();
|
||||
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
//FIXME: 망했음. CriticalFailure. 재 구현.
|
||||
|
||||
$db = DB::db();
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select startyear,year,month,killturn from game limit 1";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$admin = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select no,name,nation,nations,level,troop,npc,gold,rice from general where owner='{$userID}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select no,nation from general where no='$gen'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$you = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select name,nation,level,capital,scout from nation where nation='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$nation = MYDB_fetch_array($result);
|
||||
|
||||
$mylog = [];
|
||||
$youlog = [];
|
||||
$allog = [];
|
||||
|
||||
if($ok == "수락" && $me['level'] < 12 && $nation['level'] > 0 && $nation['scout'] == 0 && $me['nation'] != $nation['nation'] && $admin['year'] >= $admin['startyear']+3 && strpos($me['nations'], ",{$nation['nation']},") === false) {
|
||||
$youlog[] = "<C>●</><Y>{$me['name']}</> 등용에 성공했습니다.";
|
||||
$alllog[] = "<C>●</>{$admin['month']}월:<Y>{$me['name']}</>(이)가 <D><b>{$nation['name']}</b></>(으)로 <S>망명</>하였습니다.";
|
||||
$mylog[] = "<C>●</><D>{$nation['name']}</>(으)로 망명하여 수도로 이동합니다.";
|
||||
pushGeneralHistory($you, "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y>{$me['name']}</> 등용에 성공");
|
||||
pushGeneralHistory($me, "<C>●</>{$admin['year']}년 {$admin['month']}월:<D>{$nation['name']}</>(으)로 망명");
|
||||
|
||||
// 임관내역 추가
|
||||
$me['nations'] .= "{$nation['nation']},";
|
||||
|
||||
// 국가 변경, 도시 변경, 일반으로, 수도로
|
||||
$query = "update general set killturn='{$admin['killturn']}',belong=1,nation='{$you['nation']}',nations='{$me['nations']}',level=1,city='{$nation['capital']}' where no='{$me['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
// 재야가 아니면 명성N*10% 공헌N*10%감소
|
||||
if($me['level'] > 0) {
|
||||
// 1000 1000 남기고 환수
|
||||
if($me['gold'] > 1000) { $gold = $me['gold'] - 1000; $me['gold'] = 1000; } else { $gold = 0; }
|
||||
if($me['rice'] > 1000) { $rice = $me['rice'] - 1000; $me['rice'] = 1000; } else { $rice = 0; }
|
||||
$query = "update general set gold='{$me['gold']}',rice='{$me['rice']}',betray=betray+1,dedication=dedication*(1-0.1*betray),experience=experience*(1-0.1*betray) where no='{$me['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$query = "update nation set gold=gold+'$gold',rice=rice+'$rice' where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} else {
|
||||
//재야이면 100 100 증가
|
||||
$query = "update general set dedication=dedication+100,experience=experience+100 where no='{$me['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
}
|
||||
//유저이면 삭턴 리셋
|
||||
if($me['npc'] < 2) {
|
||||
$query = "update general set killturn='{$admin['killturn']}' where no='{$me['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
}
|
||||
|
||||
//태수 군사 시중 해제
|
||||
switch($me['level']) {
|
||||
case 4:
|
||||
$query = "update city set gen1=0 where gen1='{$me['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
break;
|
||||
case 3:
|
||||
$query = "update city set gen2=0 where gen2='{$me['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
break;
|
||||
case 2:
|
||||
$query = "update city set gen3=0 where gen3='{$me['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
break;
|
||||
}
|
||||
|
||||
//등용자 명성, 공헌 상승
|
||||
$query = "update general set dedication=dedication+100,experience=experience+100 where no='{$you['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
|
||||
// 부대 처리
|
||||
$query = "select no from troop where troop='{$me['troop']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$troop = MYDB_fetch_array($result);
|
||||
|
||||
//부대장일 경우
|
||||
if($troop['no'] == $me['no']) {
|
||||
// 모두 탈퇴
|
||||
$query = "update general set troop='0' where troop='{$me['troop']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
// 부대 삭제
|
||||
$query = "delete from troop where troop='{$me['troop']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} else {
|
||||
$query = "update general set troop='0' where no='{$me['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
}
|
||||
//국가 기술력 그대로
|
||||
$query = "select no from general where nation='{$nation['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$gencount = MYDB_num_rows($result);
|
||||
$gennum = $gencount;
|
||||
if($gencount < 10) $gencount = 10;
|
||||
|
||||
$query = "update nation set totaltech=tech*'$gencount',gennum='$gennum' where nation='{$nation['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
|
||||
//기존 국가 기술력 그대로
|
||||
$query = "select no from general where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$gencount = MYDB_num_rows($result);
|
||||
$gennum = $gencount;
|
||||
if($gencount < 10) $gencount = 10;
|
||||
|
||||
$query = "update nation set totaltech=tech*'$gencount',gennum='$gennum' where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
|
||||
//현 메세지 수정
|
||||
$query = "update general set msg{$num}='{$nation['name']}(으)로 등용 제의 수락',msg{$num}_type='10' where no='{$me['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} elseif($me['level'] == 12) {
|
||||
$mylog[] = "<C>●</>군주입니다. 등용 수락 불가.";
|
||||
|
||||
//현 메세지 지움
|
||||
$query = "update general set msg{$num}='{$nation['name']}(으)로 등용 제의 수락 불가',msg{$num}_type='10' where no='{$me['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} elseif($nation['level'] == 0) {
|
||||
$mylog[] = "<C>●</>없는 국가이거나 방랑군입니다. 등용 수락 불가.";
|
||||
|
||||
//현 메세지 지움
|
||||
$query = "update general set msg{$num}='{$nation['name']}(으)로 등용 제의 수락 불가',msg{$num}_type='10' where no='{$me['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} elseif($nation['scout'] != 0) {
|
||||
$mylog[] = "<C>●</>임관 금지중입니다. 등용 수락 불가.";
|
||||
|
||||
//현 메세지 지움
|
||||
$query = "update general set msg{$num}='{$nation['name']}(으)로 등용 제의 수락 불가',msg{$num}_type='10' where no='{$me['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} elseif($admin['year'] < $admin['startyear']+3) {
|
||||
$mylog[] = "<C>●</>초반 제한중입니다. 등용 수락 불가.";
|
||||
|
||||
//현 메세지 지움
|
||||
$query = "update general set msg{$num}='{$nation['name']}(으)로 등용 제의 수락 불가',msg{$num}_type='10' where no='{$me['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} elseif(strpos($me['nations'], ",{$nation['nation']},") > 0) {
|
||||
$mylog[] = "<C>●</>이미 임관했었던 국가입니다. 등용 수락 불가.";
|
||||
|
||||
//현 메세지 지움
|
||||
$query = "update general set msg{$num}='{$nation['name']}(으)로 등용 제의 수락 불가',msg{$num}_type='10' where no='{$me['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} else {
|
||||
$youlog[] = "<C>●</><Y>{$me['name']}</>(이)가 등용을 거부했습니다.";
|
||||
$mylog[] = "<C>●</><D>{$nation['name']}</>(으)로 망명을 거부했습니다.";
|
||||
|
||||
//현 메세지 지움
|
||||
$query = "update general set msg{$num}='{$nation['name']}(으)로 등용 제의 거부',msg{$num}_type='10' where no='{$me['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
}
|
||||
|
||||
pushGenLog($me, $mylog);
|
||||
pushGenLog($you, $youlog);
|
||||
pushGeneralPublicRecord($alllog, $admin['year'], $admin['month']);
|
||||
//pushWorldHistory($history, $admin['year'], $admin['month']);
|
||||
|
||||
header('location:msglist.php');
|
||||
@@ -1,142 +0,0 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
|
||||
$ok = Util::getReq('ok');
|
||||
$gen = Util::getReq('gen', 'int'); //XXX: -_-;;;;;;;;;;;;
|
||||
|
||||
extractMissingPostToGlobals();
|
||||
|
||||
//로그인 검사
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
//FIXME: 망했음. CriticalFailure. 재 구현.
|
||||
|
||||
$db = DB::db();
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select year,month from game limit 1";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$admin = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select no,name,nation,level,picture,imgsvr from general where owner='{$userID}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select no,nation from general where no='$gen'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$you = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select nation,name,power,gold,rice,surlimit,color from nation where nation='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$younation = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select nation,name,power,surlimit,color,dip{$num} as dipmsg from nation where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$mynation = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select city from city where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$losecitynum = MYDB_num_rows($result);
|
||||
|
||||
$query = "select city from city where nation='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$wincitynum = MYDB_num_rows($result);
|
||||
|
||||
//아국과의 관계
|
||||
$query = "select state from diplomacy where me='{$me['nation']}' and you='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$dip = MYDB_fetch_array($result);
|
||||
//대상국이 외교 진행중(선포중,교전중,합병수락중,통합수락중)일때
|
||||
$query = "select state from diplomacy where me='{$you['nation']}' and (state='0' or state='1' or state='3' or state='5')";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$dipcount = MYDB_num_rows($result);
|
||||
//대상국B이 아국C과 교전중인 국가A와 불가침중일때 불가(A=B 불가침, A=C(아국) 교전, B<-C(아국) 항복)
|
||||
$query = "select you,state from diplomacy where me='{$me['nation']}' and (state='0' or state='1')";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$warcount = MYDB_num_rows($result);
|
||||
// 아국과 교전중인 국가 골라냄
|
||||
$valid = 1;
|
||||
for($i=0; $i < $warcount; $i++) {
|
||||
$acdip = MYDB_fetch_array($result);
|
||||
//교전중 국가A와 대상국B 외교 확인
|
||||
$query = "select state from diplomacy where me='{$acdip['you']}' and you='{$you['nation']}'";
|
||||
$dipresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$abdip = MYDB_fetch_array($dipresult);
|
||||
|
||||
if($abdip['state'] == 7) {
|
||||
$valid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$mylog = [];
|
||||
$youlog = [];
|
||||
$alllog = [];
|
||||
$history = [];
|
||||
|
||||
if($ok == "수락") {
|
||||
// 서신 보낸 후 멸망 했을때.
|
||||
if($me['level'] < 5) {
|
||||
$mylog[] = "<C>●</>수뇌부가 아니므로 불가능합니다. 투항 실패.";
|
||||
} elseif($mynation['surlimit'] > 0) {
|
||||
$mylog[] = "<C>●</>본국이 외교제한이 지나지 않았습니다. 투항 실패.";
|
||||
} elseif($younation['surlimit'] > 0) {
|
||||
$mylog[] = "<C>●</>상대국이 외교제한이 지나지 않았습니다. 투항 실패.";
|
||||
// } elseif($losecitynum == 0) {
|
||||
// $mylog[] = "<C>●</>방랑군이므로 불가능합니다. 투항 실패.";
|
||||
} elseif($wincitynum == 0) {
|
||||
$mylog[] = "<C>●</>상대가 방랑군이므로 불가능합니다. 투항 실패.";
|
||||
} elseif($younation['power'] / $mynation['power'] <= 3) {
|
||||
$mylog[] = "<C>●</>아국과 상대국의 국력차이가 크지 않습니다. 투항 실패.";
|
||||
} elseif($losecitynum != 0 && !isClose($younation['nation'], $mynation['nation'])) {
|
||||
$mylog[] = "<C>●</>인접한 국가가 아니므로 불가능합니다. 투항 실패.";
|
||||
} elseif($dip['state'] == 0) {
|
||||
$mylog[] = "<C>●</>아국과 교전중입니다. 투항 실패.";
|
||||
} elseif($dipcount != 0) {
|
||||
$mylog[] = "<C>●</>상대국이 외교 진행중입니다. 투항 실패.";
|
||||
} elseif($valid == 0) {
|
||||
$mylog[] = "<C>●</>상대국이 아국의 교전국과 불가침중입니다. 투항 실패.";
|
||||
} elseif($mynation['dipmsg'] == "") {
|
||||
$mylog[] = "<C>●</>이미 거절했습니다. 불가침 실패.";
|
||||
} else {
|
||||
$youlog[] = "<C>●</><D><b>{$mynation['name']}</b></>(이)가 합병에 동의했습니다.";
|
||||
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【합병시도】</b></><D><b>{$mynation['name']}</b></>(와)과 <D><b>{$younation['name']}</b></>(이)가 합병을 시도합니다.";
|
||||
$mylog[] = "<C>●</><D><b>{$younation['name']}</b></>(와)과 합병에 동의했습니다.";
|
||||
$alllog[] = "<C>●</>{$admin['month']}월:<Y>{$me['name']}</>(이)가 <D><b>{$younation['name']}</b></>(와)과 <M>합병</>에 동의하였습니다.";
|
||||
pushGeneralHistory($you, "<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$mynation['name']}</b></>(와)과 합병 시도");
|
||||
pushGeneralHistory($me, "<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$younation['name']}</b></>(와)과 합병 시도");
|
||||
|
||||
//외교 변경
|
||||
$query = "update diplomacy set state='5',term='24' where me='{$mynation['nation']}' and you='{$younation['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$query = "update diplomacy set state='6',term='24' where me='{$younation['nation']}' and you='{$mynation['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
|
||||
//국메로 저장
|
||||
$msg = "【외교】{$admin['year']}년 {$admin['month']}월:{$younation['name']}(와)과 합병에 동의";
|
||||
$youmsg = "【외교】{$admin['year']}년 {$admin['month']}월:{$mynation['name']}(와)과 합병에 동의";
|
||||
|
||||
PushMsg(2, $mynation['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:{$mynation['name']}▶", $mynation['color'], $younation['name'], $younation['color'], $msg);
|
||||
PushMsg(3, $younation['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:{$mynation['name']}▶", $mynation['color'], $younation['name'], $younation['color'], $youmsg);
|
||||
}
|
||||
|
||||
//현 메세지 지움
|
||||
$query = "update nation set dip{$num}='',dip{$num}_who='0',dip{$num}_when='' where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} else {
|
||||
$youlog[] = "<C>●</><Y>{$mynation['name']}</>(이)가 항복을 거부했습니다.";
|
||||
$mylog[] = "<C>●</><D>{$younation['name']}</>(으)로 항복을 거부했습니다.";
|
||||
|
||||
//현 메세지 지움
|
||||
$query = "update nation set dip{$num}='',dip{$num}_who='0',dip{$num}_when='' where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
}
|
||||
|
||||
pushGenLog($me, $mylog);
|
||||
pushGenLog($you, $youlog);
|
||||
pushGeneralPublicRecord($alllog, $admin['year'], $admin['month']);
|
||||
pushWorldHistory($history, $admin['year'], $admin['month']);
|
||||
|
||||
header('location:msglist.php');
|
||||
+8
-199
@@ -1,202 +1,11 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
|
||||
|
||||
function getSingleMessage($messageID){
|
||||
$messageInfo = DB::db()->queryFirstRow('select * from `message` where `id` = %i', $messageID);
|
||||
|
||||
if (!$messageInfo) {
|
||||
return [false, '존재하지 않는 메시지'];
|
||||
}
|
||||
|
||||
return [true, $messageInfo];
|
||||
}
|
||||
|
||||
function getRawMessage($mailbox, $msgType, $limit=30, $fromSeq=null){
|
||||
|
||||
|
||||
$sql = 'select * from `message` where `mailbox` = %i_mailbox and `type` = %s_type and `valid_until` > now()';
|
||||
if($fromSeq !== null){
|
||||
$sql .= ' and `id` > %i_id';
|
||||
}
|
||||
$sql .= ' ORDER BY `id` desc';
|
||||
if($limit > 0){
|
||||
$sql .= ' LIMIT %i_limit';
|
||||
}
|
||||
|
||||
//TODO: table 네임의 prefix를 처리할 수 있도록 개선
|
||||
$result = DB::db()->query($sql, [
|
||||
'mailbox' => $mailbox,
|
||||
'type' => $msgType,
|
||||
'limit' => $limit,
|
||||
'time' => $fromTime
|
||||
]);
|
||||
|
||||
|
||||
return array_map(function ($row){
|
||||
return new Message($row);
|
||||
}, $result);
|
||||
}
|
||||
|
||||
function getMessage($msgType, $nationID=null, $limit=30, $fromSeq=null){
|
||||
$generalID = Session::getInstance()->generalID;
|
||||
if($generalID === null){
|
||||
return [];
|
||||
}
|
||||
|
||||
if($msgType === 'public'){
|
||||
return getRawMessage(9999, 'public', $limit, $fromSeq);
|
||||
}
|
||||
else if($msgType === 'private'){
|
||||
return getRawMessage($generalID, 'private', $limit, $fromSeq);
|
||||
}
|
||||
else if($msgType === 'national'){
|
||||
if($nationID === null){
|
||||
return [];
|
||||
}
|
||||
|
||||
return getRawMessage($nationID + 9000, 'national', $limit, $fromSeq);
|
||||
}
|
||||
else if($msgType === 'diplomacy'){
|
||||
if($nationID === null){
|
||||
return [];
|
||||
}
|
||||
|
||||
return getRawMessage($nationID + 9000, 'diplomacy', $limit, $fromSeq);
|
||||
}
|
||||
else{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function sendRawMessage($msgType, $isSender, $mailbox, $src, $dest, $msg, $date, $validUntil, $msgOption){
|
||||
|
||||
$srcNation = getNationStaticInfo($src['nation_id']);
|
||||
$destNation = getNationStaticInfo($dest['nation_id']);
|
||||
|
||||
$src['nation'] = Util::array_get($srcNation['name'], '재야');
|
||||
$src['color'] = Util::array_get($srcNation['color'], '#ffffff');
|
||||
|
||||
$dest['nation'] = Util::array_get($destNation['name'], '재야');
|
||||
$dest['color'] = Util::array_get($destNation['color'], '#ffffff');
|
||||
|
||||
if(!$isSender && $mailbox < 9000 && Util::array_get($msgOption['alert'], false)){
|
||||
//TODO:newmsg보단 lastmsg로 datetime을 넣는게 더 나아보임
|
||||
DB::db()->update('general', array(
|
||||
'newmsg' => true
|
||||
), 'no=%i', $dest['id']);
|
||||
}
|
||||
|
||||
if(isset($msgOption['alert'])){
|
||||
unset($msgOption['alert']);
|
||||
}
|
||||
|
||||
DB::db()->insert('message', [
|
||||
'address' => $dest,
|
||||
'type' => $msgType,
|
||||
'src' => $src['id'],
|
||||
'dest' => $dest['id'],
|
||||
'time' => $date,
|
||||
'valid_until' => $validUntil,
|
||||
'message' => Json::encode([
|
||||
'src' => $src,
|
||||
'dest' =>$dest,
|
||||
'text' => $msg,
|
||||
'option' => $msgOption
|
||||
], Json::DELETE_NULL)
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* @param string $msgType
|
||||
* @param mixed[] $src
|
||||
* @param mixed[] $dest
|
||||
* @param null|string $date
|
||||
* @param null|string $validUntil
|
||||
*/
|
||||
function sendMessage($msgType, array $src, array $dest, $msg, $date = null, $validUntil = null, $msgOption = null){
|
||||
if($date === null){
|
||||
$date = (new \Datetime())->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
if($validUntil === null){
|
||||
$validUntil = '9999-12-31 12:59:59';
|
||||
}
|
||||
|
||||
if($msgType === 'public'){
|
||||
//dest는 필요하지 않음
|
||||
$srcMailbox = null;
|
||||
$destMailbox = 9999;
|
||||
$dest['id'] = 9999;
|
||||
}
|
||||
else if($msgType === 'national'){
|
||||
//dest는 nation_id만 필요함
|
||||
$dest['id'] = $dest['nation_id'] + 9000;
|
||||
|
||||
if($src['nation_id'] === $dest['nation_id']){
|
||||
$srcMailbox = null;
|
||||
}
|
||||
else{
|
||||
$srcMailbox = $src['nation_id'] + 9000;
|
||||
}
|
||||
$destMailbox = $dest['nation_id'] + 9000;
|
||||
}
|
||||
else if($msgType === 'diplomacy'){
|
||||
//NOTE:외교 서신의 경우 '동일한 내용'이 두번 가지 않으므로, 별도 처리가 필요함
|
||||
$src['id'] = $dest['nation_id'] + 9000;
|
||||
$dest['id'] = $dest['nation_id'] + 9000;
|
||||
$destMailbox = $dest['id'];
|
||||
}
|
||||
else{
|
||||
//dest는 id, name이 필수
|
||||
$srcMailbox = $src['id'];
|
||||
$destMailbox = $dest['id'];
|
||||
}
|
||||
|
||||
if($srcMailbox !== null){
|
||||
sendRawMessage($msgType, true, $srcMailbox, $src, $dest, $msg, $date, $validUntil, null);
|
||||
}
|
||||
sendRawMessage($msgType, false, $destMailbox, $src, $dest, $msg, $date, $validUntil, null);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function sendScoutMsg($src, $dest, $date) {
|
||||
|
||||
return false;
|
||||
//$msgType, $isSender, $mailbox, $src, $dest, $msg, $date, $validUntil, $msgOption
|
||||
|
||||
if(!$src || !$src['id'] || !$src['nation_id']){
|
||||
return false;
|
||||
}
|
||||
|
||||
$nation = getNationStaticInfo($src['nation_id']);
|
||||
$nationName = Util::array_get($nation['name'], '재야');
|
||||
|
||||
if(!$dest || !$dest['id']){
|
||||
return false;
|
||||
}
|
||||
|
||||
$msgType = 'private';
|
||||
$option = [
|
||||
"action" => "scout"
|
||||
];
|
||||
|
||||
$msg = "{$src['nation']}(으)로 망명 권유 서신";
|
||||
$validUntil = "9999-12-31 12:59:59";//등용장의 시간 제한 없음
|
||||
|
||||
sendRawMessage('private', false, $dest['id'], $src, $dest, $msg, $date, $validUntil, $option);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function getMailboxList(){
|
||||
|
||||
$generalNations = [];
|
||||
|
||||
foreach(DB::db()->query('select `no`, `name`, `nation`, `level`, `npc` from `general` where `npc` < 2') as $general)
|
||||
foreach(DB::db()->queryAllLists('select `no`, `name`, `nation`, `level`, `npc` from `general` where `npc` < 2') as $general)
|
||||
{
|
||||
list($generalID, $generalName, $nationID, $level, $npc) = $general;
|
||||
if(!isset($generalNations[$nationID])){
|
||||
@@ -217,20 +26,20 @@ function getMailboxList(){
|
||||
$neutral = [
|
||||
"nation"=>0,
|
||||
"name"=>"재야",
|
||||
"color"=>"#ffffff"
|
||||
"color"=>"#000000"
|
||||
];
|
||||
|
||||
$result = array_map(function($nation) use ($generalNations) {
|
||||
$nationID = $nation['nation'];
|
||||
$mailbox = $nationID + 9000;
|
||||
$nation = $nation['name'];
|
||||
|
||||
$mailbox = $nationID + Message::MAILBOX_NATIONAL;
|
||||
$nationName = $nation['name'];
|
||||
$color = $nation['color'];
|
||||
$generals = Util::array_get($generalNations[$nationID], []);
|
||||
|
||||
return [
|
||||
"nationID"=>$nationID,
|
||||
"mailbox"=>$mailbox,
|
||||
"nation"=>$nationID,
|
||||
"name"=>$nationName,
|
||||
"color"=>$color,
|
||||
"general"=>$generals
|
||||
];
|
||||
@@ -270,7 +79,7 @@ function DecodeMsg($msg, $type, $who, $date, $bg, $num=0) {
|
||||
if($sndr['nation'] == 0) {
|
||||
$sndrnation = [];
|
||||
$sndrnation['name'] = '재야';
|
||||
$sndrnation['color'] = '#FFFFFF';
|
||||
$sndrnation['color'] = '#000000';
|
||||
} else {
|
||||
$sndrnation = getNationStaticInfo($sndr['nation']);
|
||||
}
|
||||
@@ -298,7 +107,7 @@ function DecodeMsg($msg, $type, $who, $date, $bg, $num=0) {
|
||||
if($rcvr['nation'] == 0) {
|
||||
$rcvrnation = [];
|
||||
$rcvrnation['name'] = '재야';
|
||||
$rcvrnation['color'] = '#FFFFFF';
|
||||
$rcvrnation['color'] = '#000000';
|
||||
} else {
|
||||
$rcvrnation = getNationStaticInfo($rcvr['nation']);
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
include('lib.php');
|
||||
include('func.php');
|
||||
|
||||
$session = Session::requireGameLogin([])->setReadOnly();
|
||||
|
||||
$generalID = $session->generalID;
|
||||
|
||||
$jsonPost = WebUtil::parseJsonPost();
|
||||
|
||||
$reqSequence = Util::toInt(Util::array_get($jsonPost['sequence'], 0));
|
||||
|
||||
|
||||
$nationID = DB::db()->queryFirstField(
|
||||
'select `nation` from `general` where no = %i',
|
||||
$generalID
|
||||
);
|
||||
|
||||
|
||||
if($nationID === null){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'소속 국가가 없습니다'
|
||||
]);
|
||||
}
|
||||
|
||||
Json::die([
|
||||
'result'=>true,
|
||||
'private'=>getMessage('private', $nationID, 10, $reqSequence),
|
||||
'public'=>getMessage('public', $nationID, 20, $reqSequence),
|
||||
'national'=>getMessage('national', $nationID, 30, $reqSequence),
|
||||
'diplomacy'=>getMessage('diplomacy', $nationID, 10, $reqSequence)
|
||||
]);
|
||||
@@ -17,12 +17,10 @@ if (!$generalID) {
|
||||
]);
|
||||
}
|
||||
|
||||
session_write_close(); // 이제 세션 안 쓴다
|
||||
|
||||
$jsonPost = WebUtil::parseJsonPost();
|
||||
|
||||
$msgID = Util::toInt(Util::array_get($jsonPost['msgID'], null), false);
|
||||
$msgResponse = Util::array_get($jsonPost['response'], null);
|
||||
$msgID = Util::toInt($jsonPost['msgID']??null);
|
||||
$msgResponse = $jsonPost['response']??null;
|
||||
|
||||
if ($msgID === null || !is_bool($msgResponse)) {
|
||||
Json::die([
|
||||
@@ -31,7 +29,13 @@ if ($msgID === null || !is_bool($msgResponse)) {
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$msg = Message::getMessageByID($msgID);
|
||||
if($msg === null){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'올바르지 않은 메시지'
|
||||
]);
|
||||
}
|
||||
$general = DB::db()->queryFirstRow('select `no`, `name`, `nation`, `nations`, `level`, `npc`, `gold`, `rice`, `troop` from `general` where `no` = %i', $generalID);
|
||||
if(!$general){
|
||||
Json::die([
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
include('lib.php');
|
||||
include('func.php');
|
||||
|
||||
$session = Session::requireGameLogin([])->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$jsonPost = WebUtil::parseJsonPost();
|
||||
$reqSequence = Util::toInt(Util::array_get($jsonPost['sequence'], 0));
|
||||
|
||||
|
||||
list($generalID, $nationID) = DB::db()->queryFirstList(
|
||||
'select `no`, `nation` from `general` where owner = %i',
|
||||
$userID
|
||||
);
|
||||
|
||||
|
||||
if($nationID === null){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'소속 국가가 없습니다'
|
||||
]);
|
||||
}
|
||||
|
||||
Json::die([
|
||||
'result'=>true,
|
||||
'private'=>array_map(function(Message $msg){
|
||||
return $msg->toArray();
|
||||
}, Message::getMessagesFromMailBox($generalID, Message::MSGTYPE_PRIVATE, 10, $reqSequence)),
|
||||
'public'=>array_map(function(Message $msg){
|
||||
return $msg->toArray();
|
||||
}, Message::getMessagesFromMailBox(Message::MAILBOX_PUBLIC, Message::MSGTYPE_PUBLIC, 20, $reqSequence)),
|
||||
'national'=>array_map(function(Message $msg){
|
||||
return $msg->toArray();
|
||||
}, Message::getMessagesFromMailBox(Message::MAILBOX_NATIONAL + $nationID, Message::MSGTYPE_NATIONAL, 20, $reqSequence)),
|
||||
'diplomacy'=>array_map(function(Message $msg){
|
||||
return $msg->toArray();
|
||||
}, Message::getMessagesFromMailBox(Message::MAILBOX_NATIONAL + $nationID, Message::MSGTYPE_DIPLOMACY, 10, 0)),
|
||||
]);
|
||||
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
include 'lib.php';
|
||||
include 'func.php';
|
||||
|
||||
$post = WebUtil::parseJsonPost();
|
||||
'@phan-var mixed[] $post';
|
||||
|
||||
$v = new Validator();
|
||||
$v->rule('required', ['mailbox','msg']);
|
||||
$v->rule('integer', 'mailbox');
|
||||
$v->rule('lengthMin', 'msg', 1);
|
||||
|
||||
if(!$v->validate()){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>$v->errorStr(),
|
||||
'msgID'=>null
|
||||
]);
|
||||
}
|
||||
|
||||
$mailbox = (int)$post['mailbox'];
|
||||
$text = StringUtil::cutStringForWidth($post['msg'], 100, '');
|
||||
|
||||
$session = Session::requireGameLogin([
|
||||
'msgID'=>null
|
||||
]);
|
||||
$userID = Session::getUserID();
|
||||
//NOTE: 전송 메시지 시간 계산을 위해 Session을 쓰기 가능 상태로 열어둠.
|
||||
|
||||
increaseRefresh('서신전달', 1);
|
||||
|
||||
if(getBlockLevel() == 1 || getBlockLevel() == 3) {
|
||||
Json::die([
|
||||
'result' => false,
|
||||
'reason' => '차단되었습니다.',
|
||||
'msgID'=>null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 메시지 전송 코드.
|
||||
*
|
||||
* TODO: 장기적으로 ajax는 한곳에 모을 필요가 있을 듯.
|
||||
*/
|
||||
|
||||
$now = new \DateTime();
|
||||
$unlimited = new \DateTime('9999-12-31');
|
||||
|
||||
$db = DB::db();
|
||||
$me = $db->queryFirstRow('SELECT `no`,`name`,`nation`,`level`,`con`,`picture`,`imgsvr` FROM general WHERE `owner`=%i', $userID);
|
||||
|
||||
if(!$me){
|
||||
$session->logoutGame();
|
||||
Json::die([
|
||||
'result' => false,
|
||||
'reason' => '로그인되지 않았습니다.',
|
||||
'msgID' => null
|
||||
]);
|
||||
}
|
||||
|
||||
$con = checkLimit($me['con']);
|
||||
if($con >= 2) {
|
||||
Json::die([
|
||||
'result' => false,
|
||||
'reason' => '접속 제한입니다.',
|
||||
'msgID' => null
|
||||
]);
|
||||
}
|
||||
|
||||
$me['icon'] = GetImageURL($me['imgsvr'], $me['picture']);
|
||||
|
||||
$srcNation = getNationStaticInfo($me['nation']);
|
||||
|
||||
$src = new MessageTarget($me['no'], $me['name'], $me['nation'], $srcNation['name'], $srcNation['color'], $me['icon']);
|
||||
|
||||
// 전체 메세지
|
||||
if($mailbox == 9999) {
|
||||
$msg = new Message(
|
||||
Message::MSGTYPE_PUBLIC,
|
||||
$src,
|
||||
null,
|
||||
$text,
|
||||
$now,
|
||||
$unlimited,
|
||||
null
|
||||
);
|
||||
$msgID = $msg->send();
|
||||
Json::die([
|
||||
'result' => true,
|
||||
'reason' => 'SUCCESS',
|
||||
'msgID' => $msgID
|
||||
]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 국가 메세지
|
||||
if($destMailbox >= Message::MAILBOX_NATIONAL) {
|
||||
|
||||
if($me['level'] < 5){
|
||||
$destNationID = $me['nation_id'];
|
||||
}
|
||||
else{
|
||||
$destNationID = $destMailbox - Message::MAILBOX_NATIONAL;
|
||||
}
|
||||
|
||||
$destNation = getNationStaticInfo($destNationID);
|
||||
|
||||
$dest = new MessageTarget(0, '', $destNation['nation'], $destNation['name'], $destNation['color']);
|
||||
|
||||
$msg = new Message(
|
||||
Message::MSGTYPE_NATIONAL,
|
||||
$src,
|
||||
$dest,
|
||||
$text,
|
||||
$now,
|
||||
$unlimited,
|
||||
null
|
||||
);
|
||||
$msgID = $msg->send();
|
||||
Json::die([
|
||||
'result' => true,
|
||||
'reason' => 'SUCCESS',
|
||||
'msgID' => $msgID
|
||||
]);
|
||||
}
|
||||
|
||||
// 개인 메세지
|
||||
if($destMailbox > 0) {
|
||||
$lastMsg = new \DateTime($session->lastMsg??'0000-00-00');
|
||||
|
||||
$msg_interval = $now->getTimestamp() - $lastMsg->getTimestamp();
|
||||
//NOTE: 여기서 유저 레벨을 구별할 코드가 필요할까?
|
||||
if($msg_interval < 2){
|
||||
Json::die([
|
||||
'result' => false,
|
||||
'reason' => '개인메세지는 2초당 1건만 보낼 수 있습니다!',
|
||||
'msgID' => null
|
||||
]);
|
||||
}
|
||||
|
||||
$session->lastMsg = $now->format('Y-m-d H:i:s');
|
||||
|
||||
$destUser = $db->queryFirstRow('SELECT `no`,`name`,`nation`,`con`,`picture`,`imgsvr` WHERE `no`=%i',$destMailbox);
|
||||
|
||||
if(!$destUser == null){
|
||||
Json::die([
|
||||
'result' => false,
|
||||
'reason' => '존재하지 않는 유저입니다.',
|
||||
'msgID' => null
|
||||
]);
|
||||
}
|
||||
|
||||
$destNation = getNationStaticInfo($destUser['nation']);
|
||||
|
||||
$dest = new MessageTarget(
|
||||
$destUser['no'],
|
||||
$destUser['name'],
|
||||
$destNation['nation'],
|
||||
$destNation['name'],
|
||||
$destNation['color'],
|
||||
GetImageURL($destUser['imgsvr'], $destUser['picture'])
|
||||
);
|
||||
|
||||
$msg = new Message(
|
||||
Message::MSGTYPE_PRIVATE,
|
||||
$src,
|
||||
$dest,
|
||||
$text,
|
||||
$now,
|
||||
$unlimited,
|
||||
null
|
||||
);
|
||||
$msgID = $msg->send();
|
||||
Json::die([
|
||||
'result' => true,
|
||||
'reason' => 'SUCCESS',
|
||||
'msgID' => $msgID
|
||||
]);
|
||||
}
|
||||
|
||||
Json::die([
|
||||
'result' => false,
|
||||
'reason' => '알 수 없는 에러',
|
||||
'msgID' => null
|
||||
]);
|
||||
@@ -1,159 +0,0 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
include 'lib.php';
|
||||
include 'func.php';
|
||||
|
||||
|
||||
$session = Session::requireGameLogin([
|
||||
'newSeq' => false
|
||||
]);
|
||||
$userID = Session::getUserID();
|
||||
//NOTE: 전송 메시지 시간 계산을 위해 Session을 쓰기 가능 상태로 열어둠.
|
||||
|
||||
/**
|
||||
* 메시지 전송 코드.
|
||||
*
|
||||
* TODO: 장기적으로 ajax는 한곳에 모을 필요가 있을 듯.
|
||||
*/
|
||||
|
||||
$post = WebUtil::parseJsonPost();
|
||||
|
||||
if(!isset($post['genlist']) || !isset($post['msg'])){
|
||||
Json::die([
|
||||
'result' => false,
|
||||
'reason' => '올바르지 않은 호출입니다.',
|
||||
'newSeq' => false
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
'@phan-var mixed[] $post';
|
||||
|
||||
$destMailbox = $post['dest_mailbox'];
|
||||
$msg = $post['msg'];
|
||||
$datetime = new \DateTime();
|
||||
$date = $datetime->format('Y-m-d H:i:s');
|
||||
|
||||
$db = DB::db();
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh('서신전달', 1);
|
||||
|
||||
if(getBlockLevel() == 1 || getBlockLevel() == 3) {
|
||||
Json::die([
|
||||
'result' => false,
|
||||
'reason' => '차단되었습니다.',
|
||||
'newSeq' => false
|
||||
]);
|
||||
}
|
||||
|
||||
$conlimit = $db->queryFirstField('select conlimit from game limit 1');
|
||||
|
||||
$me = $db->queryFirstRow('select `no`,`name`,`nation`,`level`,`con`,`picture`,`imgsvr` from `general` where `owner` = %i', $userID);
|
||||
|
||||
if(!$me){
|
||||
$session->logoutGame();
|
||||
Json::die([
|
||||
'result' => false,
|
||||
'reason' => '로그인되지 않았습니다.',
|
||||
'newSeq' => false
|
||||
]);
|
||||
}
|
||||
|
||||
$con = checkLimit($me['con'], $conlimit);
|
||||
if($con >= 2) {
|
||||
Json::die([
|
||||
'result' => false,
|
||||
'reason' => '접속 제한입니다.',
|
||||
'newSeq' => false
|
||||
]);
|
||||
}
|
||||
|
||||
$msg = StringUtil::cutStringForWidth($msg, 100, '');
|
||||
|
||||
if($msg == ''){
|
||||
Json::die([
|
||||
'result' => true,
|
||||
'reason' => 'SUCCESS',
|
||||
'newSeq' => false
|
||||
]);
|
||||
}
|
||||
|
||||
$src = [
|
||||
'id' => $me['no'],
|
||||
'name' => $me['name'],
|
||||
'icon' => $me['picture'],
|
||||
'nation_id' => $me['nation'],
|
||||
];
|
||||
|
||||
// 전체 메세지
|
||||
if($destMailbox == 9999) {
|
||||
sendMessage('public', $src, [], $msg, $date);
|
||||
// 국가 메세지
|
||||
} elseif($destMailbox >= 9000) {
|
||||
|
||||
if($me['level'] < 5){
|
||||
$real_nation = $me['nation_id'];
|
||||
}
|
||||
else{
|
||||
$real_nation = $destMailbox - 9000;
|
||||
}
|
||||
|
||||
if(!getNationStaticInfo($real_nation)){
|
||||
$real_nation = $me['nation_id'];
|
||||
}
|
||||
|
||||
$dest = [
|
||||
'nation_id' => $real_nation
|
||||
];
|
||||
|
||||
sendMessage('national', $src, $dest, $msg, $date);
|
||||
|
||||
// 개인 메세지
|
||||
} elseif($destMailbox > 0) {
|
||||
$last_msg = new \DateTime($session->last_msg?:'0000-00-00');
|
||||
|
||||
$msg_interval = $datetime->getTimestamp() - $last_msg->getTimestamp();
|
||||
//NOTE: 여기서 유저 레벨을 구별할 코드가 필요할까?
|
||||
if($msg_interval < 2){
|
||||
Json::die([
|
||||
'result' => false,
|
||||
'reason' => '개인메세지는 2초당 1건만 보낼 수 있습니다!',
|
||||
'newSeq' => false
|
||||
]);
|
||||
}
|
||||
|
||||
$destUser = $db->queryFirstRow('select `no`,`name`,`nation` from `general` where `no` = %s',$destMailbox);
|
||||
|
||||
if($destUser == null || empty($destUser)){
|
||||
Json::die([
|
||||
'result' => false,
|
||||
'reason' => '존재하지 않는 유저입니다.',
|
||||
'newSeq' => false
|
||||
]);
|
||||
}
|
||||
|
||||
$session->last_msg = $date;
|
||||
|
||||
$dest = [
|
||||
'id' => $destMailbox,
|
||||
'name' => $destUser['name'],
|
||||
'nation_id' => $destUser['nation']
|
||||
];
|
||||
|
||||
sendMessage('private', $src, $dest, $msg, $date);
|
||||
}
|
||||
else{
|
||||
Json::die([
|
||||
'result' => false,
|
||||
'reason' => '알 수 없는 에러',
|
||||
'newSeq' => false
|
||||
]);
|
||||
}
|
||||
|
||||
Json::die([
|
||||
'result' => true,
|
||||
'reason' => 'SUCCESS',
|
||||
'newSeq' => true
|
||||
]);
|
||||
+397
@@ -0,0 +1,397 @@
|
||||
|
||||
|
||||
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) > 186){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var messageTemplate = '';
|
||||
var myGeneralID=null;
|
||||
var isChief = false;
|
||||
var sequence =null;
|
||||
var myNation = null;
|
||||
var lastMsg = null;
|
||||
|
||||
var generalList = {};
|
||||
|
||||
function responseMessage(msgID, response){
|
||||
$.ajax({
|
||||
url: 'prompt_dummy.php',
|
||||
type: 'post',
|
||||
dataType:'json',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
msgID:msgID,
|
||||
response:response
|
||||
})
|
||||
}).then(refreshMsg);
|
||||
}
|
||||
|
||||
function refreshMsg(){
|
||||
return redrawMsg(fetchMsg());
|
||||
}
|
||||
|
||||
function fetchMsg(){
|
||||
return $.ajax({
|
||||
url: 'json_result.php',
|
||||
type: 'post',
|
||||
dataType:'json',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
sequence:sequence
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function redrawMsg(deferred){
|
||||
|
||||
console.log(deferred);
|
||||
|
||||
function registerSequence(obj){
|
||||
if(!obj.result){
|
||||
deferred.reject();
|
||||
return;
|
||||
}
|
||||
sequence = obj.sequence;
|
||||
return obj;
|
||||
}
|
||||
|
||||
function refineMessageObjs(obj){
|
||||
var msgList = [obj.public, obj.private, obj.diplomacy, obj.national];
|
||||
$.each(msgList, function(){
|
||||
if(!this){
|
||||
return true;
|
||||
}
|
||||
|
||||
$.each(this, function(){
|
||||
var msg = this;
|
||||
if(!msg.src.nation){
|
||||
msg.src.nation = '재야';
|
||||
msg.src.color = '#000000';
|
||||
}
|
||||
|
||||
if(!msg.dest.nation){
|
||||
msg.dest.nation = '재야';
|
||||
msg.dest.color = '#000000';
|
||||
}
|
||||
|
||||
msg.src.colorType = isBrightColor(msg.src.color)?'bright':'dark';
|
||||
msg.dest.colorType = isBrightColor(msg.dest.color)?'bright':'dark';
|
||||
});
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
|
||||
function printTemplate(obj){
|
||||
var printList = [
|
||||
[obj.public, $('#message_board .public_message'), 'public'],
|
||||
[obj.private, $('#message_board .private_message'), 'private'],
|
||||
[obj.diplomacy, $('#message_board .diplomacy_message'), 'diplomacy'],
|
||||
[obj.national, $('#message_board .national_message'), 'national'],
|
||||
];
|
||||
|
||||
$.each(printList, function(){
|
||||
var msgSource = this[0];
|
||||
var $msgBoard = this[1];
|
||||
var msgType = this[2];
|
||||
|
||||
if(!msgSource || $msgBoard.length == 0){
|
||||
console.log('No Items', msgSource, $msgBoard);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(msgType == 'diplomacy'){
|
||||
//외교는 항상 새로 그린다
|
||||
$msgBoard.empty();
|
||||
}
|
||||
|
||||
|
||||
var needRefreshLastContact = (msgType == 'private');
|
||||
|
||||
//list의 맨 앞이 가장 최신 메시지임.
|
||||
var $msgs = msgSource.map(function(msg){
|
||||
|
||||
var contactTarget = (msg.src.id != myGeneralID) ? msg.src.id : msg.dest.id;
|
||||
if(needRefreshLastContact && contactTarget != myGeneralID)
|
||||
{
|
||||
needRefreshLastContact = false;
|
||||
$('#last_contact').val(contactTarget).html(generalList[contactTarget].textName).show();
|
||||
}
|
||||
|
||||
msg.msgType = msgType;
|
||||
msg.defaultIcon = pathConfig.sharedIcon+'/default.jpg';
|
||||
var msgHtml = TemplateEngine(messageTemplate, msg);
|
||||
|
||||
|
||||
//만약 이전 메시지와 같은 id가 온 경우 덮어씌운다.
|
||||
//NOTE:현 프로세스 상에서는 같은 id가 와선 안된다.
|
||||
var $existMsg = $('#msg_{0}'.format(msg.id));
|
||||
var $msg = $(msgHtml);
|
||||
if($existMsg.length){
|
||||
console.log('메시지 충돌', $msg, $existMsg);
|
||||
$existMsg.html($msg.html());
|
||||
$msg = $existMsg;
|
||||
}
|
||||
|
||||
if(msg.option && msg.option.parent){
|
||||
//parent는 삭제.
|
||||
$('#msg_{0}'.format(msg.option.parent)).detach();
|
||||
}
|
||||
|
||||
$msg.find('button.prompt_yes').click(function(){
|
||||
if(!confirm("수락하시겠습니까?")){
|
||||
return false;
|
||||
}
|
||||
responseMessage(msg.id, true);
|
||||
|
||||
});
|
||||
|
||||
$msg.find('button.prompt_no').click(function(){
|
||||
if(!confirm("거절하시겠습니까?")){
|
||||
return false;
|
||||
}
|
||||
responseMessage(msg.id, false);
|
||||
});
|
||||
|
||||
if($existMsg.length){
|
||||
return null;
|
||||
}
|
||||
else{
|
||||
return $msg;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$msgBoard.prepend($msgs);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
deferred
|
||||
.then(registerSequence)
|
||||
.then(refineMessageObjs)
|
||||
.then(printTemplate);
|
||||
}
|
||||
|
||||
function refreshMailboxList(obj){
|
||||
//$.ajax는 data, textStatus, jqXHR를 가진다
|
||||
//when으로 묶었으므로 data를 풀어야함.
|
||||
obj = obj[0];
|
||||
|
||||
|
||||
var $mailboxList = $('#mailbox_list');
|
||||
|
||||
$mailboxList.change(function(){
|
||||
console.log($(this).val());
|
||||
})
|
||||
|
||||
var oldSelected = $mailboxList.val();
|
||||
|
||||
$mailboxList.empty();
|
||||
|
||||
var $lastContact = $('#last_contact');
|
||||
var lastContact = null;
|
||||
if($lastContact.length > 0 && $lastContact.val()>=0){
|
||||
lastContact = {
|
||||
id:$lastContact.val(),
|
||||
textName:$lastContact.html()
|
||||
};
|
||||
$lastContact = null;
|
||||
}
|
||||
|
||||
generalList = {};
|
||||
|
||||
//TODO:수뇌인 경우 각국에 대해 외교 국메를 넣을 수 있어야함.
|
||||
|
||||
$.each(obj.nation, function(){
|
||||
var nation = this;
|
||||
//console.log(nation);
|
||||
var $optgroup = $('<optgroup label="{0}"></optgroup>'.format(nation.nation));
|
||||
$optgroup.css('background-color', nation.color);
|
||||
|
||||
if(myNation.mailbox == nation.mailbox){
|
||||
myNation.color = nation.color;
|
||||
}
|
||||
|
||||
if(isBrightColor(nation.color)){
|
||||
$optgroup.css('color', 'black');
|
||||
}
|
||||
else{
|
||||
$optgroup.css('color', 'white');
|
||||
}
|
||||
|
||||
$.each(nation.general, function(){
|
||||
var generalID = this[0];
|
||||
var generalName = this[1];
|
||||
var isRuler = this.length>2;
|
||||
|
||||
|
||||
|
||||
if(generalID == myGeneralID){
|
||||
return true;
|
||||
}
|
||||
|
||||
var textName = generalName;
|
||||
if(isRuler){
|
||||
textName = '*{0}*'.format(textName);
|
||||
}
|
||||
|
||||
generalList[generalID] = {
|
||||
id:generalID,
|
||||
name:generalName,
|
||||
textName:textName,
|
||||
isRuler:isRuler,
|
||||
nation:nation.nationID,
|
||||
color:nation.color
|
||||
};
|
||||
|
||||
var $item = $('<option value="{0}">{1}</option>'.format(generalID, textName));
|
||||
$optgroup.append($item);
|
||||
});
|
||||
|
||||
$mailboxList.append($optgroup);
|
||||
});
|
||||
|
||||
var $favorite = $('<optgroup label="즐겨찾기"></optgroup>');
|
||||
|
||||
//아국메시지, 전체메시지
|
||||
var $ourCountry = $('<option value="{0}">【 아국 메세지 】</option>'.format(myNation.mailbox))
|
||||
.css({'background-color':myNation.color, 'color':isBrightColor(myNation.color)?'black':'white'});
|
||||
var $toPublic = $('<option value="9999">【 전체 메세지 】</option>');
|
||||
$favorite.append($ourCountry);
|
||||
$favorite.append($toPublic);
|
||||
|
||||
$lastContact = $('<option id="last_contact" value="-1"></option>').hide();
|
||||
if(lastContact){
|
||||
$lastContact.show().val(lastContact.id).html(lastContact.textName);
|
||||
}
|
||||
$favorite.append($lastContact);
|
||||
//TODO:운영자를 추가하는 코드도 넣을 것.
|
||||
|
||||
$mailboxList.prepend($favorite);
|
||||
|
||||
if(!oldSelected){
|
||||
$mailboxList.val(myNation.mailbox);
|
||||
}
|
||||
else{
|
||||
$mailboxList.val(oldSelected);
|
||||
}
|
||||
}
|
||||
|
||||
function registerGlobal(basicInfo){
|
||||
|
||||
myNation = {
|
||||
'id':basicInfo.myNationID,
|
||||
'mailbox':basicInfo.myNationID+9000,
|
||||
'color':'#000000',
|
||||
'nation':'재야'
|
||||
};
|
||||
lastMsg = {
|
||||
id : basicInfo.lastContact
|
||||
};
|
||||
myGeneralID = basicInfo.generalID;
|
||||
isChief = basicInfo.isChief;
|
||||
}
|
||||
|
||||
function activateMessageForm(){
|
||||
var $msgInput = $('#msg_input');
|
||||
var $msgSubmit = $('#msg_submit');
|
||||
var $mailboxList = $('#mailbox_list');
|
||||
|
||||
$msgInput.keypress(function (e) {
|
||||
var code = (e.keyCode ? e.keyCode : e.which);
|
||||
if (code == 13) {
|
||||
$msgSubmit.trigger('click');
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$msgSubmit.click(function(){
|
||||
|
||||
var text = $.trim($msgInput.val());
|
||||
$msgInput.val('').focus();
|
||||
|
||||
var targetMailbox = $mailboxList.val();
|
||||
console.log(targetMailbox, text);
|
||||
|
||||
var deferred;
|
||||
|
||||
if(text){
|
||||
deferred = $.ajax({
|
||||
url:'add_msg_dummy.php',
|
||||
type: 'post',
|
||||
dataType:'json',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
mailbox:targetMailbox,
|
||||
text:text
|
||||
})
|
||||
});
|
||||
}
|
||||
else{
|
||||
deferred = $.Deferred();
|
||||
deferred.resolve({
|
||||
result:true,
|
||||
reason:'no_text'
|
||||
});
|
||||
}
|
||||
|
||||
deferred.then(refreshMsg);
|
||||
});
|
||||
}
|
||||
|
||||
jQuery(function($){
|
||||
|
||||
//tmp_template.html은 추후 msg.js에 통합될 수 있음
|
||||
var getTemplate = $.get('tmp_template.html',function(obj){
|
||||
messageTemplate = obj;
|
||||
});
|
||||
|
||||
//basic_info.json은 세션값에 따라 동적으로 바뀌는 데이터임.
|
||||
var basicInfo = $.ajax({
|
||||
url:'basic_info.json',
|
||||
type: 'post',
|
||||
dataType:'json',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
|
||||
})
|
||||
}).then(registerGlobal);
|
||||
|
||||
//sender_list.json 은 서버측에선 캐시 가능한 데이터임.
|
||||
var senderList = $.ajax({
|
||||
url: 'sender_list.json',
|
||||
type: 'post',
|
||||
dataType:'json',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
var MessageList = fetchMsg();
|
||||
|
||||
senderList = $.when(senderList, basicInfo)
|
||||
.then(refreshMailboxList)
|
||||
.then(activateMessageForm);
|
||||
|
||||
$.when(MessageList, getTemplate, basicInfo, senderList)
|
||||
.then(function(){
|
||||
redrawMsg(MessageList);
|
||||
});
|
||||
});
|
||||
+16
-3
@@ -104,6 +104,18 @@ class Message
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toArray():array{
|
||||
return [
|
||||
'id'=>$this->id,
|
||||
'msgType'=>$this->msgType,
|
||||
'src'=>($this->src)?($this->src->toArray()):[],
|
||||
'dest'=>($this->dest)?($this->dest->toArray()):[],
|
||||
'msg'=>$this->msg,
|
||||
'msgOption'=>$this->msgOption,
|
||||
'time'=>$this->date->format('Y-m-d H:i:s')
|
||||
];
|
||||
}
|
||||
|
||||
public static function buildFromArray(array $row) : Message
|
||||
{
|
||||
$dbMessage = Json::decode($row['message']);
|
||||
@@ -165,7 +177,8 @@ class Message
|
||||
public static function getMessageByID(int $messageID) : Message
|
||||
{
|
||||
$db = DB::db();
|
||||
$row = $db->queryFirstRow('SELECT * FROM `message` WHERE `id` = %i', $messageID);
|
||||
$now = new \DateTime();
|
||||
$row = $db->queryFirstRow('SELECT * FROM `message` WHERE `id` = %i AND ValidUntil', $messageID);
|
||||
if (!$row) {
|
||||
return null;
|
||||
}
|
||||
@@ -232,8 +245,8 @@ class Message
|
||||
'time' => $this->date->format('Y-m-d H:i:s'),
|
||||
'valid_until' => $this->validUntil->format('Y-m-d H:i:s'),
|
||||
'message' => Json::encode([
|
||||
'src' => $this->src->toArray(),
|
||||
'dest' =>$this->dest->toArray(),
|
||||
'src'=>($this->src)?($this->src->toArray()):[],
|
||||
'dest'=>($this->dest)?($this->dest->toArray()):[],
|
||||
'text' => $this->msg,
|
||||
'option' => $this->msgOption
|
||||
])
|
||||
|
||||
+28
-10
@@ -8,32 +8,49 @@ class MessageTarget extends Target {
|
||||
public $nationName;
|
||||
/** @var string */
|
||||
public $color;
|
||||
/** @var string */
|
||||
public $icon;
|
||||
|
||||
public function __construct(int $generalID, string $generalName, int $nationID, string $nationName, string $color){
|
||||
public function __construct(
|
||||
int $generalID,
|
||||
string $generalName,
|
||||
int $nationID,
|
||||
string $nationName,
|
||||
string $color,
|
||||
string $icon=''
|
||||
){
|
||||
|
||||
parent::__construct($generalID, $nationID);
|
||||
|
||||
if($mailbox > Message::MAILBOX_NATIONAL){
|
||||
$this->isGeneral = false;
|
||||
}
|
||||
else{
|
||||
$this->isGeneral = true;
|
||||
if(!$icon){
|
||||
$icon = ServConfig::getSharedIconPath().'/default.jpg';
|
||||
}
|
||||
|
||||
$this->generalName = $generalName;
|
||||
$this->nationName = $nationName;
|
||||
$this->color = $color;
|
||||
$this->icon = $icon;
|
||||
}
|
||||
|
||||
public static function buildFromArray(array $arr) : MessageTarget
|
||||
{
|
||||
if(!Util::array_get($arr['nation'])){
|
||||
if(!$arr){
|
||||
return null;
|
||||
}
|
||||
if(!Util::array_get($arr['nation_id'])){
|
||||
$arr['nation'] = '재야';
|
||||
$arr['color'] = '#ffffff';
|
||||
$arr['color'] = '#000000';
|
||||
$arr['nation_id'] = 0;
|
||||
}
|
||||
|
||||
return new MessageTarget($arr['id'], $arr['name'], $arr['nation_id'], $arr['nation'], $arr['color']);
|
||||
return new MessageTarget(
|
||||
$arr['id'],
|
||||
$arr['name'],
|
||||
$arr['nation_id'],
|
||||
$arr['nation'],
|
||||
$arr['color'],
|
||||
$arr['icon']??''
|
||||
);
|
||||
}
|
||||
|
||||
public function toArray() : array{
|
||||
@@ -42,7 +59,8 @@ class MessageTarget extends Target {
|
||||
'name'=>$this->generalName,
|
||||
'nation_id'=>$this->nationID,
|
||||
'nation'=>$this->nationName,
|
||||
'color'=>$this->color
|
||||
'color'=>$this->color,
|
||||
'icon'=>$this->icon
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user