home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
games
/
volume15
/
accordian
/
part01
/
cards.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-27
|
958b
|
87 lines
/*
* cards.c - generic card utilities
*/
#include "cards.h"
char *cards[] = {
"A",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"J",
"Q",
"K"
};
char *cardnames[] = {
"Ace",
"Two",
"Three",
"Four",
"Five",
"Six",
"Seven",
"Eight",
"Nine",
"Ten",
"Jack",
"Queen",
"King"
};
char *suits[] = {
"S",
"H",
"C",
"D"
};
char *suitnames[] = {
"Spades",
"Hearts",
"Clubs",
"Diamonds"
};
shuffle()
{
int i;
for (i=0; i<52; i++) {
swap(i,RANDOM() % 52);
}
}
swap(card1,card2)
int card1, card2;
{
int face, suit;
face = deck[card1].face;
deck[card1].face = deck[card2].face;
deck[card2].face = face;
suit = deck[card1].suit;
deck[card1].suit = deck[card2].suit;
deck[card2].suit = suit;
}
newdeck()
{
int face;
int suit;
for (face = 0; face < 13; face++) {
for (suit=0; suit<4; suit++) {
deck[suit*13+face].face = face;
deck[suit*13+face].suit = suit;
}
}
}