예제 #1
0
        public string WordToLowerCase()
        {
            string lowerWord = UserWord.ToLower();

            UserWord = lowerWord;
            return(lowerWord);
        }
예제 #2
0
 //Validate UserWord
 public static bool Validate(this UserWord task)
 {
     return(task != null &&
            task.Id.Validate() &&
            task.WordId.Validate() &&
            task.UserId.Validate());
 }
예제 #3
0
 public void Calculator()
 {
     char[] wordArray = UserWord.ToCharArray();
     for (int i = 0; i < wordArray.Length; i++)
     {
         if (char.ToLower(wordArray[i]) == 'q' || char.ToLower(wordArray[i]) == 'z')
         {
             Score += 10;
         }
         else if (char.ToLower(wordArray[i]) == 'j' || char.ToLower(wordArray[i]) == 'x')
         {
             Score += 8;
         }
         else if (char.ToLower(wordArray[i]) == 'k')
         {
             Score += 5;
         }
         else if (char.ToLower(wordArray[i]) == 'f' || char.ToLower(wordArray[i]) == 'h' || char.ToLower(wordArray[i]) == 'v' || char.ToLower(wordArray[i]) == 'w' || char.ToLower(wordArray[i]) == 'y')
         {
             Score += 4;
         }
         else if (char.ToLower(wordArray[i]) == 'b' || char.ToLower(wordArray[i]) == 'c' || char.ToLower(wordArray[i]) == 'm' || char.ToLower(wordArray[i]) == 'p')
         {
             Score += 3;
         }
         else if (char.ToLower(wordArray[i]) == 'd' || char.ToLower(wordArray[i]) == 'g')
         {
             Score += 2;
         }
         else
         {
             Score += 1;
         }
     }
 }
예제 #4
0
        public void AddUserWord_DecrementsUserSearchesCountByOne()
        {
            _usersRepository.GetUsers().Returns(new List <User>
            {
                new User {
                    Id = 1, Ip = "::1", SearchesLeft = 5
                },
                new User {
                    Id = 2, Ip = "::2", SearchesLeft = 4
                },
                new User {
                    Id = 3, Ip = "::3", SearchesLeft = 3
                },
                new User {
                    Id = 4, Ip = "::4", SearchesLeft = 2
                }
            });

            var testUser     = _usersRepository.GetUsers().First();
            var testUserWord = new UserWord {
                Text = "Testas", UserId = testUser.Id
            };

            _userWordsService.AddUserWord(testUserWord.Text, testUser.Ip);

            _usersRepository.ReceivedCalls().ShouldNotBeNull();
            _userWordsRepository.ReceivedCalls().ShouldNotBeNull();
            _usersRepository.Received(2).GetUsers();
            _usersService.Received().UpdateUserSearchesCount(Arg.Is(testUser.Id), Arg.Is(testUser.SearchesLeft + 1));
        }
예제 #5
0
        public void AddUserWord_AddsNewUserWordToUserWordsRepository()
        {
            _usersRepository.GetUsers().Returns(new List <User>
            {
                new User {
                    Id = 1, Ip = "::1", SearchesLeft = 5
                },
                new User {
                    Id = 2, Ip = "::2", SearchesLeft = 4
                },
                new User {
                    Id = 3, Ip = "::3", SearchesLeft = 3
                },
                new User {
                    Id = 4, Ip = "::4", SearchesLeft = 2
                }
            });

            var testUser     = _usersRepository.GetUsers().First();
            var testUserWord = new UserWord {
                Text = "Testas", UserId = testUser.Id
            };

            _userWordsService.AddUserWord(testUserWord.Text, testUser.Ip);

            _usersRepository.ReceivedCalls().ShouldNotBeNull();
            _userWordsRepository.ReceivedCalls().ShouldNotBeNull();
            _usersRepository.Received(2).GetUsers();
            _userWordsRepository.Received(1).AddUserWord(Arg.Any <UserWord>());
        }
예제 #6
0
파일: WordsService.cs 프로젝트: qqga/cshh
        public void AddTranslate(Word word, int userWord_Id)
        {
            UserProfile userProfile = Repository.FindBy <UserProfile>(up => up.ApplicationUserId == _workContext.UserAppId).FirstOrDefault();

            if (userProfile == null)
            {
                throw new Exception("Пользователь не найден.");
            }

            UserWord userWord = Repository.GetByKey <UserWord>(userWord_Id, uw => uw.Word);

            var wordRes = Repository.Words.FindSameWordOrDefault(word, out bool isfound);

            if (!isfound)
            {
                wordRes.UserProfile_Id = userProfile.Id;
                wordRes.Text           = word.Text.ToLower();
                wordRes.Language_Id    = word.Language_Id;
                wordRes.Type_Id        = word.Type_Id;
                wordRes.DateTimeCreate = DateTime.Now;
            }

            userWord.Word.TranslationsTo.Add(wordRes);

            Repository.Update(userWord.Word, true);
        }
