Description
Implement IGameRepository interface using SQLite database for persistence.
Depends on: IGameRepository interface issue
SqliteGameRepository Class
Implements IGameRepository using Microsoft.Data.Sqlite
Database Operations
SaveGame(GameState state)
- Upserts game save by player name
- Creates tables if they don't exist
LoadGame(string playerName)
- Returns GameState if found
- Returns null if not found
SaveScore(string playerName, int score)
- Inserts new leaderboard entry
- Includes timestamp
GetLeaderboard()
- Returns top 10 scores
- Ordered by score descending
- Includes player name, score, and date
Requirements
- Creates database and tables on first run
- Use 'using' statements for connection disposal
- Proper SQL parameterization to prevent injection
- Database file: classcrawler.db
Acceptance Criteria
Description
Implement IGameRepository interface using SQLite database for persistence.
Depends on: IGameRepository interface issue
SqliteGameRepository Class
Implements IGameRepository using Microsoft.Data.Sqlite
Database Operations
SaveGame(GameState state)
LoadGame(string playerName)
SaveScore(string playerName, int score)
GetLeaderboard()
Requirements
Acceptance Criteria