Split methods + new test
continuous-integration/drone/push Build is passing Details

master
Jules LASCRET 11 months ago
parent 77054e7c3d
commit 08ed17959b

@ -839,8 +839,7 @@ namespace QwirkleClassLibrary.Games
score++; score++;
} }
if (direction.Item1 == 0 && orientation.Item1 == -1 && orientation.Item2 != -1 || if (ShouldIncreaseScore(direction, orientation))
direction.Item2 == 0 && orientation.Item2 == -1 && orientation.Item1 != -1)
{ {
score += 1; score += 1;
} }
@ -848,6 +847,11 @@ namespace QwirkleClassLibrary.Games
return score; return score;
} }
public static bool ShouldIncreaseScore(Tuple<int, int> direction, Tuple<int, int> orientation)
{
return direction.Item1 == 0 && orientation.Item1 == -1 && orientation.Item2 != -1 ||
direction.Item2 == 0 && orientation.Item2 == -1 && orientation.Item1 != -1;
}
/// <summary> /// <summary>
/// Returns the list of the positions of the players who still have tiles in their bag /// Returns the list of the positions of the players who still have tiles in their bag

@ -472,6 +472,14 @@ public class TestGame
Assert.Equal(expectedScore, score); 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<int, int>(dx, dy), new Tuple<int, int>(cellsX, cellsY)));
}
[Fact] [Fact]
public void Test_EndOfGame() public void Test_EndOfGame()
{ {

Loading…
Cancel
Save