예제 #7
0
        public void Add(IEnumerable <string> words, string setName, int lang_id, int status_id)//todo textid unsaved
        {
            var         UserAppId = _workContext.UserAppId;
            UserProfile user      = Repository.GetUserProfile(UserAppId);

            if (user == null)
            {
                throw new Exception("Пользователь не найден");
            }


            WordSet set = Repository.FindBy <WordSet>(s => s.Name == setName && s.User_Id == user.Id).FirstOrDefault();

            if (set == null)
            {
                set = new WordSet {
                    Name = setName, User = user
                };
                this.Repository.Add(set, true);
            }
            var wordsExists     = Repository.Words.ToList().AsQueryable();
            var userWordsExists = Repository.UserWords.ToList().AsQueryable();

            foreach (string word in words)
            {
                UserWord newUserWord = new UserWord(word, lang_id, status_id, set.Id, user.Id);
                newUserWord.Word = wordsExists.FindSameWordOrDefault(newUserWord.Word);
                if (!IsUserHaveWord(userWordsExists, newUserWord, UserAppId))
                {
                    Repository.Add(newUserWord);
                }
            }
            Repository.Save();
        }
예제 #8
0
        public UserWord Add(UserWord userWord, string userAppId)
        {
            var         UserAppId = _workContext.UserAppId;
            UserProfile user      = Repository.GetUserProfile(userAppId);

            if (user == null)
            {
                throw new Exception("Пользователь не найден");
            }

            UserWord newUserWord = new UserWord(userWord.Word.Text, userWord.Word.Language_Id, userWord.Status_Id, userWord.Set_Id, user.Id);

            SetWordSet(newUserWord, userWord, user);

            //newUserWord.Word.UserProfile_Id = user.Id;
            newUserWord.Word = Repository.Words.FindSameWordOrDefault(newUserWord.Word);

            if (IsUserHaveWord(Repository.UserWords, newUserWord, UserAppId))
            {
                throw new Exception("Уже есть это слово в этом наборе");
            }
            //UserWord userWord = new UserWord() { Set = wordSet, Status_Id = status.Id, Word = FindWordOrDefault(word) };
            Repository.Add(newUserWord, true);
            return(newUserWord);
        }
예제 #9
0
    void OnLobbyChatMsg(LobbyChatMsg_t lobbyChatMsg_T)
    {
        CSteamID Sayer;

        byte[]         hua = new byte[4096];
        EChatEntryType ctype;

        if (Sender.roomid == (CSteamID)lobbyChatMsg_T.m_ulSteamIDLobby)
        {
            SteamMatchmaking.GetLobbyChatEntry(Sender.roomid, (int)lobbyChatMsg_T.m_iChatID, out Sayer, hua, hua.Length, out ctype);
            Bond.IO.Safe.InputBuffer inputBuffer = new Bond.IO.Safe.InputBuffer(hua);
            Bond.Protocols.CompactBinaryReader <Bond.IO.Safe.InputBuffer> compactBinaryReader = new Bond.Protocols.CompactBinaryReader <Bond.IO.Safe.InputBuffer>(inputBuffer);
            theword = Deserialize <UserWord> .From(compactBinaryReader);

            foreach (GameObject a in ULS.UDs)
            {
                if (a.GetComponent <UserDetailScript>().ido(Sayer))
                {
                    a.GetComponent <UserDetailScript>().ClassWork(theword.myWord);
                    theword = null;
                    return;
                }
            }
        }
    }
예제 #10
0
        public void UpdateUserWord_IncrementsUserSearchesCountByOne()
        {
            _usersRepository.GetUsers().Returns(new List <User>
            {
                new User {
                    Id = 1, Ip = "::1", SearchesLeft = 5
                },
                new User {
                    Id = 2, Ip = "::2", SearchesLeft = 4
                },
                new User {
                    Id = 3, Ip = "::3", SearchesLeft = 3
                },
                new User {
                    Id = 4, Ip = "::4", SearchesLeft = 2
                }
            });

            var testUser = _usersRepository.GetUsers().First();
            var testWord = new UserWord {
                Id = 1, UserId = 1, Text = "Unit"
            };
            var updateText = "updateText";

            _userWordsService.UpdateUserWord(testWord.Id, updateText, testUser.Ip);

            _usersRepository.ReceivedCalls().ShouldNotBeNull();
            _userWordsRepository.ReceivedCalls().ShouldNotBeNull();
            _usersService.Received().UpdateUserSearchesCount(Arg.Is(testUser.Id), Arg.Is(testUser.SearchesLeft + 1));
        }
