// public async Task<bool> Join(long gameId, string userId, Color color) // { // var game = await _gameRepository.FindAsync(gameId); // if (game == null) // return false; // var user = await _userManager.FindByIdAsync(userId); // if (user == null) // return false; // // _ // } private void ChangeGameState(ChessGame chessGame, ref Game game, Move move, Color color) { game.Fen = chessGame.ToString(); game.ActiveColor = chessGame.ActiveColor.IsWhite(); game.LastMove = move.MoveNext; if (chessGame.IsCheckmate) { game.Winner = move.User.UserName; game.Status = FinalStatusFromColor(color); } else if (chessGame.IsStalemate) { game.Winner = "stalemate"; game.Status = 2; } }
private byte FinalStatusFromColor(Color color) => color.ColorType ? 3 : 4;