From 2fe8fa2c272e4b064142b982ea7b0f21a543e330 Mon Sep 17 00:00:00 2001 From: Markus Himmel Date: Sun, 28 Aug 2016 10:37:27 +0200 Subject: [PATCH] Fixes --- Morris/GameState.cs | 9 +++++---- Morris/GameWindow.xaml.cs | 5 ++++- Morris/Program.cs | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Morris/GameState.cs b/Morris/GameState.cs index 0e0fa5f..75f4a94 100644 --- a/Morris/GameState.cs +++ b/Morris/GameState.cs @@ -317,10 +317,6 @@ namespace Morris // Hinbewegter Stein Board[move.To] = (Occupation)NextToMove; - // Wiederholte Stellung - if (!playerPhase.Values.All(phase => phase == Phase.Placing) && history.Any(pastBoard => Board.SequenceEqual(pastBoard))) - Result = GameResult.Draw; - // ggf. entfernter Stein if (move.Remove.HasValue) { @@ -330,6 +326,11 @@ namespace Morris playerPhase[NextToMove.Opponent()] = Phase.Flying; } + // Wiederholte Stellung + if (!playerPhase.Values.All(phase => phase == Phase.Placing) && history.Any(pastBoard => Board.SequenceEqual(pastBoard))) + Result = GameResult.Draw; + + // Gegner hat nur noch zwei Steine if (playerPhase[NextToMove.Opponent()] != Phase.Placing && currentStones[NextToMove.Opponent()] == 2) Result = (GameResult)NextToMove; diff --git a/Morris/GameWindow.xaml.cs b/Morris/GameWindow.xaml.cs index 7db49f5..ab0b1fa 100644 --- a/Morris/GameWindow.xaml.cs +++ b/Morris/GameWindow.xaml.cs @@ -352,7 +352,10 @@ namespace Morris // Ungültiges Feld, einfach einen ungültigen Zug zurückgeben, damit GetNextMove // erneut aufgerufen wird if (error) - return null; + { + Dispatcher.Invoke(() => resetPositon(source)); + return null; + } // Source und Destination erhalten Anfang und Ende des Drag-Events mode = Mode.Normal; diff --git a/Morris/Program.cs b/Morris/Program.cs index 5168cbc..002c2a8 100644 --- a/Morris/Program.cs +++ b/Morris/Program.cs @@ -15,7 +15,7 @@ namespace Morris var a = new ConsoleInteraction(); var b = new RandomBot(); var w = new GameWindow(); - var g = new Game(w, w); + var g = new Game(w, b); g.AddObserver(a); g.AddObserver(w); Task.Run(() => g.Run(0));