feat: 자율턴 한계 표기

This commit is contained in:
2021-11-13 16:33:11 +09:00
parent d36439355d
commit 542491b278
4 changed files with 28 additions and 9 deletions
+5 -2
View File
@@ -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,
]);
+17 -7
View File
@@ -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 = `<span class="obj_tooltip" data-toggle="tooltip" data-placement="top"
><span style='color:#aaffff;'>${turnInfo.brief}</span
><span class="tooltiptext">자율턴 수행기간: ${autorunLimitYear}${autorunLimitMonth}까지</span
></span>`;
$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);
+3
View File
@@ -0,0 +1,3 @@
export function joinYearMonth(year: number, month: number): number {
return year * 12 + month - 1;
}
+3
View File
@@ -0,0 +1,3 @@
export function parseYearMonth(yearMonth: number): [number, number] {
return [(yearMonth / 12) | 0, yearMonth % 12 + 1];
}