Пример #1
0
        internal static void Edit(long facebookID, string firstName, string lastName)
        {
            PolarTicTacToeDataContext dataContext = new PolarTicTacToeDataContext();

            var curPlayer = (from p in dataContext.Players
                             where p.FacebookID == facebookID
                             select p).FirstOrDefault();

            curPlayer.FirstName = firstName;
            curPlayer.LastName = lastName;

            dataContext.SubmitChanges();
        }
Пример #2
0
        internal static Player Create(long facebookID)
        {
            PolarTicTacToeDataContext dataContext = new PolarTicTacToeDataContext();

            Player newPlayer = new Player();

            newPlayer.FacebookID = facebookID;

            dataContext.Players.InsertOnSubmit(newPlayer);

            dataContext.SubmitChanges();

            return newPlayer;
        }
Пример #3
0
        internal static Player Create(long facebookID, string firstName, string lastName)
        {
            PolarTicTacToeDataContext dataContext = new PolarTicTacToeDataContext();

            Player newPlayer = new Player();

            newPlayer.FacebookID = facebookID;
            newPlayer.FirstName = firstName;
            newPlayer.LastName = lastName;

            dataContext.Players.InsertOnSubmit(newPlayer);

            dataContext.SubmitChanges();

            return newPlayer;
        }
Пример #4
0
        public static Game Create(int ChallengerID, int OpponentID)
        {
            PolarTicTacToeDataContext dataContext = new PolarTicTacToeDataContext();

            Game newGame = new Game();
            newGame.ChallengerID = ChallengerID;
            newGame.OpponentID = OpponentID;
            newGame.StartDate = DateTime.Now;

            newGame.GameState = Utils.GameState.Active.ToString();

            dataContext.Games.InsertOnSubmit(newGame);

            dataContext.SubmitChanges();

            return newGame;
        }
Пример #5
0
        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;
            }
        }
Пример #6
0
        public void setAppRequest(long appRequest)
        {
            PolarTicTacToeDataContext dataContext = new PolarTicTacToeDataContext();

            var curGame = (from p in dataContext.Games
                           where p.ID == this.ID
                           select p).FirstOrDefault();

            curGame.CurAppRequest = appRequest;

            dataContext.SubmitChanges();
        }