Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void print(vector <int> playerhand){
- HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(hConsole, 15);
- char suits[4] = {3, 4, 5, 6}; //all the possible suits in order(3 = heart, 4 = diamond, 5 = clover, 6 = spade)
- string ranks[13] = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"}; //all possible ranks
- cout<<"\nPlayer's hand: \n"; //declares that the computer is printing the player's hand
- for(int j = 0; j < 10; j++){ //repeats for a length of 10(length of card is 10 for this program)
- for(int i = 0; i < playerhand.size(); i++){ //repeats for how many cards are in the hand
- if(j == 0 || j == 9){ //if it is the first or last line of the card
- cout<<"----------"; //outputs a line
- }
- else if(j == 1){ //the second line has the rank on the left hand side
- cout<<"|"<< ranks[playerhand[i] % 13];
- if(playerhand[i] % 13 == 9) //if the number is 10(only one that takes 2 spaces)
- cout<<" |"; //then it takes a space away to equilize it
- else
- cout<<" |"; //else all others take only 1 space
- }
- else if(j == 8){ //second to last line has the rank on the right hand side
- if(playerhand[i] % 13 == 9)
- cout<<"| "; //if the rank takes 2 spaces(10) then it puts 1 less space
- else
- cout<<"| ";//else all others take 1 space
- cout<<ranks[playerhand[i] % 13]<<"|"; //prints rank and ends card
- }
- else if(j == 4){ //if the line is in the middle, then there is a suit there
- cout<<"| "; //prints the side bar and spaces
- if(suits[playerhand[i] / 13] == char(3) || suits[playerhand[i] / 13] == char(4)){ //if the icon is a heart or diamond,
- SetConsoleTextAttribute(hConsole, 12); //sets print color to red
- cout<<suits[playerhand[i] / 13]; //prints the suit
- }
- else{ //else the only ones left are spade and clover
- SetConsoleTextAttribute(hConsole, 8); //sets print color to gray
- cout<<suits[playerhand[i] / 13]; //prints the suit
- }
- SetConsoleTextAttribute(hConsole, 15); //sets print color back to white
- cout<<" |"; //ends the card
- }
- else
- cout<<"| |"; //else there there is nothing special on that line and prints a blank
- cout<<" "; //prints the space in between cards
- }
- cout<<"\n"; //goes to next line
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement