Пример #1
0
 public BoardFinishedEventArgs(TTTBoard board, TTTPosition[,] direct, string winner)
 {
     Board = board; DirectBoard = direct; _Winner = winner;
 }
Пример #2
0
        private void GameBoard_BoardFinished(object sender, TTTBoard.BoardFinishedEventArgs e)
        {
            var board = e.Board;

            if (e.CrossWin)
            {
                f1.Add(totalgamenumber + 2, $"Crosses ({CPlayer.Name}) wins!");
                f1.Add(0, $"Round {roundnumber} Game {roundgamenumber}: {CPlayer.Name} beat {NPlayer.Name}");
                tournamentin.SpectatorMessage($"Round {roundnumber} Game {roundgamenumber}: {CPlayer.Name} beat {NPlayer.Name}");
                CPlayer.Send("You win");
                NPlayer.Send("You lose");
                won = CPlayer;
                if (Program.AllPlayers.Contains(NPlayer))
                {
                    Program.AllPlayers.Remove(NPlayer);
                }
                f1.RemovePlayer(NPlayer.Name, roundgamenumber.ToString(), roundnumber.ToString());
                f1.FinishedGame(totalgamenumber + 2);
                SpectatorUpdate();
                BT.Start();
            }
            else if (e.Draw)
            {
                f1.Add(totalgamenumber + 2, "Draw!");
                GameBoard = new TTTBoard();
                GameBoard.BoardFinished += GameBoard_BoardFinished;
                GameBoard.gamenumber     = totalgamenumber;
                GameBoard.f1             = f1;
                GameBoard.Game           = this;
                if (Program.Quick == true)
                {
                    drawcount++;
                    if (drawcount == drawsallowed)
                    {
                        TieBreaker = true;
                        f1.Add(totalgamenumber + 2, $"{CPlayer.Name} and {NPlayer.Name} go into tie breaker");
                        CPlayer.Send("Tie");
                        NPlayer.Send("Tie");
                        SpectatorUpdate();
                        dt.Start();
                    }
                    else
                    {
                        CPlayer.Send("draw");
                        NPlayer.Send("draw");
                        DrawnGame(); // this determines who's go it is.
                        CheckLastDraw();
                        SpectatorUpdate();
                    }
                }
                else
                {
                    CPlayer.Send("draw");
                    NPlayer.Send("draw");
                    DrawnGame(); // this determines who's go it is.
                    CheckLastDraw();
                    SpectatorUpdate();
                }
            }
            else if (e.NoughtWin)
            {
                f1.Add(totalgamenumber + 2, $"Nought ({NPlayer.Name}) win!");
                f1.Add(0, $"Round {roundnumber} Game {roundgamenumber}: {NPlayer.Name} beat {CPlayer.Name}");
                tournamentin.SpectatorMessage($"Round {roundnumber} Game {roundgamenumber}: {NPlayer.Name} beat {CPlayer.Name}");
                NPlayer.Send("You win");
                CPlayer.Send("You lose");
                won = NPlayer;
                if (Program.AllPlayers.Contains(CPlayer))
                {
                    Program.AllPlayers.Remove(CPlayer);
                }
                f1.RemovePlayer(CPlayer.Name, roundgamenumber.ToString(), roundnumber.ToString());
                f1.FinishedGame(totalgamenumber + 2);
                SpectatorUpdate();
                BT.Start();
            }
        }