Add frontend TypeScript types for game data models
Define Game, Route, Pokemon, RouteEncounter, Encounter, and NuzlockeRun types mirroring the backend schema, with EncounterStatus and RunStatus discriminated union types. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
---
|
---
|
||||||
# nuzlocke-tracker-sm1b
|
# nuzlocke-tracker-sm1b
|
||||||
title: Game Data Models & Types
|
title: Game Data Models & Types
|
||||||
status: todo
|
status: completed
|
||||||
type: task
|
type: task
|
||||||
priority: normal
|
priority: normal
|
||||||
created_at: 2026-02-04T15:44:08Z
|
created_at: 2026-02-04T15:44:08Z
|
||||||
updated_at: 2026-02-04T15:45:00Z
|
updated_at: 2026-02-05T12:33:38Z
|
||||||
parent: nuzlocke-tracker-f5ob
|
parent: nuzlocke-tracker-f5ob
|
||||||
blocking:
|
blocking:
|
||||||
- nuzlocke-tracker-k5lm
|
- nuzlocke-tracker-k5lm
|
||||||
@@ -17,12 +17,14 @@ blocking:
|
|||||||
Define the core data structures and TypeScript types for the application.
|
Define the core data structures and TypeScript types for the application.
|
||||||
|
|
||||||
## Checklist
|
## Checklist
|
||||||
- [ ] Define Game type (id, name, generation, region, routes)
|
- [x] Define Game type (id, name, slug, generation, region, boxArtUrl, releaseYear)
|
||||||
- [ ] Define Route/Area type (id, name, available Pokémon, game)
|
- [x] Define Route/Area type (id, name, gameId, order)
|
||||||
- [ ] Define Pokemon type (national dex number, name, types, sprite URL)
|
- [x] Define Pokemon type (id, nationalDex, name, types, spriteUrl)
|
||||||
- [ ] Define Encounter type (route, pokemon, nickname, status, caught date)
|
- [x] Define Encounter type (id, runId, routeId, pokemonId, nickname, status, catchLevel, faintLevel, caughtAt)
|
||||||
- [ ] Define NuzlockeRun type (game, settings, encounters, start date)
|
- [x] Define NuzlockeRun type (id, gameId, name, status, rules, startedAt, completedAt)
|
||||||
- [ ] Define RuleSettings type (hardcore mode, level caps, duplicates clause, etc.)
|
- [x] Define RuleSettings type (already existed in rules.ts)
|
||||||
|
- [x] Define RouteEncounter type (id, routeId, pokemonId, encounterMethod, encounterRate)
|
||||||
|
- [x] Define EncounterStatus and RunStatus discriminated union types
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
- Keep types flexible for future expansion
|
- Keep types flexible for future expansion
|
||||||
|
|||||||
62
frontend/src/types/game.ts
Normal file
62
frontend/src/types/game.ts
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
export interface Game {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
slug: string
|
||||||
|
generation: number
|
||||||
|
region: string
|
||||||
|
boxArtUrl: string | null
|
||||||
|
releaseYear: number | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Route {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
gameId: number
|
||||||
|
order: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Pokemon {
|
||||||
|
id: number
|
||||||
|
nationalDex: number
|
||||||
|
name: string
|
||||||
|
types: string[]
|
||||||
|
spriteUrl: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RouteEncounter {
|
||||||
|
id: number
|
||||||
|
routeId: number
|
||||||
|
pokemonId: number
|
||||||
|
encounterMethod: string
|
||||||
|
encounterRate: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type EncounterStatus = 'caught' | 'fainted' | 'missed'
|
||||||
|
|
||||||
|
export interface Encounter {
|
||||||
|
id: number
|
||||||
|
runId: number
|
||||||
|
routeId: number
|
||||||
|
pokemonId: number
|
||||||
|
nickname: string | null
|
||||||
|
status: EncounterStatus
|
||||||
|
catchLevel: number | null
|
||||||
|
faintLevel: number | null
|
||||||
|
caughtAt: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RunStatus = 'active' | 'completed' | 'failed'
|
||||||
|
|
||||||
|
export interface NuzlockeRun {
|
||||||
|
id: number
|
||||||
|
gameId: number
|
||||||
|
name: string
|
||||||
|
status: RunStatus
|
||||||
|
rules: NuzlockeRules
|
||||||
|
startedAt: string
|
||||||
|
completedAt: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
// Re-export for convenience
|
||||||
|
import type { NuzlockeRules } from './rules'
|
||||||
|
export type { NuzlockeRules }
|
||||||
@@ -1 +1,2 @@
|
|||||||
|
export * from './game'
|
||||||
export * from './rules'
|
export * from './rules'
|
||||||
|
|||||||
Reference in New Issue
Block a user