示例#1
0
        /// <summary>
        /// Makes the summary
        /// </summary>
        /// <param name="summary"></param>
        private void MakeSummary(string summary)
        {
            string playerLegalWords     = "";
            string opponentLegalWords   = "";
            string commonWords          = "";
            string playerIllegalWords   = "";
            string opponentIllegalWords = "";
            int    dummyVar;

            int count = 0;

            string[] words = summary.Split(new Char [] { ' ' });

            foreach (string s in words)
            {
                if (int.TryParse(s, out dummyVar))
                {
                    count++;
                    continue;
                }

                else if (count == 1)
                {
                    playerLegalWords = playerLegalWords + s + "\n";
                }

                else if (count == 2)
                {
                    opponentLegalWords = opponentLegalWords + s + "\n";
                }

                else if (count == 3)
                {
                    commonWords = commonWords + s + "\n";
                }

                else if (count == 4)
                {
                    playerIllegalWords = playerIllegalWords + s + "\n";
                }

                else if (count == 5)
                {
                    opponentIllegalWords = opponentIllegalWords + s + "\n";
                }
            }

            PlayerFinalScore.Text   = model.getPlayerScore();
            OpponentFinalScore.Text = model.getOpponentScore();
            PlayerLegal.Text        = playerLegalWords;
            OpponentLegal.Text      = opponentLegalWords;
            Common.Text             = commonWords;
            PlayerIllegal.Text      = playerIllegalWords;
            OpponentIllegal.Text    = opponentIllegalWords;
        }
示例#2
0
        /// <summary>
        /// Handle when the server sends information about the score.
        /// </summary>
        /// <param name="line"></param>
        private void ScoreReceived(String line)
        {
            // split text into the two player scores separated by space
            string[] scores = Regex.Split(line, @"[\s]+");

            // update scores in model
            model.setPlayerScore(scores[0]);
            model.setOpponentScore(scores[1]);

            // update scores in view
            this.Dispatcher.Invoke(() => PlayerScoreCount.Text   = model.getPlayerScore());
            this.Dispatcher.Invoke(() => OpponentScoreCount.Text = model.getOpponentScore());
        }