Best way to define the Cards?
#1

Heey all,

I want to define the cards from the casino like :Heart,Club,Spade and Diamond.
How can i define all the cards?


Admigo
Reply
#2

Heart, Club, Spade, Diamond
x
Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K
=
pawn Код:
new Card[4][13];
or do you mean assigning a value to them? like card=25 (with a max of 51), then

pawn Код:
Color=card/13;
Number=card%13;
25/13=1 (Club)
25%13=12 (King)
Reply
#3

Thanks for u repply.
How i check if someone has the card(playerid)?
Reply
#4

if you dont mind, show me your script. its dead easy to add a check, however you scritped it so far ^^
did you already set a players card, any value? how many cards can a player hold? what game are you scripting?
Reply
#5

I didnt made something yet. First i need to make the cards. Then i need to make the pokerhands. I want to make Texas Hold Em.
Reply
#6

With all due respect, but I don't think you'll be able to create such sophisticated script. I'd like to guard you against failure and disappointment.

I have tried to create a poker script like that, and believe me it's MUCH harder than you might think. The function to find out what hand a player has from any of 7 cards (5 on the table plus 2 in hand) alone is already 250 lines long, and yet I'm sure there are still unpatched holes in it.
Reply
#7

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:
pawn Код:
#define CARDCOLOR_DIAMOND 0
#define CARDCOLOR_HEART 1
#define CARDCOLOR_SPADE 2
#define CARDCOLOR_CLUB 3
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:
pawn Код:
new PlayerCard[MAX_PLAYERS][5];
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,
pawn Код:
new CardsToMix[52]={0,1,...};
then you mix them
pawn Код:
new temp,swapposition;
for(new a=0;a<52;a++)
{
swapposition=random(52);
temp=CardsToMix[a];
CardsToMix[a]=CardsToMix[swapposition];
CardsToMix[swapposition]=temp;
}
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.
Reply
#8

@vince i think it is possible, i know a server using a card system which can hold 5 cards each player.
Reply
#9

Quote:
Originally Posted by Vince
Посмотреть сообщение
With all due respect, but I don't think you'll be able to create such sophisticated script. I'd like to guard you against failure and disappointment.

I have tried to create a poker script like that, and believe me it's MUCH harder than you might think. The function to find out what hand a player has from any of 7 cards (5 on the table plus 2 in hand) alone is already 250 lines long, and yet I'm sure there are still unpatched holes in it.
You will not stop me from making this. I will not giving up making this script
EDIT: This is just the beginning.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)