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;