Beispiel #1
0
        /// <inheritdoc/>
        public void NotifyCardWasUncoveredd(PlayerMovementDto playerMovementDto)
        {
            string       host      = playerMovementDto.Host;
            ServiceMatch gameMatch = GetMatch(host);

            ServicePlayer player = gameMatch.GetPlayer(playerMovementDto.Username);

            if (playerMovementDto.HasFormedAPair)
            {
                player.AddUncoveredCard(playerMovementDto.CardIndex);
                gameMatch.TotalPairs++;
            }
            else
            {
                if (playerMovementDto.MovementsLeft == 0)
                {
                    player.RemoveUncoveredCard();
                }
                else
                {
                    player.AddUncoveredCard(playerMovementDto.CardIndex);
                }
            }

            IList <ServicePlayer> playersInMatch = gameMatch.GetPlayersConnectedToMatch();

            foreach (var playerInMatch in playersInMatch)
            {
                playerInMatch.MatchServiceConnection.UncoverCardd(playerMovementDto.CardIndex);
            }
        }
Beispiel #2
0
 private void FlipCard(ImageCard cardClicked)
 {
     try
     {
         _numberOfMovementsAllowed--;
         int cardIndex = _imageCards.IndexOf(cardClicked);
         _cardsFlippedInCurrentTurn.Add(cardClicked);
         PlayerMovementDto playerMovementDto = new PlayerMovementDto()
         {
             Host           = MatchHost,
             Username       = Sesion.GetSesion.Username,
             CardIndex      = cardIndex,
             MovementsLeft  = _numberOfMovementsAllowed,
             HasFormedAPair = _playerHasFormedAPair
         };
         if (_numberOfMovementsAllowed == 0 && HasFormedAPair())
         {
             playerMovementDto.HasFormedAPair = true;
         }
         _matchServiceClient.NotifyCardWasUncoveredd(playerMovementDto);
     }
     catch (EndpointNotFoundException)
     {
         MessageBox.Show(Properties.Langs.Resources.ServerConnectionLost);
     }
     catch (TimeoutException)
     {
         MessageBox.Show(Properties.Langs.Resources.ServerTimeoutError);
     }
     catch (CommunicationException)
     {
         MessageBox.Show(Properties.Langs.Resources.CommunicationInterrupted);
     }
 }