Radiant,
Your solution will very likely give the same card to more than one person.
The best way to do this in AGS is I think to make a list of the cards, shuffle it, and deal the cards out.
With the assumptions: cards are inv 10-37, characters 1-7:
Code: ags
Cheers,
Steve
Your solution will very likely give the same card to more than one person.
The best way to do this in AGS is I think to make a list of the cards, shuffle it, and deal the cards out.
With the assumptions: cards are inv 10-37, characters 1-7:
// make a list
int cardList[28];
int card = 0;
while (card < 28)
{
Ã, cardList[card] = 10 + card;Ã, // inv 10-37
Ã, card++;
}
// shuffle it
int shuffleSteps = 50;
while (shuffleSteps > 0)
{
Ã, // swap two random cards
Ã, int firstCardIndex = Random(27);
Ã, int secondCardIndex = Random(27);
Ã, int temp = cardList[firstCardIndex];
Ã, cardList[firstCardIndex] = cardList[secondCardIndex];
Ã, cardList[secondCardIndex] = temp;
Ã, shuffleSteps--;
}
// now deal out to characters
int charIndex = 1;
int cardIndex = 0;
while (charIndex < 8)
{
Ã, int cardCount = 0;
Ã, while (cardCount < 4)
Ã, {
Ã, Ã, AddInventoryToCharacter(charIndex, cardIndex);
Ã, Ã, cardIndex++;
Ã, Ã, cardCount++;
Ã, }
Ã, charIndex++;
}
Cheers,
Steve