Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- using namespace std;
- string playerone, playertwo;
- int p1win, p1lose;
- int p2win, p2lose;
- int p1drawcard;
- int p2drawcard;
- int p1highest;
- int p2highest;
- struct deck {
- string suite;
- int colorvalue;
- int cardvalue;
- string number;
- };
- deck cards[52] = {
- {"hearts", 2,3, "Two of Hearts"},
- {"hearts", 3,3, "Three of Hearts"},
- {"hearts", 4,3, "Four of Hearts"},
- {"hearts", 5,3, "Five of Hearts"},
- {"hearts", 6,3, "Six of Hearts"},
- {"hearts", 7,3, "Seven of Hearts"},
- {"hearts", 8,3, "Eight of Hearts"},
- {"hearts", 9,3, "Nine of Hearts"},
- {"hearts", 10,3, "Ten of Hearts"},
- {"hearts", 11,3, "Jack of Hearts"},
- {"hearts", 12,3, "Queen of Hearts"},
- {"hearts", 13,3, "King of Hearts"},
- {"hearts", 14,3, "Ess of Hearts"},
- {"spades", 2,4, "Two of Spades"},
- {"spades", 3,4, "Three of Spades"},
- {"spades", 4,4, "Four of Spades"},
- {"spades", 5,4, "Five of Spades"},
- {"spades", 6,4, "Six of Spades"},
- {"spades", 7,4, "Seven of Spades"},
- {"spades", 8,4, "Eight of Spades"},
- {"spades", 9,4, "Nine of Spades"},
- {"spades", 10,4, "Ten of Spades"},
- {"spades", 11,4, "Jack of Spades"},
- {"spades", 12,4, "Queen of Spades"},
- {"spades", 13,4, "King of Spades"},
- {"spades", 14,4, "Ess of Spades"},
- {"diamonds", 2,2, "Two of Diamonds"},
- {"diamonds", 3,2, "Three of Diamonds"},
- {"diamonds", 4,2, "Four of Diamonds"},
- {"diamonds", 5,2, "Five of Diamonds"},
- {"diamonds", 6,2, "Six of Diamonds"},
- {"diamonds", 7,2, "Seven of Diamonds"},
- {"diamonds", 8,2, "Eight of Diamonds"},
- {"diamonds", 9,2, "Nine of Diamonds"},
- {"diamonds", 10,2, "Ten of Diamonds"},
- {"diamonds", 11,2, "Jack of Diamonds"},
- {"diamonds", 12,2, "Queen of Diamonds"},
- {"diamonds", 13,2, "King of Diamonds"},
- {"diamonds", 14,2, "Ess of Diamonds"},
- {"clubs", 2,1, "Two of Clubs"},
- {"clubs", 3,1, "Three of Clubs"},
- {"clubs", 4,1, "Four of Clubs"},
- {"clubs", 5,1, "Five of Clubs"},
- {"clubs", 6,1, "Six of Clubs"},
- {"clubs", 7,1, "Seven of Clubs"},
- {"clubs", 8,1, "Eight of Clubs"},
- {"clubs", 9,1, "Nine of Clubs"},
- {"clubs", 10,1, "Ten of Clubs"},
- {"clubs", 11,1, "Jack of Clubs"},
- {"clubs", 12,1, "Queen of Clubs"},
- {"clubs", 13,1, "King of Clubs"},
- {"clubs", 14,1, "Ess of Clubs"},
- };
- //BÖRJA HÄR
- //Gör en shuffle funktion för deck så att alla rader blandas. Då behövs inte rand().
- //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...."?
- int game(){
- int p1holdcard;
- p1drawcard=rand()%52;
- p2drawcard=rand()%52;
- cout << cards[p1drawcard].number<<endl;
- cout << cards[p2drawcard].number <<endl;
- cout << p1drawcard<<endl;
- cout << p2drawcard<<endl;
- if (p1card>p2card){
- cout<< playerone<< " WINS!!!"<<endl;
- p1win++;
- p2lose++;
- }
- else if (p2card>p1card){
- cout << playertwo<< " WINS!!!"<<endl;
- p2win++;
- p1lose++;
- }
- return p1card;
- }
- int main() {
- srand(time(0));
- cout << "Hey players!"<<endl;
- cout << "To start we need the name of 2 players, please enter below!"<<endl;
- cout << "First player!"<<endl;
- cin>> playerone;
- cout<< "Second player!"<<endl;
- cin>> playertwo;
- cout << "Welcome " << playerone<< " & " << playertwo<<endl;
- cout << "The game persist in best of 3 rounds."<<endl;
- cout << "But the rules are simple, take 1 card each out of the deck."<<endl;
- cout << " The player that scores the highest number wins that round!"<<endl;
- cout << "Aces are to be considered as the highest value"<<endl;
- cout << "If both players draw the same value the one with highest color wins"<<endl;
- cout << "Colors are ranked spades>hearts>diamonds>cloves>"<<endl;
- cout << "Okey " <<playerone<< " & " <<playertwo<< " let the one with the most luck win!"<<endl;
- game();
- cout << p1win << p1lose << p2win << p2lose;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement