private void LoopGame() { bool correctInput = false; while (correctInput == false) { ConCont.AskToDiscard(); String discardAnswer = ConCont.EvaluateDiscardAnswer(); if (discardAnswer == "Y") { correctInput = true; DiscardCards(); EvaluateHand(); } else if (discardAnswer == "N") { correctInput = true; EvaluateHand(); } else { correctInput = false; ConCont.PrintWrongInput(); } } }
private void EvaluateHand() { int prize = Hand.Prize; Balance += prize; ConCont.PrintWinningHand(prize); }
public void StartGame() { while (Balance > 0) { Deck = new Deck(); DealCards(); ConCont.PrintBalance(Balance); ConCont.PrintDealtCards(Hand.DealtCards); LoopGame(); } }
private void DiscardCards() { List <int> discardIndices = new List <int>(); ConCont.AskHowManyCardsToDiscard(); int numOfDiscards = ConCont.EvaluateDiscardNumberAnswer(); if (numOfDiscards <= 0 || numOfDiscards > 5) { while (numOfDiscards == 0) { ConCont.PrintWrongInput(); ConCont.AskHowManyCardsToDiscard(); numOfDiscards = ConCont.EvaluateDiscardNumberAnswer(); } } while (numOfDiscards > 0) { ConCont.AskWhichCardToDiscard(); int discardIndex = ConCont.EvaluateDiscardNumberAnswer(); if (discardIndex > 0 && !discardIndices.Contains(discardIndex - 1)) { discardIndex--; discardIndices.Add(discardIndex); numOfDiscards--; } else { ConCont.PrintWrongInput(); } } var sortedIndices = discardIndices.OrderBy(o => o).ToList(); for (int i = 0; i < sortedIndices.Count; i++) { sortedIndices[i] -= i; Hand.RemoveCard(sortedIndices[i]); Hand.AddCard(Deck.Cards[0]); Deck.RemoveCard(); } ConCont.PrintDealtCards(Hand.DealtCards); }