public HttpResponseMessage PlayMove(PlayMoveRequest request)
        {
            var result = new PlayMoveResult();

            try
            {
                result = service.PlayMove(request);
            }
            catch (Exception e)
            {
                result.ErrorMessage = e.Message;
                result.Success      = false;
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, result));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Exemple #2
0
        public PlayMoveResult PlayMove(PlayMoveRequest request)
        {
            var result = new PlayMoveResult();

            try
            {
                User user = _cache.GetSecuredUser(request.SecurityKey, request.UserName);

                //getting the acting player
                Player player = null;
                foreach (Player p in user.Players)
                {
                    if (p.GetHashCode() == request.Player)
                    {
                        player = p;
                        break;
                    }
                }
                if (player == null)
                {
                    throw new PlayerNotFoundException("Player not found in user's players list");
                }

                user.ChoosePlayMove(player, new PlayMoveEventArgs(request.PlayMove, request.AmountOfMoney));

                while (player == GameCenter.FindRoomsByCriteria(-1, player).ElementAt(0).CurrentHand.CurrentRound.CurrentPlayer)
                {
                    ;
                }

                result.NextPlayer       = GameCenter.FindRoomsByCriteria(-1, player).ElementAt(0).CurrentHand.CurrentRound.CurrentPlayer.GetHashCode();
                result.TotalRaise       = GameCenter.FindRoomsByCriteria(-1, player).ElementAt(0).CurrentHand.CurrentRound.TotalRaise;
                result.LastRaise        = GameCenter.FindRoomsByCriteria(-1, player).ElementAt(0).CurrentHand.CurrentRound.LastRaise;
                result.NextPlayerInvest = GameCenter.FindRoomsByCriteria(-1, player).ElementAt(0).CurrentHand.CurrentRound.LiveBets[player];
                result.Success          = true;
            }
            catch (PokerException e)
            {
                result.Success      = false;
                result.ErrorMessage = e.Message;
                Logger.Error(e, this);
            }

            return(result);
        }