1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
#include <iostream>
#include <memory.h>
#include <time.h>
#include "Cards.h"
using namespace std;
char * ValueNames [] = {"Two",
"Three",
"Four",
"Five",
"Six",
"Seven",
"Eight",
"Nine",
"Ten",
"Jack",
"Queen",
"King",
"Ace"};
void Deal (Card Deck [], Hand MyHands [], ULong NumHands)
{
ULong HandNo;
ULong CardNo;
ULong WhichCard (0);
//Deal the hands
for (CardNo = 0; CardNo < 5; CardNo++)
for (HandNo = 0; HandNo < NumHands; HandNo++)
MyHands [HandNo].Crd [CardNo] = Deck [WhichCard++];
//Display the unsorted hands
for (HandNo = 0; HandNo < NumHands; HandNo++)
{
cout << "\nPlayer " << HandNo + 1 << "'s Hand" << endl;
for (CardNo = 0; CardNo < 5; CardNo++)
Display (MyHands [HandNo].Crd [CardNo]);
}
//Sort the hands
for (HandNo = 0; HandNo < NumHands; HandNo++)
Sort (MyHands);
//Display the sorted hands
for (HandNo = 0; HandNo < NumHands; HandNo++)
{
cout << "\nPlayer " << HandNo + 1 << "'s Sorted Hand" << endl;
for (CardNo = 0; CardNo < 5; CardNo++)
Display (MyHands [HandNo].Crd [CardNo]);
}
}
//function for sorting the hands
void Sort (Hand MyHands)
{
ULong i;
ULong NumHands (5);
bool Sorted;
Card TempCard;
do {
Sorted = true;
for (i = 0; i < NumHands; i++)
if (MyHands.Crd [i].Value > MyHands.Crd [i+1].Value)
{
TempCard = MyHands.Crd [i];
MyHands.Crd [i] = MyHands.Crd [i+1];
MyHands.Crd [i+1] = TempCard;
Sorted = false;
}
else;
} while (!Sorted);
}
//function for displaying the cards/hands on screen
void Display (const Card & Crd)
{
cout << ValueNames [Crd.Value] << " of " << (char) Crd.Suit << endl;
}
//function for shuffling cards
void Shuffle (Card Deck [])
{
long i;
bool Picked [52];
long WhichCard;
srand (time (0));
memset (Picked, false, 52 * sizeof (bool));
for (i = 0; i < 52; i++)
{
while (Picked [WhichCard = rand () % 52]);
Deck [i].Suit = (Suits) ((WhichCard / 13) + Hearts);
Deck [i].Value = (Values) (WhichCard % 13);
Picked [WhichCard] = true;
Display (Deck [i]);
}
}
//bool for royal flush
bool IsRoyalFlush (Hand & MyHand)
{
}
//bool for straight flush
bool IsStraightFlush (Hand & MyHand)
{
}
//bool for straight
bool IsStraight (Hand & MyHand)
{
}
//bool for flush
bool IsFlush (Hand & MyHand)
{
}
//bool for four of a kind
bool IsFourOfaKind (Hand & MyHand)
{
}
//bool for full house
bool IsFullHouse (Hand & MyHand)
{
}
//bool for three of a kind
bool IsThreeOfaKind (Hand & MyHand)
{
}
//bool for two pair
bool IsTwoPair (Hand & MyHand)
{
}
//bool for one pair
bool IsOnePair (Hand & MyHand)
{
}
|