From 95f1c4e62b2b8e42e0c4cc73e3775e8ea94a7ac2 Mon Sep 17 00:00:00 2001 From: DC23 Date: Mon, 9 Dec 2024 15:59:44 +1100 Subject: [PATCH] Adding some code smell comments relating to #276. No code changes since it's the wrong branch. --- src/helpers.mjs | 2 ++ src/timekeeper.mjs | 2 ++ src/uipanel.mjs | 1 + 3 files changed, 5 insertions(+) diff --git a/src/helpers.mjs b/src/helpers.mjs index 14ac7ec..edca2c2 100644 --- a/src/helpers.mjs +++ b/src/helpers.mjs @@ -65,6 +65,7 @@ export class Helpers { * @property {number} totalMinutes total elapsed minutes since 12am on day 0 * @returns {import('./timekeeper.mjs').gameTurnTime} */ + // todo: Code Smell! Why is this not a Timekeeper function? What architectural goal is served by having it here? static factorGameTurns (totalMinutes) { const gameTurnData = {} gameTurnData.totalGameTurns = Math.floor(totalMinutes / Constants.minutesPerStretch) @@ -75,6 +76,7 @@ export class Helpers { gameTurnData.turns = remainingGameTurns % Constants.stretchesPerShift gameTurnData.shiftName = Helpers.getDragonbaneShiftName(gameTurnData.shifts) + // todo: Code Smell! should use Constants.daysPerWeek gameTurnData.day = { index: (gameTurnData.days % 7) + 1 } // 1-based day index for UI gameTurnData.day.name = Helpers.getWeekdayName(gameTurnData.day.index - 1) // lookup by 0-based index gameTurnData.weekNumber = Math.floor(gameTurnData.days / 7) + 1 // 1-based week number diff --git a/src/timekeeper.mjs b/src/timekeeper.mjs index d5b3450..504b323 100644 --- a/src/timekeeper.mjs +++ b/src/timekeeper.mjs @@ -212,8 +212,10 @@ export class Timekeeper { time.days = Math.floor(totalMinutes / Constants.minutesPerDay) time.hours = Math.floor((totalMinutes % Constants.minutesPerDay) / 60) time.minutes = (totalMinutes % Constants.minutesPerDay) % 60 + // todo: Code Smell! should use Constants.daysPerWeek time.day = { index: (time.days % 7) + 1 } // 1-based day index for UI time.day.name = Helpers.getWeekdayName(time.day.index - 1) // lookup by 0-based index + // todo: Code Smell! should use Constants.daysPerWeek time.weekNumber = Math.floor(time.days / 7) + 1 // 1-based week number return time diff --git a/src/uipanel.mjs b/src/uipanel.mjs index e889a48..4f3ddad 100644 --- a/src/uipanel.mjs +++ b/src/uipanel.mjs @@ -198,6 +198,7 @@ export class UIPanel extends HandlebarsApplicationMixin(ApplicationV2) { */ id: 'etk-days', value: time.day.index, + // todo: Code Smell! should use Constants.daysPerWeek max: 7, name: game.i18n.format('JDTIMEKEEPING.Time.DayAndWeek', { day: time.day.name,