Hello Working on a poker game. I have my cards randomly being called from a file, but I want there to be no duplicates. for example, no 2 five of clubs, or 2 jack of spades in the same hand. That's basically what I have been trying to do, and once I get that done, my game should be finished Here is some of the code
string[] CardDisplay = new string[5];
for (int i = 0; i < 5; i++)
{
CardDisplay[i] = getRandomImage();
}
PokerCard[0] = PokerCard1.ImageUrl = Path.Combine("~/GameStyles/VideoPoker/Images/Poker/", CardDisplay[0]);
PokerCard[1] = PokerCard2.ImageUrl = Path.Combine("~/GameStyles/VideoPoker/Images/Poker/", CardDisplay[1]);
PokerCard[2] = PokerCard3.ImageUrl = Path.Combine("~/GameStyles/VideoPoker/Images/Poker/", CardDisplay[2]);
PokerCard[3] = PokerCard4.ImageUrl = Path.Combine("~/GameStyles/VideoPoker/Images/Poker/", CardDisplay[3]);
PokerCard[4] = PokerCard5.ImageUrl = Path.Combine("~/GameStyles/VideoPoker/Images/Poker/", CardDisplay[4]);
public string getRandomImage()
{
string[] fileNames = Directory.GetFiles(MapPath("~/GameStyles/VideoPoker/Images/Poker/"));
int CurrentPick;
CurrentPick = rand.Next(fileNames.Length);
string CardToShow = fileNames[CurrentPick];
return Path.GetFileName(CardToShow);
}
Here is a screenshot of what I have