diff --git a/Qwirkle/QwirkleClassLibrary/Games/Game.cs b/Qwirkle/QwirkleClassLibrary/Games/Game.cs index 00ac47f..9f046e7 100644 --- a/Qwirkle/QwirkleClassLibrary/Games/Game.cs +++ b/Qwirkle/QwirkleClassLibrary/Games/Game.cs @@ -839,8 +839,7 @@ namespace QwirkleClassLibrary.Games score++; } - if (direction.Item1 == 0 && orientation.Item1 == -1 && orientation.Item2 != -1 || - direction.Item2 == 0 && orientation.Item2 == -1 && orientation.Item1 != -1) + if (ShouldIncreaseScore(direction, orientation)) { score += 1; } @@ -848,7 +847,12 @@ namespace QwirkleClassLibrary.Games return score; } - + public static bool ShouldIncreaseScore(Tuple direction, Tuple orientation) + { + return direction.Item1 == 0 && orientation.Item1 == -1 && orientation.Item2 != -1 || + direction.Item2 == 0 && orientation.Item2 == -1 && orientation.Item1 != -1; + } + /// /// Returns the list of the positions of the players who still have tiles in their bag /// diff --git a/Qwirkle/TestBase/TestGame.cs b/Qwirkle/TestBase/TestGame.cs index ede3708..1775ecc 100644 --- a/Qwirkle/TestBase/TestGame.cs +++ b/Qwirkle/TestBase/TestGame.cs @@ -471,6 +471,14 @@ public class TestGame Assert.Equal(expectedScore, score); } + + [Theory] + [InlineData(0, -1, -1, 6)] + [InlineData(1, 0, 4, -1)] + public void Test_ShouldIncreaseScore(int dx, int dy, int cellsX, int cellsY) + { + Assert.True(Game.ShouldIncreaseScore(new Tuple(dx, dy), new Tuple(cellsX, cellsY))); + } [Fact] public void Test_EndOfGame()