internal static bool PlayMove(int id, int player, Tuple<int, int> spot, out int? winner, out string message) { PolarTicTacToeDataContext dataContext = new PolarTicTacToeDataContext(); var game = (from p in dataContext.Games where p.ID == id select p).FirstOrDefault(); var gameRules = new GameRules(); if (gameRules.HasPlayed(game, spot)) { message = "Spot already played"; winner = null; return false; } else { string move = spot.Item1 + ";" + spot.Item2 + ";" + String.Format("{0:g}", DateTime.Now) + ";false,"; game.Moves = game.Moves ?? ""; game.Moves += move; if (gameRules.IsFinished(game, out winner)) { winner = player; game.WinnerID = winner; game.GameState = Utils.GameState.Finished.ToString(); } dataContext.SubmitChanges(); message = ""; return true; } }