public void GameEndVerify_GameEndScoring_ShouldFail() { GameState gs = new GameState(); Player p1 = new Player(); Tile tile = new Tile('A', 12); p1.PlayingTiles.Add(tile); Player p2 = new Player(); tile = new Tile('B', 10); p2.PlayingTiles.Add(tile); Player p3 = new Player(); gs.ListOfPlayers.Add(p1); gs.ListOfPlayers.Add(p2); gs.ListOfPlayers.Add(p3); foreach (Player p in gs.ListOfPlayers) { foreach (Tile t in p.PlayingTiles) { p1.Score += AllTiles.ScoreOfLetter(t.TileChar); p2.Score -= AllTiles.ScoreOfLetter(t.TileChar); } } bool result = GameEndVerify.GameEndScoring(gs); Assert.IsFalse(result); }
public void GameEndVerify_GameEndScoring_TilebagLessThanSeven_And_ExistsPlayerNoTiles_ShouldPass() { GameState gs = new GameState(); Player p1 = new Player(); Tile tile = new Tile('A', 12); p1.PlayingTiles.Add(tile); Player p2 = new Player(); tile = new Tile('B', 10); p2.PlayingTiles.Add(tile); Player p3 = new Player(); gs.ListOfPlayers.Add(p1); gs.ListOfPlayers.Add(p2); gs.ListOfPlayers.Add(p3); foreach (Player p in gs.ListOfPlayers) { foreach (Tile t in p.PlayingTiles) { p1.Score += AllTiles.ScoreOfLetter(t.TileChar); p2.Score -= AllTiles.ScoreOfLetter(t.TileChar); } } gs.TilesBag.ListTiles.RemoveRange(5, 94); bool result = GameEndVerify.GameEndScoring(gs); Assert.IsTrue(result); }
public void AllTiles_ScoreOfLetter_O_Should_Return_1() { // Arrange // Act var result = AllTiles.ScoreOfLetter('O'); // Reset // Assert Assert.AreEqual(1, result); }
public void AllTiles_ScoreOfLetter_IllegalCharacter_Should_Return_0() { // Arrange // Act var result = AllTiles.ScoreOfLetter('*'); // Reset // Assert Assert.AreEqual(0, result); }
// Utility class for scoring public static int ScoreCalc(int fix, int j, int jM, string direction, char[,] b, BoardTiles bt) { int sum = 0; List <int> WordMultiply = new List <int>(); if (direction == "h") { for (int q = j; q <= jM; ++q) { if (b[fix, q] != '\0') { sum += AllTiles.ScoreOfLetter(b[fix, q]) * bt.LetterMultiplier(fix, q); if (bt.WordMultiplier(fix, q) != 1) { WordMultiply.Add(bt.WordMultiplier(fix, q)); } } } foreach (int n in WordMultiply) { sum *= n; } } else if (direction == "v") { for (int q = j; q <= jM; ++q) { if (b[q, fix] != '\0') { sum += AllTiles.ScoreOfLetter(b[q, fix]) * bt.LetterMultiplier(q, fix); if (bt.WordMultiplier(q, fix) != 1) { WordMultiply.Add(bt.WordMultiplier(q, fix)); } } } foreach (int n in WordMultiply) { sum *= n; } } return(sum); }