/// <summary> /// This is the page where most of the game will happen. /// </summary> /// <param name="model"></param> public GamePage(BoggleClientModel model) { InitializeComponent(); this.model = model; // test code - remove later //model.setBoard("ABCDEFGHIJKLMNOP"); //model.setTime("322"); //model.setOpponent("Lance"); //model.setPlayerName("Basil"); // remove above this // initialize scores to zero model.setPlayerScore("0"); model.setOpponentScore("0"); // set initial game information in view Timer.Text = getRemainingTime(model.getTime()); Opponent.Text = model.getOpponent(); Player.Text = model.getPlayerName(); // initialize the boggle board InitializeBoard(model.getBoard().ToCharArray()); model.TimeLineEvent += TimeReceived; model.ScoreLineEvent += ScoreReceived; model.StopLineEvent += StopReceived; model.TerminatedLineEvent += TerminatedReceived; model.IgnoreLineEvent += IgnoreReceived; }
/// <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()); }