refac,feat: Global/ExecuteEngine
- 턴 실행 - 기존 proc.php와 유사 - 변경된 턴 있음 알림
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\API\Global;
|
||||
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\TurnExecutionHelper;
|
||||
|
||||
class ExecuteEngine extends \sammo\BaseAPI
|
||||
{
|
||||
public function validateArgs(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getRequiredSessionMode(): int
|
||||
{
|
||||
return static::NO_SESSION;
|
||||
}
|
||||
|
||||
public function launch(Session $session, ?DateTimeInterface $modifiedSince, ?string $reqEtag)
|
||||
{
|
||||
$updated = TurnExecutionHelper::executeAllCommand();
|
||||
return [
|
||||
'result' => true,
|
||||
'updated' => $updated,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ const apiRealPath = {
|
||||
}, MapResult>,
|
||||
GetCachedMap: GET as APICallT<undefined, CachedMapResult>,
|
||||
GetDiplomacy: GET as APICallT<undefined, GetDiplomacyResponse>,
|
||||
ExecuteEngine: POST as APICallT<undefined, ValidResponse & { updated: boolean }>,
|
||||
},
|
||||
InheritAction: {
|
||||
BuyHiddenBuff: PUT as APICallT<{
|
||||
|
||||
Reference in New Issue
Block a user