Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void main_menu()
- {
- int option = 0;
- while((option !=1)&&(option !=2))
- {
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10);
- centerText("Welcome to OLD MAID!");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
- centerText("--------------------");
- cout << endl;
- centerText("Please choose an option: ");
- centerText("1) Start game");
- centerText("2) Read rules");
- gotoxy(40,10);
- cin >> option;
- if((option !=1)&&(option !=2))
- {
- system("cls");
- centerText("Invalid choice. Please pick again.");
- cout << endl;
- }
- if(option == 2)
- {
- system("cls");
- display_rules();
- }
- if(option == 1)
- {
- system("cls");
- }
- }
- }
- void centerText(char* s)
- {
- int l=strlen(s);
- int pos=(int)((120-l)/2);
- for(int i=0;i<pos;i++)
- cout <<" ";
- cout<<s<<endl;
- }
- void display_rules()
- { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
- cout << setiosflags(ios::left) << setw(15) << "THE OBJECTIVE: ";
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
- cout << "\t" << "To form and discard pairs, avoiding being the player holding" << endl;
- cout << "\t\t" << "the Old Maid"
- << " at the end of the game." << endl << endl;
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
- cout << "THE SET-UP: ";
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
- cout << "\t" << "Three queens are removed from the deck." << endl;
- cout << "\t\t" << "The remaining queen is the old maid." << endl;
- cout << endl << endl;
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
- cout << "THE PLAY: ";
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
- cout << "\t" << "Players remove pairs of cards from their hands.";
- cout << " The dealer then " << endl;
- cout << "\t\t" << "offers his hand,"
- << "face down, to the player on his left." << endl;
- cout << "\t\t" << "That player randomly takes one card from the dealer." << endl;
- cout << "\t\t" << "If the card matches one he already has in his hand, he puts " << endl;
- cout << "\t\t" << "the pair down. If not, he keeps it. Play proceeds clockwise, " << endl;
- cout << "\t\t" << "so the player to the left of the dealer then offers his hand," << endl;
- cout << "\t\t" << "face down, to the player on his left. This cycle repeats until" << endl;
- cout << "\t\t" << "there are no more pairs " << "and the only remaining card " << endl;
- cout << "\t\t" << "is the Old Maid." << endl;
- cout << endl;
- system("pause");
- cout << endl;
- system("cls");
- main_menu();
- }
- void Deck::sort(vector<Card> hand)
- {
- for(int i(0); i < hand.size(); i++)
- {
- for(int j(i); j < hand.size(); j++)
- {
- if(hand[i].get_suit() > hand[j].get_suit())
- {
- swap(hand[i],hand[j]);
- }
- }
- }
- }
- void Deck::card_nums(Deck deck)
- {
- vector<int> possible_choices;
- //adding the numbers at the bottom and then making them a choice
- gotoxy(0,12);
- for(int i=0;i<deck.comp_hand.size();i++)
- {
- if(i<9)
- {
- cout << " " << i+1 << " ";
- }
- else
- {
- cout << " " << i+1 << " ";
- }
- possible_choices.push_back(i+1);
- }
- gotoxy(50,25);
- cout << "Please pick a number." << endl;
- int pick;
- gotoxy(50,35);
- cin >> pick;
- while((pick>possible_choices.size()) || (pick<=0))
- {
- gotoxy(50,20);
- cout << "Invalid choice. " << endl;
- gotoxy(50,25);
- cout << "Your turn! Please pick a number." << endl;
- gotoxy(45,35);
- cout << " ";
- gotoxy(50,35);
- cin >> pick;
- }
- gotoxy(50,20);
- cout << " " << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement