From cd9bfba7c6300d866762a3ad77d7416dce67ebac Mon Sep 17 00:00:00 2001 From: hide_d Date: Fri, 15 May 2020 21:25:01 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B4=88=ED=86=A0=ED=99=94=EC=97=90=20?= =?UTF-8?q?=EC=A0=84=20=EC=9E=A5=EC=88=98=20=EB=B0=B0=EC=8B=A0=201?= =?UTF-8?q?=ED=98=B8=20=EC=B6=94=EA=B0=80,=20=EB=B0=98=ED=99=98=20?= =?UTF-8?q?=EA=B8=88=EC=95=A1=20=EC=9E=85=EB=A0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func_legacy.php | 24 ++++++++++++--- hwe/sammo/Command/Nation/che_초토화.php | 40 ++++++++++++++++++------- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/hwe/func_legacy.php b/hwe/func_legacy.php index 9e418729..d0f4341e 100644 --- a/hwe/func_legacy.php +++ b/hwe/func_legacy.php @@ -39,10 +39,26 @@ function bar($per, $h=7) { } -function optionsForCities() { - return join('', array_map(function($city){ - return ""; - }, CityConst::all())); +function optionsForCities(callable $infoCall=null) { + + if(!$infoCall){ + return join('', array_map(function($city){ + return ""; + }, CityConst::all())); + } + + $infoList = []; + $noInfoList = []; + foreach(CityConst::all() as $city){ + $info = $infoCall($city); + if(!$info){ + $noInfoList[] = ""; + continue; + } + $infoList[] = ""; + } + + return join('', array_merge($infoList, $noInfoList)); } function Submit($url, $msg="", $msg2="") { diff --git a/hwe/sammo/Command/Nation/che_초토화.php b/hwe/sammo/Command/Nation/che_초토화.php index b362ff2c..b1fad664 100644 --- a/hwe/sammo/Command/Nation/che_초토화.php +++ b/hwe/sammo/Command/Nation/che_초토화.php @@ -11,7 +11,8 @@ use \sammo\{ Command, MessageTarget, Message, - CityConst + CityConst, + CityInitialDetail }; use function \sammo\{ @@ -103,7 +104,7 @@ class che_초토화 extends Command\NationCommand{ $reqTurn = $this->getPreReqTurn()+1; - return "{$name}/{$reqTurn}턴(공백지 화, 금쌀 회수)"; + return "{$name}/{$reqTurn}턴(공백지화, 금쌀 회수, 수뇌진 명성하락)"; } public function getBrief():string{ @@ -113,6 +114,15 @@ class che_초토화 extends Command\NationCommand{ return "【{$destCityName}】{$josaUl} {$commandName}"; } + public function calcReturnAmount(array $destCity):int{ + $amount = $destCity['pop'] / 5; + foreach(['agri', 'comm', 'secu'] as $cityRes){ + $cityResMax = "{$cityRes}_max"; + $amount *= (($destCity[$cityRes] - $destCity[$cityResMax] * 0.5) / $destCity[$cityResMax]) + 1; + } + return Util::toInt($amount); + } + public function run():bool{ if(!$this->hasFullConditionMet()){ throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); @@ -144,17 +154,17 @@ class che_초토화 extends Command\NationCommand{ $josaYi = JosaUtil::pick($generalName, '이'); $josaYiNation = JosaUtil::pick($nationName, '이'); - $amount = $destCity['pop'] / 5; - foreach(['agri', 'comm', 'secu'] as $cityRes){ - $cityResMax = "{$cityRes}_max"; - $amount *= (($destCity[$cityRes] - $destCity[$cityResMax] * 0.5) / $destCity[$cityResMax]) + 1; - } - $amount = Util::toInt($amount); + $amount = $this->calcReturnAmount($destCity); $db->update('general', [ 'experience'=>$db->sqleval('experience * 0.9') ], 'nation = %i AND officer_level >= 5 AND no!=%i', $nationID, $generalID); + $db->update('general', [ + 'betray'=>$db->sqleval('betray + 1') + ], 'nation = %i AND AND no!=%i', $nationID, $generalID); + $general->increaseVar('betray', 1); + $db->update('city', [ 'trust'=>$db->sqleval('greatest(50, trust)'), 'pop'=>$db->sqleval('greatest(pop_max*0.1, pop*0.2)'), @@ -195,15 +205,25 @@ class che_초토화 extends Command\NationCommand{ public function getForm(): string { + + $cities = Util::convertArrayToDict(DB::db()->query('SELECT * FROM city WHERE nation =%i', $this->generalObj->getNationID()), 'city'); + $calc = function(CityInitialDetail $constCity)use($cities){ + if(!key_exists($constCity->id, $cities)){ + return null; + } + $amount = $this->calcReturnAmount($cities[$constCity->id]); + $amountText = number_format($amount); + return "금쌀 각 {$amountText} 회수"; + }; ob_start(); ?>
선택된 도시를 초토화 시킵니다.
도시가 공백지가 되며, 도시의 인구, 내정 상태에 따라 상당량의 국고가 확보됩니다.
-국가의 수뇌들은 명성을 잃습니다.
+국가의 수뇌들은 명성을 잃고, 모든 장수들은 배신 수치가 1 증가합니다.
목록을 선택하거나 도시를 클릭하세요.