forked from devsam/core
재야에서는 국메가 안보내지던 버그 수정
일반장이 국메를 보낼 수 없던 버그 수정 외교 서신 클래스 에러 수정
This commit is contained in:
@@ -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),"");
|
||||
|
||||
@@ -1,224 +0,0 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
function checkScoutAvailable($messageInfo, $general, $srcGeneral, $startyear, $year){
|
||||
$nationID = $messageInfo['src']['nationID'];
|
||||
|
||||
$srcNation = DB::db()->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[] = "<C>●</><Y>{$myName}</> 등용에 성공했습니다.";
|
||||
$alllog[] = "<C>●</>{$month}월:<Y>{$myName}</>(이)가 <D><b>{$nationName}</b></>(으)로 <S>망명</>하였습니다.";
|
||||
$mylog[] = "<C>●</><D>{$nationName}</>(으)로 망명하여 수도로 이동합니다.";
|
||||
pushGeneralHistory($you, "<C>●</>{$year}년 {$month}월:<Y>{$myName}</> 등용에 성공");
|
||||
pushGeneralHistory($me, "<C>●</>{$year}년 {$month}월:<D>{$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[] = "<C>●</>{$reason} 등용 수락 불가.";
|
||||
$msg = "{$nationName}(으)로 등용 제의 수락 불가";
|
||||
}
|
||||
else{
|
||||
$youlog[] = "<C>●</><Y>{$me['name']}</>(이)가 등용을 거부했습니다.";
|
||||
$mylog[] = "<C>●</><D>{$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){
|
||||
|
||||
}
|
||||
@@ -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 = " <input type=submit name=ok value=수락 onclick='return confirm(\"정말 수락하시겠습니까?\")'><input type=submit name=ok value=거절 onclick='return confirm(\"정말 거절하시겠습니까?\")'>";
|
||||
} else {
|
||||
$corebutton = " 【수락】【거절】";
|
||||
}
|
||||
if($type == 6) {
|
||||
$corebutton .= "<br>비고: {$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 = "[<font color=$mycolor>$me</font>{$sign}<font color=$youcolor>$you</font>]";
|
||||
$picture = "<img width='64' height='64' src={$imageTemp}/{$picture}>";
|
||||
if($site != "") {
|
||||
$form = "<form name=scout method=post action={$site}>";
|
||||
$form2 = "</form>";
|
||||
}
|
||||
if($num >= 0) { $num = "<input type=hidden name=num value=$num>"; }
|
||||
else { $num = ""; }
|
||||
if($who > 0) { $who = "<input type=hidden name=gen value=$who>"; }
|
||||
else { $who = ""; }
|
||||
if($when > 0) { $when = "<input type=hidden name=when value=$when>"; }
|
||||
else { $when = ""; }
|
||||
echo "
|
||||
<table width=498 border=1 bordercolordark=gray bordercolorlight=black cellpadding=0 cellspacing=0 bgcolor='$bgcolor' style=font-size:13px;table-layout:fixed;word-break:break-all;>
|
||||
<tr>
|
||||
<td width=64 height=64>$picture</td>
|
||||
$form
|
||||
<td width=434 valign=top><b>$naming</b><font size=1><$date></font> <br>{$msg}{$corebutton}</td>
|
||||
$num
|
||||
$who
|
||||
$when
|
||||
$form2
|
||||
</tr>
|
||||
</table>
|
||||
";
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ list($generalID, $nationID) = DB::db()->queryFirstList(
|
||||
if($nationID === null){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'소속 국가가 없습니다'
|
||||
'reason'=>'장수가 사망했습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
class DiplomacticMessage extends Message{
|
||||
class DiplomaticMessage extends Message{
|
||||
|
||||
const ACCEPTED = 1;
|
||||
const DECLINED = -1;
|
||||
@@ -2,7 +2,7 @@
|
||||
namespace sammo\Engine;
|
||||
|
||||
use \sammo\DB;
|
||||
use \sammo\DiplomacticMessage;
|
||||
use \sammo\DiplomaticMessage;
|
||||
|
||||
//NOTE: A가 B에게 항복, 통합 서신을 보냈을 때 통합 후 대상이 A이므로 A가 주체임.
|
||||
class Diplomacy{
|
||||
@@ -73,8 +73,8 @@ class Diplomacy{
|
||||
//항복시 : 양국 다 외교제한이 지나지 않았어야함. 국력, 장수수가 적절해야함. 인접한 국가여야함. 서로 교전중이어선 안됨.
|
||||
// 송신자가 선포, 전쟁중이어선 안됨. 송신자가 C국과 불가침인데 수신자가 C국과 전쟁중이면 안됨
|
||||
|
||||
protected function checkValidNation(array $prev = [DiplomacticMessage::ACCEPTED, '']){
|
||||
if($prev[0] !== DiplomacticMessage::ACCEPTED){
|
||||
protected function checkValidNation(array $prev = [DiplomaticMessage::ACCEPTED, '']){
|
||||
if($prev[0] !== DiplomaticMessage::ACCEPTED){
|
||||
return $prev;
|
||||
}
|
||||
|
||||
@@ -83,39 +83,39 @@ class Diplomacy{
|
||||
}
|
||||
|
||||
if($this->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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user