Example #1
0
 public HandStatProcessor(HandStatRequest request)
 {
     hCalc = new HandCalculator();
     StartHands = new List<Hand>();
     OrderedStartHands = new List<Hand>();
     BoardCards = new List<Card>();
     DeadCards = new List<Card>();
     SetUpStartHands(request);
     if (request.BoardCardIds != null && request.BoardCardIds.Count > 0)
         SetUpBoardCards(request);
     if (request.DeadCardIds != null && request.DeadCardIds.Count > 0)
         SetUpDeadCards(request);
 }
Example #2
0
        public void SetUpStartHands(HandStatRequest request)
        {
            NumPlayers = request.NumPlayers;
            //if(request.HandCardIds.Count%2 != 0 || NumPlayers != request.HandCardIds.Count/2)
            //    throw new Exception("Invalid request.");
            for (int i = 0; i < request.HandCardIds.Count; i++)
            {
                var cards = new List<Card>();
                if(request.HandCardIds[i].Count != 2)
                    throw new Exception("Invalid request.");
                for (int j = 0; j < request.HandCardIds[i].Count; j++)
                {
                    cards.Add(Card.AllCards[request.HandCardIds[i][j]]);
                }

                StartHands.Add(new Hand(cards));
            }

            OrderedStartHands = StartHands.OrderBy(sh => sh.Cards[0].Id).ToList();
        }
Example #3
0
 public void SetUpDeadCards(HandStatRequest request)
 {
     for (int i = 0; i < request.BoardCardIds.Count; i++)
         DeadCards.Add(Card.AllCards[request.DeadCardIds[i]]);
 }
Example #4
0
 public void SetUpBoardCards(HandStatRequest request)
 {
     if (request.BoardCardIds.Count > 5)
         throw new Exception("Invalid request.");
     for (int i = 0; i < request.BoardCardIds.Count; i++)
         BoardCards.Add(Card.AllCards[request.BoardCardIds[i]]);
 }
Example #5
0
 public JsonResult GetHandStats(HandStatRequest request)
 {
     var handStatProcessor = new HandStatProcessor(request);
     var response = handStatProcessor.ProcessRequest();
     return Json(response);
 }