예제 #11
0
 public bool Add(int id, UserWord word)
 {
     if (!id.Validate() && !word.Validate())
     {
         throw new Exception("Invalid model");
     }
     return(rep.Add(id, word));
 }
예제 #12
0
 bool IsUserHaveWord(IQueryable <UserWord> query, UserWord userWord, string appUserId)
 {
     return
         (userWord.Word_Id > 0 &&                                 // если слово новое - не может иметь.
          query.Any(uw =>
                    uw.Set.User.ApplicationUserId == appUserId && //для указанного пользователя
                    uw.Word_Id == userWord.Word_Id &&             // указанное слово
                    uw.Set_Id == userWord.Set_Id                  // в указаном наборе
                    ));
 }
예제 #13
0
        public ResponseResult AddWord(WordRequest.Add model, int userId)
        {
            var existWord = _dbContext.Words.FirstOrDefault(x => x.Text == model.Text);

            var userWord = new UserWord();

            if (existWord.IsNullOrDefault())
            {
                var newWord = _dbContext.Words.Add(new Word
                {
                    Text        = model.Text,
                    Sentences   = null,
                    CreatedDate = DateTime.Now,
                });

                _dbContext.SaveChanges();

                userWord = new UserWord
                {
                    UserId      = userId,
                    WordId      = newWord.Entity.Id,
                    Description = model.Description,
                    CreatedDate = DateTime.Now
                };
                _dbContext.UserWords.Add(userWord);
                _dbContext.SaveChanges();

                Task.Run(() => { AddWordModel(newWord.Entity); });
            }
            else
            {
                var exist = _dbContext.UserWords.FirstOrDefault(x => x.UserId == userId && x.WordId == existWord.Id);

                if (!exist.IsNullOrDefault())
                {
                    return new ResponseResult()
                           {
                               Error = true, ErrorMessage = "Such a word has been added before."
                           }
                }
                ;

                userWord = new UserWord
                {
                    UserId      = userId,
                    WordId      = existWord.Id,
                    Description = model.Description,
                    CreatedDate = DateTime.Now
                };
                _dbContext.UserWords.Add(userWord);
                _dbContext.SaveChanges();
            }

            return(new ResponseResult());
        }
예제 #14
0
 public string CheckForNumbers()
 {
     if (UserWord.Contains("1") || UserWord.Contains("2") || UserWord.Contains("3") || UserWord.Contains("4") || UserWord.Contains("5") || UserWord.Contains("6") || UserWord.Contains("7") || UserWord.Contains("8") || UserWord.Contains("9") || UserWord.Contains("0"))
     {
         return("Please enter a valid word");
     }
     else
     {
         return(UserWord);
     }
 }
예제 #15
0
    public void SendMyWord()
    {
        Bond.IO.Safe.OutputBuffer outputBuffer = new Bond.IO.Safe.OutputBuffer(4096);
        Bond.Protocols.CompactBinaryWriter <Bond.IO.Safe.OutputBuffer> compactBinaryWriter = new Bond.Protocols.CompactBinaryWriter <Bond.IO.Safe.OutputBuffer>(outputBuffer);
        UserWord userWord = new UserWord();

        userWord.myWord = MyWord.text;
        MyWord.text     = "";
        Serialize.To(compactBinaryWriter, userWord);
        SteamMatchmaking.SendLobbyChatMsg(Sender.roomid, outputBuffer.Data.Array, outputBuffer.Data.Array.Length);
    }
예제 #16
0
        public async Task <UserWord> AddUserWord(UserWord userWord)
        {
            using (var context = ContextFactory.CreateDbContext(ConnectionString))
            {
                await context.UserWords.AddAsync(userWord);

                await context.SaveChangesAsync();
            }

            return(userWord);
        }
예제 #17
0
        public void UserDictionaryRepositoryTest_UserWords_Add_invalidModel()
        {
            var model = new UserWord
            {
                Id     = 0,
                UserId = 1,
                WordId = 55
            };
            var result = rep.Add(1, model);

            Assert.AreEqual(false, result, string.Format("result != expected"));
        }
