Esempio n. 1
0
    // Use this for initialization
    void Awake()
    {
        m_Grid = GetComponent <Grid>();
        m_LetterPool.Init(transform);

        m_Validator = new WordValidator();
        m_Generator = new WordGenerator();
    }
Esempio n. 2
0
        public void DropBannedWords_WhenTheyAreInDifferentCase()
        {
            var validator = new WordValidator(new [] { "cC" });
            var source    = new[] { "a", "BB", "Cc", "cc", "CC" };
            var result    = source.Where(x => !validator.IsExcluded(x)).ToArray();

            Assert.That(result, Is.EquivalentTo(new [] { "a", "BB" }));
        }
Esempio n. 3
0
        public void AcceptEveryWord_WhenNoWordsAreBanned()
        {
            var validator = new WordValidator(new string[] {});
            var source    = new[] { "a", "BB", "cC" };
            var result    = source.Where(x => !validator.IsExcluded(x)).ToArray();

            Assert.That(result, Is.EquivalentTo(source));
        }
Esempio n. 4
0
        /// <summary>
        /// Handles playing a turn.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPlay_Click(object sender, EventArgs e)
        {
            if (!GamePlaying)
            {
                return;
            }

            var tilesPlayed = PlayerManager.CurrentPlayer.Tiles.Where(r => string.IsNullOrEmpty(r.Text)).Count();

            if (tilesPlayed == 0)
            {
                MessageBox.Show("You must place some tiles on the board and make a word to play. You can pass or swap your letters if cannot make a word. You can use the hint to see available words in your rack.");
                return;
            }

            var checkTilePositions = TileManager.ValidateTilePositions();
            var moveResult         = WordValidator.ValidateAllWordsInPlay();

            if (!checkTilePositions)
            {
                MessageBox.Show("The placement of your tiles is invalid.");
            }
            else if (!moveResult.Valid)
            {
                moveResult.Words.Where(w => !w.Valid).ToList().ForEach(w => MessageBox.Show($"{w.Text} is not a valid word"));
            }
            else
            {
                TileManager.ResetTilesInPlay();
                RackManager.FillRack(PlayerManager.CurrentPlayer.Tiles);

                StatManager.Moves            += 1;
                StatManager.ConsecutivePasses = 0;

                moveResult.Words.ForEach(w => Logger.LogMessage($"{PlayerManager.CurrentPlayer.Name} played {w.Text} for {w.Score} points"));
                Logger.LogMessage($"Turn ended - total score: {moveResult.TotalScore}");

                btnLetters.Text = $"{TileManager.TileBag.LetterCountRemaining()} Letters Remaining";

                // A player has finished all their tiles so the game is over
                if (PlayerManager.PlayerOne.Tiles.Count == 0 || PlayerManager.PlayerTwo.Tiles.Count == 0)
                {
                    GameOver();
                }

                PlayerManager.CurrentPlayer.Score += moveResult.TotalScore;
                PlayerManager.SwapCurrentPlayer();
            }
        }
Esempio n. 5
0
        public static IValidator CreateValidator(ValidationRequest request)
        {
            IValidator validator;

            switch (Path.GetExtension(request.FileName).ToLower())
            {
            case ".zip":
                validator = new ZipValidator(request);
                break;

            case ".pdf":
                validator = new PdfValidator(request);
                break;

            case ".xml":
                validator = new XmlValidator(request);
                break;

            case ".doc":
            case ".docx":
                validator = new WordValidator(request);
                break;

            case ".json":
                validator = new JsonValidator(request);
                break;

            case ".txt":
                validator = new TextValidator(request);
                break;

            case ".csv":
                validator = new CsvValidator(request);
                break;

            case ".html":
            case ".htm":
                validator = new HtmlValidator(request);
                break;

            default:
                validator = new UnknownValidator(request);
                break;
            }

            return(validator);
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            WordValidator validator = new WordValidator("Test Document.docx", FileFormatVersions.Office2016);
            List <ValidationErrorInfo> errorInfo = validator.ValidateDocument();

            validator.Dispose();
            if (errorInfo == null || errorInfo.Count > 0)
            {
                Console.WriteLine("Validation Errors!");

                foreach (var error in errorInfo)
                {
                    Console.WriteLine(error.Description);
                }
            }
            else
            {
                Console.WriteLine("No Validation Errors!");
            }

            Console.ReadKey();
        }
Esempio n. 7
0
 public BoggleBoxController()
 {
     _boggleService = new BoggleService();
     _wordValidator = new WordValidator();
 }
Esempio n. 8
0
 public BoggleService()
 {
     _wordValidator = new WordValidator();
 }