feat: replace game schedules with logical ticks
This commit is contained in:
+33
-10
@@ -54,14 +54,24 @@ abstract class GeneralBase
|
||||
);
|
||||
}
|
||||
|
||||
function getTurnTime(int $short = self::TURNTIME_FULL_MS): ?string
|
||||
{
|
||||
if(!key_exists('turntime', $this->raw)){
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
self::TURNTIME_FULL_MS => function ($turntime) {
|
||||
function getTurnTime(int $short = self::TURNTIME_FULL_MS): ?string
|
||||
{
|
||||
if(!key_exists('turntime', $this->raw)){
|
||||
return null;
|
||||
}
|
||||
|
||||
$rawTurnTime = $this->getVar('turntime');
|
||||
// 비교용 Dummy와 과거 fixture는 문자열을 잠시 허용하되 제품 DB는 tick만 사용합니다.
|
||||
if (is_string($rawTurnTime) && !ctype_digit(ltrim($rawTurnTime, '-'))) {
|
||||
$formattedTurnTime = $rawTurnTime;
|
||||
} else {
|
||||
$db = DB::db();
|
||||
$clock = GameClock::fromStorage(KVStorage::getStorage($db, 'game_env'));
|
||||
$formattedTurnTime = $clock->formatTick(Util::toInt($rawTurnTime), true);
|
||||
}
|
||||
|
||||
return [
|
||||
self::TURNTIME_FULL_MS => function ($turntime) {
|
||||
return $turntime;
|
||||
},
|
||||
self::TURNTIME_FULL => function ($turntime) {
|
||||
@@ -73,8 +83,21 @@ abstract class GeneralBase
|
||||
self::TURNTIME_HM => function ($turntime) {
|
||||
return substr($turntime, 11, 5);
|
||||
},
|
||||
][$short]($this->getVar('turntime'));
|
||||
}
|
||||
][$short]($formattedTurnTime);
|
||||
}
|
||||
|
||||
function getTurnTick(): ?int
|
||||
{
|
||||
if (!key_exists('turntime', $this->raw)) {
|
||||
return null;
|
||||
}
|
||||
$rawTurnTime = $this->getVar('turntime');
|
||||
if (is_string($rawTurnTime) && !ctype_digit(ltrim($rawTurnTime, '-'))) {
|
||||
$clock = GameClock::fromStorage(KVStorage::getStorage(DB::db(), 'game_env'));
|
||||
return $clock->dateTimeToTick(new \DateTimeImmutable($rawTurnTime));
|
||||
}
|
||||
return Util::toInt($rawTurnTime);
|
||||
}
|
||||
|
||||
function getNPCType(): int
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user