Пример #1
0
        //creating request for changing joker into another card
        private ChangeJokerIntoAnotherCardRequest GenerateJokerChangeRequest(PlayingCard cardToChange, CardRanks newRank, CardSuits newSuit)
        {
            ChangeJokerIntoAnotherCardRequest request = new ChangeJokerIntoAnotherCardRequest()
            {
                PlayerNumber = MainWindow.PlayerNumber,
                PlayerID     = MainWindow.PlayerID,
                CardToChange = cardToChange,
                NewRank      = newRank,
                NewSuit      = newSuit,
            };

            return(request);
        }
Пример #2
0
 private void ChangeJokerIntoCard(ChangeJokerIntoAnotherCardRequest request,
                                  MainUser control, SynchronizationContext synchCont)
 {
     try
     {
         IMakaoGameHostService   proxy    = factory.CreateChannel();
         ChangeJokerCardResponse response = proxy.ChangeJokerIntoANotherCard(request);
         if (response.PlayerID == MainWindow.PlayerID)
         {
             synchCont.Post(_ => AssignMainControCards(control, response.CurrentPlayerCards), null);
         }
     }
     catch (Exception ex)
     {
         var logger = NLog.LogManager.GetCurrentClassLogger();
         logger.Error($"Error while changing joker to another card: {ex.Message}.");
     }
 }
        //request from clinent to change joker card into some another card
        ChangeJokerCardResponse IMakaoGameHostService.ChangeJokerIntoANotherCard(ChangeJokerIntoAnotherCardRequest request)
        {
            var logger = NLog.LogManager.GetCurrentClassLogger();

            logger.Info($"Engine host received request to change joker into naother card from player {request.PlayerNumber}.");
            bool       done = false;
            PlayerData data = DataPlaceholders.MakaoEngineHostDataPlaceholders.PlayersData.Single(x => x.PlayerNumber == request.PlayerNumber);

            if (data.PlayerID == request.PlayerID)
            {
                try
                {
                    done = DataPlaceholders.GameStateHolder.EngineInstance.ChangeJockerIntoAnotherCard(request.PlayerNumber, request.CardToChange, request.NewRank, request.NewSuit, false);
                }
                catch (Exception ex)
                {
                    logger.Error($"Error while changing joker into another card: {ex.Message}.");
                }
            }
            return(GenerateJokerChangingResponse(data, done));
        }
Пример #4
0
 public void ChangeJokerIntoAnotherCard(ChangeJokerIntoAnotherCardRequest request,
                                        MainUser control, SynchronizationContext synchCont)
 {
     Task.Run(() => ChangeJokerIntoCard(request, control, synchCont));
 }