Beispiel #1
0
        public GameWord GetGuessGameWord()
        {
            var      randomWord = DAL.SDK.Kit.Instance.Words.GetRandomMainWord(0.99, 7);
            GameWord word       = new GameWord();

            word.Name               = randomWord.FormNoAcc;
            word.Characters         = getGuessWordCharacters(randomWord.FormNoAcc);
            word.Definitions        = BL.Business.KitBL.Instance.WordBL.GetWordDefinitionsByName(randomWord.FormNoAcc);
            word.SugestedCharacters = getSuggestedCharacters(word.Characters.Where(c => c.IsVisible == false).Select(s => s.Character).ToList());
            for (int i = 0; i < word.Characters.Count(); i++)
            {
                word.Characters[i].Position = i;
            }
            return(word);
        }
        public void SimpleGameCanBeSolved()
        {
            char[] gameField = new char[]
            {
                'w', 'o', 'r',
                'i', 'f', 'k',
                'e', 'l', 'd'
            };
            GameInformation            gameInfo = new GameInformation(gameField, 3, 3);
            ConcurrentWordStateMachine concurrentWordStateMachine = new ConcurrentWordStateMachine();

            concurrentWordStateMachine.AddWords("./Words/English.txt");
            GameSolver   gameSolver = new GameSolver(concurrentWordStateMachine);
            GameSolution solution   = gameSolver.SolveGameAsync(gameInfo).Result;

            Assert.True(solution.IsSolved);

            GameWord[] gameWords = new GameWord[]
            {
                //work
                new GameWord(gameInfo, new GamePoint[]
                {
                    new GamePoint(gameInfo, 0, 0),
                    new GamePoint(gameInfo, 1, 0),
                    new GamePoint(gameInfo, 2, 0),
                    new GamePoint(gameInfo, 2, 1)
                }),
                //field
                new GameWord(gameInfo, new GamePoint[]
                {
                    new GamePoint(gameInfo, 1, 1),
                    new GamePoint(gameInfo, 0, 1),
                    new GamePoint(gameInfo, 0, 2),
                    new GamePoint(gameInfo, 1, 2),
                    new GamePoint(gameInfo, 2, 2)
                })
            };

            GameState expectedGameState = new GameState(gameInfo, gameWords);

            Assert.Contains(expectedGameState, solution.GameStates);
            Assert.Single(solution.GameStates);
        }
Beispiel #3
0
 public WordAndLetterDieEventArgs(GameWord word, GameLetter letter, GameCellPos wordPosition)
 {
     this.word = word;
         this.letter = letter;
         this.wordPosition = wordPosition;
 }
Beispiel #4
0
 void StartWordAndLetterDieAnimationInternal(GameWord word, GameLetter letter)
 {
     GameCellPos wordPosition;
     if (!mainTable.TryGetObjectPosition(word, out wordPosition)) return;
     try {
         if (StartWordAndLetterDieAnimation(word, letter, wordPosition)) {
             suspendEvent.Reset();
             return;
         }
     } catch (Exception ex) {
         //TODO Log
     }
     EndWordAndLetterDieAnimation(word, letter);
 }
Beispiel #5
0
 List<GameWord> GetWordsToInsert(out int insertWidth)
 {
     insertWidth = 0;
     List<GameWord> wordsToInsert = new List<GameWord>();
     do {
         int repeats = 3;
         GameWord word;
         int[] wordRules;
         GameMap<int> wordRulesMap;
         do {
             string nextWord = GetNextWord(out wordRules, out wordRulesMap);
             if (string.IsNullOrEmpty(nextWord)) {
                 return wordsToInsert;
             }
             word = new GameWord(nextWord, wordRulesMap);
         } while ((insertWidth + word.Width) > mainTable.Width && repeats-- > 3);
         if ((insertWidth + word.Width) > mainTable.Width)
             break;
         insertWidth += word.Width;
         wordsToInsert.Add(word);
         usedWordsDict.Add(word.Word, wordRules);
     } while (true);
     return wordsToInsert;
 }
Beispiel #6
0
 protected virtual bool StartWordAndLetterDieAnimation(GameWord word, GameLetter letter, GameCellPos wordPosition)
 {
     if (OnStartWordAndLetterDieAnimation == null) return false;
     return OnStartWordAndLetterDieAnimation(this, new WordAndLetterDieEventArgs(word, letter, wordPosition));
 }
Beispiel #7
0
 public void EndWordAndLetterDieAnimation(GameWord word, GameLetter letter)
 {
     try {
         if (currentLetter == letter) {
             mainTable.RemoveObject(letter);
             currentLetter = null;
             int wordIndex;
             if ((wordIndex = currentWords.IndexOf(word)) >= 0) {
                 currentWords.RemoveAt(wordIndex);
                 mainTable.RemoveObject(word);
                 gameWords++;
                 if (gameWords >= settings.WinWordsCount) {
                     win = true;
                 }
             }
         }
     } finally {
         suspendEvent.Set();
     }
 }
Beispiel #8
0
 public void GameWordTest()
 {
     GameWord word1 = new GameWord("оловя[нн]ый");
     Assert.AreEqual(1, word1.Height);
     Assert.AreEqual(8, word1.Width);
     Assert.AreEqual(false, word1.Bitmap[0, 5]);
     Assert.AreEqual(true, word1.Bitmap[0, 0]);
     Assert.AreEqual("НН", word1.StringMap[0, 5]);
     Assert.AreEqual("О", word1.StringMap[0, 0]);
 }