Beispiel #1
0
        //==============================================================================
        //                                  The End
        //==============================================================================
        public void Fin()
        {
            Player winner = LiveBoard.PlayerOne == WhosTurn ? LiveBoard.PlayerTwo : LiveBoard.PlayerOne;
            Player loser  = LiveBoard.PlayerOne == WhosTurn? LiveBoard.PlayerOne : LiveBoard.PlayerTwo;
            string result;

            if (LiveBoard.Result == GameResult.BoardFlipped)
            {
                result = $"{LiveBoard.Result}! We will never Know..";
            }
            else if (LiveBoard.Result == GameResult.Draw)
            {
                result = $"Draw. No end game here.";
            }
            else
            {
                result = $"{LiveBoard.Result}! {winner} Wins! {LiveBoard.MoveArchive.Count / 2} moves";
            }

            GUI.RenameHeader(result);
            GUI.lbMoves.Items.Insert(0, $"Game Complete - {result}");
            GUI.lbMoves.Items.Insert(0, "");
            GUI._lbErrors.Items.Insert(0, $"Game Complete - {result}");

            if (!nGamesOn)
            {
                GUI.SetWindow_NoGameInProgress();
            }
            if (ViewBotsEnd)
            {
                LiveBoard.UpdateBoardGUI();
            }

            GameStat newGameStat = new GameStat(LiveBoard);

            GameStats.Add(newGameStat);

            if (winner.isBot)
            {
                winner.BotBrain.AddRecord(newGameStat);
            }
            if (loser.isBot)
            {
                loser.BotBrain.AddRecord(newGameStat);
            }

            //Bind the DataGrid to the Bot Records
            GUI.DG1.DataContext = BotController.GetBotRecords();

            if (nGamesOn)
            {
                GUI._txtNGames.Text = (int.Parse(GUI._txtNGames.Text) - 1).ToString();
            }

            GameOnView = false;
        }