From a0b215dab603ed397ce1bc7f23b509cc4678aa1e Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 30 Sep 2018 03:04:20 +0900 Subject: [PATCH] =?UTF-8?q?Command=20=EA=B5=AC=EC=A1=B0=20=EC=9D=BC?= =?UTF-8?q?=EB=B6=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func_command.php | 92 +++++++++++++++++++ hwe/sammo/Command/BaseCommand.php | 8 +- .../Command/{ => General}/che_기술연구.php | 3 +- .../Command/{ => General}/che_농지개간.php | 2 +- .../Command/{ => General}/che_상업투자.php | 5 +- .../Command/{ => General}/che_성벽보수.php | 2 +- .../Command/{ => General}/che_수비강화.php | 2 +- .../Command/{ => General}/che_정착장려.php | 5 +- .../Command/{ => General}/che_주민선정.php | 5 +- .../Command/{ => General}/che_치안강화.php | 2 +- hwe/sammo/Command/{ => General}/휴식.php | 5 +- hwe/sammo/Command/GeneralCommand.php | 6 ++ hwe/sammo/Command/Nation/휴식.php | 24 +++++ hwe/sammo/Command/NationCommand.php | 6 ++ hwe/sammo/GameConstBase.php | 11 ++- 15 files changed, 156 insertions(+), 22 deletions(-) rename hwe/sammo/Command/{ => General}/che_기술연구.php (98%) rename hwe/sammo/Command/{ => General}/che_농지개간.php (87%) rename hwe/sammo/Command/{ => General}/che_상업투자.php (98%) rename hwe/sammo/Command/{ => General}/che_성벽보수.php (87%) rename hwe/sammo/Command/{ => General}/che_수비강화.php (87%) rename hwe/sammo/Command/{ => General}/che_정착장려.php (97%) rename hwe/sammo/Command/{ => General}/che_주민선정.php (97%) rename hwe/sammo/Command/{ => General}/che_치안강화.php (87%) rename hwe/sammo/Command/{ => General}/휴식.php (87%) create mode 100644 hwe/sammo/Command/GeneralCommand.php create mode 100644 hwe/sammo/Command/Nation/휴식.php create mode 100644 hwe/sammo/Command/NationCommand.php diff --git a/hwe/func_command.php b/hwe/func_command.php index 66223332..b9096e33 100644 --- a/hwe/func_command.php +++ b/hwe/func_command.php @@ -615,6 +615,98 @@ function processCommand($no) { } } +function pushGeneralCommand(int $generalID, int $turnCnt=1){ + if($turnCnt == 0){ + return; + } + if($turnCnt < 0){ + pullGeneralCommand($generalID, -$turnCnt); + } + if($turnCnt >= GameConst::$maxTurn){ + return; + } + + $db = DB::db(); + + $db->update('general_turn', [ + 'turn_idx'=>$db->sqleval('turn_idx + %i', $turnCnt) + ], 'general_id=%i', $generalID); + $db->update('general_turn', [ + 'turn_idx'=>$db->sqleval('turn_idx - %i', GameConst::$maxTurn), + 'action'=>'휴식', + 'arg'=>'{}' + ], 'general_id=%i AND turn_idx >= %i', $generalID, GameConst::$maxTurn); +} + +function pullGeneralCommand(int $generalID, int $turnCnt=1){ + if($turnCnt == 0){ + return; + } + if($turnCnt < 0){ + pushGeneralCommand($generalID, -$turnCnt); + } + if($turnCnt >= GameConst::$maxTurn){ + return; + } + + $db = DB::db(); + + $db->update('general_turn', [ + 'turn_idx'=>$db->sqleval('turn_idx + %i', GameConst::$maxTurn), + 'action'=>'휴식', + 'arg'=>'{}' + ], 'general_id=%i AND turn_idx < %i', $generalID, $turnCnt); + $db->update('general_turn', [ + 'turn_idx'=>$db->sqleval('turn_idx - %i', $turnCnt) + ], 'general_id=%i', $generalID); +} + +function pushNationCommand(int $nationID, int $level, int $turnCnt=1){ + if($turnCnt == 0){ + return; + } + if($turnCnt < 0){ + pullNationCommand($nationID, $level, -$turnCnt); + } + if($turnCnt >= GameConst::$maxNationTurn){ + return; + } + + $db = DB::db(); + + $db->update('general_turn', [ + 'turn_idx'=>$db->sqleval('turn_idx + %i', $turnCnt) + ], 'general_id=%i', $generalID); + $db->update('general_turn', [ + 'turn_idx'=>$db->sqleval('turn_idx - %i', GameConst::$maxNationTurn), + 'action'=>'휴식', + 'arg'=>'{}' + ], 'general_id=%i AND turn_idx >= %i', $generalID, GameConst::$maxNationTurn); +} + +function pullNationCommand(int $nationID, int $level, int $turnCnt=1){ + if($turnCnt == 0){ + return; + } + if($turnCnt < 0){ + pushNationCommand($nationID, $level, -$turnCnt); + } + if($turnCnt >= GameConst::$maxNationTurn){ + return; + } + + $db = DB::db(); + + $db->update('general_turn', [ + 'turn_idx'=>$db->sqleval('turn_idx + %i', GameConst::$maxNationTurn), + 'action'=>'휴식', + 'arg'=>'{}' + ], 'nation_id=%i AND turn_idx < %i', $generalID, $turnCnt); + $db->update('general_turn', [ + 'turn_idx'=>$db->sqleval('turn_idx - %i', $turnCnt) + ], 'nation_id=%i', $generalID); +} + function updateCommand($no, $type=0) { $db = DB::db(); $connect=$db->get(); diff --git a/hwe/sammo/Command/BaseCommand.php b/hwe/sammo/Command/BaseCommand.php index c2e3b15c..8c966a88 100644 --- a/hwe/sammo/Command/BaseCommand.php +++ b/hwe/sammo/Command/BaseCommand.php @@ -63,10 +63,10 @@ abstract class BaseCommand{ $this->reasonNotReservable = null; } - protected function setCity(array $args=null){ + protected function setCity(?array $args=null){ $this->resetTestCache(); $db = DB::db(); - if($args == null){ + if($args === null){ $this->city = $this->generalObj->getRawCity(); if($this->city){ return; @@ -83,7 +83,7 @@ abstract class BaseCommand{ protected function setNation(?array $args = null){ $this->resetTestCache(); - if($args == null){ + if($args === null){ $this->nation = $this->generalObj->getStaticNation(); return; } @@ -158,7 +158,7 @@ abstract class BaseCommand{ $constraintInput = [ 'general'=>$this->generalObj->getRaw(), 'city'=>$this->city, - 'nation'=>$this->city, + 'nation'=>$this->nation, 'arg'=>$this->arg, 'destGeneral'=>$this->destGeneral, diff --git a/hwe/sammo/Command/che_기술연구.php b/hwe/sammo/Command/General/che_기술연구.php similarity index 98% rename from hwe/sammo/Command/che_기술연구.php rename to hwe/sammo/Command/General/che_기술연구.php index 17388257..90b78a45 100644 --- a/hwe/sammo/Command/che_기술연구.php +++ b/hwe/sammo/Command/General/che_기술연구.php @@ -1,5 +1,5 @@ Credit"; - /** @var string mapName 사용중인 지도명 */ + /** @var string 사용중인 지도명 */ public static $mapName = 'che'; - /** @var string unitSet 사용중인 유닛셋 */ + /** @var string 사용중인 유닛셋 */ public static $unitSet = 'che'; /** @var int 내정시 최하 민심 설정*/ public static $develrate = 50; @@ -86,8 +86,9 @@ class GameConstBase /** @var int 초기 시작 년도. 실제 값은 시나리오에서 정해지므로 딱히 의미는 없음. */ public static $defaultStartYear = 180; - /** @var int 최대 턴(현재는 DB상 24턴으로 고정) */ - public static $maxTurn = 24; + /** @var int 최대 턴 */ + public static $maxTurn = 30; + public static $maxNationTurn = 12; public static $statGradeLevel = 5;