Skip to content

Commit

Permalink
Texas Hold'em Shuffle&Licensing v1.1
Browse files Browse the repository at this point in the history
Texas Hold'em Shuffle&Licensing v1.1
Shuffle&Licensing Made by a9210183
  • Loading branch information
a9210183 authored May 4, 2021
1 parent ce9a2e1 commit b7c26c7
Showing 1 changed file with 86 additions and 5 deletions.
91 changes: 86 additions & 5 deletions Main.cpp
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);
}
}

0 comments on commit b7c26c7

Please sign in to comment.