Skip to content

Commit

Permalink
Adding some code smell comments relating to #276. No code changes sin…
Browse files Browse the repository at this point in the history
…ce it's the wrong branch.
  • Loading branch information
DC23 committed Dec 9, 2024
1 parent 1396a52 commit 95f1c4e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/timekeeper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/uipanel.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 95f1c4e

Please sign in to comment.