예제 #1
0
        private uint GetHighScoreWord(IEnumerable <GameDataModel> games, IEnumerable <GameMoveDataModel> moves, string userName, out string opponent, out string word)
        {
            if (games == null || games.Count() < 1 || moves == null || moves.Count() < 1)
            {
                word     = "";
                opponent = "";
                return(0);
            }

            word     = null;
            opponent = null;

            var processedWords = moves.Select(m => new WordModel
            {
                MoveId = m.Id,
                Words  = m.Words.FromJson <PlayWord[]>()
            });

            uint     hMoveId        = 0;
            int      hWordMoveScore = 0;
            PlayWord hWord          = null;

            foreach (var pWord in processedWords)
            {
                if (pWord.Words != null && pWord.Words.Length > 0)
                {
                    var maxScore = pWord.Words.Max(w => w.Score);
                    if (maxScore >= hWordMoveScore)
                    {
                        hMoveId        = pWord.MoveId;
                        hWordMoveScore = maxScore;
                        hWord          = pWord.Words.First(w => w.Score == maxScore);
                    }
                }
            }

            var gameId = moves.SingleOrDefault(m => m.Id == hMoveId)?.GameId;

            if (!string.IsNullOrEmpty(gameId))
            {
                word = hWord.GetString();
                var game = games.Single(g => g.Id == gameId);
                opponent = game.Player01 == userName
                    ? game.Player02
                    : game.Player01;
            }

            return((uint)hWordMoveScore);
        }
예제 #2
0
        public static IEnumerable <IPlayWord> ScoreMove(this Game game, IEnumerable <IPlayWord> words, IEnumerable <IPlayLetter> playLetters)
        {
            var scoredWords = new List <IPlayWord>();

            foreach (var word in words)
            {
                var scored = new PlayWord
                {
                    Letters  = word.Letters.Select(l => l.ToDto <PlayLetter>()),
                    RawScore = word.Letters.CalculateRawScore(game.Language),
                    Score    = word.Letters.CalculateEffectiveScore(game.Language, playLetters)
                };
                scoredWords.Add(scored);
            }
            ;
            return(scoredWords);
        }
        void ReleaseDesignerOutlets()
        {
            if (a1 != null)
            {
                a1.Dispose();
                a1 = null;
            }

            if (a2 != null)
            {
                a2.Dispose();
                a2 = null;
            }

            if (a3 != null)
            {
                a3.Dispose();
                a3 = null;
            }

            if (a4 != null)
            {
                a4.Dispose();
                a4 = null;
            }

            if (b1 != null)
            {
                b1.Dispose();
                b1 = null;
            }

            if (b2 != null)
            {
                b2.Dispose();
                b2 = null;
            }

            if (b3 != null)
            {
                b3.Dispose();
                b3 = null;
            }

            if (b4 != null)
            {
                b4.Dispose();
                b4 = null;
            }

            if (BoggleBud != null)
            {
                BoggleBud.Dispose();
                BoggleBud = null;
            }

            if (c1 != null)
            {
                c1.Dispose();
                c1 = null;
            }

            if (c2 != null)
            {
                c2.Dispose();
                c2 = null;
            }

            if (c3 != null)
            {
                c3.Dispose();
                c3 = null;
            }

            if (c4 != null)
            {
                c4.Dispose();
                c4 = null;
            }

            if (d1 != null)
            {
                d1.Dispose();
                d1 = null;
            }

            if (d2 != null)
            {
                d2.Dispose();
                d2 = null;
            }

            if (d3 != null)
            {
                d3.Dispose();
                d3 = null;
            }

            if (d4 != null)
            {
                d4.Dispose();
                d4 = null;
            }

            if (PlayGame != null)
            {
                PlayGame.Dispose();
                PlayGame = null;
            }

            if (PlayWord != null)
            {
                PlayWord.Dispose();
                PlayWord = null;
            }

            if (Score != null)
            {
                Score.Dispose();
                Score = null;
            }

            if (Word != null)
            {
                Word.Dispose();
                Word = null;
            }
        }