Esempio n. 1
0
        public void Finish(GameResultE gameResult)
        {
            if (Flags.IsGameFinished)
            {
                return; // we can not finish a game more than once
            }

            if (BeforeFinish != null)
            {
                BeforeFinish(this, EventArgs.Empty);
            }

            GameResult = gameResult;

            switch (gameResult)
            {
            case GameResultE.None:
                break;

            case GameResultE.InProgress:
                break;

            case GameResultE.WhiteWin:
                GameData.Result = "1-0";
                break;

            case GameResultE.WhiteLose:
                GameData.Result = "0-1";
                break;

            case GameResultE.Draw:
                GameData.Result = "1/2-1/2";
                break;

            case GameResultE.Absent:
                GameData.Result = "Line";
                break;

            case GameResultE.NoResult:
                GameData.Result = "Line";
                break;

            default:
                break;
            }

            Notations.GameFinished();

            GameData.Save();

            AutoSaveGame();

            if (AfterFinish != null)
            {
                AfterFinish(this, EventArgs.Empty);
            }
        }
Esempio n. 2
0
        public void Paste(DataTable moves)
        {
            if (BeforePaste != null)
            {
                BeforePaste(this, EventArgs.Empty);
            }

            Moves.DataTable.Clear();
            Notations.NotationView.Clear();

            AddMoves(moves);

            if (Flags.IsOffline)
            {
                // as now on paste, we set last move selected,
                // so currentMove points to that last move
                // and also clock is set by that move.
                //CurrentMove = RootMove.Clone();
                //Clock.Reset();

                Clock.Stop();
                GameResult = GameResultE.InProgress;
            }
            else
            {
                Notations.GameFinished();

                if (GameResult != GameResultE.InProgress)
                {
                    Clock.Stop();
                }
            }

            if (AfterPaste != null)
            {
                AfterPaste(this, EventArgs.Empty);
            }
        }
Esempio n. 3
0
        public void Finish(GameResultE gameResult)
        {
            if (Flags.IsGameFinished)
            {
                return; // we can not finish a game more than once
            }

            if (BeforeFinish != null)
            {
                BeforeFinish(this, EventArgs.Empty);
            }

            GameResult = gameResult;

            switch (gameResult)
            {
            case GameResultE.None:
                break;

            case GameResultE.InProgress:
                break;

            case GameResultE.WhiteWin:
                GameData.Result = "1-0";
                break;

            case GameResultE.WhiteLose:
                GameData.Result = "0-1";
                break;

            case GameResultE.Draw:
                GameData.Result = "1/2-1/2";
                break;

            case GameResultE.Absent:
                GameData.Result = "Line";
                break;

            case GameResultE.NoResult:
                GameData.Result = "Line";
                break;

            case GameResultE.ForcedWhiteLose:
                GameData.Result = "0-1 (Forced black win)";
                break;

            case GameResultE.ForcedWhiteWin:
                GameData.Result = "1-0 (Forced white win)";
                break;

            case GameResultE.ForcedDraw:
                GameData.Result = "1/2-1/2 (Forced draw)";
                break;

            default:
                break;
            }

            Notations.GameFinished();

            if (!Flags.IsDatabaseGame)
            {
                GameData.Save();
                AutoSaveGame();
            }

            //if (Flags.IsOnline && Flags.IsTimeExpired && (Flags.IsMyTurn || Flags.IsTournamentMatchTimeExpired))
            //{
            //    SocketClient.TimeExpired(DbGame.GameID, GameResult, DbGame.OpponentUserID, Flags.Flags);
            //}

            if (AfterFinish != null)
            {
                AfterFinish(this, EventArgs.Empty);
            }
        }