How seakyy/casinowpf works
Project type and purpose
• This is a desktop application written in C# using .NET 8.0 and WPF.
• It simulates two casino games (Slot Machine and Blackjack) with user interactions, game history, and modular, testable logic.
• It follows the MVVM architectural pattern and uses Commands, Services, and the Observer pattern to decouple UI and business logic.
File structure
• Top-level “src/CasinoWPF” contains:
• Models: domain objects (Card, Player, GameResult, etc.) and enums
• Games: core game logic (SlotMachine, BlackJack, GameFactory)
• Services: orchestration and cross-cutting concerns (GameManager, Session, GameLogService, ComputerPlayer, Observer, RelayCommand)
• ViewModels: UI controllers that expose Models/Services to Views (MainViewModel, GameSelectionViewModel, SlotMachineViewModel, BlackJackViewModel, etc.)
• Views: WPF XAML files and code-behind for each page or window
• Converters: value converters for bindings (CountToBooleanConverter, Visibility converters)
• “src/CasinoWPF-Tests” holds MSTest unit tests for the two games.
• CI/CD configurations live in “.github/workflows” and “.gitlab-ci.yml”.
README for additional insights
• Architecture is MVVM with Commands and Observer pattern.
• CI/CD pipelines run build and tests automatically.
a. Main components
• UI Layer (Views)
• Presentation Layer (ViewModels + RelayCommand)
• Application Services Layer (GameManager, Session, GameLogService, Observer, ComputerPlayer)
• Domain Layer (Models + Enums + Game classes via GameFactory)
• Test Suite (CasinoWPF-Tests)
• CI/CD Pipeline (GitHub Actions / GitLab CI)
b. Relationships and data flows
• Views bind (two-way) to properties and commands on ViewModels
• ViewModels invoke Commands (RelayCommand) which call into Services
• Services manage game state (Session) and orchestrate gameplay via GameFactory → Domain objects
• Observer pattern propagates state changes (e.g., game round completion) back to ViewModels
• GameLogService persists history and exposes data to a GameLogView
• Tests invoke Domain/Game classes directly to verify business rules
c. Architectural patterns
• MVVM (separate UI, binding, and logic)
• Dependency Injection (services passed into ViewModels)
• Factory pattern (GameFactory creates game instances)
• Observer pattern (for state notifications)
• Command pattern (RelayCommand for user actions)
d. Key technologies/frameworks
• .NET 8.0, WPF (XAML)
• MSTest for unit testing
• GitHub Actions / GitLab CI for build & test