-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Texas Hold'em Shuffle&Licensing v1.1
Texas Hold'em Shuffle&Licensing v1.1 Shuffle&Licensing Made by a9210183
- Loading branch information
Showing
1 changed file
with
86 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,95 @@ | ||
#include<iostream> | ||
#include<iomanip> | ||
#include <windows.h> | ||
|
||
#include <conio.h> | ||
|
||
extern void Title(); //片頭 (Title.cpp) | ||
|
||
#include <iostream> | ||
#include <iomanip> | ||
#include <string> | ||
#include <ctime> | ||
|
||
#include "Card.h" | ||
#include "Player.h" | ||
|
||
using namespace std; | ||
|
||
extern void Title(); //片頭 (Title.cpp) | ||
void ShufflePoker(); | ||
int PlayerNumber(); | ||
|
||
int main() | ||
//變數 | ||
const int NUMBER_OF_CARDS = 52; //卡數 | ||
Card poker[52]; //class Card 撲克牌物件 | ||
const int player_number = PlayerNumber(); | ||
|
||
//Shuffle | ||
void ShufflePoker() | ||
{ | ||
int deck[NUMBER_OF_CARDS] = {0};//卡片 | ||
|
||
for (int i = 0; i < NUMBER_OF_CARDS; i++) | ||
{ | ||
deck[i] = i;//帶入卡號 | ||
} | ||
|
||
srand(time(0)); //取時間 | ||
for (int i = 0; i < NUMBER_OF_CARDS; i++) //洗牌 | ||
{ | ||
int index = rand() % NUMBER_OF_CARDS; | ||
int temp = deck[i]; | ||
deck[i] = deck[index]; | ||
deck[index] = temp; | ||
} | ||
|
||
for (int i = 0; i < 52; i++) | ||
{ | ||
poker[i].setSpecies(deck[i] / 13); //輸入花色 | ||
poker[i].setNumber(deck[i] % 13); //輸入數字 | ||
} | ||
} | ||
int PlayerNumber() | ||
{ | ||
int player = 0; | ||
cout << "有幾個人: " << endl; | ||
cin >> player; | ||
return player; | ||
} | ||
void ShowPlayerCard(Player Player[],int playerNumber) | ||
{ | ||
string suits[] = { "Spades","Hearts","Diamonds","Clubs" }; | ||
string ranks[] = { "Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King" }; | ||
|
||
cout << "--------------------------Player" << playerNumber<< endl; | ||
for (int i = 0; i < 2; i++) | ||
{ | ||
cout << suits[Player[playerNumber].getCardSpecies(i)] << " " << ranks[Player[playerNumber].getCardNumber(i)] << endl; | ||
} | ||
} | ||
void inputPlayerCard(Player Player[], int playerNumber) | ||
{ | ||
Title(); | ||
static int cardNumber = 0; | ||
for (int j=0;j<playerNumber;j++) | ||
{ | ||
for (int i = 0; i < 2; i++) | ||
{ | ||
Player[j].setCard(i, poker[cardNumber]); | ||
cardNumber++; | ||
} | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
//Title(); //片頭 | ||
|
||
ShufflePoker(); //洗牌function | ||
|
||
Player Player[10]; | ||
|
||
inputPlayerCard(Player, player_number); | ||
|
||
for (int j = 0; j < player_number;j++) | ||
{ | ||
ShowPlayerCard(Player, j); | ||
} | ||
} |