Skip to content

Commit

Permalink
refactor: make OptionIcons an enum
Browse files Browse the repository at this point in the history
  • Loading branch information
Zamiell committed Nov 8, 2024
1 parent 3e57e58 commit 7211a02
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 50 deletions.
13 changes: 13 additions & 0 deletions packages/client/src/enums/OptionIcons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable complete/consistent-enum-values */

export enum OptionIcons {
Timed = "fas fa-clock",
Speedrun = "fas fa-running",
CardCycle = "fas fa-sync-alt",
DeckPlays = "fas fa-blind",
EmptyClues = "fas fa-expand",
OneExtraCard = "fas fa-plus-circle",
OneLessCard = "fas fa-minus-circle",
AllOrNothing = "fas fa-layer-group",
DetrimentalCharacters = "fas fa-flushed",
}
20 changes: 10 additions & 10 deletions packages/client/src/game/ui/Deck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
millisecondsToClockString,
} from "@hanabi-live/game";
import Konva from "konva";
import { OptionIcons } from "../../enums/OptionIcons";
import * as tooltips from "../../tooltips";
import { OptionIcons } from "../../types/OptionIcons";
import { dateTimeFormatter, timerFormatter } from "../../utils";
import { ActionType } from "../types/ActionType";
import { ReplayArrowOrder } from "../types/ReplayArrowOrder";
Expand Down Expand Up @@ -259,7 +259,7 @@ function getTooltipContent(): string {
content += `&nbsp; Variant: &nbsp;<strong>${globals.variant.name}</strong></li>`;

if (globals.options.timed) {
content += `<li><span class="game-tooltips-icon"><i class="${OptionIcons.TIMED}"></i></span>`;
content += `<li><span class="game-tooltips-icon"><i class="${OptionIcons.Timed}"></i></span>`;
content += "&nbsp; Timed: ";
content += timerFormatter(globals.options.timeBase);
content += " + ";
Expand All @@ -268,44 +268,44 @@ function getTooltipContent(): string {
}

if (globals.options.speedrun) {
content += `<li><span class="game-tooltips-icon"><i class="${OptionIcons.SPEEDRUN}"></i></span>`;
content += `<li><span class="game-tooltips-icon"><i class="${OptionIcons.Speedrun}"></i></span>`;
content += "&nbsp; Speedrun</li>";
}

if (globals.options.cardCycle) {
content += '<li><span class="game-tooltips-icon">';
content += `<i class="${OptionIcons.CARD_CYCLE}"></i></span>`;
content += `<i class="${OptionIcons.CardCycle}"></i></span>`;
content += "&nbsp; Card Cycling</li>";
}

if (globals.options.deckPlays) {
content += '<li><span class="game-tooltips-icon">';
content += `<i class="${OptionIcons.DECK_PLAYS}" style="position: relative; left: 0.2em;"></i></span>`;
content += `<i class="${OptionIcons.DeckPlays}" style="position: relative; left: 0.2em;"></i></span>`;
content += "&nbsp; Bottom-Deck Blind Plays</li>";
}

if (globals.options.emptyClues) {
content += `<li><span class="game-tooltips-icon"><i class="${OptionIcons.EMPTY_CLUES}"></i></span>`;
content += `<li><span class="game-tooltips-icon"><i class="${OptionIcons.EmptyClues}"></i></span>`;
content += "&nbsp; Empty Clues</li>";
}

if (globals.options.oneExtraCard) {
content += `<li><span class="game-tooltips-icon"><i class="${OptionIcons.ONE_EXTRA_CARD}"></i></span>`;
content += `<li><span class="game-tooltips-icon"><i class="${OptionIcons.OneExtraCard}"></i></span>`;
content += "&nbsp; One Extra Card</li>";
}

if (globals.options.oneLessCard) {
content += `<li><span class="game-tooltips-icon"><i class="${OptionIcons.ONE_LESS_CARD}"></i></span>`;
content += `<li><span class="game-tooltips-icon"><i class="${OptionIcons.OneLessCard}"></i></span>`;
content += "&nbsp; One Less Card</li>";
}

if (globals.options.allOrNothing) {
content += `<li><span class="game-tooltips-icon"><i class="${OptionIcons.ALL_OR_NOTHING}"></i></span>`;
content += `<li><span class="game-tooltips-icon"><i class="${OptionIcons.AllOrNothing}"></i></span>`;
content += "&nbsp; All or Nothing</li>";
}

if (globals.options.detrimentalCharacters) {
content += `<li><span class="game-tooltips-icon"><i class="${OptionIcons.DETRIMENTAL_CHARACTERS}"></i></span>`;
content += `<li><span class="game-tooltips-icon"><i class="${OptionIcons.DetrimentalCharacters}"></i></span>`;
content += "&nbsp; Detrimental Characters</li>";
}

Expand Down
38 changes: 19 additions & 19 deletions packages/client/src/lobby/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import type { Options } from "@hanabi-live/game";
import { getVariant } from "@hanabi-live/game";
import { OptionIcons } from "../enums/OptionIcons";
import { globals } from "../Globals";
import * as tooltips from "../tooltips";
import { OptionIcons } from "../types/OptionIcons";
import { dateTimeFormatter, timerFormatter } from "../utils";
import * as nav from "./nav";
import { tablesDraw } from "./tablesDraw";
Expand Down Expand Up @@ -349,59 +349,59 @@ function makeOptions(i: number, options: Options, otherScores: boolean) {
const icons: string[] = [];

if (options.timed) {
icons.push(OptionIcons.TIMED);
tooltipHTML += `<li><i class="${OptionIcons.TIMED}"></i>&nbsp; `;
icons.push(OptionIcons.Timed);
tooltipHTML += `<li><i class="${OptionIcons.Timed}"></i>&nbsp; `;
tooltipHTML += `Timed (${timerFormatter(
options.timeBase,
)} + ${timerFormatter(options.timePerTurn)})`;
tooltipHTML += "</li>";
}

if (options.speedrun) {
icons.push(OptionIcons.SPEEDRUN);
tooltipHTML += `<li><i class="${OptionIcons.SPEEDRUN}"></i>&nbsp; `;
icons.push(OptionIcons.Speedrun);
tooltipHTML += `<li><i class="${OptionIcons.Speedrun}"></i>&nbsp; `;
tooltipHTML += "Speedrun</li>";
}

if (options.cardCycle) {
icons.push(OptionIcons.CARD_CYCLE);
tooltipHTML += `<li><i class="${OptionIcons.CARD_CYCLE}"></i>&nbsp; `;
icons.push(OptionIcons.CardCycle);
tooltipHTML += `<li><i class="${OptionIcons.CardCycle}"></i>&nbsp; `;
tooltipHTML += "Card Cycling</li>";
}

if (options.deckPlays) {
icons.push(OptionIcons.DECK_PLAYS);
tooltipHTML += `<li><i class="${OptionIcons.DECK_PLAYS}" style="position: relative; left: 0.2em;"></i>&nbsp; `;
icons.push(OptionIcons.DeckPlays);
tooltipHTML += `<li><i class="${OptionIcons.DeckPlays}" style="position: relative; left: 0.2em;"></i>&nbsp; `;
tooltipHTML += "Bottom-Deck Blind-Plays</li>";
}

if (options.emptyClues) {
icons.push(OptionIcons.EMPTY_CLUES);
tooltipHTML += `<li><i class="${OptionIcons.EMPTY_CLUES}"></i>&nbsp; `;
icons.push(OptionIcons.EmptyClues);
tooltipHTML += `<li><i class="${OptionIcons.EmptyClues}"></i>&nbsp; `;
tooltipHTML += "Empty Clues</li>";
}

if (options.oneExtraCard) {
icons.push(OptionIcons.ONE_EXTRA_CARD);
tooltipHTML += `<li><i class="${OptionIcons.ONE_EXTRA_CARD}"></i>&nbsp; `;
icons.push(OptionIcons.OneExtraCard);
tooltipHTML += `<li><i class="${OptionIcons.OneExtraCard}"></i>&nbsp; `;
tooltipHTML += "One Extra Card</li>";
}

if (options.oneLessCard) {
icons.push(OptionIcons.ONE_LESS_CARD);
tooltipHTML += `<li><i class="${OptionIcons.ONE_LESS_CARD}"></i>&nbsp; `;
icons.push(OptionIcons.OneLessCard);
tooltipHTML += `<li><i class="${OptionIcons.OneLessCard}"></i>&nbsp; `;
tooltipHTML += "One Less Card</li>";
}

if (options.allOrNothing) {
icons.push(OptionIcons.ALL_OR_NOTHING);
tooltipHTML += `<li><i class="${OptionIcons.ALL_OR_NOTHING}"></i>&nbsp; `;
icons.push(OptionIcons.AllOrNothing);
tooltipHTML += `<li><i class="${OptionIcons.AllOrNothing}"></i>&nbsp; `;
tooltipHTML += "All or Nothing</li>";
}

if (options.detrimentalCharacters) {
icons.push(OptionIcons.DETRIMENTAL_CHARACTERS);
tooltipHTML += `<li><i class="${OptionIcons.DETRIMENTAL_CHARACTERS}"></i>&nbsp; `;
icons.push(OptionIcons.DetrimentalCharacters);
tooltipHTML += `<li><i class="${OptionIcons.DetrimentalCharacters}"></i>&nbsp; `;
tooltipHTML += "Detrimental Characters</li>";
}

Expand Down
20 changes: 10 additions & 10 deletions packages/client/src/lobby/pregame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { MAX_PLAYERS, MIN_PLAYERS, getVariant } from "@hanabi-live/game";
import { assertNotNull, eRange, iRange } from "complete-common";
import { globals } from "../Globals";
import * as chat from "../chat";
import { OptionIcons } from "../enums/OptionIcons";
import * as tooltips from "../tooltips";
import { OptionIcons } from "../types/OptionIcons";
import {
getHTMLElement,
setBrowserAddressBarPath,
Expand Down Expand Up @@ -178,7 +178,7 @@ export function getOptionIcons(
let html = "";

if (options.timed) {
html += `<li><i id="${idPrefix}-options-timer-${rowId}" class="${OptionIcons.TIMED}" `;
html += `<li><i id="${idPrefix}-options-timer-${rowId}" class="${OptionIcons.Timed}" `;
html += `data-tooltip-content="#${idPrefix}-tooltip-timer-${rowId}"></i>&nbsp; (`;
html += timerFormatter(options.timeBase);
html += " + ";
Expand All @@ -198,7 +198,7 @@ export function getOptionIcons(
}

if (options.speedrun) {
html += `<li><i id="${idPrefix}-options-speedrun-${rowId}" class="${OptionIcons.SPEEDRUN}" `;
html += `<li><i id="${idPrefix}-options-speedrun-${rowId}" class="${OptionIcons.Speedrun}" `;
html += `data-tooltip-content="#${idPrefix}-tooltip-speedrun-${rowId}"></i></li>`;
html += `
<div class="hidden">
Expand All @@ -210,7 +210,7 @@ export function getOptionIcons(
}

if (options.cardCycle) {
html += `<li><i id="${idPrefix}-options-card-cycle-${rowId}" class="${OptionIcons.CARD_CYCLE}" `;
html += `<li><i id="${idPrefix}-options-card-cycle-${rowId}" class="${OptionIcons.CardCycle}" `;
html += `data-tooltip-content="#${idPrefix}-tooltip-card-cycle-${rowId}"></i></li>`;
html += `
<div class="hidden">
Expand All @@ -222,7 +222,7 @@ export function getOptionIcons(
}

if (options.deckPlays) {
html += `<li><i id="${idPrefix}-options-deck-plays-${rowId}" class="${OptionIcons.DECK_PLAYS}" `;
html += `<li><i id="${idPrefix}-options-deck-plays-${rowId}" class="${OptionIcons.DeckPlays}" `;
html += 'style="position: relative; left: 0.2em;" ';
html += `data-tooltip-content="#${idPrefix}-tooltip-deck-plays-${rowId}"></i></li>`;
html += `
Expand All @@ -235,7 +235,7 @@ export function getOptionIcons(
}

if (options.emptyClues) {
html += `<li><i id="${idPrefix}-options-empty-clues-${rowId}" class="${OptionIcons.EMPTY_CLUES}" `;
html += `<li><i id="${idPrefix}-options-empty-clues-${rowId}" class="${OptionIcons.EmptyClues}" `;
html += `data-tooltip-content="#${idPrefix}-tooltip-empty-clues-${rowId}"></i></li>`;
html += `
<div class="hidden">
Expand All @@ -247,7 +247,7 @@ export function getOptionIcons(
}

if (options.oneExtraCard) {
html += `<li><i id="${idPrefix}-options-one-extra-card-${rowId}" class="${OptionIcons.ONE_EXTRA_CARD}" `;
html += `<li><i id="${idPrefix}-options-one-extra-card-${rowId}" class="${OptionIcons.OneExtraCard}" `;
html += `data-tooltip-content="#${idPrefix}-tooltip-one-extra-card-${rowId}"></i></li>`;
html += `
<div class="hidden">
Expand All @@ -259,7 +259,7 @@ export function getOptionIcons(
}

if (options.oneLessCard) {
html += `<li><i id="${idPrefix}-options-one-less-card-${rowId}" class="${OptionIcons.ONE_LESS_CARD}" `;
html += `<li><i id="${idPrefix}-options-one-less-card-${rowId}" class="${OptionIcons.OneLessCard}" `;
html += `data-tooltip-content="#${idPrefix}-tooltip-one-less-card-${rowId}"></i></li>`;
html += `
<div class="hidden">
Expand All @@ -271,7 +271,7 @@ export function getOptionIcons(
}

if (options.allOrNothing) {
html += `<li><i id="${idPrefix}-options-all-or-nothing-${rowId}" class="${OptionIcons.ALL_OR_NOTHING}" `;
html += `<li><i id="${idPrefix}-options-all-or-nothing-${rowId}" class="${OptionIcons.AllOrNothing}" `;
html += `data-tooltip-content="#${idPrefix}-tooltip-all-or-nothing-${rowId}"></i></li>`;
html += `
<div class="hidden">
Expand All @@ -283,7 +283,7 @@ export function getOptionIcons(
}

if (options.detrimentalCharacters) {
html += `<li><i id="${idPrefix}-options-characters-${rowId}" class="${OptionIcons.DETRIMENTAL_CHARACTERS}" `;
html += `<li><i id="${idPrefix}-options-characters-${rowId}" class="${OptionIcons.DetrimentalCharacters}" `;
html += `data-tooltip-content="#${idPrefix}-tooltip-characters-${rowId}"></i></li>`;
html += `
<div class="hidden">
Expand Down
11 changes: 0 additions & 11 deletions packages/client/src/types/OptionIcons.ts

This file was deleted.

0 comments on commit 7211a02

Please sign in to comment.