CodebreakerApp / Codebreaker.Xaml

MIT License
0 stars 1 forks source link

ViewModel refactoring and simplification #174

Closed szv closed 2 months ago

szv commented 2 months ago

Pull Request Summary

This pull request includes significant changes to the game logic and structure, with a focus on refactoring and simplifying the codebase. The changes are primarily in the GamePageViewModel, Game, and Move classes.

Major Changes

  1. Package Update: The Microsoft.Extensions.Options package was updated from 7.0.1 to 8.0.2.

  2. Class Removals: Several classes were removed, including GameViewModel, MoveViewModel, GamePageViewModelOptions, GameMode, GameMoveValue, SelectionAndKeyPegs, GameStateChangedMessage, and GameMoveMessage.

  3. Class Additions: New classes were added, including GameEndedMessage, GameStartedMessage, MakeMoveMessage, Field, Game, and Move.

  4. Refactoring of GamePageViewModel: This class was refactored to remove dependencies on IDialogService and IOptions<GamePageViewModelOptions>, and to add dependencies on IGamesClient and IInfoBarService. The StartGameAsync and SetMoveAsync methods were also refactored.

  5. Refactoring of Game and Move classes: The Game class was refactored to change the GameId property to Id, to add the IsFinished property, and to change the FieldValues and Moves properties from ICollection to ObservableCollection. The Move class was refactored to remove the MoveId and MoveNumber properties, and to change the GuessPegs and KeyPegs properties from ObservableCollection to ICollection.

Design Decisions

The refactoring of the GamePageViewModel, Game, and Move classes was done to simplify the codebase and improve maintainability. The removal of certain classes and properties, and the addition of others, was done to streamline the game logic and make it more intuitive. The change in dependencies for GamePageViewModel was made to improve the class's testability and decouple it from specific services. The changes in property types from ICollection to ObservableCollection (and vice versa) were made to better reflect the nature of the data being handled.

christiannagel commented 2 months ago

unit tests don't run successfully! @szv