From 0de4476096f8b99672e2cdcbd47f940da8c92c90 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Wed, 27 Apr 2022 02:43:04 +0900 Subject: [PATCH] =?UTF-8?q?refac,feat:=20Global/ExecuteEngine=20-=20?= =?UTF-8?q?=ED=84=B4=20=EC=8B=A4=ED=96=89=20-=20=EA=B8=B0=EC=A1=B4=20proc.?= =?UTF-8?q?php=EC=99=80=20=EC=9C=A0=EC=82=AC=20-=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=EB=90=9C=20=ED=84=B4=20=EC=9E=88=EC=9D=8C=20=EC=95=8C=EB=A6=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/API/Global/ExecuteEngine.php | 29 ++++++++++++++++++++++++++ hwe/sammo/TurnExecutionHelper.php | 23 +++++++++++--------- hwe/ts/SammoAPI.ts | 1 + 3 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 hwe/sammo/API/Global/ExecuteEngine.php diff --git a/hwe/sammo/API/Global/ExecuteEngine.php b/hwe/sammo/API/Global/ExecuteEngine.php new file mode 100644 index 00000000..cd8cf8ed --- /dev/null +++ b/hwe/sammo/API/Global/ExecuteEngine.php @@ -0,0 +1,29 @@ + true, + 'updated' => $updated, + ]; + } +} diff --git a/hwe/sammo/TurnExecutionHelper.php b/hwe/sammo/TurnExecutionHelper.php index eab02c40..fcd34031 100644 --- a/hwe/sammo/TurnExecutionHelper.php +++ b/hwe/sammo/TurnExecutionHelper.php @@ -237,7 +237,7 @@ class TurnExecutionHelper $general = General::createGeneralObjFromDB($rawGeneral['no']); $turnObj = new static($general); - $env = $gameStor->getAll();//NOTE: 매번 재 갱신하도록 유지할 것. + $env = $gameStor->getAll(); //NOTE: 매번 재 갱신하도록 유지할 것. [$startYear, $year, $month, $turnterm] = $gameStor->getValuesAsArray(['startyear', 'year', 'month', 'turnterm']); $hasNationTurn = false; @@ -264,11 +264,11 @@ class TurnExecutionHelper $turnObj->preprocessCommand($env); - if ($general->getNPCType() >= 2){ + if ($general->getNPCType() >= 2) { $ai = new GeneralAI($turnObj->getGeneral()); } else { - $limitYearMonth = $general->getAuxVar('autorun_limit')??Util::joinYearMonth($year-2, $month); - if(Util::joinYearMonth($year, $month) < $limitYearMonth){ + $limitYearMonth = $general->getAuxVar('autorun_limit') ?? Util::joinYearMonth($year - 2, $month); + if (Util::joinYearMonth($year, $month) < $limitYearMonth) { $ai = new GeneralAI($turnObj->getGeneral()); } } @@ -315,7 +315,7 @@ class TurnExecutionHelper $currentTurn = $general->getTurnTime(); $general->increaseVarWithLimit('myset', 3, null, 9); - if(($autorun_user['limit_minutes']??false) && $general->getNPCType() < 2 && $hasReservedTurn){ + if (($autorun_user['limit_minutes'] ?? false) && $general->getNPCType() < 2 && $hasReservedTurn) { $autorun_limit = Util::joinYearMonth($year, $month); $autorun_limit += intdiv($autorun_user['limit_minutes'], $turnterm); @@ -329,7 +329,7 @@ class TurnExecutionHelper return [false, $currentTurn]; } - static public function executeAllCommand() + static public function executeAllCommand(): bool { //if(!timeover()) { return; } @@ -339,16 +339,16 @@ class TurnExecutionHelper if (TimeUtil::now(true) < $gameStor->turntime) { //턴 시각 이전이면 아무것도 하지 않음 - return true; + return false; } if (!tryLock()) { - return; + return false; } if ($gameStor->isunited == 2 || $gameStor->isunited == 3) { //천통시에는 동결 - return; + return false; } $gameStor->cacheAll(); @@ -361,6 +361,7 @@ class TurnExecutionHelper $date = TimeUtil::now(true); // 최종 처리 월턴의 다음 월턴시간 구함 + $lastExecuted = $gameStor->turntime; $prevTurn = cutTurn($gameStor->turntime, $gameStor->turnterm); $nextTurn = addTurn($prevTurn, $gameStor->turnterm); @@ -392,7 +393,7 @@ class TurnExecutionHelper $gameStor->turntime = $currentTurn; } unlock(); - return; + return $currentTurn !== null && $lastExecuted !== $currentTurn; } @@ -482,5 +483,7 @@ class TurnExecutionHelper // 잡금 해제 $gameStor->resetCache(); unlock(); + + return $currentTurn !== null && $lastExecuted !== $currentTurn; } } diff --git a/hwe/ts/SammoAPI.ts b/hwe/ts/SammoAPI.ts index 844cea74..0ce97172 100644 --- a/hwe/ts/SammoAPI.ts +++ b/hwe/ts/SammoAPI.ts @@ -70,6 +70,7 @@ const apiRealPath = { }, MapResult>, GetCachedMap: GET as APICallT, GetDiplomacy: GET as APICallT, + ExecuteEngine: POST as APICallT, }, InheritAction: { BuyHiddenBuff: PUT as APICallT<{