diff --git a/FloodIt/Logic/Gameplay/ComputerFloodRace.cs b/FloodIt/Logic/Gameplay/ComputerFloodRace.cs index bfadfa8..787243e 100644 --- a/FloodIt/Logic/Gameplay/ComputerFloodRace.cs +++ b/FloodIt/Logic/Gameplay/ComputerFloodRace.cs @@ -135,26 +135,35 @@ private List> AquisitionsByColor() { List> ret = new List>(); + Dictionary dict = new Dictionary(); + HashSet uniqueTiles = new HashSet(); - foreach (var color in Tile.colors) + for (var i = 0; i < game.GameGrid.GridDimension; i++) { - - HashSet uniqueTiles = new HashSet(); - - for (var i = 0; i < game.GameGrid.GridDimension; i++) + for (var j = 0; j < game.GameGrid.GridDimension; j++) { - for (var j = 0; j < game.GameGrid.GridDimension; j++) + Tile tile = game.GameGrid[i, j]; + if (!uniqueTiles.Contains(tile.Id) + && tile.Owner == TileOwner.None + && HasSameOwnerTileNeighbor(TileOwner.Computer, i, j)) { - Tile tile = game.GameGrid[i, j]; - if (tile.TileColor == color && tile.Owner == TileOwner.None && HasSameOwnerTileNeighbor(TileOwner.Computer, i, j)) + + uniqueTiles.Add(tile.Id); + + if (!dict.ContainsKey(tile.TileColor)) { - uniqueTiles.Add(tile.Id); + dict[tile.TileColor] = 0; } + + ++dict[tile.TileColor]; + } } + } - ret.Add(new Tuple(uniqueTiles.Count, color)); - + foreach (var color in dict.Keys) + { + ret.Add(new Tuple(dict[color], color)); } return ret.OrderByDescending(o => o.Item1).ToList(); diff --git a/FloodIt/Logic/Gameplay/TwoPlayerFloodRace.cs b/FloodIt/Logic/Gameplay/TwoPlayerFloodRace.cs index 491144e..adebd58 100644 --- a/FloodIt/Logic/Gameplay/TwoPlayerFloodRace.cs +++ b/FloodIt/Logic/Gameplay/TwoPlayerFloodRace.cs @@ -75,6 +75,7 @@ public override void OnColorSelect(Color color) turn = -turn; game.Painter.Repaint(); + OnScoreboardChanged(); if (HasEnded()) {