Exemple #1
0
        private static void CreateRandomVowels(int v)
        {
            int n = v;
            int x = 20;  // Try at most to change 20 letters

            while (n > 0 && x > 0)
            {
                int i = r.Next(gridsize);
                int j = r.Next(gridsize);

                if (EngLetterScoring.IsConsonant((string)LetterPropGrid[i, j].ASCIIString))
                {
                    LetterPropGrid[i, j].letter = EngLetterScoring.RandomVowel();
                    n--;
                }
                x--;
            }
        }
Exemple #2
0
        private static SpellInfo.SpellOut CastSpell(SpellInfo si, LetterProp lp)
        {
            SpellInfo.SpellOut so;
            so.si     = null;
            so.worked = true;
//            bool SpellWorked = true;
//          NextSpell = null;

            switch (si.spellType)
            {
            case SpellInfo.SpellType.DestroyLetter:
                SpellDestroyLetter(lp);
                break;

            case SpellInfo.SpellType.DestroyGroup:
                SpellDestroyLetterGroupSmall(lp);
                break;

            case SpellInfo.SpellType.RandomVowels:
                CreateRandomVowels(5);
                break;

            case SpellInfo.SpellType.ChangeToVowel:
                lp.letter = EngLetterScoring.RandomVowel();
                break;

            case SpellInfo.SpellType.Burn:
                BurnTile(lp);
                break;

            case SpellInfo.SpellType.LetterSwap:
                if (LetterSwapStep == 0)
                {
                    LetterSwapFirst = lp;
                    LetterSwapStep  = 1;
                    so.si           = si;
                    return(so);
                }
                else
                {
                    so.worked       = SwapLetters(lp, LetterSwapFirst);
                    LetterSwapFirst = null;
                    LetterSwapStep  = 0;
                    so.si           = null;
                }
                break;

            case SpellInfo.SpellType.ConvertLetter:
                ConvertLetterTile(lp);
                break;

            case SpellInfo.SpellType.WordHint:
                GetBestHint(10);
                break;

            case SpellInfo.SpellType.WordHint2:
                GetBestHint(200);
                break;

            case SpellInfo.SpellType.RotateL:
                so.worked = Rotate(lp, -1);
                break;

            case SpellInfo.SpellType.RotateR:
                so.worked = Rotate(lp, 1);
                break;

            case SpellInfo.SpellType.Rotate180:
                so.worked = Rotate(lp, 4);
                break;

            case SpellInfo.SpellType.HintOnLetter:
                GetBestHint(lp);
                break;

            case SpellInfo.SpellType.AnyLetter:
                //PickALetter p = new PickALetter();
                //var result = p.ShowAsync();
                // if(result == ContentDialogResult.Primary)
            {
                //lp.letter = p.letter;
                so.worked = true;
            }
            break;

            case SpellInfo.SpellType.ColumnBGone:
                for (int i = gridsize - 1; i >= 0; i--)
                {
                    RemoveAndReplaceTile(lp.I, i);
                }
                break;

            case SpellInfo.SpellType.RowBGone:
                for (int i = gridsize - 1; i >= 0; i--)
                {
                    RemoveAndReplaceTile(i, lp.J);
                }
                break;
            }

            //freeSpell = false;
            so.si = null;

            return(so);
        }