Пример #1
0
        private async Task ValidateLetter()
        {
            Attempts++;
            var wordArray = Word.ToCharArray();

            if (wordArray.Contains(Letter))
            {
                foreach (Match m in Regex.Matches(Word, Letter.ToString()))
                {
                    Letters[m.Index] = Letter;
                }

                if (!Letters.Any(c => c == '_'))
                {
                    await Win();
                }
            }
            else
            {
                IncorrectLetters.Add(Letter);
                SetImage();

                if (IncorrectLetters.Count == 6)
                {
                    await Loose();
                }
            }
        }
        public bool IsDefiniteLetter(string letter)
        {
            if (Text == "er" && Letters.Any() && !Letters.Contains("r"))
            {
                return(true);
            }

            foreach (var pattern in PerfectPatterns)
            {
                if (pattern.Key == Text)
                {
                    if (Letters + letter == pattern.Value)
                    {
                        return(true);
                    }
                }
            }

            return(Letters + letter == Text);
        }
        public string[] GetPossibleLetters()
        {
            List <string> matches = Text.Select(each => each.ToString()).ToList();

            if (Letters.Any())
            {
                //matches = Text.Select(each => each.ToString()).ToList();
            }
            else
            {
                //matches = Text.Take(1).Select(each => each.ToString()).ToList();
            }

            // Todo:  Use patterns like this instead?
            if (ArticulationPlace == ArticulationPlaces.Glottal)
            {
                matches.AddRange(new[] { "h" });
            }

            switch (Text)
            {
            case "aa":
                matches.AddRange(new[] { "o", "h", "r", "u" });
                break;

            case "ae":
                matches.AddRange(new[] { "i" });
                break;

            case "ah":
                matches.AddRange(new[] { "i", "l", "o", "e", "t", "y", "u" });   // bustling (silent t)
                break;

            case "ao":
                matches.AddRange(new[] { "u", "h" });
                break;

            case "aw":
                return(new[] { "o", "u", "g", "h", "w" });

            case "ay":
                return(new[] { "e", "u", "y", "i", "g", "h" });

            case "b":
                matches.AddRange(new[] { "a", "i" });
                break;

            case "ch":
                matches.AddRange(new[] { "t" });
                break;

            case "dh":
                matches.AddRange(new[] { "t" });
                break;

            case "eh":
                matches.AddRange(new[] { "a", "i", "y" });
                break;

            case "ey":
                matches.AddRange(new[] { "a", "e", "i", "g", "h" });
                break;

            case "er":
                matches.AddRange(new[] { "a" });
                break;

            case "f":
                matches.AddRange(new[] { "p", "h" });
                break;

            case "g":
                matches.AddRange(new[] { "x" });
                break;

            case "k":
                /*if (Letters.Contains("q")) {
                 *  matches.AddRange(new[] {"u", "i"});
                 * }*/

                matches.AddRange(new[] { "c", "x", "h", "q" });
                break;

            case "l":
                matches.AddRange(new[] { "a" });
                break;

            case "iy":
                matches.AddRange(new[] { "e", "a" });
                break;

            case "jh":
                matches.AddRange(new[] { "d", "g" });
                break;

            case "ih":
                matches.AddRange(new[] { "e", "y", "a" });
                break;

            case "m":
                matches.AddRange(new[] { "n" });
                break;

            case "n":
                matches.AddRange(new[] { "e", "d" });
                break;

            case "ow":
                matches.AddRange(new[] { "h", "a" });
                break;

            case "oy":
                matches.AddRange(new[] { "i", "u", "e" });
                break;

            case "p":
                matches.AddRange(new[] { "e", "i", "a" });
                break;

            case "r":
                matches.AddRange(new[] { "e" });
                break;

            case "s":
                matches.AddRange(new[] { "c", "z" /*, "t"*/ });
                break;

            case "sh":
                matches.AddRange(new[] { "t", "i", "c", "e" });
                break;

            case "t":
                matches.AddRange(new[] { "d", "e" });
                break;

            case "uh":
                matches.AddRange(new[] { "o" });
                break;

            case "uw":
                matches.AddRange(new[] { "h", "i" });
                break;

            case "v":
                matches.AddRange(new[] { "s" });
                break;

            case "w":
                matches.AddRange(new[] { "h" });
                break;

            case "y":
                matches.AddRange(new[] { "j", "l" });
                break;

            case "z":
                matches.AddRange(new[] { "s", "e", "i" });
                break;

            case "zh":
                matches.AddRange(new[] { "s", "g", "i", "j" });
                break;
            }

            return(matches.ToArray());
        }