private void putAceinposition(int index) { //recall 8s go in (index == 0 || index == 9 || index == 10 ) Boolean notlocatedthenew8 = true; int index8 = 0; PokerCard Card8 = AllCards[index]; while (notlocatedthenew8) { Card TempCard1 = AllCards[index8]; if (TempCard1.GetCardValue() == 8) { if (index8 == 10) { return;//all done } if (index8 == 9) { index8 = 10; } if (index8 == 0) { index8 = 9;// 0 is already in its place go to the next pos } } else { // its ok to swap them AllCards[aceindex] is not an ace PokerCard OriginalCard = AllCards[index8]; AllCards[index8] = Card8; AllCards[index] = OriginalCard; notlocatedthenew8 = false; } } }
private void PlayCard(int index, Hand hand) { if (hand.isPlayer && !gameManager.CheckIfValidMove(PlayerHand, index, CardonTopofPile)) //Check if player move is valid { return; } else { CardonTopofPile = gameManager.PlayCard(hand, index, CardonTopofPile); updateGraphics(hand, index, true); if (hand.isPlayer && !gameManager.HasWon(PlayerHand)) // If hand is player, start dealer turn { DealerLogic(); } } if (gameManager.HasWon(hand)) // Check for win { if (hand.isPlayer) { MessageBox.Show("Congratulations, You won!"); } else { MessageBox.Show("Dealer Won."); } GameOver = true; } }
public void shuffleCards() { ResetCardsDiscarded();//added for crazy 8's int timestoshuffle = ranNumberGenerator.Next(41, 100); for (int index = 0; index < timestoshuffle; index++) { int r1 = ranNumberGenerator.Next(0, 52); int r2 = ranNumberGenerator.Next(0, 52); PokerCard TempCard1 = AllCards[r1]; if (TempCard1.GetCardisanAce()) { TempCard1.SetCardToAceValue11(); } PokerCard TempCard2 = AllCards[r2]; if (TempCard2.GetCardisanAce()) { TempCard2.SetCardToAceValue11(); } AllCards[r1] = TempCard2; AllCards[r2] = TempCard1; } String msg = " "; for (int index = 0; index < 52; index++) { int value = AllCards[index].GetCardValue(); msg = msg + "i: " + index + " value is : " + value + "\n"; Console.WriteLine("i: " + index + " value is : " + value); } // MessageBox.Show(msg); }
public void DealACardtoMe(PokerCard ACard) { if (numberofcards < 5) { MyCards[numberofcards] = ACard; totalvalue = totalvalue + ACard.GetCardValue(); numberofcards++; } }
private void DealACardtoDealer() { int cardnumber = DealerHand.GetNumberofCards(); if (cardnumber < 5) { PokerCard ACard = DeckofCards.GetNextCard(); DealerHand.DealACardtoMe(ACard); updateGraphics(DealerHand, cardnumber, false); } }
public void LoadCards() { PokerCard ACard; String msg = ""; try { string[] list = Directory.GetFiles(@"cards", "*.gif"); Array.Sort(list); int suit = 0; for (int index = 0; index < 52; index++) { int value = GetNextCardValue(index); Image image = Image.FromFile(list[index]); ACard = new PokerCard(image, value, suit++); if (suit == 4) { suit = 0; } if (index > 31 && index < 36) { ACard.SetCardToAce(); } AllCards[index] = ACard; } string[] list2 = Directory.GetFiles(@"cards", "Wfswbackcard*.gif"); Image Backimage = Image.FromFile(list2[0]); ACardBack = new Card(Backimage, 0); } catch (Exception e) { if (tries < 2) { msg = "Error Please make sure the card files in the Directory. \nWhen you put the cards in the Directory hit OK button.\n\n " + e.ToString(); MessageBox.Show(msg); tries++; LoadCards(); } else { Environment.Exit(1); } } }
private void AddCardToHand(Hand hand) { for (int i = 0; i < 5; i++) // Looping through cards in deck to find a discarded card { PokerCard card = hand.GetaCard(i); if (card.isDiscarded) { hand.setACard(i, DeckofCards.GetNextCard()); updateGraphics(hand, i, true); if (!hand.isPlayer) { Task.Delay(1000).Wait(); //if hand is dealer, add delay. } break; } } }
private void updateGraphics(Hand handToUpdate, int index, bool updateCardOnTop) { List <Button> buttonListToUse = GetButtonList(handToUpdate); // Returns which list of Buttons to use for update. PokerCard card = handToUpdate.GetaCard(index); if (card.isDiscarded) { buttonListToUse[index].Image = BackCard.GetCardImage();; } else { buttonListToUse[index].Image = card.GetCardImage(); } if (updateCardOnTop) { TopCardButton.Image = CardonTopofPile.GetCardImage(); } }
public void DealACardtoMeIndex(PokerCard ACard, int index) { MyCards[index] = ACard; MyCards[index].Setdiscarded(false); totalvalue = totalvalue + ACard.GetCardValue(); }
public void setACard(int index, PokerCard card) { MyCards[index] = card; }
private void ChangeCardinCardPile(PokerCard ACard) { ACard.isDiscarded = true; CardonTopofPile = ACard; TopCardButton.Image = ACard.GetCardImage(); }
private void DealACardtoCardPile() { PokerCard ACard = DeckofCards.GetNextCard(); ChangeCardinCardPile(ACard); }