From 7ef3f0d5c52742a6f76e4b907a9686f0683bd31f Mon Sep 17 00:00:00 2001 From: hide_d Date: Tue, 17 Apr 2018 01:54:57 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=84=EC=8B=9C=EB=A1=9C=20=EC=99=B8?= =?UTF-8?q?=EA=B5=90=20=EC=84=9C=EC=8B=A0=20=EB=B0=9B=EB=8A=94=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/j_msg_decide_opt.php | 89 ++++------------------------------------ 1 file changed, 9 insertions(+), 80 deletions(-) diff --git a/hwe/j_msg_decide_opt.php b/hwe/j_msg_decide_opt.php index c22deca0..466159de 100644 --- a/hwe/j_msg_decide_opt.php +++ b/hwe/j_msg_decide_opt.php @@ -29,13 +29,6 @@ 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([ @@ -44,87 +37,23 @@ if(!$general){ ]); } -list($result, $messageInfo) = getSingleMessage($msgID); - -if (!$result) { +$msg = Message::getMessageByID($msgID); +if($msg === null){ Json::die([ 'result'=>false, - 'reason'=>$messageInfo + 'reason'=>'올바르지 않은 메시지' ]); } -'@phan-var-force mixed[] $messageInfo'; - -$msgType = $messageInfo['type']; - -$validUntil = $messageInfo['valid_until']; -$date = date('Y-m-d H:i:s'); -if ($validUntil < $date) { - Json::die([ - 'result'=>false, - 'reason'=>'만료된 메시지' - ]); +if($msgResponse){ + $result = $msg->agreeMessage($general['no']); } - -$msgOption = Json::decode(Util::array_get($messageInfo['option'], '{}')); -$msgAction = Util::array_get($msgOption['action'], null); -$messageInfo['option'] = $msgOption; - -$msgSrc = Json::decode($messageInfo['src']); -$messageInfo['src'] = $msgSrc; -$msgDest = Json::decode($messageInfo['dest']); -$messageInfo['dest'] = $msgDest; - -if (!$msgAction) { - Json::die([ - 'result'=>false, - 'reason'=>'응답 대상 메시지 아님' - ]); -} - -if ($msgType == 'diplomacy' && $msgSrc['nation_id'] != $msgDest['nation_id']) { - //여기로 올일이 있나? - Json::die([ - 'result'=>false, - 'reason'=>'(버그) 외교 대상 동일' - ]); -} - -if($msgType == 'diplomacy'){ - if($general['level'] < 6){ - Json::die([ - 'result'=>false, - 'reason'=>'외교 권한 없음' - ]); - } - - if($general['nation'] != $msgDest['nation_id']){ - Json::die([ - 'result'=>false, - 'reason'=>'올바르지 않은 소속 국가' - ]); - } -} - -switch ($msgAction) { -case 'scout': - //TODO: 등용장 받음. 함수 호출 - $result = acceptScout($messageInfo, $general, $msgResponse); - break; -case 'ally': - $result = acceptAlly($messageInfo, $general, $msgResponse); - break; - //TODO:기타 등등 -case '': - Json::die([]); - break; -default: - //구현이 정상적으로 된 경우 이쪽으로 오지 않음 - $result = [false, '처리 대상 아님']; +else{ + $result = $msg->declineMessage($general['no']); } Json::die([ - 'result' => $result[0], - 'reason' => $result[1] + 'result' => $result===DiplomaticMessage::ACCEPTED, + 'reason' => 'result' ]); \ No newline at end of file