private void FindAllWords(StringBuilder curword, int i, int j) { curword.Append(LetterGrid[i, j].ASCIIChar); if (curword.Length < 15) { if (curword.Length >= 3) { if (EngLetterScoring.IsWord(curword)) { Word w = new Word(CurWordList); if (!WordsFromLetter.Contains(w)) { WordsFromLetter.Add(w); } } } if (EngLetterScoring.PartialExists(curword.ToString())) { if (i > 0) { if (j > 0) { FindAllWords(curword, i - 1, j - 1); } FindAllWords(curword, i - 1, j); if (j < WSGameState.gridsize - 1) { FindAllWords(curword, i - 1, j + 1); } } if (j > 0) { FindAllWords(curword, i, j - 1); } if (j < WSGameState.gridsize - 1) { FindAllWords(curword, i, j + 1); } if (i < WSGameState.gridsize - 1) { if (j > 0) { FindAllWords(curword, i + 1, j - 1); } FindAllWords(curword, i + 1, j); if (j < WSGameState.gridsize - 1) { FindAllWords(curword, i + 1, j + 1); } } } } curword.Remove(curword.Length - 1, 1); // one by one add each letter. If there is no match, then stop that branch }
public static int ScoreManna() { int addedManna = EngLetterScoring.ScoreManna(SelLetterList); Manna += addedManna; UpdateManaScore(); return(addedManna); }
public static void InitGameGlobal() { GameObject go = GameObject.Find("BoardBackground"); boardScript = (Board)go.GetComponent(typeof(Board)); EngLetterScoring.LoadDictionary(); LetterProp.InitLetterPropertyList(boardScript); }
public string LetterPopup() { string ret = Convert.ToChar(letter).ToString() + "=" + EngLetterScoring.LetterValue(letter).ToString(); if (GetLetterMult() > 1) { ret += " Letter x" + GetLetterMult().ToString(); } else if (GetWordMult() >= 1) { ret += " Word x" + (GetWordMult() + 1).ToString(); } return(ret); }
private static void ConvertLetterTile(LetterProp lp) { byte changeletter = lp.letter; for (int i = gridsize - 1; i >= 0; i--) { for (int j = gridsize - 1; j >= 0; j--) { if (LetterPropGrid[i, j].letter == changeletter) { LetterPropGrid[i, j].letter = EngLetterScoring.GetRandomLetter(false, GetFortune()); } } } }
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--; } }
public LetterProp(int level, bool levelup, int _i, int _j, Transform _tf) { tt = CreateNewTile(level, levelup); Tf = _tf; LetterAnimator = Tf.GetChild(0).gameObject.GetComponent <Animator>(); tileScript = (Tile)Tf.GetChild(0).gameObject.GetComponent(typeof(Tile)); tileScript.SetPos(I, J, this); letter = EngLetterScoring.GetRandomLetter(IsBurning(), WSGameState.GetFortune()); I = _i; J = _j; UpdateLetterDisplay(); UpdateMaterial(); }
private static void AddToTryList() { WordScoreItem wsi = new WordScoreItem() { word = GetCurrentWord(), score = ScoreWord(), wordscorestring = EngLetterScoring.GetWordTally(SelLetterList), simplescore = ScoreWordSimple() }; int indx = TryWordList.FindIndex(f => (f.score < wsi.score)); if (indx >= 0) { TryWordList.Insert(indx, wsi); } else { TryWordList.Add(wsi); } boardScript.ClearTryList(); foreach (WordScoreItem wsi_I in TryWordList) { boardScript.AddTryList(wsi_I.word + " " + wsi_I.score.ToString()); //TryList.Items.Add(wsi_I.word + " " + wsi_I.score.ToString()); } }
internal static string ScoreWordString() { return(EngLetterScoring.ScoreWordString(SelLetterList)); }
internal static int ScoreWord() { return(EngLetterScoring.ScoreWord(GetCurrentWord())); }
internal static void SubmitWord() { string s = GetCurrentWord().ToLower(); if (EngLetterScoring.IsWord(s)) { ScoreStats ss = RecordWordScore(); RemoveWordAndReplaceTiles(); Deselect(null); boardScript.ResetSubmitButton(); bool gameOver = ProcessLetters(); if (gameOver) { RemoveGameBoard(); //SaveStats(); Resume = false; boardScript.EndGanme(); //ResetSavedGame(); } else { if (ss.MannaScore > 0) { //ScoreFlash.Foreground = WordWarLogic.GetFortuneColor(WordWarLogic.ScoreWord()); //ScoreFlash.Text = "Manna +" + ss.MannaScore; //await BeginAsync(ScoreMotionSmall); } if (ss.bonus > 0) { //ScoreFlash.Foreground = WordWarLogic.GetFortuneColor(WordWarLogic.ScoreWord()); //ScoreFlash.Text = "Bonus +" + ss.bonus; //await BeginAsync(ScoreMotionSmall); } if (ss.si != null) { boardScript.ShowMsg("Nice word, you've earned a " + ss.si.FriendlyName + " spell."); } TurnOver(); if (CheckNextLevel(totalScore)) { boardScript.LevelSound(); string levelmsg = "Welcom to Level " + CurrentLevel.ToString() + "\n\n"; if (Spells.HasSpells()) { levelmsg += "You have new spells"; } boardScript.ShowMsg(levelmsg); } boardScript.ScoreWordSound(); } } else { Deselect(null); //CurrentWord.Text = "Not a known word. Try again"; } }
public static void LetterClick(int i, int j) { LetterProp lp = LetterPropGrid[i, j]; //LetterTipPopup.IsOpen = false; if (NextSpell != null) { SpellInfo.SpellOut so = CastSpell(NextSpell, lp); if (so.si == null && so.worked) { if (freeSpell) { Spells.RemoveFoundSpell(NextSpell); } else { ChangeManna(-NextSpell.MannaPoints); } } NextSpell = so.si; } else { if (SelLetterList.Count >= 0) { //string curword = GetCurrentWord().ToLower(); // Check if button is adject to the last if (!(IsLetterAdjacentToLastButton(lp) && !SelLetterList.Contains(lp))) { // Deselect except for the one you just clicked. if (!Deselect(lp)) { lp.SelectorObject = boardScript.SelectLet(lp.I, lp.J); //lp.SetSelected(true); } } else { //lp.SetSelected(true); lp.SelectorObject = boardScript.SelectLet(lp.I, lp.J); } SelLetterList.Add(lp); boardScript.SetCurrentWord(GetCurrentWord() + "\n" + GetWordTally()); // add if for > 3 letters //CurrentWord.Text = GetWordTally(); // if it's a word, update color to green if (SelLetterList.Count > 2 && EngLetterScoring.IsWord(GetCurrentWord())) { boardScript.IndicateGoodWord(true); // if it's a word, remember it. AddToTryList(); } else { boardScript.IndicateGoodWord(false); } } } }
internal static string GetWordTally() { return(EngLetterScoring.GetWordTally(SelLetterList)); }
internal static ScoreStats RecordWordScore() { ScoreStats ss = new ScoreStats(); int wordTotal = ScoreWord(); //HistoryList.Items.Insert(0, GetWordTally()); boardScript.AddHistory(GetCurrentWord() + " " + GetWordTally()); totalScore += wordTotal; if (wordTotal > HighScoreWordValue) { HighScoreWordValue = wordTotal; HighScoreWord = GetCurrentWord(); HighScoreWordTally = EngLetterScoring.GetWordTally(SelLetterList); } WordScoreItem wsi = new WordScoreItem() { word = GetCurrentWord(), score = wordTotal, wordscorestring = EngLetterScoring.GetWordTally(SelLetterList), simplescore = ScoreWordSimple() }; ss.bonus = EngLetterScoring.LengthBonus(wsi.word); FortuneWordScoreHistory.Add(wsi); if (FortuneWordScoreHistory.Count > EffWordCount) { FortuneWordScoreHistory.RemoveAt(0); } HistoryWords.Add(wsi); CheckTopBestWordScores(wsi); CheckTopBestWordScoresSimple(wsi); CheckTopLongestWordScores(wsi); totalwords++; TotalEfficiency = totalScore / totalwords; Efficiency = GetLatestEff(); if (GetFortune() == FortuneLevel.Great) { FortuneLevelCount++; } else { FortuneLevelCount = 0; } if (FortuneLevelCount > 4) { Manna += (FortuneLevelCount - 4); } ss.MannaScore = ScoreManna(); // If it's a big or price word, give them a spell based on the word. string curword = GetCurrentWord(); if (wordTotal > 14 || curword.Length >= 8) { SpellInfo si = null; if (wordTotal > 70 || curword.Length > 16) { si = Spells.GetSpell(6, level); } else if (wordTotal > 55 || curword.Length > 15) { si = Spells.GetSpell(5, level); } else if (wordTotal > 45 || curword.Length > 14) { si = Spells.GetSpell(4, level); } else if (wordTotal > 35 || curword.Length > 13) { si = Spells.GetSpell(3, level); } else if (wordTotal > 25 || curword.Length > 11) { si = Spells.GetSpell(2, level); } else if (wordTotal > 17 || curword.Length > 9) { si = Spells.GetSpell(1, level); } else if (wordTotal > 14 || curword.Length >= 8) { si = Spells.GetSpell(0, level); } ss.si = si; } UpdateFortune(); UpdateStats(); return(ss); }
private void FindAllWords(int i, int j, LetterProp lp) { if (CurrentWordFind.Exists(key => (key.i == i && key.j == j))) { return; } CurrentWordFind.Add(new WordElement(i, j, LetterGrid[i, j].letter)); CurWordList.Add(LetterGrid[i, j]); if (CurrentWordFind.Count < 20) { string _curword = CurrentWordString(); if (CurrentWordFind.Count >= 3) { if (EngLetterScoring.IsWord(_curword) && CurrentWordFind.Exists(key => key.i == lp.I && key.j == lp.J)) { Word w = new Word(CurWordList); if (!WordsFromLetter.Contains(w)) { WordsFromLetter.Add(w); } } } if (EngLetterScoring.PartialExists(_curword)) { if (i > 0) { if (j > 0) { FindAllWords(i - 1, j - 1, lp); } FindAllWords(i - 1, j, lp); if (j < WSGameState.gridsize - 1) { FindAllWords(i - 1, j + 1, lp); } } if (j > 0) { FindAllWords(i, j - 1, lp); } if (j < WSGameState.gridsize - 1) { FindAllWords(i, j + 1, lp); } if (i < WSGameState.gridsize - 1) { if (j > 0) { FindAllWords(i + 1, j - 1, lp); } FindAllWords(i + 1, j, lp); if (j < WSGameState.gridsize - 1) { FindAllWords(i + 1, j + 1, lp); } } } } CurrentWordFind.RemoveAt(CurrentWordFind.Count - 1); CurWordList.RemoveAt(CurWordList.Count - 1); }
public Word(List <LetterProp> lplist) { word = EngLetterScoring.GetCurrentWord(lplist); score = EngLetterScoring.ScoreWord(word); }
// a z // t z public bool FindAnyWord2(int i, int j) { bool ret = false; if (CurrentWordFind.Exists(key => (key.i == i && key.j == j))) { return(false); } CurrentWordFind.Add(new WordElement(i, j, LetterGrid[i, j].letter)); //Debug.WriteLine(i.ToString() + " " + j.ToString() + " " + CurrentWordString()); if (CurrentWordFind.Count < 15) { string curword = CurrentWordString(); if (EngLetterScoring.PartialExists(curword)) { if (CurrentWordFind.Count >= 3) { if (EngLetterScoring.IsWord(curword)) { ret = true; } } if (i > 0) { if (j > 0) { if (!ret && FindAnyWord(i - 1, j - 1)) { ret = true; } } if (!ret && FindAnyWord(i - 1, j)) { ret = true; } if (j < WSGameState.gridsize - 1) { if (!ret && FindAnyWord(i - 1, j + 1)) { ret = true; } } } if (j > 0) { if (!ret && FindAnyWord(i, j - 1)) { ret = true; } } if (j < WSGameState.gridsize - 1) { if (!ret && FindAnyWord(i, j + 1)) { ret = true; } } if (i < WSGameState.gridsize - 1) { if (j > 0) { if (!ret && FindAnyWord(i + 1, j - 1)) { ret = true; } } if (!ret && FindAnyWord(i + 1, j)) { ret = true; } if (j < WSGameState.gridsize - 1) { if (!ret && FindAnyWord(i + 1, j + 1)) { ret = true; } } } } } CurrentWordFind.RemoveAt(CurrentWordFind.Count - 1); return(ret); }
public bool FindAnyWord(int i, int j) { bool ret = false; if (LetterGridUsed[i, j]) { return(false); } LetterGridUsed[i, j] = true; curword[curwordoff++] = LetterGridByte[i, j]; //Debug.WriteLine(i.ToString() + " " + j.ToString() + " " + CurrentWordString()); if (curwordoff <= 15) { string _curword = new string(curword, 0, curwordoff); if (EngLetterScoring.PartialExists(_curword)) { if (curwordoff >= 3) { if (EngLetterScoring.IsWord(_curword)) { ret = true; } } if (i > 0) { if (j > 0) { if (!ret && FindAnyWord(i - 1, j - 1)) { ret = true; } } if (!ret && FindAnyWord(i - 1, j)) { ret = true; } if (j < WSGameState.gridsize - 1) { if (!ret && FindAnyWord(i - 1, j + 1)) { ret = true; } } } if (j > 0) { if (!ret && FindAnyWord(i, j - 1)) { ret = true; } } if (j < WSGameState.gridsize - 1) { if (!ret && FindAnyWord(i, j + 1)) { ret = true; } } if (i < WSGameState.gridsize - 1) { if (j > 0) { if (!ret && FindAnyWord(i + 1, j - 1)) { ret = true; } } if (!ret && FindAnyWord(i + 1, j)) { ret = true; } if (j < WSGameState.gridsize - 1) { if (!ret && FindAnyWord(i + 1, j + 1)) { ret = true; } } } } } curword[curwordoff] = '\0'; curwordoff--; LetterGridUsed[i, j] = false; return(ret); }
private static int ScoreWordSimple() { return(EngLetterScoring.ScoreWordSimple(SelLetterList)); }
public static string GetWordTally(List <LetterProp> lp_list) { string curword = GetCurrentWord(lp_list); return(ScoreWord(curword) + "=>" + EngLetterScoring.ScoreWordString(lp_list)); }
internal static string GetCurrentWord() { return(EngLetterScoring.GetCurrentWord(SelLetterList)); }
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); }