diff --git a/components/Card.tsx b/components/Card.tsx index 91aaea8..77a6103 100644 --- a/components/Card.tsx +++ b/components/Card.tsx @@ -6,8 +6,7 @@ import TiltCard from '@/components/TiltCard'; import ToolTip from '@/components/ToolTip'; import StackTheDeck from '@/components/StackTheDeck'; import Sheen from '@/components/Sheen'; -import getCardInfo from '@/tools/getCardInfo'; -import getURL from '@/tools/getURL'; +import { getCardInfo, getURL } from '@/tools'; import tarokkaCards from '@/constants/tarokkaCards'; import { layout } from '@/constants/tarokka'; diff --git a/components/CardSelect.tsx b/components/CardSelect.tsx index 482ec0c..19204d1 100644 --- a/components/CardSelect.tsx +++ b/components/CardSelect.tsx @@ -3,7 +3,7 @@ import { CircleX } from 'lucide-react'; import { useAppContext } from '@/app/AppContext'; import TarokkaDeck from '@/lib/TarokkaDeck'; -import getURL from '@/tools/getURL'; +import { getURL } from '@/tools'; import { Deck } from '@/types'; diff --git a/components/Notes.tsx b/components/Notes.tsx index 92c988b..4a3279a 100644 --- a/components/Notes.tsx +++ b/components/Notes.tsx @@ -6,7 +6,7 @@ import { CircleX, ScrollText } from 'lucide-react'; import { useAppContext } from '@/app/AppContext'; import CopyButton from '@/components/CopyButton'; import Scrim from '@/components/Scrim'; -import getCardInfo from '@/tools/getCardInfo'; +import { getCardInfo } from '@/tools'; import { cardMap, layout } from '@/constants/tarokka'; export default function Notes() { diff --git a/lib/GameStore.ts b/lib/GameStore.ts index b1e1431..fb93ec8 100644 --- a/lib/GameStore.ts +++ b/lib/GameStore.ts @@ -1,6 +1,5 @@ import Deck from '@/lib/TarokkaDeck'; -import generateID from '@/tools/simpleID'; -import parseMilliseconds from '@/tools/parseMilliseconds'; +import { generateID, parseMilliseconds } from '@/tools'; import { HOUR, DAY, SETTINGS } from '@/constants'; import { GameState, GameUpdate, Settings, Tilt } from '@/types'; diff --git a/lib/StandardDeck.ts b/lib/StandardDeck.ts index 49568a2..42a70a6 100644 --- a/lib/StandardDeck.ts +++ b/lib/StandardDeck.ts @@ -1,4 +1,4 @@ -import getRandomItems from '@/tools/getRandomItems'; +import { getRandomItems } from '@/tools'; import cards from '@/constants/standardCards'; import type { StandardCard } from '@/types'; diff --git a/lib/TarokkaDeck.ts b/lib/TarokkaDeck.ts index 7820a22..5b725b4 100644 --- a/lib/TarokkaDeck.ts +++ b/lib/TarokkaDeck.ts @@ -1,4 +1,4 @@ -import getRandomItems from '@/tools/getRandomItems'; +import { getRandomItems } from '@/tools'; import cards from '@/constants/tarokkaCards'; import type { TarokkaCard, TarokkaGameCard } from '@/types'; diff --git a/server.ts b/server.ts index cc887ef..99865ad 100644 --- a/server.ts +++ b/server.ts @@ -3,7 +3,7 @@ import { createServer } from 'http'; import { Server as SocketIOServer, type Socket } from 'socket.io'; import GameStore from '@/lib/GameStore'; -import omit from '@/tools/omit'; +import { omit } from '@/tools'; import { thirtyFPS } from '@/constants/time'; import type { ClientUpdate, GameUpdate, Tilt } from '@/types'; diff --git a/tools/getCardInfo.ts b/tools/getCardInfo.ts index 47e6d78..386433a 100644 --- a/tools/getCardInfo.ts +++ b/tools/getCardInfo.ts @@ -1,12 +1,12 @@ -import { isHighCard, isLowCard } from '@/tools/cardTypes'; +import { isHighCard, isLowCard } from '@/tools'; import { Layout, Settings, TarokkaGameCard } from '@/types'; -export default function getTooltip( +export const getCardInfo = ( card: TarokkaGameCard, position: Layout, dm: boolean, settings: Settings, -) { +) => { const { card: cardName, description, flipped } = card; let text: string[] = []; @@ -39,4 +39,4 @@ export default function getTooltip( } return text; -} +}; diff --git a/tools/getRandomItems.ts b/tools/getRandomItems.ts index df1cd7a..3c99ad8 100644 --- a/tools/getRandomItems.ts +++ b/tools/getRandomItems.ts @@ -1,4 +1,4 @@ -export default function getRandomItems(items: T[], count: number): T[] { +export const getRandomItems = (items: T[], count: number): T[] => { const shuffled = [...items]; // Fisher-Yates shuffle @@ -8,4 +8,4 @@ export default function getRandomItems(items: T[], count: number): T[] { } return count > shuffled.length ? shuffled : shuffled.slice(0, count); -} +}; diff --git a/tools/getURL.ts b/tools/getURL.ts index 5539f20..3c519e4 100644 --- a/tools/getURL.ts +++ b/tools/getURL.ts @@ -1,8 +1,8 @@ import { cardStyles, standardMap } from '@/constants/tarokka'; import { Settings, TarokkaCard, TarokkaGameCard } from '@/types'; -export default function getURL(card: TarokkaCard | TarokkaGameCard, settings: Settings) { +export const getURL = (card: TarokkaCard | TarokkaGameCard, settings: Settings) => { const styleConfig = cardStyles[settings.cardStyle]; const fileBase = settings.cardStyle === 'standard' ? standardMap[card.id] : card.id; return `${styleConfig.baseURL}${fileBase}${card.extension || styleConfig.extension}`; -} +}; diff --git a/tools/index.ts b/tools/index.ts index 2926079..b0c5d0d 100644 --- a/tools/index.ts +++ b/tools/index.ts @@ -1,4 +1,11 @@ +export * from '@/tools/cardTypes'; +export * from '@/tools/getCardInfo'; +export * from '@/tools/getRandomItems'; +export * from '@/tools/getURL'; export * from '@/tools/log'; +export * from '@/tools/omit'; +export * from '@/tools/parseMilliseconds'; export * from '@/tools/reduceTilts'; +export * from '@/tools/simpleID'; export * from '@/tools/throttle'; export * from '@/tools/validTilt'; diff --git a/tools/omit.ts b/tools/omit.ts index 3c5d349..7e7a8cc 100644 --- a/tools/omit.ts +++ b/tools/omit.ts @@ -1,7 +1,7 @@ -export default function omit>( +export const omit = >( obj: T, propToRemove: keyof T, -): Omit { +): Omit => { const { [propToRemove]: _, ...rest } = obj; return rest; -} +}; diff --git a/tools/parseMilliseconds.ts b/tools/parseMilliseconds.ts index 4b29331..802df8d 100644 --- a/tools/parseMilliseconds.ts +++ b/tools/parseMilliseconds.ts @@ -7,7 +7,7 @@ export interface ParsedMilliseconds { seconds: number; } -export default function parseMilliseconds(timestamp: number): ParsedMilliseconds { +export const parseMilliseconds = (timestamp: number): ParsedMilliseconds => { const days = Math.floor(timestamp / DAY); timestamp %= DAY; @@ -21,4 +21,4 @@ export default function parseMilliseconds(timestamp: number): ParsedMilliseconds timestamp %= SECOND; return { days, hours, minutes, seconds }; -} +}; diff --git a/tools/simpleID.ts b/tools/simpleID.ts index 61700d1..0423767 100644 --- a/tools/simpleID.ts +++ b/tools/simpleID.ts @@ -1,9 +1,7 @@ -import getRandomItems from '@/tools/getRandomItems'; +import { getRandomItems } from '@/tools'; const alphabet = '0123456789abcdefghijklmnopqrstuvwxyz'; -const generateID = (length: number = 6) => { +export const generateID = (length: number = 6) => { return getRandomItems(alphabet.split(''), length).join(''); }; - -export default generateID;