From cb589e9e2678fa290ba5dcff804f2ebd5f867e0d Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 13 Dec 2020 22:05:07 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A2=85=EC=A0=84=EC=88=98=EB=9D=BD=20?= =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Command/Nation/che_종전수락.php | 393 +++++++++++----------- 1 file changed, 198 insertions(+), 195 deletions(-) diff --git a/hwe/sammo/Command/Nation/che_종전수락.php b/hwe/sammo/Command/Nation/che_종전수락.php index a11aab44..18bf5b4c 100644 --- a/hwe/sammo/Command/Nation/che_종전수락.php +++ b/hwe/sammo/Command/Nation/che_종전수락.php @@ -1,195 +1,198 @@ -arg === null) { - return false; - } - - if (!key_exists('destNationID', $this->arg)) { - return false; - } - $destNationID = $this->arg['destNationID']; - if (!is_int($destNationID)) { - return false; - } - if ($destNationID < 1) { - return false; - } - - if (!key_exists('destGeneralID', $this->arg)) { - return false; - } - $destGeneralID = $this->arg['destGeneralID']; - if (!is_int($destGeneralID)) { - return false; - } - if ($destGeneralID <= 0) { - return false; - } - if ($destGeneralID == $this->generalObj->getID()) { - return false; - } - - $this->arg = [ - 'destNationID' => $destNationID, - 'destGeneralID' => $destGeneralID, - ]; - return true; - } - - protected function init() - { - $general = $this->generalObj; - - $env = $this->env; - $relYear = $env['year'] - $env['startyear']; - - $this->setCity(); - $this->setNation(); - - - $nationID = $this->nation['nation']; - - $this->permissionConstraints = [ - ConstraintHelper::AlwaysFail('예약 불가능 커맨드') - ]; - } - - protected function initWithArg() - { - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], [], 1); - $this->setDestGeneral($destGeneral); - $this->setDestNation($this->arg['destNationID']); - - $this->fullConditionConstraints = [ - ConstraintHelper::BeChief(), - ConstraintHelper::NotBeNeutral(), - ConstraintHelper::ExistsDestNation(), - ConstraintHelper::ExistsDestGeneral(), - ConstraintHelper::ReqDestNationValue('nation', '소속', '==', $this->destGeneralObj->getNationID(), '제의 장수가 국가 소속이 아닙니다'), - ConstraintHelper::AllowDiplomacyBetweenStatus( - [0, 1], - '상대국과 선포, 전쟁중이지 않습니다.' - ), - ]; - } - - public function canDisplay():bool{ - return false; - } - - public function getCost(): array - { - return [0, 0]; - } - - public function getPreReqTurn(): int - { - return 0; - } - - public function getPostReqTurn(): int - { - return 0; - } - - public function getBrief(): string - { - $commandName = $this->getName(); - $destNationName = getNationStaticInfo($this->arg['destNationID'])['name']; - return "{$destNationName}국과 종전 합의"; - } - - public function run(): bool - { - if (!$this->hasFullConditionMet()) { - throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); - } - - $db = DB::db(); - $env = $this->env; - - $general = $this->generalObj; - $generalName = $general->getName(); - - $nation = $this->nation; - $nationID = $nation['nation']; - $nationName = $nation['name']; - - $destNation = $this->destNation; - $destNationID = $destNation['nation']; - $destNationName = $destNation['name']; - - $logger = $general->getLogger(); - $destLogger = $this->destGeneralObj->getLogger(); - - $db->update( - 'diplomacy', - [ - 'state' => 2, - 'term' => 0 - ], - '(me=%i AND you=%i) OR (you=%i AND me=%i)', - $nationID, - $destNationID, - $nationID, - $destNationID - ); - - $josaYiGeneral = JosaUtil::pick($generalName, '이'); - $josaYiNation = JosaUtil::pick($nationName, '이'); - - $josaWa = JosaUtil::pick($destNationName, '와'); - $logger->pushGeneralActionLog("{$destNationName}{$josaWa} 종전에 합의했습니다.", ActionLogger::PLAIN); - $logger->pushGeneralHistoryLog("{$destNationName}{$josaWa} 종전 수락"); - - $logger->pushGlobalActionLog("{$generalName}{$josaYiGeneral} {$destNationName}{$josaWa} 종전 합의 하였습니다."); - $logger->pushGlobalHistoryLog("【종전】{$nationName}{$josaYiNation} {$destNationName}{$josaWa} 종전 합의 하였습니다."); - - - $josaWa = JosaUtil::pick($nationName, '와'); - $destLogger->pushGeneralActionLog("{$nationName}{$josaWa} 종전에 성공했습니다.", ActionLogger::PLAIN); - $destLogger->pushGeneralHistoryLog("{$nationName}{$josaWa} 종전 성공"); - - $general->applyDB($db); - $destLogger->flush(); - - return true; - } -} +arg === null) { + return false; + } + + if (!key_exists('destNationID', $this->arg)) { + return false; + } + $destNationID = $this->arg['destNationID']; + if (!is_int($destNationID)) { + return false; + } + if ($destNationID < 1) { + return false; + } + + if (!key_exists('destGeneralID', $this->arg)) { + return false; + } + $destGeneralID = $this->arg['destGeneralID']; + if (!is_int($destGeneralID)) { + return false; + } + if ($destGeneralID <= 0) { + return false; + } + if ($destGeneralID == $this->generalObj->getID()) { + return false; + } + + $this->arg = [ + 'destNationID' => $destNationID, + 'destGeneralID' => $destGeneralID, + ]; + return true; + } + + protected function init() + { + $general = $this->generalObj; + + $env = $this->env; + $relYear = $env['year'] - $env['startyear']; + + $this->setCity(); + $this->setNation(); + + + $nationID = $this->nation['nation']; + + $this->permissionConstraints = [ + ConstraintHelper::AlwaysFail('예약 불가능 커맨드') + ]; + } + + protected function initWithArg() + { + $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], [], 1); + $this->setDestGeneral($destGeneral); + $this->setDestNation($this->arg['destNationID']); + + $this->fullConditionConstraints = [ + ConstraintHelper::BeChief(), + ConstraintHelper::NotBeNeutral(), + ConstraintHelper::ExistsDestNation(), + ConstraintHelper::ExistsDestGeneral(), + ConstraintHelper::ReqDestNationValue('nation', '소속', '==', $this->destGeneralObj->getNationID(), '제의 장수가 국가 소속이 아닙니다'), + ConstraintHelper::AllowDiplomacyBetweenStatus( + [0, 1], + '상대국과 선포, 전쟁중이지 않습니다.' + ), + ]; + } + + public function canDisplay():bool{ + return false; + } + + public function getCost(): array + { + return [0, 0]; + } + + public function getPreReqTurn(): int + { + return 0; + } + + public function getPostReqTurn(): int + { + return 0; + } + + public function getBrief(): string + { + $commandName = $this->getName(); + $destNationName = getNationStaticInfo($this->arg['destNationID'])['name']; + return "{$destNationName}국과 종전 합의"; + } + + public function run(): bool + { + if (!$this->hasFullConditionMet()) { + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + + $db = DB::db(); + $env = $this->env; + + $general = $this->generalObj; + $generalName = $general->getName(); + + $nation = $this->nation; + $nationID = $nation['nation']; + $nationName = $nation['name']; + + $destNation = $this->destNation; + $destNationID = $destNation['nation']; + $destNationName = $destNation['name']; + + $logger = $general->getLogger(); + $destLogger = $this->destGeneralObj->getLogger(); + + $db->update( + 'diplomacy', + [ + 'state' => 2, + 'term' => 0 + ], + '(me=%i AND you=%i) OR (you=%i AND me=%i)', + $nationID, + $destNationID, + $nationID, + $destNationID + ); + + \sammo\SetNationFront($nationID); + \sammo\SetNationFront($destNationID); + + $josaYiGeneral = JosaUtil::pick($generalName, '이'); + $josaYiNation = JosaUtil::pick($nationName, '이'); + + $josaWa = JosaUtil::pick($destNationName, '와'); + $logger->pushGeneralActionLog("{$destNationName}{$josaWa} 종전에 합의했습니다.", ActionLogger::PLAIN); + $logger->pushGeneralHistoryLog("{$destNationName}{$josaWa} 종전 수락"); + + $logger->pushGlobalActionLog("{$generalName}{$josaYiGeneral} {$destNationName}{$josaWa} 종전 합의 하였습니다."); + $logger->pushGlobalHistoryLog("【종전】{$nationName}{$josaYiNation} {$destNationName}{$josaWa} 종전 합의 하였습니다."); + + + $josaWa = JosaUtil::pick($nationName, '와'); + $destLogger->pushGeneralActionLog("{$nationName}{$josaWa} 종전에 성공했습니다.", ActionLogger::PLAIN); + $destLogger->pushGeneralHistoryLog("{$nationName}{$josaWa} 종전 성공"); + + $general->applyDB($db); + $destLogger->flush(); + + return true; + } +}