From 9b79d12521be10390295380262b780e44fe656e8 Mon Sep 17 00:00:00 2001 From: hide_d Date: Mon, 16 Apr 2018 23:29:17 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=AC=EC=95=BC=EC=97=90=EC=84=9C=EB=8A=94?= =?UTF-8?q?=20=EA=B5=AD=EB=A9=94=EA=B0=80=20=EC=95=88=EB=B3=B4=EB=82=B4?= =?UTF-8?q?=EC=A7=80=EB=8D=98=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EC=9D=BC=EB=B0=98=EC=9E=A5=EC=9D=B4=20=EA=B5=AD=EB=A9=94?= =?UTF-8?q?=EB=A5=BC=20=EB=B3=B4=EB=82=BC=20=EC=88=98=20=EC=97=86=EB=8D=98?= =?UTF-8?q?=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95=20=EC=99=B8=EA=B5=90?= =?UTF-8?q?=20=EC=84=9C=EC=8B=A0=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func.php | 9 - hwe/func_diplomacy.php | 224 ------------------ hwe/func_message.php | 127 ---------- hwe/j_msg_get_recent.php | 2 +- hwe/j_msg_submit.php | 2 +- ...acticMessage.php => DiplomaticMessage.php} | 2 +- hwe/sammo/Engine/Diplomacy.php | 90 +++---- hwe/sammo/Message.php | 12 +- 8 files changed, 54 insertions(+), 414 deletions(-) delete mode 100644 hwe/func_diplomacy.php rename hwe/sammo/{DiplomacticMessage.php => DiplomaticMessage.php} (99%) diff --git a/hwe/func.php b/hwe/func.php index e4190542..65c6d9d5 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -18,7 +18,6 @@ require_once 'func_time_event.php'; require_once('func_template.php'); require_once('func_message.php'); require_once('func_map.php'); -require_once('func_diplomacy.php'); require_once('func_command.php'); /** @@ -1721,14 +1720,6 @@ function checkTurn() { $query = "update game set turntime='$date'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - // 3턴 전 시간 - $letterdate = subTurn($date, $admin['turnterm'], 3); - //기한 지난 외교 메세지 지움(3개월 유지) - //if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', '.__LINE__); - for($i=0; $i < 5; $i++) { - $query = "update nation set dip{$i}='',dip{$i}_who='0',dip{$i}_type='0',dip{$i}_when='' where dip{$i}_when < '$letterdate'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - } // 부상 과도 제한 $query = "update general set injury='80' where injury>'80'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); diff --git a/hwe/func_diplomacy.php b/hwe/func_diplomacy.php deleted file mode 100644 index 700e8951..00000000 --- a/hwe/func_diplomacy.php +++ /dev/null @@ -1,224 +0,0 @@ -queryFirstRow('SELECT `level`, `scout` FROM `nation` WHERE `nation` = %i', $nationID); - - $realNationID = $srcGeneral['nation']; - - - - if($general['level'] == 12) { - return [false, "군주입니다."]; - } - if(!$srcNation || $srcNation['level'] == 0) { - return [false, "없는 국가이거나 방랑군입니다."]; - } - if($realNationID != $nationID){ - return [false, "권유자의 소속이 바뀌었습니다."]; - } - if($srcNation['scout'] != 0) { - return [false, "임관 금지중입니다."]; - } - if($year < $startyear+3) { - return [false, "초반 제한중입니다."]; - } - if(strpos($general['nations'], ",{$nationID},") > 0) { - return [false, "이미 임관했었던 국가입니다."]; - } - - return [true, null]; - -} - -function acceptScout($messageInfo, $general, $msgResponse){ - $me = $general; - $you = DB::db()->queryFirstRow('SELECT `no`, `name`, `nation` FROM `general` WHERE `no` = %i', $messageInfo['src']['id']); - - list($startyear, $year, $month, $killturn) = Util::convertDictToArray(DB::db()->queryFirstRow('SELECT `startyear`, `year`, `month`, `killturn` FROM `game` LIMIT 1'), ['startyear', 'year', 'month', `killturn`]); - - list($avaliableScout, $reason) = checkScoutAvailable($messageInfo, $general, $you, $startyear, $year); - - if(!$msgResponse || !$avaliableScout){ - return declineScout($messageInfo, $reason); - } - - $nation = getNationStaticInfo($messageInfo['src']['nationID']); - $generalID = $me['no']; - $nationID = $nation['nation']; - $nationName = $nation['name']; - $myName = $me['name']; - - $mylog = []; - $youlog = []; - $alllog = []; - - $youlog[] = "{$myName} 등용에 성공했습니다."; - $alllog[] = "●{$month}월:{$myName}(이)가 {$nationName}(으)로 망명하였습니다."; - $mylog[] = "{$nationName}(으)로 망명하여 수도로 이동합니다."; - pushGeneralHistory($you, "●{$year}년 {$month}월:{$myName} 등용에 성공"); - pushGeneralHistory($me, "●{$year}년 {$month}월:{$nationName}(으)로 망명"); - - $me['nations'] .= "{$nationID},"; - - $updateMe = [ - 'belong'=>1, - 'nation'=>$nationID, - 'level'=>1, - 'city'=>$nation['capital'], - 'troop'=>0 - ]; - - - //처리가 조금 다름. - - $db = DB::db(); - - - if($me['level'] > 0){ - $updateOldNation = [ - 'totaltech' => $db->sqleval('`tech`*greatest(10, `gennum`-1)'), - 'gennum' => $db->sqleval('greatest(10, `gennum`-1)') - ]; - - if($me['gold'] > 1000){ - $updateOldNation['gold'] = $db->sqleval('`gold` + %i', $me['gold'] - 1000); - $updateMe['gold'] = 1000; - } - if($me['rice'] > 1000){ - $updateOldNation['rice'] = $db->sqleval('`rice` + %i', $me['rice'] - 1000); - $updateMe['rice'] = 1000; - } - - $updateMe['betray'] = $db->sqleval('`betray` + 1'); - $updateMe['dedication'] = $db->sqleval('dedication*(1-0.1*betray)'); - $updateMe['experience'] = $db->sqleval('experience*(1-0.1*betray)'); - - $db->update('nation', $updateOldNation, 'nation = %i', $messageInfo['dest']['nationID']); - } - else{ - $updateMe['dedication'] = $db->sqleval('dedication + 100'); - $updateMe['experience'] = $db->sqleval('experience + 100'); - } - - if($me['npc'] < 2){ - $updateMe['killturn'] = $killturn; - } - - $db->update('general', $updateMe, 'no = %i', $generalID); - - $db->query('UPDATE nation set '. - 'gennum = greatest(10, (SELECT count(`id`) from general where `nation` = %i_nation)), '. - 'totaltech = tech * greatest(10, (SELECT count(`id`) from general where `nation` = %i_nation)) '. - 'where nation=%i_nation', ['nation'=>$nationID]); - - //태수 군사 시중 해제 - switch($me['level']) { - case 4: - $db->query('update city set gen1=0 where gen1=%i', $generalID); - break; - case 3: - $db->query('update city set gen3=0 where gen2=%i', $generalID); - break; - case 2: - $db->query('update city set gen3=0 where gen2=%i', $generalID); - break; - } - - $db->query('UPDATE general left join troop on troop.troop = general.troop set general.troop = 0 where troop.no = %i', $generalID); - $db->query('delete from troop where no = %i', $generalID); - - $db->query('UPDATE `message` SET `valid_until`=\'1234-11-22 11:22:33\' WHERE `id` = %i', $messageInfo['id']); - $msg = "{$nationName}(으)로 등용 제의 수락"; - sendRawMessage('private', false, $general['no'], $messageInfo['src'], $messageInfo['dest'], $msg, null, null, ['parent'=>$messageInfo['id']]); - - pushGenLog($me, $mylog); - pushGenLog($you, $youlog); - pushGeneralPublicRecord($alllog, $year, $month); - pushWorldHistory($alllog, $year, $month); - - return [true, 'success']; -} - -function declineScout($messageInfo, $reason=null){ - $me = [ - 'no'=>$messageInfo['dest']['id'], - 'name'=>$messageInfo['dest']['name'] - ]; - $you = ['no'=>$messageInfo['src']['id']]; - - $nation = getNationStaticInfo($messageInfo['src']['nationID']); - $generalID = $me['no']; - $nationID = $nation['nation']; - $nationName = $nation['name']; - $myName = $me['name']; - - $mylog = []; - $youlog = []; - - - $nationName = $messageInfo['src']['nation']; - if($reason){ - $mylog[] = "●{$reason} 등용 수락 불가."; - $msg = "{$nationName}(으)로 등용 제의 수락 불가"; - } - else{ - $youlog[] = "{$me['name']}(이)가 등용을 거부했습니다."; - $mylog[] = "{$nationName}(으)로 망명을 거부했습니다."; - $msg = "{$nationName}(으)로 등용 제의 거부"; - } - - $db = DB::db(); - $db->query('UPDATE `message` SET `valid_until`=\'1234-11-22 11:22:33\' WHERE `id` = %i', $messageInfo['id']); - - sendRawMessage('private', false, $you['no'], $messageInfo['src'], $messageInfo['dest'], $msg, null, null, ['parent'=>$messageInfo['id']]); - - pushGenLog($me, $mylog); - pushGenLog($you, $youlog); - - return [true, 'success']; -} - -function acceptAlly($messageInfo, $general, $msgResponse){ - return [false, 'NYI']; -} - -function declineAlly($messageInfo, $general, $msgResponse){ - -} - -function acceptBreakAlly($messageInfo, $general, $msgResponse){ - -} - -function declineBreakAlly($messageInfo, $general, $msgResponse){ - -} - -function acceptStopWar($messageInfo, $general, $msgResponse){ - -} - -function declineStopWar($messageInfo, $general, $msgResponse){ - -} - - -function acceptMergeNations($messageInfo, $general, $msgResponse){ - -} - -function declineMergeNations($messageInfo, $general, $msgResponse){ - -} - - -function acceptSurrender($messageInfo, $general, $msgResponse){ - -} - -function declineSurrender($messageInfo, $general, $msgResponse){ - -} \ No newline at end of file diff --git a/hwe/func_message.php b/hwe/func_message.php index ba178c9e..3f512278 100644 --- a/hwe/func_message.php +++ b/hwe/func_message.php @@ -48,58 +48,6 @@ function getMailboxList(){ //Legacy -// type : xx,xx(불가침기간,타입) -// who : xxxx,xxxx(발신인, 수신인) -function DecodeMsg($msg, $type, $who, $date, $bg, $num=0) { - $db = DB::db(); - $connect=$db->get(); - $userID = Session::getUserID(); - - //FIXME: 폐기 - $query = "select no,nation,name,picture,level from general where owner='{$userID}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $me = MYDB_fetch_array($result); - - // 1 : 전메, 2 : 아국->타국, 3 : 타국->아국 - // 4 : 합병, 5 : 통합, 6 : 불가침, 7 : 종전, 8 : 파기 - // 9 : 자신->타인, 10 : 타인 -> 자신, 11 : 등용 - $category = $type % 100; - $term = intdiv($type, 100); - $from = intdiv($who, 10000); - $to = $who % 10000; - - $query = "select name,picture,imgsvr,nation from general where no='$from'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $sndr = MYDB_fetch_array($result); - - $sndrnation = getNationStaticInfo($sndr['nation']); - - switch($bg) { - case 2: - case 4: $bgcolor = "#CC6600"; break; - } - - if($category == 6) { - $query = "select reserved from diplomacy where me='{$sndr['nation']}' and you='{$me['nation']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $dip = MYDB_fetch_array($result); - - ShowMsg($bgcolor, $category, $sndr['picture'], $sndr['imgsvr'], "{$sndr['name']}:{$sndrnation['name']}▶", $sndrnation['color'], $sndr['name'], $sndrnation['color'], $msg, $date, $num, $from, $term, $me['level'], $dip['reserved']); - } elseif($category <= 8) { - $rcvrnation = getNationStaticInfo($to); - - ShowMsg($bgcolor, $category, $sndr['picture'], $sndr['imgsvr'], "{$sndr['name']}:{$sndrnation['name']}▶", $sndrnation['color'], $rcvrnation['name'], $rcvrnation['color'], $msg, $date, $num, $from, $term, $me['level']); - } elseif($category <= 11) { - $query = "select name,picture,nation from general where no='$to'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $rcvr = MYDB_fetch_array($result); - - $rcvrnation = getNationStaticInfo($rcvr['nation']); - ShowMsg($bgcolor, $category, $sndr['picture'], $sndr['imgsvr'], "{$sndr['name']}:{$sndrnation['name']}▶", $sndrnation['color'], "{$rcvr['name']}:{$rcvrnation['name']}", $rcvrnation['color'], $msg, $date, $num, $from, $term); - } -} - - function moveMsg($table, $msgtype, $msgnum, $msg, $type, $who, $when, $column, $value) { $db = DB::db(); $connect=$db->get(); @@ -108,78 +56,3 @@ function moveMsg($table, $msgtype, $msgnum, $msg, $type, $who, $when, $column, $ $query = "update {$table} set {$msgtype}{$msgnum}='$msg',{$msgtype}{$msgnum}_type='$type',{$msgtype}{$msgnum}_who='$who',{$msgtype}{$msgnum}_when='$when' where {$column}='$value'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); } - -function MsgDip($bg) { - $db = DB::db(); - $connect=$db->get(); - $userID = Session::getUserID(); - - $query = "select no,nation from general where owner='{$userID}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $me = MYDB_fetch_array($result); - - $query = "select dip0,dip1,dip2,dip3,dip4,dip0_who,dip1_who,dip2_who,dip3_who,dip4_who,dip0_when,dip1_when,dip2_when,dip3_when,dip4_when,dip0_type,dip1_type,dip2_type,dip3_type,dip4_type from nation where nation='{$me['nation']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $nation = MYDB_fetch_array($result); - - if($nation['dip0']) { echo "\n"; DecodeMsg($nation['dip0'], $nation['dip0_type'], $nation['dip0_who'], $nation['dip0_when'], $bg, 0); } - if($nation['dip1']) { echo "\n"; DecodeMsg($nation['dip1'], $nation['dip1_type'], $nation['dip1_who'], $nation['dip1_when'], $bg, 1); } - if($nation['dip2']) { echo "\n"; DecodeMsg($nation['dip2'], $nation['dip2_type'], $nation['dip2_who'], $nation['dip2_when'], $bg, 2); } - if($nation['dip3']) { echo "\n"; DecodeMsg($nation['dip3'], $nation['dip3_type'], $nation['dip3_who'], $nation['dip3_when'], $bg, 3); } - if($nation['dip4']) { echo "\n"; DecodeMsg($nation['dip4'], $nation['dip4_type'], $nation['dip4_who'], $nation['dip4_when'], $bg, 4); } -} - -function ShowMsg($bgcolor, $type, $picture, $imgsvr, $me, $mycolor, $you, $youcolor, $msg, $date, $num=0, $who=0, $when=0, $level=0, $note="") { - if($msg == "") return; - - $msg = Tag2Code($msg); - - $site = ""; $form = ""; $form2 = ""; - if($type == 11 || ($type >= 4 && $type <= 8 && $level >= 5)) { - $corebutton = " "; - } else { - $corebutton = " 【수락】【거절】"; - } - if($type == 6) { - $corebutton .= "
비고: {$note}"; - } - switch($type) { - case 1: $sign = ""; $corebutton = ""; break; - case 2: $sign = ""; $corebutton = ""; break; - case 3: $sign = ""; $corebutton = ""; break; - case 4: $sign = ""; $site = "d_surrender.php"; break; - case 5: $sign = ""; $site = "d_merge.php"; break; - case 6: $sign = ""; $site = "d_ally.php"; break; - case 7: $sign = ""; $site = "d_cease.php"; break; - case 8: $sign = ""; $site = "d_cancel.php"; break; - case 9: $sign = ""; $corebutton = ""; break; - case 10: $sign = ""; $corebutton = ""; break; - case 11: $sign = ""; $site = "d_scout.php"; break; - } - $imageTemp = GetImageURL($imgsvr); - $naming = "[$me{$sign}$you]"; - $picture = ""; - if($site != "") { - $form = "
"; - $form2 = "
"; - } - if($num >= 0) { $num = ""; } - else { $num = ""; } - if($who > 0) { $who = ""; } - else { $who = ""; } - if($when > 0) { $when = ""; } - else { $when = ""; } - echo " - - - - $form - - $num - $who - $when - $form2 - -
$picture$naming<$date>
{$msg}{$corebutton}
- "; -} diff --git a/hwe/j_msg_get_recent.php b/hwe/j_msg_get_recent.php index 0d097207..ceb85cf5 100644 --- a/hwe/j_msg_get_recent.php +++ b/hwe/j_msg_get_recent.php @@ -20,7 +20,7 @@ list($generalID, $nationID) = DB::db()->queryFirstList( if($nationID === null){ Json::die([ 'result'=>false, - 'reason'=>'소속 국가가 없습니다' + 'reason'=>'장수가 사망했습니다.' ]); } diff --git a/hwe/j_msg_submit.php b/hwe/j_msg_submit.php index 81853731..f5e2a066 100644 --- a/hwe/j_msg_submit.php +++ b/hwe/j_msg_submit.php @@ -100,7 +100,7 @@ if($mailbox == Message::MAILBOX_PUBLIC) { if($mailbox >= Message::MAILBOX_NATIONAL) { if($me['level'] < 5){ - $destNationID = $me['nation_id']; + $destNationID = $me['nation']; } else{ $destNationID = $mailbox - Message::MAILBOX_NATIONAL; diff --git a/hwe/sammo/DiplomacticMessage.php b/hwe/sammo/DiplomaticMessage.php similarity index 99% rename from hwe/sammo/DiplomacticMessage.php rename to hwe/sammo/DiplomaticMessage.php index 774628a9..3bce0a74 100644 --- a/hwe/sammo/DiplomacticMessage.php +++ b/hwe/sammo/DiplomaticMessage.php @@ -1,7 +1,7 @@ srcNation['level'] == 0 || $this->destNation['level'] == 0){ - return [DiplomacticMessage::DECLINED, '방랑군과 외교룰 수행할 수 없습니다.']; + return [DiplomaticMessage::DECLINED, '방랑군과 외교룰 수행할 수 없습니다.']; } return $prev; } - protected function checkNotWar(array $prev = [DiplomacticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomacticMessage::ACCEPTED){ + protected function checkNotWar(array $prev = [DiplomaticMessage::ACCEPTED, '']){ + if($prev[0] !== DiplomaticMessage::ACCEPTED){ return $prev; } if($this->srcToDestDiplomacy['state'] == 0 || $this->srcToDestDiplomacy['state'] == 0 ||$this->destToSrcDiplomacy['state'] == 1 || $this->destToSrcDiplomacy['state'] == 1){ - return [DiplomacticMessage::DECLINED, '상대국과 선포, 전쟁 중입니다.']; + return [DiplomaticMessage::DECLINED, '상대국과 선포, 전쟁 중입니다.']; } return $prev; } - protected function checkNonAggressionTreaty(array $prev = [DiplomacticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomacticMessage::ACCEPTED){ + protected function checkNonAggressionTreaty(array $prev = [DiplomaticMessage::ACCEPTED, '']){ + if($prev[0] !== DiplomaticMessage::ACCEPTED){ return $prev; } if($this->srcToDestDiplomacy['state'] !== 7 || $this->destToSrcDiplomacy['state'] !== 7){ - return [DiplomacticMessage::DECLINED, '상대국과 불가침 중이 아닙니다.']; + return [DiplomaticMessage::DECLINED, '상대국과 불가침 중이 아닙니다.']; } return $prev; } - protected function checkInWar(array $prev = [DiplomacticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomacticMessage::ACCEPTED){ + protected function checkInWar(array $prev = [DiplomaticMessage::ACCEPTED, '']){ + if($prev[0] !== DiplomaticMessage::ACCEPTED){ return $prev; } @@ -124,64 +124,64 @@ class Diplomacy{ return $prev; } - return [DiplomacticMessage::DECLINED, '상대국과 선포, 전쟁 중이 아닙니다.']; + return [DiplomaticMessage::DECLINED, '상대국과 선포, 전쟁 중이 아닙니다.']; } - protected function checkDiplomacyLimit(array $prev = [DiplomacticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomacticMessage::ACCEPTED){ + protected function checkDiplomacyLimit(array $prev = [DiplomaticMessage::ACCEPTED, '']){ + if($prev[0] !== DiplomaticMessage::ACCEPTED){ return $prev; } if($this->destNation['surlimit'] > 0){ - return [DiplomacticMessage::DECLINED, '본국의 외교 기한이 남아있습니다.']; + return [DiplomaticMessage::DECLINED, '본국의 외교 기한이 남아있습니다.']; } if($this->srcNation['surlimit'] > 0){ - return [DiplomacticMessage::DECLINED, '상대국의 외교 기한이 남아있습니다.']; + return [DiplomaticMessage::DECLINED, '상대국의 외교 기한이 남아있습니다.']; } return $prev; } - protected function checkStrictlyAdjacent(array $prev = [DiplomacticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomacticMessage::ACCEPTED){ + protected function checkStrictlyAdjacent(array $prev = [DiplomaticMessage::ACCEPTED, '']){ + if($prev[0] !== DiplomaticMessage::ACCEPTED){ return $prev; } if(!\sammo\isClose($this->srcNation['nation'], $this->destNation['nation'], false)){ - return [DiplomacticMessage::DECLINED, '상대국의 도시들과 보급선이 이어지지 않았습니다.']; + return [DiplomaticMessage::DECLINED, '상대국의 도시들과 보급선이 이어지지 않았습니다.']; } return $prev; } - protected function checkAdjacent(array $prev = [DiplomacticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomacticMessage::ACCEPTED){ + protected function checkAdjacent(array $prev = [DiplomaticMessage::ACCEPTED, '']){ + if($prev[0] !== DiplomaticMessage::ACCEPTED){ return $prev; } if(!\sammo\isClose($this->srcNation['nation'], $this->destNation['nation'], true)){ - return [DiplomacticMessage::DECLINED, '상대국의 도시와 인접하지 않았습니다.']; + return [DiplomaticMessage::DECLINED, '상대국의 도시와 인접하지 않았습니다.']; } return $prev; } - protected function checkAlreadyMerging(array $prev = [DiplomacticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomacticMessage::ACCEPTED){ + protected function checkAlreadyMerging(array $prev = [DiplomaticMessage::ACCEPTED, '']){ + if($prev[0] !== DiplomaticMessage::ACCEPTED){ return $prev; } if((3 <= $this->srcToDestDiplomacy['state'] && $this->srcToDestDiplomacy['state'] <= 6) ||(3 <= $this->destToSrcDiplomacy['state'] && $this->destToSrcDiplomacy['state'] <= 6)){ - return [DiplomacticMessage::DECLINED, '상대국과 합병 중입니다.']; + return [DiplomaticMessage::DECLINED, '상대국과 합병 중입니다.']; } return $prev; } - protected function checkSrcNationHasNeutralDiplomacy(array $prev = [DiplomacticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomacticMessage::ACCEPTED){ + protected function checkSrcNationHasNeutralDiplomacy(array $prev = [DiplomaticMessage::ACCEPTED, '']){ + if($prev[0] !== DiplomaticMessage::ACCEPTED){ return $prev; } @@ -195,18 +195,18 @@ class Diplomacy{ foreach($states as $state){ if($state == 0 || $state == 1){ - return [DiplomacticMessage::DECLINED, '상대국이 전쟁 중입니다.']; + return [DiplomaticMessage::DECLINED, '상대국이 전쟁 중입니다.']; } if(3 <= $state && $state <= 6){ - return [DiplomacticMessage::DECLINED, '상대국이 합병 중입니다.']; + return [DiplomaticMessage::DECLINED, '상대국이 합병 중입니다.']; } } return $prev; } - protected function checkContradictoryDiplomacy(array $prev = [DiplomacticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomacticMessage::ACCEPTED){ + protected function checkContradictoryDiplomacy(array $prev = [DiplomaticMessage::ACCEPTED, '']){ + if($prev[0] !== DiplomaticMessage::ACCEPTED){ return $prev; } @@ -221,26 +221,26 @@ class Diplomacy{ ); if($cnt > 0){ - return [DiplomacticMessage::DECLINED, '상대국이 본국의 교전국과 불가침중입니다.']; + return [DiplomaticMessage::DECLINED, '상대국이 본국의 교전국과 불가침중입니다.']; } return $prev; } - protected function checkMorePower(array $prev = [DiplomacticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomacticMessage::ACCEPTED){ + protected function checkMorePower(array $prev = [DiplomaticMessage::ACCEPTED, '']){ + if($prev[0] !== DiplomaticMessage::ACCEPTED){ return $prev; } if($this->srcNation['power'] < $this->destNation['power'] * 3){ - return [DiplomacticMessage::DECLINED, '상대국과 국력차가 크지 않습니다.']; + return [DiplomaticMessage::DECLINED, '상대국과 국력차가 크지 않습니다.']; } return $prev; } - protected function checkMergePower(array $prev = [DiplomacticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomacticMessage::ACCEPTED){ + protected function checkMergePower(array $prev = [DiplomaticMessage::ACCEPTED, '']){ + if($prev[0] !== DiplomaticMessage::ACCEPTED){ return $prev; } @@ -257,13 +257,13 @@ class Diplomacy{ $mergedPower = ($this->srcNation['power'] + $this->destNation['power'])/2; $ZPower = ($mergedPower - $powerAvg) / $powerStddev; if($ZPower >= -0.25){ - return [DiplomacticMessage::DECLINED, '두 국가의 국력 평균이 상위 60% 보다 높습니다.']; + return [DiplomaticMessage::DECLINED, '두 국가의 국력 평균이 상위 60% 보다 높습니다.']; } $mergedGeneral = ($this->srcNation['gennum'] + $this->destNation['gennum'])/2; $ZGeneral = ($mergedGeneral - $genAvg) / $genStddev; if($ZGeneral >= -0.67){ - return [DiplomacticMessage::DECLINED, '두 국가의 장수수 평균이 상위 75% 보다 높습니다.']; + return [DiplomaticMessage::DECLINED, '두 국가의 장수수 평균이 상위 75% 보다 높습니다.']; } return $prev; @@ -275,7 +275,7 @@ class Diplomacy{ $chk = $this->checkAlreadyMerging($chk); list($result, $reason) = $chk; - if($result !== DiplomacticMessage::ACCEPTED){ + if($result !== DiplomaticMessage::ACCEPTED){ return $chk; } @@ -297,7 +297,7 @@ class Diplomacy{ $chk = $this->checkNonAggressionTreaty($chk); list($result, $reason) = $chk; - if($result !== DiplomacticMessage::ACCEPTED){ + if($result !== DiplomaticMessage::ACCEPTED){ return $chk; } @@ -319,7 +319,7 @@ class Diplomacy{ $chk = $this->checkInWar($chk); list($result, $reason) = $chk; - if($result !== DiplomacticMessage::ACCEPTED){ + if($result !== DiplomaticMessage::ACCEPTED){ return $chk; } @@ -345,7 +345,7 @@ class Diplomacy{ $chk = $this->checkMergePower($chk); list($result, $reason) = $chk; - if($result !== DiplomacticMessage::ACCEPTED){ + if($result !== DiplomaticMessage::ACCEPTED){ return $chk; } @@ -378,7 +378,7 @@ class Diplomacy{ $chk = $this->checkMorePower($chk); list($result, $reason) = $chk; - if($result !== DiplomacticMessage::ACCEPTED){ + if($result !== DiplomaticMessage::ACCEPTED){ return $chk; } diff --git a/hwe/sammo/Message.php b/hwe/sammo/Message.php index 80818f30..e73fff6e 100644 --- a/hwe/sammo/Message.php +++ b/hwe/sammo/Message.php @@ -67,7 +67,7 @@ class Message $this->isInboxMail = true; break; } - if($mailbox > Message::MAILBOX_NATIONAL){ + if($mailbox >= Message::MAILBOX_NATIONAL){ if($this->msgType === Message::MSGTYPE_DIPLOMACY){ $this->isInboxMail = true; break; @@ -150,7 +150,7 @@ class Message $action = Util::array_get($option['action'], null); if ($msgType === self::MSGTYPE_DIPLOMACY) { - $objMessage = new DiplomacticMessage(...$args); + $objMessage = new DiplomaticMessage(...$args); } elseif ($action === 'scout') { $objMessage = new ScoutMessage(...$args); } else { @@ -167,9 +167,6 @@ class Message if ($mailbox > self::MAILBOX_PUBLIC) { return false; } - if ($mailbox == self::MAILBOX_NATIONAL) { - return false; - } if ($mailbox <= 0) { return false; } @@ -213,9 +210,12 @@ class Message throw new \InvalidArgumentException('올바르지 않은 $msgType'); } + $date = (new \DateTime())->format('Y-m-d H:i:s'); + $where = new \WhereClause('and'); $where->add('mailbox = %i', $mailbox); $where->add('type = %s', $msgType); + $where->add('valid_until > %s', $date); if ($fromSeq > 0) { $where->add('id > %i', $fromSeq); } @@ -239,7 +239,7 @@ class Message $src_id = $this->src->generalID; $dest_id = self::MAILBOX_PUBLIC; } - else if($mailbox > self::MAILBOX_NATIONAL){ + else if($mailbox >= self::MAILBOX_NATIONAL){ $src_id = $this->src->nationID + self::MAILBOX_NATIONAL; $dest_id = $this->dest->nationID + self::MAILBOX_NATIONAL; }