diff --git a/hwe/_admin8.php b/hwe/_admin8.php index 4f143310..80cd1552 100644 --- a/hwe/_admin8.php +++ b/hwe/_admin8.php @@ -83,10 +83,6 @@ for ($i=0; $i < $dipcount; $i++) { case 0: $state = "교 전"; break; case 1: $state = "선포중"; break; case 2: $state = "통 상"; break; - case 3: $state = "통합수락중"; break; - case 4: $state = "통합제의중"; break; - case 5: $state = "합병수락중"; break; - case 6: $state = "합병제의중"; break; case 7: $state = "불가침"; break; } diff --git a/hwe/b_dipcenter.php b/hwe/b_dipcenter.php index 50f89990..0dddc990 100644 --- a/hwe/b_dipcenter.php +++ b/hwe/b_dipcenter.php @@ -112,10 +112,6 @@ foreach(getAllNationStaticInfo() as $staticNation): 0 => "교 전", 1 => "선포중", 2 => "통 상", - 3 => "통합수락중", - 4 => "통합제의중", - 5 => "합병수락중", - 6 => "합병제의중", 7 => "불가침", ][$diplomacyState['state']]; diff --git a/hwe/b_diplomacy.php b/hwe/b_diplomacy.php index caf93202..16fc3dc8 100644 --- a/hwe/b_diplomacy.php +++ b/hwe/b_diplomacy.php @@ -175,7 +175,7 @@ for($i=0; $i < $nationcount; $i++) { "; } ?> - align=center>불가침 : @, 합병 : , 통상 : ㆍ, 선포 : , 교전 : + align=center>불가침 : @, 통상 : ㆍ, 선포 : , 교전 : diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index 9c320596..6ba7551e 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -465,7 +465,6 @@ function postUpdateMonthly() 'term'=>6, ], 'state = 1 AND term = 0'); - //NOTE: diplomacy에서 3=>4 통합, 5=>6 합병이 있었음 //초반이후 방랑군 자동 해체 if ($admin['year'] >= $admin['startyear'] + 2) { checkWander(); diff --git a/hwe/j_myBossInfo.php b/hwe/j_myBossInfo.php index 6732d4fc..0aedad40 100644 --- a/hwe/j_myBossInfo.php +++ b/hwe/j_myBossInfo.php @@ -199,9 +199,6 @@ function do추방(General $general, int $myOfficerLevel):?string{ header('location:b_myBossInfo.php', true, 303); die(); } - $dipcount1 = $db->queryFirstField('SELECT count(no) FROM diplomacy WHERE me=%i AND state>=3 AND state<=4', $nationID); - $dipcount2 = $db->queryFirstField('SELECT count(no) FROM diplomacy WHERE me=%i AND state>=5 AND state<=6', $nationID); - $gold = 0; $rice = 0; // 금쌀1000이상은 남김 @@ -222,29 +219,19 @@ function do추방(General $general, int $myOfficerLevel):?string{ $general->setVar('makelimit', 12); $general->setVar('permission', 'normal'); - if($dipcount1 > 0) { - $josaYi = JosaUtil::pick($generalName, '이'); - $logger->pushGlobalActionLog("통합에 반대하던 {$generalName}{$josaYi} {$nationName}에서 숙청당했습니다."); - $logger->pushGeneralActionLog("통합에 반대하다가 {$nationName}에서 숙청당했습니다.", ActionLogger::PLAIN); - } elseif($dipcount2 > 0) { - $josaYi = JosaUtil::pick($generalName, '이'); - $logger->pushGlobalActionLog("합병에 반대하던 {$generalName}{$josaYi} {$nationName}에서 숙청당했습니다."); - $logger->pushGeneralActionLog("합병에 반대하다가 {$nationName}에서 숙청당했습니다.", ActionLogger::PLAIN); - } else { - $josaYi = JosaUtil::pick($generalName, '이'); - $logger->pushGlobalActionLog("{$generalName}{$josaYi} {$nationName}에서 추방당했습니다."); - $logger->pushGeneralActionLog("{$nationName}에서 추방당했습니다.", ActionLogger::PLAIN); + $josaYi = JosaUtil::pick($generalName, '이'); + $logger->pushGlobalActionLog("{$generalName}{$josaYi} {$nationName}에서 추방당했습니다."); + $logger->pushGeneralActionLog("{$nationName}에서 추방당했습니다.", ActionLogger::PLAIN); - // 명성/공헌 N*10%감소 - if($env['year'] <= $env['startyear'] && $general->getVar('npc') < 2){ - $general->setVar('makelimit', $oldMakeLimit); - } - else{ - $betrayCnt = $general->getVar('betray'); - $general->addExperience(-$general->getVar('experience')*0.1*$betrayCnt); - $general->addDedication(-$general->getVar('dedication')*0.1*$betrayCnt); - $general->increaseVarWithLimit('betray', 1, null, GameConst::$maxBetrayCnt); - } + // 명성/공헌 N*10%감소 + if($env['year'] <= $env['startyear'] && $general->getVar('npc') < 2){ + $general->setVar('makelimit', $oldMakeLimit); + } + else{ + $betrayCnt = $general->getVar('betray'); + $general->addExperience(-$general->getVar('experience')*0.1*$betrayCnt); + $general->addDedication(-$general->getVar('dedication')*0.1*$betrayCnt); + $general->increaseVarWithLimit('betray', 1, null, GameConst::$maxBetrayCnt); } //부대장일 경우 diff --git a/hwe/sammo/Command/General/che_선양.php b/hwe/sammo/Command/General/che_선양.php index 2476076d..6229303e 100644 --- a/hwe/sammo/Command/General/che_선양.php +++ b/hwe/sammo/Command/General/che_선양.php @@ -77,10 +77,6 @@ class che_선양 extends Command\GeneralCommand ConstraintHelper::BeLord(), ConstraintHelper::ExistsDestGeneral(), ConstraintHelper::FriendlyDestGeneral(), - ConstraintHelper::DisallowDiplomacyStatus( - $this->generalObj->getNationID(), - [4 => '현재 통합 진행중입니다.'] - ) ]; } diff --git a/hwe/sammo/Command/General/che_하야.php b/hwe/sammo/Command/General/che_하야.php index 531afa37..293c790d 100644 --- a/hwe/sammo/Command/General/che_하야.php +++ b/hwe/sammo/Command/General/che_하야.php @@ -72,33 +72,17 @@ class che_하야 extends Command\GeneralCommand{ $nationID = $this->nation['nation']; $nationName = $this->nation['name']; - $josaUl = JosaUtil::pick($nationName, '을'); - - $dipState = Util::arrayGroupBy($db->query('SELECT no, state FROM diplomacy WHERE me = %i', $nationID), 'state'); - + $logger = $general->getLogger(); - if(key_exists('3', $dipState) || key_exists('4', $dipState)){ - $logger->pushGeneralActionLog("통합에 반대하며 {$nationName}에서 떠났습니다. <1>$date"); - $logger->pushGeneralHistoryLog("통합에 반대하며 {$nationName}{$josaUl} 떠남"); - $logger->pushGlobalActionLog("{$generalName}{$josaYi} 통합에 반대하며 {$nationName}{$josaUl} 떠났습니다."); - } - else if(key_exists('5', $dipState) || key_exists('6', $dipState)){ - $logger->pushGeneralActionLog("합병에 반대하며 {$nationName}에서 떠났습니다. <1>$date"); - $logger->pushGeneralHistoryLog("합병에 반대하며 {$nationName}{$josaUl} 떠남"); - $logger->pushGlobalActionLog("{$generalName}{$josaYi} 합병에 반대하며 {$nationName}{$josaUl} 떠났습니다."); - } - else{ - $logger->pushGeneralActionLog("{$nationName}에서 하야했습니다. <1>$date"); - $logger->pushGeneralHistoryLog("{$nationName}에서 하야"); - $logger->pushGlobalActionLog("{$generalName}{$josaYi} {$nationName}에서 하야했습니다."); - $general->setVar('experience', $general->getVar('experience') * (1 - 0.1 * $general->getVar('betray'))); - $general->addExperience(0, false); - $general->setVar('dedication', $general->getVar('dedication') * (1 - 0.1 * $general->getVar('betray'))); - $general->addDedication(0, false); - $general->increaseVarWithLimit('betray', 1, null, GameConst::$maxBetrayCnt); - - } + $logger->pushGeneralActionLog("{$nationName}에서 하야했습니다. <1>$date"); + $logger->pushGeneralHistoryLog("{$nationName}에서 하야"); + $logger->pushGlobalActionLog("{$generalName}{$josaYi} {$nationName}에서 하야했습니다."); + $general->setVar('experience', $general->getVar('experience') * (1 - 0.1 * $general->getVar('betray'))); + $general->addExperience(0, false); + $general->setVar('dedication', $general->getVar('dedication') * (1 - 0.1 * $general->getVar('betray'))); + $general->addDedication(0, false); + $general->increaseVarWithLimit('betray', 1, null, GameConst::$maxBetrayCnt); $newGold = Util::valueFit($general->getVar('gold'), null, GameConst::$defaultGold); $newRice = Util::valueFit($general->getVar('rice'), null, GameConst::$defaultRice); diff --git a/hwe/sammo/Command/Nation/che_불가침수락.php b/hwe/sammo/Command/Nation/che_불가침수락.php index de039dda..a739f77b 100644 --- a/hwe/sammo/Command/Nation/che_불가침수락.php +++ b/hwe/sammo/Command/Nation/che_불가침수락.php @@ -140,10 +140,6 @@ class che_불가침수락 extends Command\NationCommand ConstraintHelper::DisallowDiplomacyBetweenStatus([ 0 => '아국과 이미 교전중입니다.', 1 => '아국과 이미 선포중입니다.', - 3 => '아국과 외교 진행중입니다.', - 4 => '아국과 외교 진행중입니다.', - 5 => '아국과 외교 진행중입니다.', - 6 => '아국과 외교 진행중입니다.', ]), ]; } diff --git a/hwe/sammo/Command/Nation/che_불가침제의.php b/hwe/sammo/Command/Nation/che_불가침제의.php index 039ce590..4391351b 100644 --- a/hwe/sammo/Command/Nation/che_불가침제의.php +++ b/hwe/sammo/Command/Nation/che_불가침제의.php @@ -126,10 +126,6 @@ class che_불가침제의 extends Command\NationCommand ConstraintHelper::DisallowDiplomacyBetweenStatus([ 0 => '아국과 이미 교전중입니다.', 1 => '아국과 이미 선포중입니다.', - 3 => '아국과 외교 진행중입니다.', - 4 => '아국과 외교 진행중입니다.', - 5 => '아국과 외교 진행중입니다.', - 6 => '아국과 외교 진행중입니다.', ]), ]; } diff --git a/hwe/sammo/Command/Nation/che_선전포고.php b/hwe/sammo/Command/Nation/che_선전포고.php index 8ac468b3..39e436dd 100644 --- a/hwe/sammo/Command/Nation/che_선전포고.php +++ b/hwe/sammo/Command/Nation/che_선전포고.php @@ -95,11 +95,6 @@ class che_선전포고 extends Command\NationCommand ConstraintHelper::DisallowDiplomacyBetweenStatus([ 0 => '아국과 이미 교전중입니다.', 1 => '아국과 이미 선포중입니다.', - 7 => '아국과 불가침중입니다.', - ]), - ConstraintHelper::DisallowDiplomacyStatus($this->destNation['nation'], [ - 3 => '상대국이 외교 진행중입니다.', - 5 => '상대국이 외교 진행중입니다.' ]), ]; } diff --git a/hwe/sammo/DiplomaticMessage.php b/hwe/sammo/DiplomaticMessage.php index 12d7d36d..3dafe4d0 100644 --- a/hwe/sammo/DiplomaticMessage.php +++ b/hwe/sammo/DiplomaticMessage.php @@ -11,8 +11,6 @@ class DiplomaticMessage extends Message{ const TYPE_NO_AGGRESSION = 'noAggression'; //불가침 const TYPE_CANCEL_NA = 'cancelNA'; //불가침 파기 const TYPE_STOP_WAR = 'stopWar'; //종전 - const TYPE_MERGE = 'merge'; //통합 - const TYPE_SURRENDER = 'surrender'; //항복 protected $diplomaticType = ''; protected $diplomacyName = ''; @@ -38,8 +36,6 @@ class DiplomaticMessage extends Message{ case self::TYPE_NO_AGGRESSION: $this->diplomacyName = '불가침'; break; case self::TYPE_CANCEL_NA: $this->diplomacyName = '불가침 파기'; break; case self::TYPE_STOP_WAR: $this->diplomacyName = '종전'; break; - case self::TYPE_MERGE: $this->diplomacyName = '통합'; break; - case self::TYPE_SURRENDER: $this->diplomacyName = '투항'; break; default: throw new \RuntimeException('diplomaticType이 올바르지 않음'); } @@ -139,91 +135,6 @@ class DiplomaticMessage extends Message{ return [self::ACCEPTED, '']; } - protected function acceptMerge(){ - $helper = new Engine\Diplomacy($this->src->nationID, $this->dest->nationID); - $chk = $helper->acceptMerge($this->src->generalID, $this->dest->generalID); - if($chk[0] !== self::ACCEPTED){ - return $chk; - } - - $josaWa = JosaUtil::pick($this->src->nationName, '와'); - pushGeneralHistory( - $this->dest->generalID, - ["●{$helper->year}년 {$helper->month}월:{$this->src->nationName}{$josaWa} 통합 시도"] - ); - pushGenLog( - $this->dest->generalID, - ["{$this->src->nationName}{$josaWa} 통합에 동의했습니다."] - ); - - $josaWa = JosaUtil::pick($this->src->nationName, '와'); - $josaYi = JosaUtil::pick($this->dest->generalName, '이'); - pushGeneralPublicRecord( - ["●{$helper->month}월:{$this->dest->generalName}{$josaYi} {$this->src->nationName}{$josaWa} 통합에 동의하였습니다."], - $helper->year, - $helper->month); - $josaYi = JosaUtil::pick($this->src->generalName, '이'); - - - $josaWa = JosaUtil::pick($this->dest->nationName, '와'); - pushGeneralHistory( - $this->src->generalID, - ["●{$helper->year}년 {$helper->month}월:{$this->dest->nationName}{$josaWa} 통합 시도"] - ); - $josaYi = JosaUtil::pick($this->dest->nationName, '이'); - pushGenLog( - $this->src->generalID, - ["{$this->dest->nationName}{$josaYi} 통합에 동의했습니다."] - ); - pushWorldHistory( - ["●{$helper->year}년 {$helper->month}월:【통합시도】{$this->dest->nationName}{$josaWa}과 {$this->src->nationName}{$josaYi} 통합을 시도합니다."], - $helper->year, - $helper->month - ); - - return $chk; - } - - protected function acceptSurrender(){ - $helper = new Engine\Diplomacy($this->src->nationID, $this->dest->nationID); - $chk = $helper->acceptSurrender($this->src->generalID, $this->dest->generalID); - if($chk[0] !== self::ACCEPTED){ - return $chk; - } - - $josaRo = JosaUtil::pick($this->src->nationName, '로'); - pushGeneralHistory( - $this->src->generalID, - ["●{$helper->year}년 {$helper->month}월:{$this->dest->nationName}에게 투항 제의"] - ); - pushGeneralHistory( - $this->dest->generalID, - ["●{$helper->year}년 {$helper->month}월:{$this->src->nationName}{$josaRo} 투항 동의"] - ); - pushGenLog( - $this->dest->generalID, - ["{$this->src->nationName}{$josaRo} 투항에 동의했습니다."] - ); - $josaYi = JosaUtil::pick($this->dest->nationName, '이'); - pushGenLog( - $this->src->generalID, - ["{$this->dest->nationName}{$josaYi} 투항에 동의했습니다."] - ); - $josaYi = JosaUtil::pick($this->dest->generalName, '이'); - pushGeneralPublicRecord( - ["●{$helper->month}월:{$this->dest->generalName}{$josaYi} {$this->src->nationName}{$josaRo} 투항에 동의하였습니다."], - $helper->year, - $helper->month); - $josaYi = JosaUtil::pick($this->dest->nationName, '이'); - pushWorldHistory( - ["●{$helper->year}년 {$helper->month}월:【투항시도】{$this->dest->nationName}{$josaYi} {$this->src->nationName}{$josaRo} 투항합니다."], - $helper->year, - $helper->month - ); - - return $chk; - } - /** * @return int 수행 결과 반환, ACCEPTED(등용장 소모), DECLINED(등용장 소모), INVALID 중 반환 */ @@ -270,12 +181,6 @@ class DiplomaticMessage extends Message{ case self::TYPE_STOP_WAR: list($result, $reason) = $this->stopWar(); break; - case self::TYPE_MERGE: - list($result, $reason) = $this->acceptMerge(); - break; - case self::TYPE_SURRENDER: - list($result, $reason) = $this->acceptSurrender(); - break; default: throw new \RuntimeException('diplomaticType이 올바르지 않음'); } diff --git a/hwe/sammo/Engine/Battle.php b/hwe/sammo/Engine/Battle.php deleted file mode 100644 index 30aa375e..00000000 --- a/hwe/sammo/Engine/Battle.php +++ /dev/null @@ -1,6 +0,0 @@ -queryFirstRow( - 'SELECT nation, `name`, `power`, capital, gold, rice, gennum, surlimit, color, `level` FROM nation WHERE nation=%i', - $srcNationID - ); - - $destNation = $db->queryFirstRow( - 'SELECT nation, `name`, `power`, capital, gold, rice, gennum, surlimit, color, `level` FROM nation WHERE nation=%i', - $destNationID - ); - - if(!$srcNation || !$destNation){ - return; - } - - $this->srcToDestDiplomacy = $db->queryFirstRow( - 'SELECT * FROM diplomacy WHERE me = %i AND you = %i', - $srcNationID, - $destNationID - ); - - $this->destToSrcDiplomacy = $db->queryFirstRow( - 'SELECT * FROM diplomacy WHERE me = %i AND you = %i', - $destNationID, - $srcNationID - ); - - $this->srcNation = $srcNation; - $this->destNation = $destNation; - $this->valid = true; - - list( - $this->startYear, - $this->year, - $this->month - ) = $gameStor->getValuesAsArray(['startyear', 'year', 'month']); - - } - - //방랑군이 아니어야함 - //상대도 방랑군이 아니어야함 - - //불가침시 : 교전중이 아니어야함, 선포중이 아니어야함. (서로) 합병중이 아니어얗. - //불가침 파기시 : 불가침 중이어야함. - //종전시 : 교전중이거나 선포중이어야함. - //합병시 : 양국 다 외교제한이 지나지 않았어야함. 국력, 장수수가 적절해야함. 인접한 국가여야함. 서로 교전중이어선 안됨. - // 송신자가 선포, 전쟁중이어선 안됨. 송신자가 C국과 불가침인데 수신자가 C국과 전쟁중이면 안됨 - //항복시 : 양국 다 외교제한이 지나지 않았어야함. 국력, 장수수가 적절해야함. 인접한 국가여야함. 서로 교전중이어선 안됨. - // 송신자가 선포, 전쟁중이어선 안됨. 송신자가 C국과 불가침인데 수신자가 C국과 전쟁중이면 안됨 - - protected function checkValidNation(array $prev = [DiplomaticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomaticMessage::ACCEPTED){ - return $prev; - } - - if(!$this->srcNation || !$this->destNation || !$this->valid){ - return [DiplomaticMessage::DECLINED, '올바르지 않은 국가입니다.']; - } - - if($this->srcNation['level'] == 0 || $this->destNation['level'] == 0){ - return [DiplomaticMessage::DECLINED, '방랑군과 외교룰 수행할 수 없습니다.']; - } - - return $prev; - } - - 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 [DiplomaticMessage::DECLINED, '상대국과 선포, 전쟁 중입니다.']; - } - - return $prev; - } - - protected function checkNonAggressionTreaty(array $prev = [DiplomaticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomaticMessage::ACCEPTED){ - return $prev; - } - - if($this->srcToDestDiplomacy['state'] !== 7 || $this->destToSrcDiplomacy['state'] !== 7){ - return [DiplomaticMessage::DECLINED, '상대국과 불가침 중이 아닙니다.']; - } - - return $prev; - } - - protected function checkInWar(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 $prev; - } - - return [DiplomaticMessage::DECLINED, '상대국과 선포, 전쟁 중이 아닙니다.']; - } - - protected function checkDiplomacyLimit(array $prev = [DiplomaticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomaticMessage::ACCEPTED){ - return $prev; - } - - if($this->destNation['surlimit'] > 0){ - return [DiplomaticMessage::DECLINED, '본국의 외교 기한이 남아있습니다.']; - } - - if($this->srcNation['surlimit'] > 0){ - return [DiplomaticMessage::DECLINED, '상대국의 외교 기한이 남아있습니다.']; - } - - return $prev; - } - - protected function checkStrictlyAdjacent(array $prev = [DiplomaticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomaticMessage::ACCEPTED){ - return $prev; - } - - if(!\sammo\isNeighbor($this->srcNation['nation'], $this->destNation['nation'], false)){ - return [DiplomaticMessage::DECLINED, '상대국의 도시들과 보급선이 이어지지 않았습니다.']; - } - - return $prev; - } - - protected function checkAdjacent(array $prev = [DiplomaticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomaticMessage::ACCEPTED){ - return $prev; - } - - if(!\sammo\isNeighbor($this->srcNation['nation'], $this->destNation['nation'], true)){ - return [DiplomaticMessage::DECLINED, '상대국의 도시와 인접하지 않았습니다.']; - } - - return $prev; - } - - 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 [DiplomaticMessage::DECLINED, '상대국과 합병 중입니다.']; - } - - return $prev; - } - - protected function checkSrcNationHasNeutralDiplomacy(array $prev = [DiplomaticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomaticMessage::ACCEPTED){ - return $prev; - } - - $db = \sammo\DB::db(); - - $states = $db->queryFirstColumn( - 'SELECT `state` FROM diplomacy WHERE `state` NOT IN (2, 7) AND me=%i AND you <>%i', - $this->srcNation['nation'], - $this->destNation['nation'] - ); - - foreach($states as $state){ - if($state == 0 || $state == 1){ - return [DiplomaticMessage::DECLINED, '상대국이 전쟁 중입니다.']; - } - if(3 <= $state && $state <= 6){ - return [DiplomaticMessage::DECLINED, '상대국이 합병 중입니다.']; - } - } - - return $prev; - } - - protected function checkContradictoryDiplomacy(array $prev = [DiplomaticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomaticMessage::ACCEPTED){ - return $prev; - } - - $db = \sammo\DB::db(); - - $cnt = $db->queryFirstField( - 'SELECT count(dest.you) FROM diplomacy src - JOIN diplomacy dest ON src.you = dest.you AND src.me != dest.me - WHERE src.state = 7 AND dest.state IN (0, 1) AND src.me = %i AND dest.me = %i', - $this->srcNation['nation'], - $this->destNation['nation'] - ); - - if($cnt > 0){ - return [DiplomaticMessage::DECLINED, '상대국이 본국의 교전국과 불가침중입니다.']; - } - - return $prev; - } - - protected function checkMorePower(array $prev = [DiplomaticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomaticMessage::ACCEPTED){ - return $prev; - } - - if($this->srcNation['power'] < $this->destNation['power'] * 3){ - return [DiplomaticMessage::DECLINED, '상대국과 국력차가 크지 않습니다.']; - } - - return $prev; - } - - protected function checkMergePower(array $prev = [DiplomaticMessage::ACCEPTED, '']){ - if($prev[0] !== DiplomaticMessage::ACCEPTED){ - return $prev; - } - - $db = DB::db(); - list( - $powerAvg, - $powerStddev, - $genAvg, - $genStddev - ) = $db->queryFirstList( - 'SELECT avg(`power`), std(`power`), avg(`gennum`), std(`gennum`) FROM nation WHERE `level` >= 1' - ); - - $mergedPower = ($this->srcNation['power'] + $this->destNation['power'])/2; - $ZPower = ($mergedPower - $powerAvg) / $powerStddev; - if($ZPower >= -0.25){ - return [DiplomaticMessage::DECLINED, '두 국가의 국력 평균이 상위 60% 보다 높습니다.']; - } - - $mergedGeneral = ($this->srcNation['gennum'] + $this->destNation['gennum'])/2; - $ZGeneral = ($mergedGeneral - $genAvg) / $genStddev; - if($ZGeneral >= -0.67){ - return [DiplomaticMessage::DECLINED, '두 국가의 장수수 평균이 상위 75% 보다 높습니다.']; - } - - return $prev; - } - - public function cancelNA(){ - $chk = $this->checkValidNation(); - $chk = $this->checkNonAggressionTreaty($chk); - - [$result, $reason] = $chk; - if($result !== DiplomaticMessage::ACCEPTED){ - return $chk; - } - - $db = DB::db(); - $db->update('diplomacy',[ - 'state'=>2, - 'term'=>0 - ], - '(me=%i AND you=%i) OR (you=%i AND me=%i)', - $this->srcNation['nation'], $this->destNation['nation'], - $this->srcNation['nation'], $this->destNation['nation']); - - return $chk; - } - - public function acceptMerge(int $srcGeneral, int $destGeneral){ - $chk = $this->checkValidNation(); - $chk = $this->checkDiplomacyLimit($chk); - $chk = $this->checkContradictoryDiplomacy($chk); - $chk = $this->checkSrcNationHasNeutralDiplomacy($chk); - $chk = $this->checkStrictlyAdjacent($chk); - $chk = $this->checkMergePower($chk); - - list($result, $reason) = $chk; - if($result !== DiplomaticMessage::ACCEPTED){ - return $chk; - } - - $db = DB::db(); - $db->update('diplomacy',[ - 'state'=>4, - 'term'=>24 - ], - 'me=%i AND you=%i', - $this->srcNation['nation'], $this->destNation['nation']); - - $db->update('diplomacy',[ - 'state'=>3, - 'term'=>24 - ], - 'you=%i AND me=%i', - $this->srcNation['nation'], $this->destNation['nation']); - - return $chk; - } - - public function acceptSurrender(int $srcGeneral, int $destGeneral){ - $chk = $this->checkValidNation(); - $chk = $this->checkDiplomacyLimit($chk); - $chk = $this->checkContradictoryDiplomacy($chk); - $chk = $this->checkSrcNationHasNeutralDiplomacy($chk); - $chk = $this->checkStrictlyAdjacent($chk); - $chk = $this->checkMorePower($chk); - - list($result, $reason) = $chk; - if($result !== DiplomaticMessage::ACCEPTED){ - return $chk; - } - - $db = DB::db(); - $db->update('diplomacy',[ - 'state'=>6, - 'term'=>24 - ], - 'me=%i AND you=%i', - $this->srcNation['nation'], $this->destNation['nation']); - - $db->update('diplomacy',[ - 'state'=>5, - 'term'=>24 - ], - 'you=%i AND me=%i', - $this->srcNation['nation'], $this->destNation['nation']); - - return $chk; - } -} \ No newline at end of file diff --git a/hwe/sammo/GameConstBase.php b/hwe/sammo/GameConstBase.php index 83992284..17ccf07d 100644 --- a/hwe/sammo/GameConstBase.php +++ b/hwe/sammo/GameConstBase.php @@ -304,7 +304,6 @@ class GameConstBase 'che_몰수', ], '외교'=>[ - //'che_항복권고', 'che_물자원조', 'che_불가침제의', 'che_선전포고',