public ActionResult Draw(int[] arr, int betAmt) { drawCards = new List <Card>(); for (int i = 0; i < arr.Length; i++) { if (arr[i] == 0) { drawCards.Add(dealCards[i + 5]); } else { drawCards.Add(dealCards[i]); } } GameViewModel gameStatus = new GameViewModel { Message = "Game Over", Hand = drawCards, GameOver = true, Credits = (int)userAccountInfo.Credits, BetAmount = betAmt, Paytable = dbContext.JacksOrBetterPayouts.ToList() }; HandInfo.EvaluateHand(gameStatus, drawCards, userAccountInfo); return(Json(gameStatus, JsonRequestBehavior.AllowGet)); }
public GameModel Draw(int[] arr, int bet) { for (int i = 0; i < arr.Length; i++) { if (arr[i] == 0) { _drawCards.Add(_dealCards[i + 5]); } else { _drawCards.Add(_dealCards[i]); } } GameModel model = new GameModel { Message = ApplicationConstants.GameOver, Hand = _drawCards, GameOver = true, Credits = (int)_userAccountInfo.Credits, BetAmount = bet, DoubleBonusPaytable = dbContext.DoubleBonusPayouts.ToList() }; HandInfo.EvaluateHand(model, _drawCards, _userAccountInfo); if (model.Credits <= 0) { model.Credits = 100; _userAccountInfo.Credits = 100; dbContext.SaveChanges(); } return(model); }
public ActionResult Deal(int bet) { int userId = 1; userAccountInfo = dbContext.UserAccounts.Where(u => u.UserId == userId).FirstOrDefault(); List <int> shuffle = GameAction.ShuffleDeck(); dealCards = new List <Card>(); foreach (var item in shuffle) { var card = dbContext.Cards.Where(c => c.CardId == item).FirstOrDefault(); dealCards.Add(card); } foreach (var item in dealCards) { item.ImageName = item.ImageName.Insert(0, "/Images/"); } GameViewModel gameStatus = new GameViewModel { Message = "Hold / Draw 1 to 5 Cards", Hand = dealCards.Take(5).ToList(), GameOver = false, BetAmount = bet }; gameStatus.Paytable = dbContext.JacksOrBetterPayouts.ToList(); gameStatus.Credits = (int)userAccountInfo.Credits - gameStatus.BetAmount; HandInfo.EvaluateHand(gameStatus, dealCards, userAccountInfo); return(Json(gameStatus, JsonRequestBehavior.AllowGet)); }
public GameModel Deal(int bet) { List <int> shuffle = GameAction.ShuffleDeck(); _dealCards = new List <Card>(); foreach (var item in shuffle) { var card = dbContext.Cards.Where(c => c.CardId == item).FirstOrDefault(); _dealCards.Add(card); } GameModel model = new GameModel { Message = ApplicationConstants.HoldDrawMessage, Hand = _dealCards.Take(5).ToList(), GameOver = false, BetAmount = bet, DoubleBonusPaytable = dbContext.DoubleBonusPayouts.ToList(), Credits = (int)_userAccountInfo.Credits - bet }; HandInfo.EvaluateHand(model, _dealCards, _userAccountInfo); if (model.Credits <= 0) { model.Credits = 100; _userAccountInfo.Credits = 100; dbContext.SaveChanges(); } model.DoubleBonusPaytable = model.DoubleBonusPaytable.OrderByDescending(e => e.Id).ToList(); return(model); }