Refac: 메시지 타입 지정으로 MessageType Enum 사용
This commit is contained in:
+10
-8
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
@@ -111,7 +113,7 @@ switch ($btn) {
|
|||||||
case "경험치1000":
|
case "경험치1000":
|
||||||
$text = $btn . " 지급!";
|
$text = $btn . " 지급!";
|
||||||
foreach ($genlist as $generalID) {
|
foreach ($genlist as $generalID) {
|
||||||
$msg = new Message(Message::MSGTYPE_PRIVATE, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
||||||
$msg->send(true);
|
$msg->send(true);
|
||||||
}
|
}
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
@@ -122,7 +124,7 @@ switch ($btn) {
|
|||||||
case "공헌치1000":
|
case "공헌치1000":
|
||||||
$text = $btn . " 지급!";
|
$text = $btn . " 지급!";
|
||||||
foreach ($genlist as $generalID) {
|
foreach ($genlist as $generalID) {
|
||||||
$msg = new Message(Message::MSGTYPE_PRIVATE, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
||||||
$msg->send(true);
|
$msg->send(true);
|
||||||
}
|
}
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
@@ -133,7 +135,7 @@ switch ($btn) {
|
|||||||
case "보숙10000":
|
case "보숙10000":
|
||||||
$text = "보병숙련도+10000 지급!";
|
$text = "보병숙련도+10000 지급!";
|
||||||
foreach ($genlist as $generalID) {
|
foreach ($genlist as $generalID) {
|
||||||
$msg = new Message(Message::MSGTYPE_PRIVATE, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
||||||
$msg->send(true);
|
$msg->send(true);
|
||||||
}
|
}
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
@@ -143,7 +145,7 @@ switch ($btn) {
|
|||||||
case "궁숙10000":
|
case "궁숙10000":
|
||||||
$text = "궁병숙련도+10000 지급!";
|
$text = "궁병숙련도+10000 지급!";
|
||||||
foreach ($genlist as $generalID) {
|
foreach ($genlist as $generalID) {
|
||||||
$msg = new Message(Message::MSGTYPE_PRIVATE, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
||||||
$msg->send(true);
|
$msg->send(true);
|
||||||
}
|
}
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
@@ -154,7 +156,7 @@ switch ($btn) {
|
|||||||
$src = MessageTarget::buildQuick($session->generalID);
|
$src = MessageTarget::buildQuick($session->generalID);
|
||||||
$text = "기병숙련도+10000 지급!";
|
$text = "기병숙련도+10000 지급!";
|
||||||
foreach ($genlist as $generalID) {
|
foreach ($genlist as $generalID) {
|
||||||
$msg = new Message(Message::MSGTYPE_PRIVATE, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
||||||
$msg->send(true);
|
$msg->send(true);
|
||||||
}
|
}
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
@@ -165,7 +167,7 @@ switch ($btn) {
|
|||||||
$src = MessageTarget::buildQuick($session->generalID);
|
$src = MessageTarget::buildQuick($session->generalID);
|
||||||
$text = "귀병숙련도+10000 지급!";
|
$text = "귀병숙련도+10000 지급!";
|
||||||
foreach ($genlist as $generalID) {
|
foreach ($genlist as $generalID) {
|
||||||
$msg = new Message(Message::MSGTYPE_PRIVATE, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
||||||
$msg->send(true);
|
$msg->send(true);
|
||||||
}
|
}
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
@@ -176,7 +178,7 @@ switch ($btn) {
|
|||||||
$src = MessageTarget::buildQuick($session->generalID);
|
$src = MessageTarget::buildQuick($session->generalID);
|
||||||
$text = "차병숙련도+10000 지급!";
|
$text = "차병숙련도+10000 지급!";
|
||||||
foreach ($genlist as $generalID) {
|
foreach ($genlist as $generalID) {
|
||||||
$msg = new Message(Message::MSGTYPE_PRIVATE, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
||||||
$msg->send(true);
|
$msg->send(true);
|
||||||
}
|
}
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
@@ -196,7 +198,7 @@ switch ($btn) {
|
|||||||
case "메세지 전달":
|
case "메세지 전달":
|
||||||
$text = $msg ?? '';
|
$text = $msg ?? '';
|
||||||
foreach ($genlist as $generalID) {
|
foreach ($genlist as $generalID) {
|
||||||
$msg = new Message(Message::MSGTYPE_PRIVATE, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
||||||
$msg->send(true);
|
$msg->send(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
//로그인 검사
|
//로그인 검사
|
||||||
@@ -18,7 +20,7 @@ $msg = Util::getPost('msg', 'string', '메시지');
|
|||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
//NOTE: 왜 기능이 admin2와 admin4가 같이 있는가?
|
//NOTE: 왜 기능이 admin2와 admin4가 같이 있는가?
|
||||||
//NOTE: 왜 블럭 시 admin4에선 금쌀을 없애지 않는가?
|
//NOTE: 왜 블럭 시 admin4에선 금쌀을 없애지 않는가?
|
||||||
switch ($btn) {
|
switch ($btn) {
|
||||||
case "블럭 해제":
|
case "블럭 해제":
|
||||||
@@ -66,7 +68,7 @@ switch ($btn) {
|
|||||||
$src = MessageTarget::buildQuick($session->generalID);
|
$src = MessageTarget::buildQuick($session->generalID);
|
||||||
foreach($genlist as $generalID){
|
foreach($genlist as $generalID){
|
||||||
$msgObj = new Message(
|
$msgObj = new Message(
|
||||||
Message::MSGTYPE_PRIVATE,
|
MessageType::private,
|
||||||
$src,
|
$src,
|
||||||
MessageTarget::buildQuick($generalID),
|
MessageTarget::buildQuick($generalID),
|
||||||
$msg,
|
$msg,
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
@@ -119,7 +121,7 @@ else{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$msg = new Message(
|
$msg = new Message(
|
||||||
Message::MSGTYPE_DIPLOMACY,
|
MessageType::diplomacy,
|
||||||
$src,
|
$src,
|
||||||
$dest,
|
$dest,
|
||||||
$msgText,
|
$msgText,
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
@@ -104,7 +106,7 @@ else{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$msg = new Message(
|
$msg = new Message(
|
||||||
Message::MSGTYPE_DIPLOMACY,
|
MessageType::diplomacy,
|
||||||
$src,
|
$src,
|
||||||
$dest,
|
$dest,
|
||||||
$msgText,
|
$msgText,
|
||||||
@@ -115,7 +117,7 @@ $msg = new Message(
|
|||||||
$msgID = $msg->send();
|
$msgID = $msg->send();
|
||||||
|
|
||||||
$msg = new Message(
|
$msg = new Message(
|
||||||
Message::MSGTYPE_NATIONAL,
|
MessageType::national,
|
||||||
$src,
|
$src,
|
||||||
$dest,
|
$dest,
|
||||||
$msgText,
|
$msgText,
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
@@ -73,7 +75,7 @@ $db->update('ng_diplomacy', [
|
|||||||
$msgText = "외교 서신(#{$letterNo})이 회수되었습니다.";
|
$msgText = "외교 서신(#{$letterNo})이 회수되었습니다.";
|
||||||
|
|
||||||
$msg = new Message(
|
$msg = new Message(
|
||||||
Message::MSGTYPE_DIPLOMACY,
|
MessageType::diplomacy,
|
||||||
$src,
|
$src,
|
||||||
$dest,
|
$dest,
|
||||||
$msgText,
|
$msgText,
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
@@ -176,7 +178,7 @@ else{
|
|||||||
|
|
||||||
|
|
||||||
$msg = new Message(
|
$msg = new Message(
|
||||||
Message::MSGTYPE_DIPLOMACY,
|
MessageType::diplomacy,
|
||||||
$src,
|
$src,
|
||||||
$dest,
|
$dest,
|
||||||
$msgText,
|
$msgText,
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
include('lib.php');
|
include('lib.php');
|
||||||
include('func.php');
|
include('func.php');
|
||||||
|
|
||||||
@@ -83,7 +85,7 @@ if($reqType == 'private'){
|
|||||||
$nextSequence = $msg->id;
|
$nextSequence = $msg->id;
|
||||||
}
|
}
|
||||||
return $msg->toArray();
|
return $msg->toArray();
|
||||||
}, Message::getMessagesFromMailBoxOld($generalID, Message::MSGTYPE_PRIVATE, $reqTo, 15));
|
}, Message::getMessagesFromMailBoxOld($generalID, MessageType::private, $reqTo, 15));
|
||||||
}
|
}
|
||||||
else if($reqType == 'public'){
|
else if($reqType == 'public'){
|
||||||
$result['public'] = array_map(function(Message $msg)use (&$nextSequence){
|
$result['public'] = array_map(function(Message $msg)use (&$nextSequence){
|
||||||
@@ -91,7 +93,7 @@ else if($reqType == 'public'){
|
|||||||
$nextSequence = $msg->id;
|
$nextSequence = $msg->id;
|
||||||
}
|
}
|
||||||
return $msg->toArray();
|
return $msg->toArray();
|
||||||
}, Message::getMessagesFromMailBoxOld(Message::MAILBOX_PUBLIC, Message::MSGTYPE_PUBLIC, $reqTo, 15));
|
}, Message::getMessagesFromMailBoxOld(Message::MAILBOX_PUBLIC, MessageType::public, $reqTo, 15));
|
||||||
}
|
}
|
||||||
else if($reqType == 'national'){
|
else if($reqType == 'national'){
|
||||||
$result['national'] = array_map(function(Message $msg)use (&$nextSequence){
|
$result['national'] = array_map(function(Message $msg)use (&$nextSequence){
|
||||||
@@ -99,7 +101,7 @@ else if($reqType == 'national'){
|
|||||||
$nextSequence = $msg->id;
|
$nextSequence = $msg->id;
|
||||||
}
|
}
|
||||||
return $msg->toArray();
|
return $msg->toArray();
|
||||||
}, Message::getMessagesFromMailBoxOld(Message::MAILBOX_NATIONAL + $nationID, Message::MSGTYPE_NATIONAL, $reqTo, 15));
|
}, Message::getMessagesFromMailBoxOld(Message::MAILBOX_NATIONAL + $nationID, MessageType::national, $reqTo, 15));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$result['diplomacy'] = array_map(function(Message $msg)use (&$nextSequence, $permission){
|
$result['diplomacy'] = array_map(function(Message $msg)use (&$nextSequence, $permission){
|
||||||
@@ -112,7 +114,7 @@ else{
|
|||||||
$values['option']['invalid'] = true;
|
$values['option']['invalid'] = true;
|
||||||
}
|
}
|
||||||
return $values;
|
return $values;
|
||||||
}, Message::getMessagesFromMailBoxOld(Message::MAILBOX_NATIONAL + $nationID, Message::MSGTYPE_DIPLOMACY, $reqTo, 15));
|
}, Message::getMessagesFromMailBoxOld(Message::MAILBOX_NATIONAL + $nationID, MessageType::diplomacy, $reqTo, 15));
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::die($result);
|
Json::die($result);
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
include('lib.php');
|
include('lib.php');
|
||||||
include('func.php');
|
include('func.php');
|
||||||
|
|
||||||
@@ -66,7 +68,7 @@ $result['private'] = array_map(function(Message $msg) use (&$nextSequence, &$min
|
|||||||
$lastType = 'private';
|
$lastType = 'private';
|
||||||
}
|
}
|
||||||
return $msg->toArray();
|
return $msg->toArray();
|
||||||
}, Message::getMessagesFromMailBox($generalID, Message::MSGTYPE_PRIVATE, 15, $reqSequence));
|
}, Message::getMessagesFromMailBox($generalID, MessageType::private, 15, $reqSequence));
|
||||||
|
|
||||||
$result['public'] = array_map(function(Message $msg)use (&$nextSequence, &$minSequence, &$lastType){
|
$result['public'] = array_map(function(Message $msg)use (&$nextSequence, &$minSequence, &$lastType){
|
||||||
if($msg->id > $nextSequence){
|
if($msg->id > $nextSequence){
|
||||||
@@ -77,7 +79,7 @@ $result['public'] = array_map(function(Message $msg)use (&$nextSequence, &$minSe
|
|||||||
$lastType = 'public';
|
$lastType = 'public';
|
||||||
}
|
}
|
||||||
return $msg->toArray();
|
return $msg->toArray();
|
||||||
}, Message::getMessagesFromMailBox(Message::MAILBOX_PUBLIC, Message::MSGTYPE_PUBLIC, 15, $reqSequence));
|
}, Message::getMessagesFromMailBox(Message::MAILBOX_PUBLIC, MessageType::public, 15, $reqSequence));
|
||||||
|
|
||||||
$result['national'] = array_map(function(Message $msg)use (&$nextSequence, &$minSequence, &$lastType){
|
$result['national'] = array_map(function(Message $msg)use (&$nextSequence, &$minSequence, &$lastType){
|
||||||
if($msg->id > $nextSequence){
|
if($msg->id > $nextSequence){
|
||||||
@@ -88,7 +90,7 @@ $result['national'] = array_map(function(Message $msg)use (&$nextSequence, &$min
|
|||||||
$lastType = 'national';
|
$lastType = 'national';
|
||||||
}
|
}
|
||||||
return $msg->toArray();
|
return $msg->toArray();
|
||||||
}, Message::getMessagesFromMailBox(Message::MAILBOX_NATIONAL + $nationID, Message::MSGTYPE_NATIONAL, 15, $reqSequence));
|
}, Message::getMessagesFromMailBox(Message::MAILBOX_NATIONAL + $nationID, MessageType::national, 15, $reqSequence));
|
||||||
|
|
||||||
$result['diplomacy']= array_map(function(Message $msg)use (&$nextSequence, &$minSequence, &$lastType, $permission){
|
$result['diplomacy']= array_map(function(Message $msg)use (&$nextSequence, &$minSequence, &$lastType, $permission){
|
||||||
if($msg->id > $nextSequence){
|
if($msg->id > $nextSequence){
|
||||||
@@ -104,7 +106,7 @@ $result['diplomacy']= array_map(function(Message $msg)use (&$nextSequence, &$min
|
|||||||
$values['option']['invalid'] = true;
|
$values['option']['invalid'] = true;
|
||||||
}
|
}
|
||||||
return $values;
|
return $values;
|
||||||
}, Message::getMessagesFromMailBox(Message::MAILBOX_NATIONAL + $nationID, Message::MSGTYPE_DIPLOMACY, 15, $reqSequence));
|
}, Message::getMessagesFromMailBox(Message::MAILBOX_NATIONAL + $nationID, MessageType::diplomacy, 15, $reqSequence));
|
||||||
|
|
||||||
if($lastType !== null){
|
if($lastType !== null){
|
||||||
array_pop($result[$lastType]);
|
array_pop($result[$lastType]);
|
||||||
|
|||||||
+16
-14
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
include 'lib.php';
|
include 'lib.php';
|
||||||
include 'func.php';
|
include 'func.php';
|
||||||
|
|
||||||
@@ -27,7 +29,7 @@ $text = trim(StringUtil::cutStringForWidth($post['text'], 199, ''));
|
|||||||
|
|
||||||
$session = Session::requireGameLogin([
|
$session = Session::requireGameLogin([
|
||||||
'msgID'=>null
|
'msgID'=>null
|
||||||
]);
|
]);
|
||||||
$userID = Session::getUserID();
|
$userID = Session::getUserID();
|
||||||
//NOTE: 전송 메시지 시간 계산을 위해 Session을 쓰기 가능 상태로 열어둠.
|
//NOTE: 전송 메시지 시간 계산을 위해 Session을 쓰기 가능 상태로 열어둠.
|
||||||
|
|
||||||
@@ -43,7 +45,7 @@ if(getBlockLevel() == 1 || getBlockLevel() == 3) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 메시지 전송 코드.
|
* 메시지 전송 코드.
|
||||||
*
|
*
|
||||||
* TODO: 장기적으로 ajax는 한곳에 모을 필요가 있을 듯.
|
* TODO: 장기적으로 ajax는 한곳에 모을 필요가 있을 듯.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -63,7 +65,7 @@ if(!$me){
|
|||||||
}
|
}
|
||||||
|
|
||||||
$con = checkLimit($me['con']);
|
$con = checkLimit($me['con']);
|
||||||
if($con >= 2) {
|
if($con >= 2) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
'reason' => '접속 제한입니다.',
|
'reason' => '접속 제한입니다.',
|
||||||
@@ -80,12 +82,12 @@ $src = new MessageTarget($me['no'], $me['name'], $srcNation['nation'], $srcNatio
|
|||||||
// 전체 메세지
|
// 전체 메세지
|
||||||
if($mailbox == Message::MAILBOX_PUBLIC) {
|
if($mailbox == Message::MAILBOX_PUBLIC) {
|
||||||
$msg = new Message(
|
$msg = new Message(
|
||||||
Message::MSGTYPE_PUBLIC,
|
MessageType::public,
|
||||||
$src,
|
|
||||||
$src,
|
$src,
|
||||||
$text,
|
$src,
|
||||||
$now,
|
$text,
|
||||||
$unlimited,
|
$now,
|
||||||
|
$unlimited,
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
$msgID = $msg->send();
|
$msgID = $msg->send();
|
||||||
@@ -96,7 +98,7 @@ if($mailbox == Message::MAILBOX_PUBLIC) {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 국가 메세지
|
// 국가 메세지
|
||||||
if($mailbox >= Message::MAILBOX_NATIONAL) {
|
if($mailbox >= Message::MAILBOX_NATIONAL) {
|
||||||
@@ -109,10 +111,10 @@ if($mailbox >= Message::MAILBOX_NATIONAL) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($destNationID == $me['nation']){
|
if($destNationID == $me['nation']){
|
||||||
$msgType = Message::MSGTYPE_NATIONAL;
|
$msgType = MessageType::national;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$msgType = Message::MSGTYPE_DIPLOMACY;
|
$msgType = MessageType::diplomacy;
|
||||||
}
|
}
|
||||||
|
|
||||||
$destNation = getNationStaticInfo($destNationID);
|
$destNation = getNationStaticInfo($destNationID);
|
||||||
@@ -149,11 +151,11 @@ if($mailbox > 0) {
|
|||||||
'msgID' => null
|
'msgID' => null
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$session->lastMsg = $now->format('Y-m-d H:i:s');
|
$session->lastMsg = $now->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
$destUser = $db->queryFirstRow('SELECT `no`,`name`,`nation`,`officer_level`,`con`,`picture`,`imgsvr`,permission,penalty FROM general WHERE `no`=%i',$mailbox);
|
$destUser = $db->queryFirstRow('SELECT `no`,`name`,`nation`,`officer_level`,`con`,`picture`,`imgsvr`,permission,penalty FROM general WHERE `no`=%i',$mailbox);
|
||||||
|
|
||||||
if(!$destUser){
|
if(!$destUser){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
@@ -183,7 +185,7 @@ if($mailbox > 0) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$msg = new Message(
|
$msg = new Message(
|
||||||
Message::MSGTYPE_PRIVATE,
|
MessageType::private,
|
||||||
$src,
|
$src,
|
||||||
$dest,
|
$dest,
|
||||||
$text,
|
$text,
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
@@ -268,7 +270,7 @@ function do추방(General $general, int $myOfficerLevel):?string{
|
|||||||
GetImageURL($general->getVar('imgsvr'), $general->getVar('picture'))
|
GetImageURL($general->getVar('imgsvr'), $general->getVar('picture'))
|
||||||
);
|
);
|
||||||
$msg = new Message(
|
$msg = new Message(
|
||||||
Message::MSGTYPE_PUBLIC,
|
MessageType::public,
|
||||||
$src,
|
$src,
|
||||||
$src,
|
$src,
|
||||||
$str,
|
$str,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use sammo\DTO\AuctionBidItemData;
|
|||||||
use sammo\DTO\AuctionInfo;
|
use sammo\DTO\AuctionInfo;
|
||||||
use sammo\Enums\AuctionType;
|
use sammo\Enums\AuctionType;
|
||||||
use sammo\Enums\InheritanceKey;
|
use sammo\Enums\InheritanceKey;
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
use sammo\Enums\RankColumn;
|
use sammo\Enums\RankColumn;
|
||||||
use sammo\Enums\ResourceType;
|
use sammo\Enums\ResourceType;
|
||||||
|
|
||||||
@@ -245,7 +246,7 @@ abstract class Auction
|
|||||||
//TODO: 전역 알림이 나타나야한다. 일반 메시지보다는 중요하고, 메시지보단 약하게..
|
//TODO: 전역 알림이 나타나야한다. 일반 메시지보다는 중요하고, 메시지보단 약하게..
|
||||||
//TODO: 바로가기를 제공하는 편이 좋을 것 같다.
|
//TODO: 바로가기를 제공하는 편이 좋을 것 같다.
|
||||||
$msg = new Message(
|
$msg = new Message(
|
||||||
Message::MSGTYPE_PRIVATE,
|
MessageType::private,
|
||||||
$src,
|
$src,
|
||||||
$dest,
|
$dest,
|
||||||
$reason,
|
$reason,
|
||||||
@@ -509,7 +510,7 @@ abstract class Auction
|
|||||||
//TODO: 전역 알림이 나타나야한다. 일반 메시지보다는 중요하고, 메시지보단 약하게..
|
//TODO: 전역 알림이 나타나야한다. 일반 메시지보다는 중요하고, 메시지보단 약하게..
|
||||||
//TODO: 바로가기를 제공하는 편이 좋을 것 같다.
|
//TODO: 바로가기를 제공하는 편이 좋을 것 같다.
|
||||||
$msg = new Message(
|
$msg = new Message(
|
||||||
Message::MSGTYPE_PRIVATE,
|
MessageType::private,
|
||||||
$src,
|
$src,
|
||||||
$dest,
|
$dest,
|
||||||
$failReason,
|
$failReason,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use sammo\DTO\AuctionBidItem;
|
|||||||
use sammo\DTO\AuctionInfo;
|
use sammo\DTO\AuctionInfo;
|
||||||
use sammo\DTO\AuctionInfoDetail;
|
use sammo\DTO\AuctionInfoDetail;
|
||||||
use sammo\Enums\AuctionType;
|
use sammo\Enums\AuctionType;
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
use sammo\Enums\ResourceType;
|
use sammo\Enums\ResourceType;
|
||||||
|
|
||||||
abstract class AuctionBasicResource extends Auction
|
abstract class AuctionBasicResource extends Auction
|
||||||
@@ -145,7 +146,7 @@ abstract class AuctionBasicResource extends Auction
|
|||||||
//TODO: 전역 알림이 나타나야한다. 일반 메시지보다는 중요하고, 메시지보단 약하게..
|
//TODO: 전역 알림이 나타나야한다. 일반 메시지보다는 중요하고, 메시지보단 약하게..
|
||||||
//TODO: 바로가기를 제공하는 편이 좋을 것 같다.
|
//TODO: 바로가기를 제공하는 편이 좋을 것 같다.
|
||||||
$msg = new Message(
|
$msg = new Message(
|
||||||
Message::MSGTYPE_PRIVATE,
|
MessageType::private,
|
||||||
$src,
|
$src,
|
||||||
$dest,
|
$dest,
|
||||||
"{$this->auctionID}번 {$hostResName} 경매에 입찰이 없어 취소되었습니다.",
|
"{$this->auctionID}번 {$hostResName} 경매에 입찰이 없어 취소되었습니다.",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ use function \sammo\GetImageURL;
|
|||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
class che_몰수 extends Command\NationCommand
|
class che_몰수 extends Command\NationCommand
|
||||||
{
|
{
|
||||||
@@ -186,7 +187,7 @@ class che_몰수 extends Command\NationCommand
|
|||||||
GetImageURL($destGeneral->getVar('imgsvr'), $destGeneral->getVar('picture'))
|
GetImageURL($destGeneral->getVar('imgsvr'), $destGeneral->getVar('picture'))
|
||||||
);
|
);
|
||||||
$msg = new Message(
|
$msg = new Message(
|
||||||
Message::MSGTYPE_PUBLIC,
|
MessageType::public,
|
||||||
$src,
|
$src,
|
||||||
$src,
|
$src,
|
||||||
$text,
|
$text,
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ use function \sammo\getNationStaticInfo;
|
|||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
class che_불가침제의 extends Command\NationCommand
|
class che_불가침제의 extends Command\NationCommand
|
||||||
{
|
{
|
||||||
@@ -202,7 +203,7 @@ class che_불가침제의 extends Command\NationCommand
|
|||||||
$josaWa = JosaUtil::pick($nationName, '와');
|
$josaWa = JosaUtil::pick($nationName, '와');
|
||||||
|
|
||||||
$msg = new DiplomaticMessage(
|
$msg = new DiplomaticMessage(
|
||||||
Message::MSGTYPE_DIPLOMACY,
|
MessageType::diplomacy,
|
||||||
$src,
|
$src,
|
||||||
$dest,
|
$dest,
|
||||||
"{$nationName}{$josaWa} {$year}년 {$month}월까지 불가침 제의 서신",
|
"{$nationName}{$josaWa} {$year}년 {$month}월까지 불가침 제의 서신",
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ use function \sammo\GetImageURL;
|
|||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
class che_불가침파기제의 extends Command\NationCommand{
|
class che_불가침파기제의 extends Command\NationCommand{
|
||||||
static protected $actionName = '불가침 파기 제의';
|
static protected $actionName = '불가침 파기 제의';
|
||||||
@@ -150,7 +151,7 @@ class che_불가침파기제의 extends Command\NationCommand{
|
|||||||
$validUntil->add(new \DateInterval("PT{$validMinutes}M"));
|
$validUntil->add(new \DateInterval("PT{$validMinutes}M"));
|
||||||
|
|
||||||
$msg = new DiplomaticMessage(
|
$msg = new DiplomaticMessage(
|
||||||
Message::MSGTYPE_DIPLOMACY,
|
MessageType::diplomacy,
|
||||||
$src,
|
$src,
|
||||||
$dest,
|
$dest,
|
||||||
"{$nationName}의 불가침 파기 제의 서신",
|
"{$nationName}의 불가침 파기 제의 서신",
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ use function \sammo\GetImageURL;
|
|||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
class che_선전포고 extends Command\NationCommand
|
class che_선전포고 extends Command\NationCommand
|
||||||
{
|
{
|
||||||
@@ -175,7 +176,7 @@ class che_선전포고 extends Command\NationCommand
|
|||||||
$destNation['color']
|
$destNation['color']
|
||||||
);
|
);
|
||||||
$msg = new Message(
|
$msg = new Message(
|
||||||
Message::MSGTYPE_NATIONAL,
|
MessageType::national,
|
||||||
$src,
|
$src,
|
||||||
$dest,
|
$dest,
|
||||||
$text,
|
$text,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ use function \sammo\GetImageURL;
|
|||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
class che_종전제의 extends Command\NationCommand{
|
class che_종전제의 extends Command\NationCommand{
|
||||||
static protected $actionName = '종전 제의';
|
static protected $actionName = '종전 제의';
|
||||||
@@ -148,7 +149,7 @@ class che_종전제의 extends Command\NationCommand{
|
|||||||
$validUntil->add(new \DateInterval("PT{$validMinutes}M"));
|
$validUntil->add(new \DateInterval("PT{$validMinutes}M"));
|
||||||
|
|
||||||
$msg = new DiplomaticMessage(
|
$msg = new DiplomaticMessage(
|
||||||
Message::MSGTYPE_DIPLOMACY,
|
MessageType::diplomacy,
|
||||||
$src,
|
$src,
|
||||||
$dest,
|
$dest,
|
||||||
"{$nationName}의 종전 제의 서신",
|
"{$nationName}의 종전 제의 서신",
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
class DiplomaticMessage extends Message{
|
class DiplomaticMessage extends Message{
|
||||||
|
|
||||||
const ACCEPTED = 1;
|
const ACCEPTED = 1;
|
||||||
@@ -18,7 +20,7 @@ class DiplomaticMessage extends Message{
|
|||||||
protected $validDiplomacy = true;
|
protected $validDiplomacy = true;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $msgType,
|
MessageType $msgType,
|
||||||
MessageTarget $src,
|
MessageTarget $src,
|
||||||
MessageTarget $dest,
|
MessageTarget $dest,
|
||||||
string $msg,
|
string $msg,
|
||||||
@@ -27,7 +29,7 @@ class DiplomaticMessage extends Message{
|
|||||||
array $msgOption
|
array $msgOption
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ($msgType !== self::MSGTYPE_DIPLOMACY){
|
if ($msgType !== MessageType::diplomacy){
|
||||||
throw new \InvalidArgumentException('DiplomaticMessage msgType');
|
throw new \InvalidArgumentException('DiplomaticMessage msgType');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,7 +210,7 @@ class DiplomaticMessage extends Message{
|
|||||||
|
|
||||||
$josaYi = JosaUtil::pick($this->src->nationName, '이');
|
$josaYi = JosaUtil::pick($this->src->nationName, '이');
|
||||||
$newMsg = new Message(
|
$newMsg = new Message(
|
||||||
self::MSGTYPE_NATIONAL,
|
MessageType::national,
|
||||||
$this->dest,
|
$this->dest,
|
||||||
$this->src,
|
$this->src,
|
||||||
"【외교】{$year}년 {$month}월: {$this->src->nationName}{$josaYi} {$this->dest->nationName}에게 제안한 {$this->diplomacyDetail}",
|
"【외교】{$year}년 {$month}월: {$this->src->nationName}{$josaYi} {$this->dest->nationName}에게 제안한 {$this->diplomacyDetail}",
|
||||||
@@ -224,7 +226,7 @@ class DiplomaticMessage extends Message{
|
|||||||
$newMsg->send();
|
$newMsg->send();
|
||||||
|
|
||||||
$newMsg = new Message(
|
$newMsg = new Message(
|
||||||
self::MSGTYPE_DIPLOMACY,
|
MessageType::diplomacy,
|
||||||
$this->dest,
|
$this->dest,
|
||||||
$this->src,
|
$this->src,
|
||||||
"【외교】{$year}년 {$month}월: {$this->src->nationName}{$josaYi} {$this->dest->nationName}에게 제안한 {$this->diplomacyDetail}",
|
"【외교】{$year}년 {$month}월: {$this->src->nationName}{$josaYi} {$this->dest->nationName}에게 제안한 {$this->diplomacyDetail}",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use \sammo\Util;
|
|||||||
use \sammo\DB;
|
use \sammo\DB;
|
||||||
use sammo\DTO\BettingInfo;
|
use sammo\DTO\BettingInfo;
|
||||||
use sammo\DTO\SelectItem;
|
use sammo\DTO\SelectItem;
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
use sammo\Json;
|
use sammo\Json;
|
||||||
use sammo\KVStorage;
|
use sammo\KVStorage;
|
||||||
use sammo\Message;
|
use sammo\Message;
|
||||||
@@ -138,7 +139,7 @@ class OpenNationBetting extends \sammo\Event\Action
|
|||||||
GetImageURL($general['imgsvr'], $general['picture'])
|
GetImageURL($general['imgsvr'], $general['picture'])
|
||||||
);
|
);
|
||||||
$msg = new Message(
|
$msg = new Message(
|
||||||
Message::MSGTYPE_PRIVATE,
|
MessageType::private,
|
||||||
$src,
|
$src,
|
||||||
$dest,
|
$dest,
|
||||||
$text,
|
$text,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace sammo;
|
|||||||
|
|
||||||
use sammo\Command\GeneralCommand;
|
use sammo\Command\GeneralCommand;
|
||||||
use sammo\Command\NationCommand;
|
use sammo\Command\NationCommand;
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
use sammo\Enums\RankColumn;
|
use sammo\Enums\RankColumn;
|
||||||
use sammo\Scenario\NPC;
|
use sammo\Scenario\NPC;
|
||||||
|
|
||||||
@@ -3703,7 +3704,7 @@ class GeneralAI
|
|||||||
GetImageURL($general->getVar('imgsvr'), $general->getVar('picture'))
|
GetImageURL($general->getVar('imgsvr'), $general->getVar('picture'))
|
||||||
);
|
);
|
||||||
$msg = new Message(
|
$msg = new Message(
|
||||||
Message::MSGTYPE_PUBLIC,
|
MessageType::public,
|
||||||
$src,
|
$src,
|
||||||
$src,
|
$src,
|
||||||
$general->getVar('npcmsg'),
|
$general->getVar('npcmsg'),
|
||||||
|
|||||||
+36
-82
@@ -1,16 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
class Message
|
class Message
|
||||||
{
|
{
|
||||||
const MAILBOX_PUBLIC = 9999;
|
const MAILBOX_PUBLIC = 9999;
|
||||||
const MAILBOX_NATIONAL = 9000;
|
const MAILBOX_NATIONAL = 9000;
|
||||||
|
|
||||||
const MSGTYPE_PUBLIC = 'public';
|
|
||||||
const MSGTYPE_PRIVATE = 'private';
|
|
||||||
const MSGTYPE_NATIONAL = 'national';
|
|
||||||
const MSGTYPE_DIPLOMACY = 'diplomacy';
|
|
||||||
|
|
||||||
//기본 정보
|
//기본 정보
|
||||||
public $mailbox = null;
|
public $mailbox = null;
|
||||||
public $id = null;
|
public $id = null;
|
||||||
@@ -18,39 +15,15 @@ class Message
|
|||||||
|
|
||||||
protected $sendCnt = 0;
|
protected $sendCnt = 0;
|
||||||
|
|
||||||
public $msgType;
|
|
||||||
/** @var \sammo\MessageTarget */
|
|
||||||
public $src;
|
|
||||||
/** @var \sammo\MessageTarget */
|
|
||||||
public $dest;
|
|
||||||
public $msg;
|
|
||||||
/** @var \DateTime */
|
|
||||||
public $date;
|
|
||||||
/** @var \DateTime */
|
|
||||||
public $validUntil;
|
|
||||||
|
|
||||||
public $msgOption;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $msgType,
|
public MessageType $msgType,
|
||||||
MessageTarget $src,
|
public MessageTarget $src,
|
||||||
MessageTarget $dest,
|
public MessageTarget $dest,
|
||||||
string $msg,
|
public string $msg,
|
||||||
\DateTime $date,
|
public \DateTime $date,
|
||||||
\DateTime $validUntil,
|
public \DateTime $validUntil,
|
||||||
array $msgOption
|
public array $msgOption
|
||||||
) {
|
) {
|
||||||
if (!static::isValidMsgType($msgType)) {
|
|
||||||
throw new \InvalidArgumentException('올바르지 않은 msgType');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->msgType = $msgType;
|
|
||||||
$this->src = $src;
|
|
||||||
$this->dest = $dest;
|
|
||||||
$this->msg = $msg;
|
|
||||||
$this->date = $date;
|
|
||||||
$this->validUntil = $validUntil;
|
|
||||||
$this->msgOption = $msgOption;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSentInfo(int $mailbox, int $messageID) : self
|
public function setSentInfo(int $mailbox, int $messageID) : self
|
||||||
@@ -61,19 +34,19 @@ class Message
|
|||||||
|
|
||||||
do{
|
do{
|
||||||
if($mailbox === Message::MAILBOX_PUBLIC){
|
if($mailbox === Message::MAILBOX_PUBLIC){
|
||||||
if($this->msgType !== Message::MSGTYPE_PUBLIC){
|
if($this->msgType !== MessageType::public){
|
||||||
throw new \InvalidArgumentException('올바르지 않은 mailbox, msgType !== MSGTYPE_PUBLIC');
|
throw new \InvalidArgumentException('올바르지 않은 mailbox, msgType !== MessageType::public');
|
||||||
}
|
}
|
||||||
$this->isInboxMail = true;
|
$this->isInboxMail = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if($mailbox >= Message::MAILBOX_NATIONAL){
|
if($mailbox >= Message::MAILBOX_NATIONAL){
|
||||||
if($this->msgType === Message::MSGTYPE_DIPLOMACY){
|
if($this->msgType === MessageType::diplomacy){
|
||||||
$this->isInboxMail = true;
|
$this->isInboxMail = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ($this->msgType !== Message::MSGTYPE_NATIONAL) {
|
if ($this->msgType !== MessageType::national) {
|
||||||
throw new \InvalidArgumentException('올바르지 않은 mailbox, msgType not in (MSGTYPE_DIPLOMACY, MSGTYPE_NATIONAL)');
|
throw new \InvalidArgumentException('올바르지 않은 mailbox, msgType not in (MessageType::diplomacy, MessageType::national)');
|
||||||
}
|
}
|
||||||
if($this->dest->nationID + Message::MAILBOX_NATIONAL === $mailbox){
|
if($this->dest->nationID + Message::MAILBOX_NATIONAL === $mailbox){
|
||||||
$this->isInboxMail = true;
|
$this->isInboxMail = true;
|
||||||
@@ -85,7 +58,7 @@ class Message
|
|||||||
}
|
}
|
||||||
throw new \InvalidArgumentException('송신, 수신국 둘 중의 어느 메일함도 아닙니다');
|
throw new \InvalidArgumentException('송신, 수신국 둘 중의 어느 메일함도 아닙니다');
|
||||||
}
|
}
|
||||||
if($this->msgType !== Message::MSGTYPE_PRIVATE){
|
if($this->msgType !== MessageType::private){
|
||||||
throw new \InvalidArgumentException('올바르지 않은 mailbox, msgType !== MSGTYPE_PRIVATE');
|
throw new \InvalidArgumentException('올바르지 않은 mailbox, msgType !== MSGTYPE_PRIVATE');
|
||||||
}
|
}
|
||||||
if($this->dest->generalID === $mailbox){
|
if($this->dest->generalID === $mailbox){
|
||||||
@@ -105,11 +78,11 @@ class Message
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function toArray():array{
|
public function toArray():array{
|
||||||
if($this->msgType === Message::MSGTYPE_PUBLIC){
|
if($this->msgType === MessageType::public){
|
||||||
$src = $this->src->toArray();
|
$src = $this->src->toArray();
|
||||||
$dest = null;
|
$dest = null;
|
||||||
}
|
}
|
||||||
else if($this->msgType === Message::MSGTYPE_NATIONAL || $this->msgType === Message::MSGTYPE_DIPLOMACY){
|
else if($this->msgType === MessageType::national || $this->msgType === MessageType::diplomacy){
|
||||||
$src = $this->src->toArray();
|
$src = $this->src->toArray();
|
||||||
$dest = $this->dest->toArray();
|
$dest = $this->dest->toArray();
|
||||||
}
|
}
|
||||||
@@ -120,7 +93,7 @@ class Message
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'id'=>$this->id,
|
'id'=>$this->id,
|
||||||
'msgType'=>$this->msgType,
|
'msgType'=>$this->msgType->value,
|
||||||
'src'=>$src,
|
'src'=>$src,
|
||||||
'dest'=>$dest,
|
'dest'=>$dest,
|
||||||
'text'=>$this->msg,
|
'text'=>$this->msg,
|
||||||
@@ -133,7 +106,7 @@ class Message
|
|||||||
{
|
{
|
||||||
$dbMessage = Json::decode($row['message']);
|
$dbMessage = Json::decode($row['message']);
|
||||||
|
|
||||||
$msgType = $row['type'];
|
$msgType = MessageType::from($row['type']);
|
||||||
$src = MessageTarget::buildFromArray($dbMessage['src']);
|
$src = MessageTarget::buildFromArray($dbMessage['src']);
|
||||||
$dest = MessageTarget::buildFromArray($dbMessage['dest']);
|
$dest = MessageTarget::buildFromArray($dbMessage['dest']);
|
||||||
$option = Util::array_get($dbMessage['option'], []);
|
$option = Util::array_get($dbMessage['option'], []);
|
||||||
@@ -149,7 +122,7 @@ class Message
|
|||||||
];
|
];
|
||||||
|
|
||||||
$action = Util::array_get($option['action'], null);
|
$action = Util::array_get($option['action'], null);
|
||||||
if ($msgType === self::MSGTYPE_DIPLOMACY && $action !== null) {
|
if ($msgType === MessageType::diplomacy && $action !== null) {
|
||||||
$objMessage = new DiplomaticMessage(...$args);
|
$objMessage = new DiplomaticMessage(...$args);
|
||||||
} elseif ($action === 'scout') {
|
} elseif ($action === 'scout') {
|
||||||
$objMessage = new ScoutMessage(...$args);
|
$objMessage = new ScoutMessage(...$args);
|
||||||
@@ -164,7 +137,7 @@ class Message
|
|||||||
|
|
||||||
protected static function isValidMailBox(int $mailbox): bool
|
protected static function isValidMailBox(int $mailbox): bool
|
||||||
{
|
{
|
||||||
if ($mailbox > self::MAILBOX_PUBLIC) {
|
if ($mailbox > MessageType::public) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($mailbox <= 0) {
|
if ($mailbox <= 0) {
|
||||||
@@ -173,17 +146,6 @@ class Message
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function isValidMsgType(string $msgType): bool
|
|
||||||
{
|
|
||||||
switch ($msgType) {
|
|
||||||
case static::MSGTYPE_PUBLIC: return true;
|
|
||||||
case static::MSGTYPE_PRIVATE: return true;
|
|
||||||
case static::MSGTYPE_NATIONAL: return true;
|
|
||||||
case static::MSGTYPE_DIPLOMACY: return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getMessageByID(int $messageID) : ?Message
|
public static function getMessageByID(int $messageID) : ?Message
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
@@ -197,24 +159,20 @@ class Message
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $mailbox 메일 사서함.
|
* @param int $mailbox 메일 사서함.
|
||||||
* @param string $msgType 메일 타입. MSGTYPE 중 하나.
|
* @param MessageType $msgType 메일 타입.
|
||||||
* @param int $limit 가져오고자 하는 수. 0 이하의 값이면 모두.
|
* @param int $limit 가져오고자 하는 수. 0 이하의 값이면 모두.
|
||||||
* @param int $fromSeq 가져오고자 하는 위치. $fromSeq보다 '큰' seq만 가져온다. 따라서 0 이하이면 모두 가져옴.
|
* @param int $fromSeq 가져오고자 하는 위치. $fromSeq보다 '큰' seq만 가져온다. 따라서 0 이하이면 모두 가져옴.
|
||||||
* @return Message[]
|
* @return Message[]
|
||||||
*/
|
*/
|
||||||
public static function getMessagesFromMailBox(int $mailbox, string $msgType, int $limit=30, int $fromSeq = 0)
|
public static function getMessagesFromMailBox(int $mailbox, MessageType $msgType, int $limit=30, int $fromSeq = 0)
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
if (!static::isValidMsgType($msgType)) {
|
|
||||||
throw new \InvalidArgumentException('올바르지 않은 $msgType');
|
|
||||||
}
|
|
||||||
|
|
||||||
$date = (new \DateTime())->format('Y-m-d H:i:s');
|
$date = (new \DateTime())->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
$where = new \WhereClause('and');
|
$where = new \WhereClause('and');
|
||||||
$where->add('mailbox = %i', $mailbox);
|
$where->add('mailbox = %i', $mailbox);
|
||||||
$where->add('type = %s', $msgType);
|
$where->add('type = %s', $msgType->value);
|
||||||
$where->add('valid_until > %s', $date);
|
$where->add('valid_until > %s', $date);
|
||||||
if ($fromSeq > 0) {
|
if ($fromSeq > 0) {
|
||||||
$where->add('id >= %i', $fromSeq);
|
$where->add('id >= %i', $fromSeq);
|
||||||
@@ -233,24 +191,20 @@ class Message
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $mailbox 메일 사서함.
|
* @param int $mailbox 메일 사서함.
|
||||||
* @param string $msgType 메일 타입. MSGTYPE 중 하나.
|
* @param MessageType $msgType 메일 타입.
|
||||||
* @param int $toSeq 가져오고자 하는 위치. $toSeq보다 '작은' seq만 가져온다.
|
* @param int $toSeq 가져오고자 하는 위치. $toSeq보다 '작은' seq만 가져온다.
|
||||||
* @param int $limit 가져오고자 하는 수.
|
* @param int $limit 가져오고자 하는 수.
|
||||||
* @return Message[]
|
* @return Message[]
|
||||||
*/
|
*/
|
||||||
public static function getMessagesFromMailBoxOld(int $mailbox, string $msgType, int $toSeq, int $limit = 20)
|
public static function getMessagesFromMailBoxOld(int $mailbox, MessageType $msgType, int $toSeq, int $limit = 20)
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
if (!static::isValidMsgType($msgType)) {
|
|
||||||
throw new \InvalidArgumentException('올바르지 않은 $msgType');
|
|
||||||
}
|
|
||||||
|
|
||||||
$date = (new \DateTime())->format('Y-m-d H:i:s');
|
$date = (new \DateTime())->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
$where = new \WhereClause('and');
|
$where = new \WhereClause('and');
|
||||||
$where->add('mailbox = %i', $mailbox);
|
$where->add('mailbox = %i', $mailbox);
|
||||||
$where->add('type = %s', $msgType);
|
$where->add('type = %s', $msgType->value);
|
||||||
$where->add('valid_until > %s', $date);
|
$where->add('valid_until > %s', $date);
|
||||||
$where->add('id < %i', $toSeq);
|
$where->add('id < %i', $toSeq);
|
||||||
|
|
||||||
@@ -296,7 +250,7 @@ class Message
|
|||||||
'overwrite'=>[$msgObj->id]
|
'overwrite'=>[$msgObj->id]
|
||||||
];
|
];
|
||||||
|
|
||||||
if($msgObj->msgType == Message::MSGTYPE_PRIVATE || $msgObj->msgType == Message::MSGTYPE_NATIONAL){
|
if($msgObj->msgType === MessageType::private || $msgObj->msgType === MessageType::national){
|
||||||
$receiveID = $msgObj->msgOption['receiverMessageID']??null;
|
$receiveID = $msgObj->msgOption['receiverMessageID']??null;
|
||||||
if($receiveID !== null){
|
if($receiveID !== null){
|
||||||
$msgObj2 = static::getMessageByID($receiveID);
|
$msgObj2 = static::getMessageByID($receiveID);
|
||||||
@@ -345,7 +299,7 @@ class Message
|
|||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$db->insert('message', [
|
$db->insert('message', [
|
||||||
'mailbox' => $mailbox,
|
'mailbox' => $mailbox,
|
||||||
'type' => $this->msgType,
|
'type' => $this->msgType->value,
|
||||||
'src' => $src_id,
|
'src' => $src_id,
|
||||||
'dest' => $dest_id,
|
'dest' => $dest_id,
|
||||||
'time' => $this->date->format('Y-m-d H:i:s'),
|
'time' => $this->date->format('Y-m-d H:i:s'),
|
||||||
@@ -364,13 +318,13 @@ class Message
|
|||||||
if($this->sendCnt > 1){
|
if($this->sendCnt > 1){
|
||||||
throw new \RuntimeException('이미 전송한 메일입니다.');
|
throw new \RuntimeException('이미 전송한 메일입니다.');
|
||||||
}
|
}
|
||||||
if($this->msgType === self::MSGTYPE_PRIVATE && $this->src->generalID !== $this->dest->generalID){
|
if($this->msgType === MessageType::private && $this->src->generalID !== $this->dest->generalID){
|
||||||
return $this->sendRaw($this->src->generalID);
|
return $this->sendRaw($this->src->generalID);
|
||||||
}
|
}
|
||||||
if($this->msgType === self::MSGTYPE_NATIONAL && $this->src->nationID !== $this->dest->nationID){
|
if($this->msgType === MessageType::national && $this->src->nationID !== $this->dest->nationID){
|
||||||
return $this->sendRaw($this->src->nationID + self::MAILBOX_NATIONAL);
|
return $this->sendRaw($this->src->nationID + self::MAILBOX_NATIONAL);
|
||||||
}
|
}
|
||||||
if($this->msgType === self::MSGTYPE_DIPLOMACY){
|
if($this->msgType === MessageType::diplomacy){
|
||||||
if(key_exists('action', $this->msgOption)){
|
if(key_exists('action', $this->msgOption)){
|
||||||
$tmp = $this->msgOption;
|
$tmp = $this->msgOption;
|
||||||
$this->msgOption = null;
|
$this->msgOption = null;
|
||||||
@@ -391,7 +345,7 @@ class Message
|
|||||||
throw new \RuntimeException('이미 전송한 메일입니다.');
|
throw new \RuntimeException('이미 전송한 메일입니다.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->msgType === self::MSGTYPE_PRIVATE){
|
if($this->msgType === MessageType::private){
|
||||||
if(!($this->msgOption['silence']??false)){
|
if(!($this->msgOption['silence']??false)){
|
||||||
//XXX: 알림을 이런식으로 보내는게 맞는가에 대한 의문 있음
|
//XXX: 알림을 이런식으로 보내는게 맞는가에 대한 의문 있음
|
||||||
DB::db()->update('general', [
|
DB::db()->update('general', [
|
||||||
@@ -401,11 +355,11 @@ class Message
|
|||||||
return $this->sendRaw($this->dest->generalID);
|
return $this->sendRaw($this->dest->generalID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->msgType === self::MSGTYPE_NATIONAL){
|
if($this->msgType === MessageType::national){
|
||||||
return $this->sendRaw($this->dest->nationID + self::MAILBOX_NATIONAL);
|
return $this->sendRaw($this->dest->nationID + self::MAILBOX_NATIONAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->msgType === self::MSGTYPE_DIPLOMACY){
|
if($this->msgType === MessageType::diplomacy){
|
||||||
if(!($this->msgOption['silence']??false)){
|
if(!($this->msgOption['silence']??false)){
|
||||||
//XXX: 알림을 이런식으로 보내는게 맞는가에 대한 의문 있음
|
//XXX: 알림을 이런식으로 보내는게 맞는가에 대한 의문 있음
|
||||||
DB::db()->update('general', [
|
DB::db()->update('general', [
|
||||||
@@ -415,7 +369,7 @@ class Message
|
|||||||
return $this->sendRaw($this->dest->nationID + self::MAILBOX_NATIONAL);
|
return $this->sendRaw($this->dest->nationID + self::MAILBOX_NATIONAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->msgType === self::MSGTYPE_PUBLIC){
|
if($this->msgType === MessageType::public){
|
||||||
return $this->sendRaw(self::MAILBOX_PUBLIC);
|
return $this->sendRaw(self::MAILBOX_PUBLIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\MessageType;
|
||||||
|
|
||||||
class ScoutMessage extends Message{
|
class ScoutMessage extends Message{
|
||||||
|
|
||||||
const ACCEPTED = 1;
|
const ACCEPTED = 1;
|
||||||
@@ -9,7 +11,7 @@ class ScoutMessage extends Message{
|
|||||||
protected $validScout = true;
|
protected $validScout = true;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $msgType,
|
MessageType $msgType,
|
||||||
MessageTarget $src,
|
MessageTarget $src,
|
||||||
MessageTarget $dest,
|
MessageTarget $dest,
|
||||||
string $msg,
|
string $msg,
|
||||||
@@ -18,7 +20,7 @@ class ScoutMessage extends Message{
|
|||||||
array $msgOption
|
array $msgOption
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ($msgType !== self::MSGTYPE_PRIVATE){
|
if ($msgType !== MessageType::private){
|
||||||
throw new \InvalidArgumentException('DiplomaticMessage msgType');
|
throw new \InvalidArgumentException('DiplomaticMessage msgType');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +100,7 @@ class ScoutMessage extends Message{
|
|||||||
|
|
||||||
$josaRo = JosaUtil::pick($this->src->nationName, '로');
|
$josaRo = JosaUtil::pick($this->src->nationName, '로');
|
||||||
$newMsg = new Message(
|
$newMsg = new Message(
|
||||||
self::MSGTYPE_PRIVATE,
|
MessageType::private,
|
||||||
$this->src,
|
$this->src,
|
||||||
$this->dest,
|
$this->dest,
|
||||||
"{$this->src->nationName}{$josaRo} 등용 제의 수락",
|
"{$this->src->nationName}{$josaRo} 등용 제의 수락",
|
||||||
@@ -120,7 +122,7 @@ class ScoutMessage extends Message{
|
|||||||
|
|
||||||
$josaRo = JosaUtil::pick($this->src->nationName, '로');
|
$josaRo = JosaUtil::pick($this->src->nationName, '로');
|
||||||
$newMsg = new Message(
|
$newMsg = new Message(
|
||||||
self::MSGTYPE_PRIVATE,
|
MessageType::private,
|
||||||
$this->src,
|
$this->src,
|
||||||
$this->dest,
|
$this->dest,
|
||||||
"{$this->src->nationName}{$josaRo} 등용 제의 거부",
|
"{$this->src->nationName}{$josaRo} 등용 제의 거부",
|
||||||
@@ -223,6 +225,6 @@ class ScoutMessage extends Message{
|
|||||||
'action'=>'scout'
|
'action'=>'scout'
|
||||||
];
|
];
|
||||||
|
|
||||||
return new ScoutMessage(Message::MSGTYPE_PRIVATE, $src, $dest, $msg, $date, $validUntil, $msgOption);
|
return new ScoutMessage(MessageType::private, $src, $dest, $msg, $date, $validUntil, $msgOption);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user