async Task IHandleAsync <NewGameEventModel> .HandleAsync(NewGameEventModel message) { if (NewGameVM == null) { throw new BasicBlankException("New game was not even active. Therefore, I should not have received message for requesting new game"); } if (AlwaysNewGame == false) { await CloseSpecificChildAsync(NewGameVM); NewGameVM = null;//forgot to set to null. } if (MainVM != null) { await CloseSpecificChildAsync(MainVM); } MainVM = null; //looks like i have to set to null manually. //i think i should load it again anyways (?) and set the old to nothing. so a fresh one will be created. //maybe we don't need the update code but we still need the load processes. //since we have code for closing, hopefully i am not forced to figure out how to delete controls (?) await _saves.DeleteSinglePlayerGameAsync(); //i think. await NewGameRequestedAsync(); await StartNewGameAsync(); }
public async Task MakeMoveAsync(GameSpace thisSpace) { var thisList = MoveList(thisSpace); foreach (var item in thisList) { item.HasImage = false; //for now. } var nextSpace = _saveRoot.SpaceList[PreviousPiece]; nextSpace.HasImage = false; GameSpace tempPiece = new GameSpace(); tempPiece.Color = cs.Blue; tempPiece.HasImage = true; await Aggregator.AnimateMovePiecesAsync(PreviousPiece, thisSpace.Vector, tempPiece); thisSpace.HasImage = true; PreviousPiece = new Vector(); //i think int Manys = PiecesRemaining(); if (Manys == 1) { await _thisState.DeleteSinglePlayerGameAsync(); await ShowWinAsync(); return; } await _thisState.SaveSimpleSinglePlayerGameAsync(_saveRoot); }
public async Task MakeMoveAsync(XPuzzleSpaceInfo thisSpace) { _results = EnumMoveList.None; if (IsValidMove(thisSpace) == false) { _results = EnumMoveList.TurnOver; return; } XPuzzleSpaceInfo previousSpace; previousSpace = _games.SpaceList[PreviousOpen]; previousSpace.Color = cs.Navy; thisSpace.Color = cs.Black; previousSpace.Text = thisSpace.Text; thisSpace.Text = ""; PreviousOpen = thisSpace.Vector; //i think if (HasWon() == true) { _results = EnumMoveList.Won; //no saving of game. await _thisSave.DeleteSinglePlayerGameAsync(); return; } await _thisSave.SaveSimpleSinglePlayerGameAsync(_games); _results = EnumMoveList.MadeMove; }
//private async Task RestoreGameAsync() //{ // _saveRoot = await _thisState.RetrieveSinglePlayerGameAsync<MinesweeperSaveInfo>(); //} public async Task ShowWinAsync() { await UIPlatform.ShowMessageAsync("You Win"); //ThisMod.NewGameVisible = true; await _thisState.DeleteSinglePlayerGameAsync(); //send message to show win. await this.SendGameOverAsync(); }
public async Task FinishRoundAsync() { _saveRoot !.ThisStats.Turn = "None"; _saveRoot.PlayerList.ForEach(x => { if (HasWon(x.Id) == true) { x.WonPrevious = true; x.Wins++; } else { x.WonPrevious = false; x.Losses++; } if (x.PlayerCategory == EnumPlayerCategory.Self) { _saveRoot.ThisStats.Wins = x.Wins; _saveRoot.ThisStats.Losses = x.Losses; } }); if (_saveRoot.WhatNumber < 6) { _saveRoot.WhatNumber += 1; //_thisMod.NewGameVisible = true; await ShowRoundAsync(); _command.IsExecuting = false; } else { _saveRoot.WhatSet += 1; if (_saveRoot.WhatSet < 5) { _saveRoot.WhatNumber = 1; await ShowRoundAsync(); //iffy. //_thisMod.NewGameVisible = true; //_thisMod.CanEndTurn = true; _command.IsExecuting = false; } else { _saveRoot.ThisStats.Status = "Game is over"; await _thisState.DeleteSinglePlayerGameAsync(); await EndGameAsync(); } } }