예제 #18
0
        public void UserDictionaryRepositoryTest_UserWords_Delete_invalidModel()
        {
            var model = new UserWord
            {
                Id     = 0,
                UserId = 1,
                WordId = 105
            };
            var result = rep.Delete(1, model.Id);

            Assert.AreEqual(-1, result, string.Format("result != expected"));
        }
예제 #19
0
        public WordResponse.WordCard GetWordCard(int userId, int currentIndex = 1, bool isRandom = false)
        {
            var authorizedWords = GetUserWordsBySettings(userId);

            if (currentIndex > authorizedWords.words.Count)
            {
                return(new WordResponse.WordCard
                {
                    IsOver = true,
                });
            }

            var userWord = new UserWord();

            if (isRandom)
            {
                var random = new Random();

                userWord = authorizedWords.words[random.Next(authorizedWords.words.Count)];
            }
            else
            {
                userWord = authorizedWords.words[currentIndex - 1];
            }

            return(new WordResponse.WordCard
            {
                Sentences = userWord.Word.Sentences.Where(w => !w.IsPrivate || (w.IsPrivate && w.UserId == userWord.UserId)).Select(s => s.Text).ToList(),
                Description = userWord.Description,
                Word = userWord.Word.Text,
                CurrentIndex = currentIndex,
                IsFavorite = userWord.IsFavorite,
                IsOver = currentIndex == authorizedWords.words.Count,
                Point = userWord.Point,
                UserWordId = userWord.Id,
                WordCount = authorizedWords.words.Where(w => !w.IsLearned).Count(),
                Definations = userWord.Word.WordDefinitions.Select(s => new WordResponse.Definations
                {
                    Defination = s.Definition,
                    Id = s.Id,
                    Type = s.PartOfSpeech,
                }).ToList(),
                Frequency = userWord.Word.WordFrequencies.Select(s => s.PerMillion).FirstOrDefault(),
                Prononciations = userWord.Word.WordPronunciations.Select(s => new WordResponse.Prononciation
                {
                    All = s.All ?? string.Empty,
                    Verb = s.Verb ?? string.Empty,
                    Noun = s.Noun ?? string.Empty,
                }).FirstOrDefault(),
                IsLearned = userWord.IsLearned,
            });
        }
 public bool CheckInput()
 {
     char[] checkWord = UserWord.ToCharArray();
     for (int i = 0; i < checkWord.Length; i++)
     {
         bool correct = Char.IsLetter(checkWord[i]);
         if (correct == false)
         {
             return(false);
         }
     }
     return(true);
 }
예제 #21
0
        public void UserDictionaryServiceTest_Add_valid()
        {
            var model = new UserWord
            {
                Id     = 1,
                UserId = 1,
                WordId = 1
            };
            var expected = rep.Add(1, model);
            var actual   = service.Add(1, model);

            Assert.AreEqual(expected, actual);
        }
예제 #22
0
        public ActionResult AddUserWord([FromBody] UserWord word)
        {
            if (String.IsNullOrWhiteSpace(word.Text))
            {
                return(BadRequest(new { errorMessage = "word is required" }));
            }

            var ipAddress = HttpContext.Connection.RemoteIpAddress.ToString();

            _userWordsService.AddUserWord(word.Text, ipAddress);

            return(Ok());
        }
예제 #23
0
        public string JqGridAdd(UserWordJqViewModel editWordVM)
        {
            try
            {
                UserWord map = _mapper.Map <UserWord>(editWordVM);

                _wordsService.Add(map);
            }
            catch (Exception ex)
            {
                return(this.BadRequestAndCollectEx(ex));
            }

            return(null);
        }
예제 #24
0
        public void AddUserWord(UserWord userWord)
        {
            if (userWord == null)
            {
                throw new ArgumentNullException("argument userWord is null");
            }

            _wordsDB_CFContext.UserWords.Add(new UserWordEntity
            {
                Id     = userWord.Id,
                Word   = userWord.Text,
                UserId = userWord.UserId
            });

            _wordsDB_CFContext.SaveChanges();
        }
예제 #25
0
        public int OccurrenceCounter()
        {
            int    counter = 0;
            string word    = UserWord.ToLower();
            string phrase  = UserPhrase.ToLower();

            string[] phraseArray = phrase.Split(" ");
            foreach (string phraseItem in phraseArray)
            {
                if (phraseItem == word)
                {
                    counter++;
                }
            }
            return(counter);
        }
        public int CountWord()
        {
            int Count = 0;

            UserWord.ToLower();


            foreach (var word in Sentence)
            {
                if (word == word)
                {
                    Count++;
                }
            }
            return(Count);
        }
