KoogleApp/CLAUDE.md

3.1 KiB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Build & Test Commands

# Build solution
dotnet build KoogleApp.sln

# Run the application
dotnet run --project KoogleApp/KoogleApp.csproj

# Run all tests
dotnet test

# Run specific test class
dotnet test --filter "FullyQualifiedName~Koogle.Tests.ReducerTests.ThrowPanelStateTests"

# Run specific test method
dotnet test --filter "FullyQualifiedName~Koogle.Tests.GameTraining.GameTrainingServiceTest.ServiceWorksCorrectly"

Entity Framework Migrations

# Create migration
dotnet ef migrations add <MigrationName> --project ./KoogleApp/KoogleApp.csproj

# Update database (Development)
dotnet ef --startup-project ./KoogleApp/KoogleApp.csproj --project ./KoogleApp/KoogleApp.csproj database update -- Development

Architecture Overview

This is a Blazor Server application (.NET 9) for tracking a 9-pin bowling (Kegeln) game. It uses:

  • Fluxor for state management (Redux pattern)
  • MudBlazor for UI components
  • SignalR for real-time synchronization between clients
  • Entity Framework Core with SQL Server

Fluxor Store Structure (Store/)

The state is organized into feature slices following the Redux pattern:

  • Store/Game/ - Core game state management
    • ThrowPanel/ - Pin states (9 pins), throw counter, throw mode (Reposition/Decrease)
    • Participants/ - Active players and turn order
    • Setup/ - Game configuration state
    • UndoRedo/ - History management for game actions
    • Menus/ - Game-specific menu actions
    • ThrowTimer/ - Timer state for throws
  • Store/Player/ - Player management (CRUD)
  • Store/DayFeature/ - Day/session management
  • Store/ModelFeature/ - Shared model state

Each feature contains: State.cs, Actions.cs, Reducers.cs, Effects.cs, Selectors.cs

Game Plugin System (Games/)

Games are implemented as plugins via IKnownGame interface:

  • IKnownGame - Defines game metadata and component types
  • IGameService - Handles game logic (throws, player progression)
  • IGameSetupModel / IGameModel / IGameState - Data contracts with JSON serialization support

Current implementations:

  • Games/Training/ - Training mode
  • Games/Shit/ - "Shit" game variant

To add a new game:

  1. Create folder in Games/ with IKnownGame implementation
  2. Create setup component (Razor), board component, and IGameService implementation
  3. Add JSON type discriminator to IGameState and IGameSetupModel interfaces

Key Models

  • ThrowPanelState - Contains 9 pin states (PinStatus: Standing/Fallen/Disabled), throw mode, throw counter
  • GameProgress - Tracks state transitions during a throw (before/after states)
  • ParticipantsState - Player order and turn tracking

Real-time Sync

SharedModelHub (SignalR) broadcasts state changes between connected clients. HubConnectionService manages client-side connections.

Services Registration

Services/ServiceExtension.cs contains DI registration:

  • AddDbServices() - Database and Identity
  • AddAppServices() - Fluxor, repositories, game services (auto-discovered via reflection)