diff --git a/hwe/sammo/Command/Nation/che_백성동원.php b/hwe/sammo/Command/Nation/che_백성동원.php new file mode 100644 index 00000000..dbb37de8 --- /dev/null +++ b/hwe/sammo/Command/Nation/che_백성동원.php @@ -0,0 +1,161 @@ +arg = []; + + return true; + } + + protected function init(){ + $general = $this->generalObj; + + $env = $this->env; + + $this->setCity(); + $this->setNation(['strategic_cmd_limit']); + + $this->runnableConstraints=[ + ConstraintHelper::OccupiedCity(), + ConstraintHelper::BeChief(), + ConstraintHelper::AllowDiplomacyStatus($this->generalObj->getNationID(), [ + 0 + ], '전쟁중이 아닙니다.'), + ConstraintHelper::SuppliedDestCity(), + 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*4)*10); + + $nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm); + return $nextTerm; + } + + public function getBrief():string{ + $commandName = $this->getName(); + $destCityName = CityConst::byID($this->arg['destCityID'])->name; + return "【{$destCityName}】에 {$commandName}"; + } + + public function run():bool{ + if(!$this->isRunnable()){ + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + + $db = DB::db(); + + $general = $this->generalObj; + $generalID = $general->getID(); + $generalName = $general->getName(); + $date = $general->getTurnTime($general::TURNTIME_HM); + + $year = $this->env['year']; + $month = $this->env['month']; + + $destCity = $this->destCity; + $destCityID = $destCity['city']; + $destCityName = $destCity['name']; + + $nationID = $general->getNationID(); + $nationName = $this->nation['name']; + + $logger = $general->getLogger(); + $logger->pushGeneralActionLog("백성동원 발동! <1>$date"); + + $general->increaseVar( + 'experience', + $general->onCalcStat($general, + 'experience', 5 * ($this->getPreReqTurn() + 1) + )); + $general->increaseVar( + 'dedication', + $general->onCalcStat($general, + 'dedication', 5 * ($this->getPreReqTurn() + 1) + )); + + $josaYi = JosaUtil::pick($generalName, '이'); + + $broadcastMessage = "{$generalName}{$josaYi} {$destCityName}백성동원을 하였습니다."; + + $targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID); + foreach($targetGeneralList as $targetGeneralID){ + $targetLogger = new ActionLogger($targetGeneralID, $nationID, $year, $month); + $targetLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN); + $targetLogger->flush(); + } + + $db->update('city', [ + 'def' => $db->sqleval('GREATEST(def2 * 0.8, def)'), + 'wall' => $db->sqleval('GREATEST(wall2 * 0.8, wall)'), + ], 'city=%i', $destCityID); + + $josaYiNation = JosaUtil::pick($nationName, '이'); + + + $logger->pushGeneralHistoryLog('백성동원을 발동'); + $logger->pushNationalHistoryLog("【전략】{$nationName}{$josaYiNation} {$destCityName}백성동원을 하였습니다."); + + $db->update('nation', ['strategic_cmd_limit' => $this->getPostReqTurn()], 'nation=%i', $nationID); + + $general->setResultTurn(new LastTurn($this->getName(), $this->arg, 0)); + $general->applyDB($db); + + return true; + } + + public function getForm(): string + { + ob_start(); +?> +
+선택된 도시에 백성을 동원해 성벽을 쌓습니다.
+아국 도시만 가능합니다.
+목록을 선택하거나 도시를 클릭하세요.
+
+
+arg = []; @@ -50,7 +50,8 @@ class che_수몰 extends Command\NationCommand{ ConstraintHelper::NotNeutralDestCity(), ConstraintHelper::NotOccupiedDestCity(), ConstraintHelper::BattleGroundCity(), - ConstraintHelper::AvailableStrategicCommand() + ConstraintHelper::AvailableStrategicCommand(), + ConstraintHelper::OccupiedDestCity() ]; } @@ -64,7 +65,7 @@ class che_수몰 extends Command\NationCommand{ public function getPostReqTurn():int{ $genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit); - $nextTerm = Util::round(sqrt($genCount*8)*10); + $nextTerm = Util::round(sqrt($genCount*4)*10); $nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm); return $nextTerm; @@ -148,9 +149,10 @@ class che_수몰 extends Command\NationCommand{ 'wall' => $db->sqleval('wall * 0.2'), ], 'city=%i', $destCityID); + $josaYiNation = JosaUtil::pick($nationName, '이'); $logger->pushGeneralHistoryLog('수몰을 발동'); - $logger->pushNationalHistoryLog("{$generalName}{$josaYi} {$destNationName}{$destCityName}수몰을 발동"); + $logger->pushNationalHistoryLog("【전략】{$nationName}{$josaYiNation} {$destCityName}수몰을 발동하였습니다."); $db->update('nation', ['strategic_cmd_limit' => $this->getPostReqTurn()], 'nation=%i', $nationID); @@ -159,4 +161,20 @@ class che_수몰 extends Command\NationCommand{ return true; } + + public function getForm(): string + { + ob_start(); +?> +
+선택된 도시에 수몰을 발동합니다.
+전쟁중인 상대국 도시만 가능합니다.
+목록을 선택하거나 도시를 클릭하세요.
+
+
+nation['gennum'], GameConst::$initialNationGenLimit); - $nextTerm = Util::round(sqrt($genCount*4)*10); + $nextTerm = Util::round(sqrt($genCount*8)*10); $nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm); return $nextTerm;