예제 #27
0
        public void ExtensionsTest_Validate_UserWord()
        {
            var good = new UserWord
            {
                Id     = 0,
                WordId = 1,
                UserId = 1
            };
            var bad = new UserWord
            {
                Id     = -1,
                WordId = -1,
                UserId = 1
            };

            Assert.AreEqual(true, good.Validate());
            Assert.AreEqual(false, bad.Validate());
        }
예제 #28
0
        public ActionResult UpdateUserWord([FromBody] UserWord word)
        {
            if (word.Id < 0 || String.IsNullOrWhiteSpace(word.Text))
            {
                return(NotFound(new { errorMessage = $"word with id of {word.Id} could not be found" }));
            }

            try
            {
                var ipAddress = HttpContext.Connection.RemoteIpAddress.ToString();
                _userWordsService.UpdateUserWord(word.Id, word.Text, ipAddress);
            }
            catch
            {
                return(NotFound(new { errorMessage = $"word with id of {word.Id} could not be found" }));
            }

            return(Ok());
        }
예제 #29
0
        public void RemoveUserWord_ThrowsArgumentException()
        {
            _userWordsRepository.GetUserWords().Returns(new List <UserWord>
            {
                new UserWord {
                    Id = 1, UserId = 1, Text = "Unit"
                },
                new UserWord {
                    Id = 2, UserId = 1, Text = "Testas"
                },
                new UserWord {
                    Id = 3, UserId = 2, Text = "Mockinimo"
                },
                new UserWord {
                    Id = 3, UserId = 2, Text = "Karkasas"
                }
            });

            _usersRepository.GetUsers().Returns(new List <User>
            {
                new User {
                    Id = 1, Ip = "::1", SearchesLeft = 5
                },
                new User {
                    Id = 2, Ip = "::2", SearchesLeft = 4
                },
                new User {
                    Id = 3, Ip = "::3", SearchesLeft = 3
                },
                new User {
                    Id = 4, Ip = "::4", SearchesLeft = 2
                }
            });

            var testUser = _usersRepository.GetUsers().First();
            var testWord = new UserWord {
                Id = 100, Text = "Random word"
            };

            Should.Throw <ArgumentException>(() => _userWordsService.RemoveUserWord(testWord.Text, testUser.Ip));
            _userWordsRepository.ReceivedCalls().ShouldNotBeNull();
            _userWordsRepository.Received(1).GetUserWords();
        }
