15.09.2012, 22:12
ok, the best idea is to see the whole cardset as one array of values from 0 to 51. there are 4*13=52 cards, no joker in poker.. argh that rhymes.
the worthless "color" is the diamond, then increasing to heart, spade, club:
now you can work with those "multiplicators", or a fake 2nd array, to use the values 0-12 aswell.
CARDCOLOR_CLUB*13+1 is the ace indeed, where +12 is the king.
let each player hold 5 cards max:
now you are facing the problem "how to spread cards to players without repeating a single card?"
to answer this question in advance: how do you do it irl? you take 52 cards,
then you mix them
now, since the cards are mixed, give each player one, while increasing the "pointer" to the card array by 1 each time..
if any questions arise, i think we all are glad to help :P
@Vince: i agree, poker is not that easy to script, i prefer (french) roulette ^^
scripting the rules "only" maybe is easier than we might think, but when it comes to a NPC opponent, then i would even place a wager on a fail.
the worthless "color" is the diamond, then increasing to heart, spade, club:
pawn Код:
#define CARDCOLOR_DIAMOND 0
#define CARDCOLOR_HEART 1
#define CARDCOLOR_SPADE 2
#define CARDCOLOR_CLUB 3
CARDCOLOR_CLUB*13+1 is the ace indeed, where +12 is the king.
let each player hold 5 cards max:
pawn Код:
new PlayerCard[MAX_PLAYERS][5];
to answer this question in advance: how do you do it irl? you take 52 cards,
pawn Код:
new CardsToMix[52]={0,1,...};
pawn Код:
new temp,swapposition;
for(new a=0;a<52;a++)
{
swapposition=random(52);
temp=CardsToMix[a];
CardsToMix[a]=CardsToMix[swapposition];
CardsToMix[swapposition]=temp;
}
if any questions arise, i think we all are glad to help :P
@Vince: i agree, poker is not that easy to script, i prefer (french) roulette ^^
scripting the rules "only" maybe is easier than we might think, but when it comes to a NPC opponent, then i would even place a wager on a fail.