From 9ea8d3ec975e89345235991f8affb5b4a733f769 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 22 Mar 2020 02:34:04 +0900 Subject: [PATCH] =?UTF-8?q?=ED=94=BC=EC=9E=A5=ED=8C=8C=EC=9E=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Command/Nation/che_백성동원.php | 2 +- hwe/sammo/Command/Nation/che_피장파장.php | 231 ++++++++++++++++++++++ hwe/sammo/Command/Nation/che_허보.php | 24 +-- 3 files changed, 238 insertions(+), 19 deletions(-) create mode 100644 hwe/sammo/Command/Nation/che_피장파장.php diff --git a/hwe/sammo/Command/Nation/che_백성동원.php b/hwe/sammo/Command/Nation/che_백성동원.php index b84f9e7b..60a6fb17 100644 --- a/hwe/sammo/Command/Nation/che_백성동원.php +++ b/hwe/sammo/Command/Nation/che_백성동원.php @@ -62,7 +62,7 @@ class che_백성동원 extends Command\NationCommand{ } public function getPreReqTurn():int{ - return 2; + return 0; } public function getPostReqTurn():int{ diff --git a/hwe/sammo/Command/Nation/che_피장파장.php b/hwe/sammo/Command/Nation/che_피장파장.php new file mode 100644 index 00000000..af3e5b7b --- /dev/null +++ b/hwe/sammo/Command/Nation/che_피장파장.php @@ -0,0 +1,231 @@ +arg === null){ + return false; + } + //NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음 + if(!key_exists('destNationID', $this->arg)){ + return false; + } + $destNationID = $this->arg['destNationID']; + + if(!is_int($destNationID)){ + return false; + } + if($destNationID < 1){ + return false; + } + + $this->arg = [ + 'destNationID'=>$destNationID + ]; + return true; + } + + protected function init(){ + $general = $this->generalObj; + + $env = $this->env; + + $this->setCity(); + $this->setNation(['strategic_cmd_limit']); + + $this->setDestNation($this->arg['destNationID'], null); + + $this->runnableConstraints=[ + ConstraintHelper::OccupiedCity(), + ConstraintHelper::BeChief(), + ConstraintHelper::NotNeutralDestCity(), + ConstraintHelper::NotOccupiedDestCity(), + ConstraintHelper::DisallowDiplomacyBetweenStatus( + [0, 1], + '선포, 전쟁중인 상대국에게만 가능합니다.' + ), + ConstraintHelper::AvailableStrategicCommand(), + ]; + + } + + public function getCost():array{ + return [0, 0]; + } + + public function getPreReqTurn():int{ + return 2; + } + + public function getPostReqTurn():int{ + $genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit); + $nextTerm = Util::round(sqrt($genCount*2)*10); + + $nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm); + return $nextTerm; + } + + public function getBrief():string{ + $commandName = $this->getName(); + $destNationName = getNationStaticInfo($this->arg['destNationID'])['name']; + return "【{$destNationName}】에 {$commandName}"; + } + + + public function run():bool{ + if(!$this->isRunnable()){ + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + + $db = DB::db(); + $env = $this->env; + + $general = $this->generalObj; + $generalID = $general->getID(); + $generalName = $general->getName(); + $date = $general->getTurnTime($general::TURNTIME_HM); + + $year = $this->env['year']; + $month = $this->env['month']; + + $nation = $this->nation; + $nationID = $nation['nation']; + $nationName = $nation['name']; + + $destNation = $this->destNation; + $destNationID = $destNation['nation']; + $destNationName = $destNation['name']; + + $josaYi = JosaUtil::pick($generalName, '이'); + $josaYiNation = JosaUtil::pick($nationName, '이'); + + $commandName = $this->getName(); + $josaUl = JosaUtil::pick($commandName, '을'); + + $logger = $general->getLogger(); + $logger->pushGeneralActionLog("{$commandName} 발동! <1>$date"); + + $general->increaseVar( + 'experience', + $general->onCalcStat($general, + 'experience', 5 * ($this->getPreReqTurn() + 1) + )); + $general->increaseVar( + 'dedication', + $general->onCalcStat($general, + 'dedication', 5 * ($this->getPreReqTurn() + 1) + )); + + $logger = $general->getLogger(); + + $broadcastMessage = "{$generalName}{$josaYi} {$destNationName}{$commandName}{$josaUl} 발동하였습니다."; + + $nationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID); + foreach($nationGeneralList as $nationGeneralID){ + $nationGeneralLogger = new ActionLogger($nationGeneralID, $nationID, $year, $month); + $nationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN); + $nationGeneralLogger->flush(); + } + + $josaYiCommand = JosaUtil::pick($commandName, '이'); + + $broadcastMessage = "아국에 {$commandName}{$josaYiCommand} 발동되었습니다."; + + $destNationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID); + foreach($destNationGeneralList as $destNationGeneralID){ + $destNationGeneralLogger = new ActionLogger($destNationGeneralID, $destNationID, $year, $month); + $destNationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN); + $destNationGeneralLogger->flush(); + } + + $destNationLogger = new ActionLogger(0, $destNationID, $year, $month); + $destNationLogger->pushNationalHistoryLog("{$nationName}{$generalName}{$josaYi} 아국에 {$commandName}{$josaUl} 발동"); + $destNationLogger->flush(); + + $logger->pushNationalHistoryLog("{$generalName}{$josaYi} {$destNationName}{$commandName}{$josaUl} 발동"); + + $db->update('nation', [ + 'strategic_cmd_limit' => $db->sqleval('strategic_cmd_limit + %i', static::$delayCnt) + ], 'nation = %i', $destNationID); + + $general->applyDB($db); + + return true; + } + + public function getJSFiles(): array + { + return [ + 'js/defaultSelectNationByMap.js' + ]; + } + + public function getForm(): string + { + $generalObj = $this->generalObj; + $nationID = $generalObj->getNationID(); + $nationList = []; + $testTurn = new LastTurn($this->getName(), null, $this->getPreReqTurn()); + foreach(getAllNationStaticInfo() as $destNation){ + if($destNation['nation'] == $nationID){ + continue; + } + + $testTurn->setArg(['destNationID'=>$destNation['nation']]); + $testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID'=>$destNation['nation']]); + if($testCommand->isRunnable()){ + $destNation['availableCommand'] = true; + } + else{ + $destNation['availableCommand'] = false; + } + + $nationList[] = $destNation; + } + + ob_start(); +?> +
+선택된 국가에 피장파장을 발동합니다.
+선포, 전쟁중인 상대국에만 가능합니다.
+상대 국가를 목록에서 선택하세요.
+배경색은 현재 피장파장 불가능 국가는 붉은색으로 표시됩니다.
+ +queryFirstColumn('SELECT city FROM city WHERE nation = %i AND supply = 1', $destNationID); $targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND city=%i', $destNationID, $destCityID); - $destNationLogged = false; foreach(General::createGeneralObjListFromDB($targetGeneralList) as $targetGeneralID => $targetGeneral){ $targetLogger = $targetGeneral->getLogger(); $targetLogger->pushGeneralActionLog($destBroadcastMessage, ActionLogger::PLAIN); - if(!$destNationLogged){ - $targetLogger->pushNationalHistoryLog( - "{$nationName}{$generalName}{$josaYi} 아국의 {$destCityName}허보를 발동", ActionLogger::PLAIN - ); - $destNationLogged = true; - } $moveCityID = Util::choiceRandom($destNationCityList); if($moveCityID == $destCityID){ @@ -164,19 +157,14 @@ class che_허보 extends Command\NationCommand{ } $targetGeneral->setVar('city', $moveCityID); - $targetGeneral->applyDB($db); } - if(!$targetGeneralList){ - //아무도 없었다! - $destNationLordID = $db->queryFirstField('SELECT no FROM general WHERE nation=%i AND level=12', $destNationID); - $targetLogger = new ActionLogger($destNationLordID, $destNationID, $year, $month); - $targetLogger->pushNationalHistoryLog( - "{$nationName}{$generalName}{$josaYi} 아국의 {$destCityName}허보를 발동", ActionLogger::PLAIN - ); - $targetLogger->flush(); - } + $destNationLogger = new ActionLogger(0, $destNationID, $year, $month); + $destNationLogger->pushNationalHistoryLog( + "{$nationName}{$generalName}{$josaYi} 아국의 {$destCityName}허보를 발동", ActionLogger::PLAIN + ); + $destNationLogger->flush(); $db->update('city', [