예제 #30
0
        public UserWord Add(UserWord userWord, string example, int translateLanguage_Id, string translates, string userAppId)
        {
            UserProfile user        = Repository.GetUserProfile(userAppId);
            var         newUserWord = Add(userWord, userAppId);

            if (!string.IsNullOrWhiteSpace(example))
            {
                WordDefinition wordDefinition = new WordDefinition()
                {
                    Word_Id = newUserWord.Word_Id, Example = example, Public = true, UserProfile_Id = user.Id
                };
                Repository.Add(wordDefinition, true);
            }
            if (!string.IsNullOrWhiteSpace(translates))
            {
                var translatesArr = translates.Split(',').Select(_ => _.Trim().ToLower()).Select(_ => new Word()
                {
                    Language_Id = translateLanguage_Id, Text = _
                });
                var newWord = Repository.GetByKey <Word>(newUserWord.Word_Id, _ => _.TranslationsTo);

                foreach (var newWordTranslate in translatesArr)
                {
                    var wordRes = Repository.Words.FindSameWordOrDefault(newWordTranslate, out bool isfound);
                    if (!isfound)
                    {
                        wordRes.UserProfile_Id = user.Id;
                        wordRes.Text           = newWordTranslate.Text?.ToLower();
                        wordRes.Language_Id    = newWordTranslate.Language_Id;
                        wordRes.Type_Id        = newWordTranslate.Type_Id;
                        wordRes.DateTimeCreate = DateTime.Now;
                    }

                    newWord.TranslationsTo.Add(wordRes);

                    Repository.Update(newWord);
                }
                Repository.Save();
            }

            return(newUserWord);
        }
 public void Update(UserWord context, int placeOfSelf, bool checkPhonotactics)
 {
     this.placeInWord = placeOfSelf;
             if (checkPhonotactics)
                     CheckPhonotactics (context, placeOfSelf);
             ApplyColor ();
 }
        public override UserWord Parse(string word, bool bySyllables=false)
        {
            string substringToDecode = word.TrimEnd ();

                        preSyllable = new List<LetterSoundComponent> ();
                        int numBlanksToRestore = word.Length - substringToDecode.Length;
                        if (bySyllables) {
                                preSyllable = ParseSyllables (substringToDecode);
                        }
                        if (!bySyllables || preSyllable.Count == 0) {
                                preSyllable = ParseBlendsDigraphsAndLetters (substringToDecode);
                                IdentifyVowelSoundsAndPhonotacticErrorsBySyllable (preSyllable);
                        }
                        //we need to check the phonotactics after we have collected ad appended

                        UserWord userWord = new UserWord (preSyllable);

                        userWord.ApplyColoursToLetterSoundComponents (checkPhonotactics);
                        userWord.RecordIndexOfLastNonBlankLetter ();

                        RestoreBlanks (userWord, numBlanksToRestore);

                        return userWord;
        }
 void RestoreBlanks(UserWord word, int num)
 {
     while (num>0) {
                         word.Add (new Blank ());
                         num--;
                 }
 }
    //the word will have at most 6 letters.
    //we need to put these letters in the indexes 1 to 6
    public void UpdateColoursOfTangibleLetters(UserWord newWord)
    {
        for (int positionOfLetter=0; positionOfLetter<newWord.Count; positionOfLetter++) {
                        LetterSoundComponent p = newWord.Get (positionOfLetter);
                        Color color = p.GetColour();

                        // int positionOfLetter_ = NUM_LETTER_POSITIONS - positionOfLetter;
                        positionOfLetter = positionOfLetter + 1;
                        ApplyNewColorTo (positionOfLetter, color);

                }
    }
    public void CheckPhonotactics(UserWord context, int placeOfSelf)
    {
        foreach (PhonotacticChecker.Phonotactics rule in rules)
                        if (rule (context.LetterSoundUnits, this, placeOfSelf)) {
                                violatesPhonotactics = true;
                                context.PhonotacticViolation (this, placeOfSelf); //alert the context (cache the fact that we're in error straight away)
                                return; //once we break a single phonotactical rule, stop checking - has the form of "or"
                        }
                //if we got here, then we (currently) have not broken any rules.

                //only the affixes (which are represented by enduring objects, not objects that are renewed each time as the letters are)
                //could be in the position where we need to "change" the state from
                //violates (i.e., place "s" affix next to y)
                //to, does not violate (the user changes the y to an i).
                //in these cases, we need to notify the context (which woud have remembered that we violated them)
                //that the violation was fixed.
                //the context will respond by checking eaxch of its letters for a violation.
                if (violatesPhonotactics == true) //mostly in case this is an affix. if we fixed an error we'd made previously, then tell the context to check if all other errors are fixed (and we should switch).
                        context.PhonotacticsWereFixed (this, placeOfSelf); //all letters "refresh" each time there is a change but the affix objects are enduring.
                violatesPhonotactics = false;
    }
 int FindIndexOfGraphemeThatCorrespondsToLastNonBlankPhonogram(UserWord userWord)
 {
     int cursor = endingIndexOfUserLetters;
             foreach (LetterSoundComponent p in userWord) {
                     if (p is Blank)
                             cursor -= p.Length;
                     else
                             return cursor;
             }
             return cursor;
 }
    void AssignNewColoursAndSoundsToLetters(UserWord letterSoundComponents, LetterGridController letterGridController, bool flash)
    {
        int indexOfLetterBarCell = startingIndexOfUserLetters;

                foreach (LetterSoundComponent p in letterSoundComponents) {
                        //ending index == total number of letters minus one.

                        if (indexOfLetterBarCell <= endingIndexOfUserLetters) { //no longer required because I fixed the bug in the LCFactoryManager that caused the error, but I'm leaving this here for redundant error protection...

                                if (p is LetterSoundComposite) {
                                        LetterSoundComposite l = (LetterSoundComposite)p;
                                        foreach (LetterSoundComponent lc in l.Children) {

                                                UpdateInterfaceLetters (lc, letterGridController, indexOfLetterBarCell, flash);
                                                indexOfLetterBarCell++;
                                        }
                                } else {

                                        UpdateInterfaceLetters (p, letterGridController, indexOfLetterBarCell, flash);

                                        indexOfLetterBarCell++;
                                }

                        }
                }
    }