Advertisement
Guest User

second versioin ronhaaalp

a guest
Oct 16th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. using namespace std;
  4.  
  5. string playerone, playertwo;
  6. int p1win, p1lose;
  7. int p2win, p2lose;
  8. int p1drawcard;
  9. int p2drawcard;
  10. int p1highest;
  11. int p2highest;
  12.  
  13.  
  14. struct deck {
  15.     string suite;
  16.     int colorvalue;
  17.     int cardvalue;
  18.  
  19.     string number;
  20.    
  21. };
  22. deck cards[52] = {
  23.         {"hearts", 2,3, "Two of Hearts"},
  24.         {"hearts", 3,3, "Three of Hearts"},
  25.         {"hearts", 4,3, "Four of Hearts"},
  26.         {"hearts", 5,3, "Five of Hearts"},
  27.         {"hearts", 6,3, "Six of Hearts"},
  28.         {"hearts", 7,3, "Seven of Hearts"},
  29.         {"hearts", 8,3, "Eight of Hearts"},
  30.         {"hearts", 9,3, "Nine of Hearts"},
  31.         {"hearts", 10,3, "Ten of Hearts"},
  32.         {"hearts", 11,3, "Jack of Hearts"},
  33.         {"hearts", 12,3, "Queen of Hearts"},
  34.         {"hearts", 13,3, "King of Hearts"},
  35.         {"hearts", 14,3, "Ess of Hearts"},
  36.         {"spades", 2,4, "Two of Spades"},
  37.         {"spades", 3,4, "Three of Spades"},
  38.         {"spades", 4,4, "Four of Spades"},
  39.         {"spades", 5,4, "Five of Spades"},
  40.         {"spades", 6,4, "Six of Spades"},
  41.         {"spades", 7,4, "Seven of Spades"},
  42.         {"spades", 8,4, "Eight of Spades"},
  43.         {"spades", 9,4, "Nine of Spades"},
  44.         {"spades", 10,4, "Ten of Spades"},
  45.         {"spades", 11,4, "Jack of Spades"},
  46.         {"spades", 12,4, "Queen of Spades"},
  47.         {"spades", 13,4, "King of Spades"},
  48.         {"spades", 14,4, "Ess of Spades"},
  49.         {"diamonds", 2,2, "Two of Diamonds"},
  50.         {"diamonds", 3,2, "Three of Diamonds"},
  51.         {"diamonds", 4,2, "Four of Diamonds"},
  52.         {"diamonds", 5,2, "Five of Diamonds"},
  53.         {"diamonds", 6,2, "Six of Diamonds"},
  54.         {"diamonds", 7,2, "Seven of Diamonds"},
  55.         {"diamonds", 8,2, "Eight of Diamonds"},
  56.         {"diamonds", 9,2, "Nine of Diamonds"},
  57.         {"diamonds", 10,2, "Ten of Diamonds"},
  58.         {"diamonds", 11,2, "Jack of Diamonds"},
  59.         {"diamonds", 12,2, "Queen of Diamonds"},
  60.         {"diamonds", 13,2, "King of Diamonds"},
  61.         {"diamonds", 14,2, "Ess of Diamonds"},
  62.         {"clubs", 2,1, "Two of Clubs"},
  63.         {"clubs", 3,1, "Three of Clubs"},
  64.         {"clubs", 4,1, "Four of Clubs"},
  65.         {"clubs", 5,1, "Five of Clubs"},
  66.         {"clubs", 6,1, "Six of Clubs"},
  67.         {"clubs", 7,1, "Seven of Clubs"},
  68.         {"clubs", 8,1, "Eight of Clubs"},
  69.         {"clubs", 9,1, "Nine of Clubs"},
  70.         {"clubs", 10,1, "Ten of Clubs"},
  71.         {"clubs", 11,1, "Jack of Clubs"},
  72.         {"clubs", 12,1, "Queen of Clubs"},
  73.         {"clubs", 13,1, "King of Clubs"},
  74.         {"clubs", 14,1, "Ess of Clubs"},
  75. };
  76.  
  77. //BÖRJA HÄR
  78. //Gör en shuffle funktion för deck så att alla rader blandas. Då behövs inte rand().
  79. //Har gett färg ett värde och nummer på korten ett värde. Funkar det som det är nu eller måste alla anges som "4,2... 1,5....3,1...."?
  80.  
  81.  
  82.  
  83. int game(){
  84.    
  85.     int p1holdcard;
  86.     p1drawcard=rand()%52;
  87.     p2drawcard=rand()%52;
  88.     cout << cards[p1drawcard].number<<endl;
  89.  
  90.    
  91.     cout << cards[p2drawcard].number <<endl;
  92.     cout << p1drawcard<<endl;
  93.     cout << p2drawcard<<endl;
  94.    
  95.     if (p1card>p2card){
  96.         cout<< playerone<< " WINS!!!"<<endl;
  97.         p1win++;
  98.         p2lose++;
  99.        
  100.        
  101.     }
  102.    
  103.     else if (p2card>p1card){
  104.         cout << playertwo<< " WINS!!!"<<endl;
  105.         p2win++;
  106.         p1lose++;
  107.     }
  108.    
  109.    
  110.     return p1card;
  111.     }
  112.  
  113. int main() {
  114.    
  115.     srand(time(0));
  116.    
  117.     cout << "Hey players!"<<endl;
  118.     cout << "To start we need the name of 2 players, please enter below!"<<endl;
  119.     cout << "First player!"<<endl;
  120.     cin>> playerone;
  121.     cout<< "Second player!"<<endl;
  122.     cin>> playertwo;
  123.    
  124.    
  125.     cout << "Welcome " << playerone<< " & " << playertwo<<endl;
  126.     cout << "The game persist in best of 3 rounds."<<endl;
  127.     cout << "But the rules are simple, take 1 card each out of the deck."<<endl;
  128.     cout << " The player that scores the highest number wins that round!"<<endl;
  129.     cout <<  "Aces are to be considered as the highest value"<<endl;
  130.    
  131.    
  132.     cout << "If both players draw the same value the one with highest color wins"<<endl;
  133.     cout << "Colors are ranked spades>hearts>diamonds>cloves>"<<endl;
  134.     cout << "Okey " <<playerone<< " & " <<playertwo<< " let the one with the most luck win!"<<endl;
  135.     game();
  136.     cout << p1win << p1lose << p2win << p2lose;
  137.     return 0;
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement