diff --git a/hwe/js/processing.js b/hwe/js/processing.js index 26683855..9ef63016 100644 --- a/hwe/js/processing.js +++ b/hwe/js/processing.js @@ -73,9 +73,11 @@ jQuery(function($) { } }, 'integerArray': function($obj) { - return $obj.map(function() { - return parseInt($(this).val()); + var result = []; + $obj.each(function() { + result.push(parseInt($(this).val())); }); + return result; } } diff --git a/hwe/sammo/Command/Nation/che_물자원조.php b/hwe/sammo/Command/Nation/che_물자원조.php index 9224099d..03deaa13 100644 --- a/hwe/sammo/Command/Nation/che_물자원조.php +++ b/hwe/sammo/Command/Nation/che_물자원조.php @@ -1,282 +1,282 @@ -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('amountList', $this->arg)){ - return false; - } - $amountList = $this->arg['amountList']; - if(!is_array($amountList)){ - return false; - } - - if(count($amountList) != 2){ - return false; - } - - [$goldAmount, $riceAmount] = $amountList; - - if(!is_int($goldAmount) || !is_int($riceAmount)){ - return false; - } - if($goldAmount < 0 || $riceAmount < 0){ - return false; - } - if($goldAmount == 0 && $riceAmount == 0){ - return false; - } - - $this->arg = [ - 'destNationID'=>$destNationID, - 'amountList'=>[$goldAmount, $riceAmount] - ]; - return true; - } - - protected function init(){ - $general = $this->generalObj; - - $this->setCity(); - $this->setNation(['gold', 'rice', 'surlimit']); - - $this->minConditionConstraints=[ - ConstraintHelper::OccupiedCity(), - ConstraintHelper::BeChief(), - ConstraintHelper::SuppliedCity(), - ConstraintHelper::ReqNationValue('surlimit', '외교제한', '==', 0, '외교제한중입니다.'), - ]; - } - - protected function initWithArg() - { - $destNationID = $this->arg['destNationID']; - $this->setDestNation($destNationID, ['gold', 'rice', 'surlimit']); - - [$goldAmount, $riceAmount] = $this->arg['amountList']; - $limit = $this->nation['level'] * GameConst::$coefAidAmount; - - if($goldAmount > $limit || $riceAmount > $limit){ - $this->fullConditionConstraints[ - ConstraintHelper::AlwaysFail('작위 제한량 이상은 보낼 수 없습니다.') - ]; - return; - } - - $this->fullConditionConstraints=[ - ConstraintHelper::ExistsDestNation(), - ConstraintHelper::OccupiedCity(), - ConstraintHelper::BeChief(), - ConstraintHelper::SuppliedCity(), - ConstraintHelper::ReqNationGold(GameConst::$basegold+(($goldAmount>0)?1:0)), - ConstraintHelper::ReqNationRice(GameConst::$baserice+(($riceAmount>0)?1:0)), - ConstraintHelper::ReqNationValue('surlimit', '외교제한', '==', 0, '외교제한중입니다.'), - ConstraintHelper::ReqDestNationValue('surlimit', '외교제한', '==', 0, '상대국이 외교제한중입니다.'), - ]; - } - - public function getCost():array{ - return [0, 0]; - } - - public function getPreReqTurn():int{ - return 0; - } - - public function getPostReqTurn():int{ - return 12; - } - - public function getBrief():string{ - [$goldAmount, $riceAmount] = $this->arg['amountList']; - $goldAmountText = number_format($goldAmount); - $riceAmountText = number_format($riceAmount); - $destNationName = $this->destNation['name']; - $commandName = $this->getName(); - return "【{$destNationName}】에게 국고 {$goldAmountText} 병량 {$riceAmountText} {$commandName}"; - } - - - public function run():bool{ - if(!$this->hasFullConditionMet()){ - throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); - } - - $db = DB::db(); - - $general = $this->generalObj; - $generalID = $general->getID(); - $date = $general->getTurnTime($general::TURNTIME_HM); - - $nation = $this->nation; - $nationID = $nation['nation']; - $nationName = $nation['name']; - - $destNationID = $this->destNation['nation']; - $destNationName = $this->destNation['name']; - - - [$goldAmount, $riceAmount] = $this->arg['amountList']; - - - $goldAmount = Util::valueFit( - $goldAmount, - 0, - $nation['gold'] - GameConst::$basegold - ); - - $riceAmount = Util::valueFit( - $riceAmount, - 0, - $nation['rice'] - GameConst::$baserice - ); - - $goldAmountText = number_format($goldAmount); - $riceAmountText = number_format($riceAmount); - - - $logger = $general->getLogger(); - - $year = $this->env['year']; - $month = $this->env['month']; - - - - $josaRo = JosaUtil::pick($destNationName, '로'); - - - - $broadcastMessage = "{$destNationName}{$josaRo} 금{$goldAmountText} 쌀{$riceAmountText}을 지원했습니다."; - - $chiefList = $db->queryFirstColumn('SELECT no FROM general WHERE officer_level >= 5 AND no != %i AND nation = %i', $generalID, $nationID); - foreach($chiefList as $chiefID){ - $chiefLogger = new ActionLogger($chiefID, $nationID, $year, $month); - $chiefLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN); - $chiefLogger->flush(); - } - - $logger->pushGeneralHistoryLog("{$destNationName}{$josaRo} 금{$goldAmountText} 쌀{$riceAmountText}을 지원"); - $logger->pushNationalHistoryLog("{$destNationName}{$josaRo} 금{$goldAmountText} 쌀{$riceAmountText}을 지원"); - $logger->pushGlobalHistoryLog("【원조】{$nationName}에서 {$destNationName}{$josaRo} 물자를 지원합니다"); - - $logger->pushGeneralActionLog($broadcastMessage); - $logger->pushGeneralActionLog("{$destNationName}{$josaRo} 물자를 지원합니다. <1>$date", ActionLogger::PLAIN); - - $destBroadcastMessage = $broadcastMessage = "{$nationName}에서 금{$goldAmountText} 쌀{$riceAmountText}을 원조했습니다."; - $destChiefList = $db->queryFirstColumn('SELECT no FROM general WHERE officer_level >= 5 AND nation = %i', $destNationID); - foreach($destChiefList as $destChiefID){ - $destChiefLogger = new ActionLogger($destChiefID, $nationID, $year, $month); - $destChiefLogger->pushGeneralActionLog($destBroadcastMessage, ActionLogger::PLAIN); - $destChiefLogger->flush(); - } - - $josaRoSrc = JosaUtil::pick($nationName, '로'); - $destNationLogger = new ActionLogger(0, $destChiefID, $year, $month); - $destNationLogger->pushNationalHistoryLog("{$nationName}{$josaRoSrc}부터 금{$goldAmountText} 쌀{$riceAmountText}을 지원 받음"); - - - - $db->update('nation', [ - 'gold'=>$db->sqleval('gold - %i', $goldAmount), - 'rice'=>$db->sqleval('rice - %i', $riceAmount), - 'surlimit'=>$db->sqleval('surlimit + %i', $this->getPostReqTurn()) - ], 'nation = %i', $nationID); - - $db->update('nation', [ - 'gold'=>$db->sqleval('gold + %i', $goldAmount), - 'rice'=>$db->sqleval('rice + %i', $riceAmount), - ], 'nation = %i', $destNationID); - - $general->addExperience(5); - $general->addDedication(5); - - $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); - $general->applyDB($db); - - return true; - } - - public function getJSFiles(): array - { - return [ - 'js/defaultSelectNationByMap.js' - ]; - } - - - public function getForm(): string - { - $currentNationLevel = getNationStaticInfo($this->generalObj->getNationID())['level']; - ob_start(); -?> -
-타국에게 원조합니다.
-작위별로 금액 제한이 있습니다.
- [$levelText,,]): ?> -:
- -원조할 국가를 목록에서 선택하세요.
- -국고 -병량 -
-
-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('amountList', $this->arg)){ + return false; + } + $amountList = $this->arg['amountList']; + if(!is_array($amountList)){ + return false; + } + + if(count($amountList) != 2){ + return false; + } + + [$goldAmount, $riceAmount] = $amountList; + + if(!is_int($goldAmount) || !is_int($riceAmount)){ + return false; + } + if($goldAmount < 0 || $riceAmount < 0){ + return false; + } + if($goldAmount == 0 && $riceAmount == 0){ + return false; + } + + $this->arg = [ + 'destNationID'=>$destNationID, + 'amountList'=>[$goldAmount, $riceAmount] + ]; + return true; + } + + protected function init(){ + $general = $this->generalObj; + + $this->setCity(); + $this->setNation(['gold', 'rice', 'surlimit']); + + $this->minConditionConstraints=[ + ConstraintHelper::OccupiedCity(), + ConstraintHelper::BeChief(), + ConstraintHelper::SuppliedCity(), + ConstraintHelper::ReqNationValue('surlimit', '외교제한', '==', 0, '외교제한중입니다.'), + ]; + } + + protected function initWithArg() + { + $destNationID = $this->arg['destNationID']; + $this->setDestNation($destNationID, ['gold', 'rice', 'surlimit']); + + [$goldAmount, $riceAmount] = $this->arg['amountList']; + $limit = $this->nation['level'] * GameConst::$coefAidAmount; + + if($goldAmount > $limit || $riceAmount > $limit){ + $this->fullConditionConstraints[ + ConstraintHelper::AlwaysFail('작위 제한량 이상은 보낼 수 없습니다.') + ]; + return; + } + + $this->fullConditionConstraints=[ + ConstraintHelper::ExistsDestNation(), + ConstraintHelper::OccupiedCity(), + ConstraintHelper::BeChief(), + ConstraintHelper::SuppliedCity(), + ConstraintHelper::ReqNationGold(GameConst::$basegold+(($goldAmount>0)?1:0)), + ConstraintHelper::ReqNationRice(GameConst::$baserice+(($riceAmount>0)?1:0)), + ConstraintHelper::ReqNationValue('surlimit', '외교제한', '==', 0, '외교제한중입니다.'), + ConstraintHelper::ReqDestNationValue('surlimit', '외교제한', '==', 0, '상대국이 외교제한중입니다.'), + ]; + } + + public function getCost():array{ + return [0, 0]; + } + + public function getPreReqTurn():int{ + return 0; + } + + public function getPostReqTurn():int{ + return 12; + } + + public function getBrief():string{ + [$goldAmount, $riceAmount] = $this->arg['amountList']; + $goldAmountText = number_format($goldAmount); + $riceAmountText = number_format($riceAmount); + $destNationName = $this->destNation['name']; + $commandName = $this->getName(); + return "【{$destNationName}】에게 국고 {$goldAmountText} 병량 {$riceAmountText} {$commandName}"; + } + + + public function run():bool{ + if(!$this->hasFullConditionMet()){ + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + + $db = DB::db(); + + $general = $this->generalObj; + $generalID = $general->getID(); + $date = $general->getTurnTime($general::TURNTIME_HM); + + $nation = $this->nation; + $nationID = $nation['nation']; + $nationName = $nation['name']; + + $destNationID = $this->destNation['nation']; + $destNationName = $this->destNation['name']; + + + [$goldAmount, $riceAmount] = $this->arg['amountList']; + + + $goldAmount = Util::valueFit( + $goldAmount, + 0, + $nation['gold'] - GameConst::$basegold + ); + + $riceAmount = Util::valueFit( + $riceAmount, + 0, + $nation['rice'] - GameConst::$baserice + ); + + $goldAmountText = number_format($goldAmount); + $riceAmountText = number_format($riceAmount); + + + $logger = $general->getLogger(); + + $year = $this->env['year']; + $month = $this->env['month']; + + + + $josaRo = JosaUtil::pick($destNationName, '로'); + + + + $broadcastMessage = "{$destNationName}{$josaRo} 금{$goldAmountText} 쌀{$riceAmountText}을 지원했습니다."; + + $chiefList = $db->queryFirstColumn('SELECT no FROM general WHERE officer_level >= 5 AND no != %i AND nation = %i', $generalID, $nationID); + foreach($chiefList as $chiefID){ + $chiefLogger = new ActionLogger($chiefID, $nationID, $year, $month); + $chiefLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN); + $chiefLogger->flush(); + } + + $logger->pushGeneralHistoryLog("{$destNationName}{$josaRo} 금{$goldAmountText} 쌀{$riceAmountText}을 지원"); + $logger->pushNationalHistoryLog("{$destNationName}{$josaRo} 금{$goldAmountText} 쌀{$riceAmountText}을 지원"); + $logger->pushGlobalHistoryLog("【원조】{$nationName}에서 {$destNationName}{$josaRo} 물자를 지원합니다"); + + $logger->pushGeneralActionLog($broadcastMessage); + $logger->pushGeneralActionLog("{$destNationName}{$josaRo} 물자를 지원합니다. <1>$date", ActionLogger::PLAIN); + + $destBroadcastMessage = $broadcastMessage = "{$nationName}에서 금{$goldAmountText} 쌀{$riceAmountText}을 원조했습니다."; + $destChiefList = $db->queryFirstColumn('SELECT no FROM general WHERE officer_level >= 5 AND nation = %i', $destNationID); + foreach($destChiefList as $destChiefID){ + $destChiefLogger = new ActionLogger($destChiefID, $nationID, $year, $month); + $destChiefLogger->pushGeneralActionLog($destBroadcastMessage, ActionLogger::PLAIN); + $destChiefLogger->flush(); + } + + $josaRoSrc = JosaUtil::pick($nationName, '로'); + $destNationLogger = new ActionLogger(0, $destChiefID, $year, $month); + $destNationLogger->pushNationalHistoryLog("{$nationName}{$josaRoSrc}부터 금{$goldAmountText} 쌀{$riceAmountText}을 지원 받음"); + + + + $db->update('nation', [ + 'gold'=>$db->sqleval('gold - %i', $goldAmount), + 'rice'=>$db->sqleval('rice - %i', $riceAmount), + 'surlimit'=>$db->sqleval('surlimit + %i', $this->getPostReqTurn()) + ], 'nation = %i', $nationID); + + $db->update('nation', [ + 'gold'=>$db->sqleval('gold + %i', $goldAmount), + 'rice'=>$db->sqleval('rice + %i', $riceAmount), + ], 'nation = %i', $destNationID); + + $general->addExperience(5); + $general->addDedication(5); + + $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); + $general->applyDB($db); + + return true; + } + + public function getJSFiles(): array + { + return [ + 'js/defaultSelectNationByMap.js' + ]; + } + + + public function getForm(): string + { + $currentNationLevel = getNationStaticInfo($this->generalObj->getNationID())['level']; + ob_start(); +?> +
+타국에게 원조합니다.
+작위별로 금액 제한이 있습니다.
+ [$levelText,,]): ?> +:
+ +원조할 국가를 목록에서 선택하세요.
+ +국고 +병량 +
+
+