Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- #include <algorithm>
- #include <cstdlib>
- using namespace std;
- void game_prompt(int &number_players, int &number_rounds){
- cout << "Enter number of players: ";
- cin >> number_players;
- cout << "Enter the number of rounds: ";
- cin >> number_rounds;
- }
- void initial_input(string &secret_message, string &word_display){
- cin.ignore();
- cout << "Enter the secret message: ";
- getline(cin, secret_message);
- transform(secret_message.begin(), secret_message.end(), secret_message.begin(), ::toupper);
- for (int i = 0; i < secret_message.length(); i++){
- if (secret_message[i] == ' '){
- word_display.append(" ");
- }
- else {
- word_display.append("_ ");
- }
- }
- }
- void balance_management(int player, int money_count[3][2], int money, int purpose){
- /*
- purpose 1: add/subtract money
- purpose 2: move round money to game money and clears round money
- purpose 3: clear round money
- */
- if (purpose == 1) {
- money_count[player-1][0] = money_count[player-1][0] + money;
- }
- else if(purpose == 2){
- money_count[player-1][1] = money_count[player-1][1] + money_count[player-1][0];
- money_count[player-1][0] = 0;
- }
- else if(purpose == 3){
- money_count[player-1][0] = 0;
- }
- }
- bool solve_puzzle(string secret_message){
- cin.ignore();
- string word_guess;
- cout << "What is your guess: ";
- getline(cin,word_guess);
- transform(word_guess.begin(), word_guess.end(), word_guess.begin(), ::toupper);
- if (word_guess == secret_message){
- cout << "Congratulations! You guessed the phrase: " << secret_message << endl;
- return true;
- }
- else {
- cout << "That is not the correct phrase" << endl;
- return false;
- }
- }
- void player_roll(string secret_message, string word_display, int money_count[3][2], int player){
- int roll = rand()%21, multiplier;
- cout << "Roll: " << roll << endl;
- char consonant;
- if (roll == 0){
- balance_management(player, money_count, 0, 3);
- }
- else if (roll == 21){
- //end the turn prematurely
- }
- else {
- //guess a non-vowel. For each correct, increase 'multiplier' by 1
- //set round money == round money * multiplier
- //edit word display to hold the correct values
- cout << "Guess a consonant: ";
- cin >> consonant;
- consonant = toupper(consonant);
- for (int i = 0; i < secret_message.length(); i++){
- if (secret_message[i] == consonant){
- multiplier++;
- word_display[2*i+1] = consonant;
- balance_management(player, money_count, roll*multiplier, 1);
- }
- }
- }
- }
- char vowel_purchase(int money_count[3][2], int &b){
- char vowel;
- if (money_count[b-1][0] >= 10){
- balance_management(b, money_count, -10, 1);
- while(true){
- cout << "Enter a vowel: ";
- cin >> vowel;
- vowel = toupper(vowel);
- switch(vowel){
- case 'A':
- case 'E':
- case 'I':
- case 'O':
- case 'U':
- case 'Y':
- cin.ignore();
- return vowel;
- default:
- cout << "Not a valid input" << endl;
- break;
- }
- }
- }
- else{
- cout << "You do not have enough money" << endl;
- b--;
- cin.ignore();
- return '.'; //Since I have to have a return a value, I return "."
- }
- }
- ///*
- void player_turn(int money_count[3][2], int &b, string secret_message, string word_display, bool &cont){
- int option = 4;
- cout << "1 - Solve the Puzzle" << endl << "2 - Purchase a Vowel" << endl << "3 - Roll the dice" << endl;
- while(true){
- cout << endl << "What would you like to do: ";
- cin >> option;
- cin.ignore();
- if (option == 1){
- cont = solve_puzzle(secret_message);
- break;
- }
- else if (option == 2){
- vowel_purchase(money_count, b);
- break;
- }
- else if (option == 3){
- player_roll(secret_message, word_display, money_count, b);
- break;
- }
- else{
- cout << "Not a valid option" << endl;
- }
- }
- }
- void display(){
- }
- void word_display_edit(string word_display, string secret_message, char chr){
- }
- //*/
- int main(){
- srand(time(NULL));
- //Variable Declarations
- string secret_message, word_display;
- int number_players, number_rounds, money_count[3][2] = {16};
- bool cont;
- game_prompt(number_players, number_rounds);
- for(int a = 1; a <= number_rounds; a++){
- cont == false;
- word_display = " "; //technically there will be a space in front of the word at all times
- initial_input(secret_message, word_display);
- while(cont == false){
- for(int b = 1;b <= number_players; b++){
- player_turn(money_count, b, secret_message, word_display, cont);
- if (cont == true){
- break;
- }
- }
- if(cont == true){
- break;
- }
- }
- }
- //testing
- //game_prompt(1,secret_message, word_display, number_players, number_rounds);
- bool check = solve_puzzle(secret_message);
- cout << secret_message << endl;
- cout << word_display << endl;
- //end testing
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement