示例#1
0
        public void Check(Int32 externGuess)
        {
            IGuessService clientCB = OperationContext.Current.GetCallbackChannel<IGuessService>();
            Player currentPlayer = _players[clientCB];
            Guess guess = new Guess(externGuess.ToString(), currentPlayer.Name);
            played.Add(guess);

            if (_randomInt == externGuess)
            {
                clientCB.GameOver(true, played);
                foreach (KeyValuePair<IGuessService, Player> copyied in _players)
                {
                    if (copyied.Key != clientCB)
                    {
                        copyied.Key.GameOver(false, played);
                    }
                }
            }
            else
            {
                if (externGuess < _randomInt){guess.Tipp = GuessTipp.ToLow;}
                else { guess.Tipp = GuessTipp.ToHigh; }

                foreach (KeyValuePair<IGuessService, Player> player in _players)
                {
                    player.Key.PlayerGuess(guess);
                }
            }
        }
示例#2
0
 public void Leave()
 {
     IGuessService clientCB = OperationContext.Current.GetCallbackChannel<IGuessService>();
     Player quit = _players[clientCB];
     Guess msg = new Guess("Has quit the game!", quit.Name);
     played.Add(msg);
     foreach (KeyValuePair<IGuessService, Player> play in _players)
     {
         play.Key.PlayerGuess(msg);
         if (play.Key != clientCB)
         {
             play.Key.ConnectCanceled();
         }
     }
     _players.Remove(clientCB);
 }
示例#3
0
        public void Check(Int32 tipp)
        {
            IGuessService clientCallback = OperationContext.Current.GetCallbackChannel<IGuessService>();
            Player currentPlayer = players[clientCallback];
            Guess guess = new Guess(currentPlayer.Name, tipp.ToString());
            playedValues.Add(guess);
            KeyValuePair<IGuessService, Player>[] copyiedPlayers = players.ToArray();
            if (tipp == secret)
            {
                clientCallback.GameOver(true, playedValues);

                foreach (KeyValuePair<IGuessService, Player> player in copyiedPlayers)
                {
                    if (player.Key != clientCallback)
                    {
                        player.Key.GameOver(false, playedValues);
                    }
                }
            }

            else
            {

                if (tipp < secret)
                {
                    guess.Tipp = GuessTipp.ToLow;
                }
                else
                {
                    guess.Tipp = GuessTipp.ToHeight;
                }
                foreach (KeyValuePair<IGuessService, Player> player in copyiedPlayers)
                {
                    player.Key.PlayerGuess(guess);
                }
            }
        }
示例#4
0
 public void Leave()
 {
     IGuessService clientCallback = OperationContext.Current.GetCallbackChannel<IGuessService>();
     Player quitplayer = players[clientCallback];
     Guess msg = new Guess(quitplayer.Name, "Has Quit");
     playedValues.Add(msg);
     KeyValuePair<IGuessService, Player>[] copiedPlayers = players.ToArray();
     foreach (KeyValuePair<IGuessService, Player> player in copiedPlayers)
     {
         player.Key.PlayerGuess(msg);
         if (player.Key != clientCallback)
         {
             player.Key.ConnectCanceled();
         }
     }
     players.Remove(clientCallback);
 }