Beispiel #1
0
        private static void _Main(string[] args)
        {
            StartNewGame();
            Thread.Sleep(500);
            SpectatorClient client = new SpectatorClient(IPAddress.Loopback);

            ChessAction action;
            do
            {
                action = client.ReadAction();
                Console.WriteLine(action);
            }
            while (!(action is EndGameAction));

            while (true)
                System.Threading.Thread.Sleep(1);
        }
Beispiel #2
0
 private void CreateNewGame(SpectatorClient spectator)
 {
     var board = this.boardControl.StartNew(new Player(), new Player(), spectator.StartingFEN);
     board.Start();
     new System.Threading.Thread(() =>
     {
         ChessAction action = null;
         do
         {
             try
             {
                 action = spectator.ReadAction();
                 this.Invoke((Delegate)(Action<Board, ChessAction>)ProcessAction, board, action);
             }
             catch
             {
                 //MessageBox.Show("The server stop responding.");
                 //return;
                 continue;
             }
         }
         while (!(action is EndGameAction));
     }) { IsBackground = true }.Start();
 }
Beispiel #3
0
 private void fromNetworkToolStripMenuItem_Click(object sender, EventArgs e)
 {
     var spectator = new SpectatorClient(ServerDiscovery.FindServers().First().Address);
     CreateNewGame(spectator);
 }
Beispiel #4
0
        private void fromFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var dlg = new OpenFileDialog() { Filter = "Chess File|*.chess", InitialDirectory = Environment.CurrentDirectory };
            var result = dlg.ShowDialog(this);

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                var spectator = new SpectatorClient(dlg.OpenFile());
                CreateNewGame(spectator);
            }
        }