[Test] public void TestPlayUnrelated() { var part = new WordPart("MER", new Cell(4, 4), Direction.Right); var played = part.Play(new Cell(0, 0), 'E'); Assert.AreEqual(part, played); }
public void TestPlay(string word, Direction direction, int row, int column, char letter, string newWord, int newRow, int newColumn) { var part = new WordPart(word, new Cell(4, 4), direction); var played = part.Play(new Cell(row, column), letter); Assert.AreEqual(newWord, played.Word); Assert.AreEqual(new Cell(newRow, newColumn), played.First); Assert.AreEqual(direction, played.Direction); }
[Test] public void TestPlayVortexAddStars() { var part1 = new WordPart("LETTRE", new Cell(4, 2), Direction.Right); var board1 = new Board().Play(part1); var part2 = new WordPart("JOUES", new Cell(0, 8), Direction.Down); var played = LetterPlayTest.GetPlayed(part2); var extra = part1.Play(new Cell(4, 8), 'S'); var play = new PlayPath(part2, new WordPartCollection(extra), played.ToConstant(), new ConstantList <char>()); var board2 = board1.Play(play); Assert.AreEqual(new PlayerScore(0, 0), board2.Score.Current); Assert.AreEqual(new PlayerScore(12, 0), board2.Score.Other); }
[Test] public void TestPlaySecondExpert() { var part1 = new WordPart("LETTRE", new Cell(4, 2), Direction.Right); var board1 = new Board().Play(part1); var part2 = new WordPart("MOTEUR", new Cell(1, 8), Direction.Down); var played = LetterPlayTest.GetPlayed(part2); var extra = part1.Play(new Cell(4, 8), 'E'); var play = new PlayPath(part2, new WordPartCollection(extra), played, new ConstantList <char>()); var board2 = board1.Play(play); Assert.AreEqual(new PlayerScore(0, 0), board2.Score.Current); Assert.AreEqual(new PlayerScore(12, 1), board2.Score.Other); }
public WordPart Play(Cell cell, char letter) { WordPart part = null; var beforePlayed = before == null ? (WordPart)null : before.Play(cell, letter); var afterPlayed = after == null ? (WordPart)null : after.Play(cell, letter); if (beforePlayed != null && afterPlayed != null) { part = beforePlayed.Merge(afterPlayed); } else if (beforePlayed != null) { part = beforePlayed; } else if (afterPlayed != null) { part = afterPlayed; } return(part); }