コード例 #1
0
ファイル: Program.cs プロジェクト: mygibbs/Chess
        static void Main(string[] args)
        {
            Board = new ChessBoard();
            Board.GameEnded += (b, w) => { Winner = w; };

            while (!Board.GameOver)
            {
                Draw();
                Console.SetCursorPosition(40, 22);
                Console.Write("From: ");
                string from = Console.ReadLine();
                Console.SetCursorPosition(40, 23);
                Console.Write("To:   ");
                string to = Console.ReadLine();

                Console.SetCursorPosition(40, 21);

                try
                {
                    if (!Board[from].To(Board[to]))
                    {
                        Console.Write("Invalid move.");
                        Console.ReadLine();
                    }
                }
                catch { Console.Write("Invalid move."); Console.ReadLine(); }
            }

            Draw();
            Console.SetCursorPosition(40, 22);
            Console.Write("Game Over: ");
            Console.Write((Winner == ChessWinner.StaleMate ? "Stalemate" : Winner.ToString() + " won") + "!");
            Console.ReadLine();
        }
コード例 #2
0
ファイル: ChessGame.xaml.cs プロジェクト: mygibbs/Chess
 private void GameOver(ChessClientPlayer player, ChessWinner r)
 {
     this.InvokeIfRequired(() =>
         {
             if (r != (ChessWinner)0) MessageBox.Show((r == ChessWinner.StaleMate ? "Stalemate" : r.ToString() + " wins") + "!", "Game Over");
             else MessageBox.Show("A player quit.");
             this.Close();
         });
 }