void Move(Move move) { TimeSpan elapsed = moveWatch.Elapsed; if (board.CurrentPlayer == player0) { if (elapsed > player0MaxMove) { p0Series.Title = string.Format("{0} ({1})", player0.Name, player0MaxMove = elapsed); } } else if (elapsed > player1MaxMove) { p1Series.Title = string.Format("{0} ({1})", player1.Name, player1MaxMove = elapsed); } if (move == null) { Result = string.Format("{0} hat aufgegeben!", board.CurrentPlayer.Name); CheckForTimeout(player0, player0MaxMove); CheckForTimeout(player1, player1MaxMove); Close(); return; } Debug.WriteLine(board.CurrentPlayer.Name + " : " + move.From + " - " + move.To); if (board.OpposingPlayer is Server.NetworkEnemy) { ((Server.NetworkEnemy)board.OpposingPlayer).ReportEnemyMove(move); } IPlayer current = board.CurrentPlayer; board = board.MovePiece(move.From, move.To); p0Points.Add(new Point(moves, board.GetPoints(player0))); p1Points.Add(new Point(moves, board.GetPoints(player1))); moves++; ShowBoard(); Delay(TimeSpan.FromMilliseconds(800) - elapsed, () => { if (!board.IsFilled && board.GetPoints(player0) > 0 && board.GetPoints(player1) > 0) { moveWatch.Restart(); if (!(board.CurrentPlayer is HumanPlayer)) { board.CurrentPlayer.MakeMove(board, board.CurrentPlayer != current ? move : null, Move); } } else { Result = string.Format("{0} hat gewonnen! {1}", (board.GetPointDelta(player0) > 0 ? player0 : player1).Name, Title); CheckForTimeout(player0, player0MaxMove); CheckForTimeout(player1, player1MaxMove); Close(); } }); }
void ShowBoard() { this.boardControl.ItemsSource = board.Positions.Select(pos => new PieceVM { Position = pos, PieceColor = board.IsHole(pos) ? Brushes.Gray : board[pos] == null ? null : board[pos] == player0 ? Brushes.Black : Brushes.White, StrokeThickness = board[pos] != null ? 1.0 : 0.0 }); Title = board.GetPoints(player0) + " - " + board.GetPoints(player1); }