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; }
public async Task MakeMoveAsync(XPuzzleSpaceInfo space) { await _gameBoard !.MakeMoveAsync(space); EnumMoveList NextMove = _gameBoard.Results(); if (NextMove == EnumMoveList.TurnOver) { return; //will automatically enable it again. } if (NextMove == EnumMoveList.Won) { await UIPlatform.ShowMessageAsync("Congratulations, you won"); await this.SendGameOverAsync(); //only if you won obviously. } }
public bool IsValidMove(XPuzzleSpaceInfo thisSpace) //so it can be used for testing { if (thisSpace.Vector.Column == PreviousOpen.Column && thisSpace.Vector.Row == PreviousOpen.Row) { return(false); } XPuzzleSpaceInfo newSpace; newSpace = _games.SpaceList[PreviousOpen]; if (thisSpace.Vector.Column + 1 == newSpace.Vector.Column) { if (thisSpace.Vector.Row == newSpace.Vector.Row) { return(true); } } if (thisSpace.Vector.Column - 1 == newSpace.Vector.Column) { if (thisSpace.Vector.Row == newSpace.Vector.Row) { return(true); } } if (thisSpace.Vector.Row + 1 == newSpace.Vector.Row) { if (thisSpace.Vector.Column == newSpace.Vector.Column) { return(true); } } if (thisSpace.Vector.Row - 1 == newSpace.Vector.Row) { if (thisSpace.Vector.Column == newSpace.Vector.Column) { return(true); } } return(false); }
public async Task MakeMoveAsync(int row, int column) { XPuzzleSpaceInfo thisSpace = _games.SpaceList[row, column]; await MakeMoveAsync(thisSpace); //so i can do for testing. }
public bool IsValidMove(int row, int column) { XPuzzleSpaceInfo thisSpace = _games.SpaceList[row, column]; return(IsValidMove(thisSpace)); }