Files
whattoplay/src/features/games/schema.ts

37 lines
1004 B
TypeScript

import type { GameState } from "@/shared/db/schema"
export const gameStateLabels: Record<GameState, string> = {
not_set: "Not Set",
wishlisted: "Wishlisted",
playlisted: "Playlisted",
playing: "Playing",
finished: "Finished",
perfected: "Perfected",
abandoned: "Abandoned",
bad_game: "Bad Game",
}
export const gameStateColors: Record<GameState, string> = {
not_set: "bg-gray-400",
wishlisted: "bg-purple-500",
playlisted: "bg-blue-500",
playing: "bg-green-500",
finished: "bg-emerald-600",
perfected: "bg-yellow-500",
abandoned: "bg-red-500",
bad_game: "bg-red-700",
}
export function formatRating(rating: number): string {
if (rating < 0) return "Unrated"
const stars = rating / 2
const full = Math.floor(stars)
const half = stars % 1 >= 0.5 ? "½" : ""
return `${"★".repeat(full)}${half}${"☆".repeat(5 - full - (half ? 1 : 0))}`
}
export function formatPlaytime(hours: number): string {
if (hours < 1) return `${Math.round(hours * 60)}m`
return `${hours.toFixed(1)}h`
}