private bool IsGameOver(List <Pieces> whitePieces, List <Pieces> blackPieces) { int newWins = _account.SelectedUser.Wins; int newLoss = _account.SelectedUser.Losses; // Continue if king exists. Add one to win/loss otherwise if (chessboard.KingExists(whitePieces) && chessboard.KingExists(blackPieces)) { return(false); } else if (!chessboard.KingExists(blackPieces)) { newWins = _account.AddOneToWins(_account.SelectedUser.UserId); } else if (!chessboard.KingExists(whitePieces)) { newLoss = _account.AddOneToLosses(_account.SelectedUser.UserId); } //Refresh data WhiteHistory.Content = " White Moves"; BlackHistory.Content = " Black Moves"; string data = $"{_account.SelectedUser.Name}, Wins: {newWins}, Losses: {newLoss}."; UserData.Text = data; return(true); }
public void AddOneToWinsAddsOneToWins() { using var db = new GameContext(); _account.CreateUser("Jimmy", "jkchuong", "visual"); _account.AddOneToWins("jkchuong"); _account.SetSelectedUser("jkchuong"); var wins = _account.SelectedUser.Wins; Assert.AreEqual(1, wins); }