示例#1
0
文件: Board.cs 项目: dedale/wordox
        [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);
        }
示例#2
0
文件: Board.cs 项目: dedale/wordox
        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);
        }
示例#3
0
        [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);
        }
示例#4
0
        [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);
        }
示例#5
0
        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);
        }