private void ToggleEditMode()
 {
     Model.EditMode    = !Model.EditMode;
     Model.EditorState = Model.CommittedState;
     ClearMove();
     Model.AvailableActions = Model.EditMode ? null :
                              AvailableActionController.GetAvailableActions(Model.CommittedState, new HashSet <Guid>());
 }
 private void NewGame()
 {
     Model.Game = new GameState {
         new NewGame()
     };
     Model.CommittedState = Model.Game.Last().NewState;
     Model.EditMode       = false;
     ClearMove();
     Model.AvailableActions =
         AvailableActionController.GetAvailableActions(Model.CommittedState, new HashSet <Guid>());
 }
 private void CommitEditedBoard(State state)
 {
     Model.Game.Add(new BoardEditor {
         InitialState = Model.CommittedState, NewState = state
     });
     Model.CommittedState = state;
     Model.EditMode       = false;
     Model.EditorState    = state;
     ClearMove();
     Model.AvailableActions =
         AvailableActionController.GetAvailableActions(Model.CommittedState, new HashSet <Guid>());
 }
 private void LoadGame(State state)
 {
     Model.Game = new GameState {
         new LoadState(state)
     };
     Model.CommittedState = state;
     Model.EditMode       = false;
     Model.EditorState    = state;
     ClearMove();
     Model.AvailableActions =
         AvailableActionController.GetAvailableActions(Model.CommittedState, new HashSet <Guid>());
 }
 private void CommitMove()
 {
     if ((Model.SelectionState == SelectionState.EmptySelected ||
          Model.SelectionState == SelectionState.MoveSelected) && (Model.ActionsByObjectTargetSize?.Any() ?? false))
     {
         var(updatedModel, errorMessage) =
             Model.Game.CommitPlayerMove(Model.ActionsByObjectTargetSize.First().Action);
         if (errorMessage == null)
         {
             Model.CommittedState = updatedModel;
             ClearMove();
             var seenList = new HashSet <Guid>();
             Model.AvailableActions =
                 AvailableActionController.GetAvailableActions(Model.CommittedState, seenList);
         }
     }
 }
        public GamePlayerController(IGamePlayerModel model, IGamePlayerView view)
        {
            Model                   = model;
            View                    = view;
            view.InputEvent        += ViewOnInputEvent;
            view.NavigateEvent     += ViewOnNavigateEvent;
            Model.CommittedState    = Model.Game.Last().NewState;
            Model.SelectionObject   = Location.Undefined;
            Model.SelectionTarget   = Location.Undefined;
            Model.SelectedVariation = null;
            Model.EditorState       = Model.CommittedState;
            Model.InHand            = Cell.Empty;
            Model.SelectionState    = SelectionState.Unselected;
            var seenList = new HashSet <Guid>();

            Model.AvailableActions =
                AvailableActionController.GetAvailableActions(Model.CommittedState, seenList);
            Model.EditMode     = false;
            Model.Restrictions = RestrictionState.None;
        }