diff --git a/hwe/j_get_reserved_command.php b/hwe/j_get_reserved_command.php index d966088a..593508c9 100644 --- a/hwe/j_get_reserved_command.php +++ b/hwe/j_get_reserved_command.php @@ -21,9 +21,11 @@ foreach($rawTurn as [$turn_idx, $action, $arg, $brief]){ ]; } + [$turnTerm, $year, $month, $lastExecute] = $gameStor->getValuesAsArray(['turnterm', 'year', 'month', 'turntime']); -$turnTime = $db->queryFirstField('SELECT turntime FROM general WHERE no=%i', $generalID); +[$turnTime, $rawGeneralAux] = $db->queryFirstList('SELECT turntime, aux FROM general WHERE no=%i', $generalID); +$generalAux = Json::decode($rawGeneralAux??'{}'); if(cutTurn($turnTime, $turnTerm) > cutTurn($lastExecute, $turnTerm)){ //이미 이번달에 실행된 턴이다. @@ -42,5 +44,6 @@ Json::die([ 'year'=>$year, 'month'=>$month, 'date'=>TimeUtil::now(true), - 'turn'=>$commandList + 'turn'=>$commandList, + 'autorun_limit'=> $generalAux['autorun_limit']??null, ]); \ No newline at end of file diff --git a/hwe/ts/main.ts b/hwe/ts/main.ts index 68bd0e3c..36cfb7b6 100644 --- a/hwe/ts/main.ts +++ b/hwe/ts/main.ts @@ -13,6 +13,8 @@ import './msg.ts'; import './map.ts'; import { exportWindow } from './util/exportWindow'; import {stringifyUrl} from 'query-string'; +import { joinYearMonth } from './util/joinYearMonth'; +import { parseYearMonth } from './util/parseYearMonth'; exportWindow($, '$'); type TurnArg = { @@ -33,6 +35,7 @@ type ReservedTurnResponse = { month: number, date: string, turn: TurnItem[], + autorun_limit: number|null, } $(function ($) { @@ -65,10 +68,12 @@ $(function ($) { const turnTime = parseTime(data.turnTime); let nextTurnTime = new Date(turnTime); - let year = data.year; - let month = data.month; + let nowYearMonth = joinYearMonth(data.year, data.month); + const autorunLimitYearMonth = data.autorun_limit ?? nowYearMonth - 1; + const [autorunLimitYear, autorunLimitMonth] = parseYearMonth(autorunLimitYearMonth); for (const [turnIdx, turnInfo] of Object.entries(data.turn)) { + const [year, month] = parseYearMonth(nowYearMonth); const $tr = $(`#command_${turnIdx}`); $tr.find('.time_pad').text(formatTime(nextTurnTime, 'HH:mm')); @@ -76,6 +81,15 @@ $(function ($) { const $turn_pad = $tr.find('.turn_pad'); const $turn_text = $turn_pad.find('.turn_text'); $turn_text.text(turnInfo.brief).css('font-size', '13px'); + if(nowYearMonth <= autorunLimitYearMonth){ + const autorunTooltip = `${turnInfo.brief}자율턴 수행기간: ${autorunLimitYear}년 ${autorunLimitMonth}까지`; + $turn_text.html(autorunTooltip); + initTooltip($turn_text); + } + const oWidth = unwrap($turn_pad.innerWidth()); const iWidth = unwrap($turn_text.outerWidth()); @@ -85,11 +99,7 @@ $(function ($) { } nextTurnTime = addMinutes(nextTurnTime, data.turnTerm); - month += 1; - if (month >= 13) { - year += 1; - month -= 12; - } + nowYearMonth += 1; } console.log(data); diff --git a/hwe/ts/util/joinYearMonth.ts b/hwe/ts/util/joinYearMonth.ts new file mode 100644 index 00000000..f06a954d --- /dev/null +++ b/hwe/ts/util/joinYearMonth.ts @@ -0,0 +1,3 @@ +export function joinYearMonth(year: number, month: number): number { + return year * 12 + month - 1; +} \ No newline at end of file diff --git a/hwe/ts/util/parseYearMonth.ts b/hwe/ts/util/parseYearMonth.ts new file mode 100644 index 00000000..a174a984 --- /dev/null +++ b/hwe/ts/util/parseYearMonth.ts @@ -0,0 +1,3 @@ +export function parseYearMonth(yearMonth: number): [number, number] { + return [(yearMonth / 12) | 0, yearMonth % 12 + 1]; +} \ No newline at end of file