Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <array>
- #include <string>
- using namespace std;
- #pragma region VARIABLES
- // map size of 7*7
- string map[49] = {};
- // seeds
- // buy price, quantity, selling price
- const double abcde[3] = { 7, 5, 3.5 };
- const double fghij[3] = { 15, 7, 5.36 };
- const double klmnop[3] = { 25, 7, 10.71 };
- const int qrstuvw[3] = { 40, 10, 14 };
- const int xyz[3] = { 100, 3, 50 };
- // bag
- int myBag[5];
- // upgradeActive or Not variables
- bool doubleSeeds = false;
- bool quadSeeds = false;
- bool infiniteSeeds = false;
- // doubleSeeds
- bool doubleSeedPlanted = false;
- int quadSeedsPlanted = 1;
- // other variables
- double money = 8; // DEFAULT: 8
- char choice;
- int shopChoice;
- int plantChoice;
- string seedInput;
- int days = 1;
- #pragma endregion
- void createMyBag() {
- // Start with ten abcde seeds
- myBag[0] = abcde[1] + 5;
- }
- void createSpaces() {
- for (int i = 0; i < 50; i = i + 1) {
- map[i] = "#";
- }
- }
- void createBoard() {
- // First Line
- for (int i = 1; i < 8; i = i + 1) {
- cout << map[i] << " | ";
- }
- cout << "\n";
- // Dividers
- for (int i = 1; i < 8; i = i + 1) {
- if (i < 2) {
- cout << "--+";
- }
- else if (i > 6) {
- cout << "---";
- }
- else {
- cout << "---+";
- }
- }
- cout << "\n";
- // Second Line
- for (int i = 8; i < 15; i = i + 1) {
- cout << map[i] << " | ";
- }
- cout << "\n";
- // Dividers
- for (int i = 8; i < 15; i = i + 1) {
- if (i < 9) {
- cout << "--+";
- }
- else if (i > 13) {
- cout << "---";
- }
- else {
- cout << "---+";
- }
- }
- cout << "\n";
- // Third Line
- for (int i = 15; i < 22; i = i + 1) {
- cout << map[i] << " | ";
- }
- cout << "\n";
- // Dividers
- for (int i = 15; i < 22; i = i + 1) {
- if (i < 16) {
- cout << "--+";
- }
- else if (i > 20) {
- cout << "---";
- }
- else {
- cout << "---+";
- }
- }
- cout << "\n";
- // Fourth Line
- for (int i = 22; i < 29; i = i + 1) {
- cout << map[i] << " | ";
- }
- cout << "\n";
- // Dividers
- for (int i = 22; i < 29; i = i + 1) {
- if (i < 23) {
- cout << "--+";
- }
- else if (i > 27) {
- cout << "---";
- }
- else {
- cout << "---+";
- }
- }
- cout << "\n";
- // Fifth Line
- for (int i = 29; i < 36; i = i + 1) {
- cout << map[i] << " | ";
- }
- cout << "\n";
- // Dividers
- for (int i = 29; i < 36; i = i + 1) {
- if (i < 30) {
- cout << "--+";
- }
- else if (i > 34) {
- cout << "---";
- }
- else {
- cout << "---+";
- }
- }
- cout << "\n";
- // Sixth Line
- for (int i = 36; i < 43; i = i + 1) {
- cout << map[i] << " | ";
- }
- cout << "\n";
- // Dividers
- for (int i = 36; i < 43; i = i + 1) {
- if (i < 37) {
- cout << "--+";
- }
- else if (i > 41) {
- cout << "---";
- }
- else {
- cout << "---+";
- }
- }
- cout << "\n";
- // Seventh Line
- for (int i = 43; i < 50; i = i + 1) {
- cout << map[i] << " | ";
- }
- cout << "\n";
- // Dividers
- for (int i = 36; i < 43; i = i + 1) {
- cout << "---";
- }
- // Lazy extra dividers
- cout << "-----";
- cout << "\n";
- }
- void upgradeShop() {
- // Leave
- cout << "0. Leave upgrade shop" << endl;
- // Double Seeds
- cout << "1. Plant 2 seeds in 1 day ($10)" << endl;
- // Quad Seeds
- cout << "2. Plant 4 seeds in 1 day ($50)" << endl;
- // Infinite Seeds
- cout << "3. Plant all your seeds in 1 day ($250)" << endl;
- cin >> shopChoice;
- // Activating upgrades
- switch (shopChoice) {
- case 1:
- if (money >= 10) {
- cout << "Purchase successful" << endl;
- money = money - 10;
- doubleSeeds = true;
- }
- else {
- cout << "You don't have enough money!\n";
- }
- break;
- case 2:
- if (money >= 50) {
- cout << "Purchase successful" << endl;
- money = money - 50;
- doubleSeeds = false;
- quadSeeds = true;
- }
- else {
- cout << "You don't have enough money!\n";
- }
- break;
- case 3:
- if (money >= 250) {
- cout << "Purchase successful" << endl;
- money = money - 250;
- doubleSeeds = false;
- quadSeeds = false;
- infiniteSeeds = true;
- }
- }
- }
- void seedShop() {
- cout << "0. Leave the Seed Shop" << endl;
- cout << "1. ABCDE Seeds; 7$ for 5" << endl;
- cout << "2. FGHIJ Seeds; 15$ for 7" << endl;
- cout << "3. KLMNOP Seeds; 25$ for 7" << endl;
- cout << "4. QRSTUVW Seeds; 40$ for 10" << endl;
- cout << "5. XYZ Seeds; 100$ for 3" << endl;
- cin >> shopChoice;
- switch (shopChoice) {
- default:
- break;
- case 1:
- if (money >= 7) {
- cout << "Purchase successful." << endl;
- money = money - 7;
- myBag[0] = myBag[0] + 5;
- }
- else {
- cout << "Purhcase unsuccessful, insufficient funds." << endl;
- }
- break;
- case 2:
- if (money >= 15) {
- cout << "Purchase successful." << endl;
- money = money - 15;
- myBag[1] = myBag[1] + 7;
- }
- else {
- cout << "Purchase unsuccessful, insufficient funds." << endl;
- }
- break;
- case 3:
- if (money >= 25) {
- cout << "Purhcase successful." << endl;
- money = money - 25;
- myBag[2] = myBag[2] + 7;
- }
- else {
- cout << "Purchase unsuccessful, insufficient funds." << endl;
- }
- break;
- case 4:
- if (money >= 40) {
- cout << "Purchase successful." << endl;
- money = money - 40;
- myBag[3] = myBag[3] + 10;
- }
- else {
- cout << "Purchase unsuccessful, insufficient funds." << endl;
- }
- break;
- case 5:
- if (money >= 100) {
- cout << "Purchase successful, enjoy your overpriced seeds." << endl;
- money = money - 100;
- myBag[4] = myBag[4] + 3;
- }
- else {
- cout << "Purchase unsuccesful, insufficient funds... makes sense, they are some pretty pricey seeds." << endl;
- }
- }
- cout << "(y/n) Continue browsing? ";
- cin >> choice;
- if (choice == 'y') {
- seedShop();
- }
- }
- void plantSeeds() {
- // Printing users seeds
- cout << "\n";
- cout << "Current Seeds: " << endl;
- cout << "ABCDE Seeds: " << myBag[0] << endl;
- cout << "FGHIJ Seeds: " << myBag[1] << endl;
- cout << "KLMNOP Seeds: " << myBag[2] << endl;
- cout << "QRSTUVW Seeds: " << myBag[3] << endl;
- cout << "XYZ Seeds: " << myBag[4] << endl;
- cout << "\n";
- // Input for seed choice
- cout << "Which seed? (use the first letter, lowercase)" << endl;
- cin >> seedInput;
- // ABCDE SEED
- if (seedInput == "a") {
- // Reset seedInput variable
- seedInput = "#";
- // Choosing where to place seeds
- cout << "Where?" << endl;
- cout << "(use a number)" << endl;
- cin >> plantChoice;
- cout << "\n";
- // If there is a seed there/not
- if (map[plantChoice] == "A") {
- cout << "You already have a plant there..." << endl;
- plantSeeds();
- }
- else {
- map[plantChoice] = "A";
- cout << "Seed planted." << endl;
- // Removing 1 seed from bag
- myBag[0] = myBag[0] - 1;
- }
- }
- // FGHIJ SEED
- if (seedInput == "f") {
- // Reset seedInput variable
- seedInput = "#";
- // Choosing where to place seeds
- cout << "Where?" << endl;
- cout << "(use a number)" << endl;
- cin >> plantChoice;
- cout << "\n";
- // If there is a seed there/not
- if (map[plantChoice] == "F") {
- cout << "You already have a plant there..." << endl;
- plantSeeds();
- }
- else {
- map[plantChoice] = "F";
- cout << "Seed planted." << endl;
- // Removing 1 seed from bag
- myBag[1] = myBag[1] - 1;
- }
- }
- // KLMNOP SEED
- if (seedInput == "k") {
- // Reset seedInput variable
- seedInput = "#";
- // Choosing where to place seeds
- cout << "Where?" << endl;
- cout << "(use a number)" << endl;
- cin >> plantChoice;
- cout << "\n";
- // If there is a seed there/not
- if (map[plantChoice] == "K") {
- cout << "You already have a plant there..." << endl;
- plantSeeds();
- }
- else {
- map[plantChoice] = "K";
- cout << "Seed planted." << endl;
- // Removing 1 seed from bag
- myBag[2] = myBag[2] - 1;
- }
- }
- // QRSTUVW SEED
- if (seedInput == "q") {
- // Reset seedInput variable
- seedInput = "#";
- // Choosing where to place seeds
- cout << "Where?" << endl;
- cout << "(use a number)" << endl;
- cin >> plantChoice;
- cout << "\n";
- // If there is a seed there/not
- if (map[plantChoice] == "Q") {
- cout << "You already have a plant there..." << endl;
- plantSeeds();
- }
- else {
- map[plantChoice] = "Q";
- cout << "Seed planted." << endl;
- // Removing 1 seed from bag
- myBag[3] = myBag[3] - 1;
- }
- }
- // XYZ SEED
- if (seedInput == "x") {
- // Reset seedInput variable
- seedInput = "#";
- // Choosing where to place seeds
- cout << "Where?" << endl;
- cout << "(use a number)" << endl;
- cin >> plantChoice;
- cout << "\n";
- // If there is a seed there/not
- if (map[plantChoice] == "X") {
- cout << "You already have a plant there..." << endl;
- plantSeeds();
- }
- else {
- map[plantChoice] = "X";
- cout << "Seed planted." << endl;
- // Removing 1 seed from bag
- myBag[4] = myBag[4] - 1;
- }
- }
- // To plant more than one seed - Double Seeds
- if (doubleSeeds && !doubleSeedPlanted) {
- cout << "(y/n) Plant another seed? ";
- cin >> choice;
- switch (choice) {
- case 'y':
- doubleSeedPlanted = true;
- plantSeeds();
- }
- }
- // To plant more than one seed - Quad Seeds
- if (quadSeeds && (quadSeedsPlanted != 4)) {
- cout << "(y/n) Plant another seed? ";
- cin >> choice;
- switch (choice) {
- case 'y':
- quadSeedsPlanted = quadSeedsPlanted + 1;
- plantSeeds();
- }
- }
- // To plant more than one seed - Infinite Seeds
- if (infiniteSeeds) {
- cout << "(y/n) Plant another seed? ";
- cin >> choice;
- switch (choice) {
- case 'y':
- plantSeeds();
- }
- }
- // Resets double seeds
- doubleSeedPlanted = false;
- // Resets quad seeds
- quadSeedsPlanted = 1;
- }
- void characterChoice() {
- cout << "1. Plant seeds\n2. Buy upgrade\n3. Skip day\n4. Buy seeds ";
- cin >> choice;
- switch (choice) {
- case '1':
- plantSeeds();
- break;
- case '2':
- system("cls");
- upgradeShop();
- break;
- case '3':
- cout << "You go off to bed early." << endl;
- break;
- case '4':
- system("cls");
- seedShop();
- }
- }
- void growingSeeds() {
- // Allowing ABCDE seeds to grow
- for (int grow = 0; grow < 50; grow = grow + 1) {
- // Stage 1 -> 2
- if (map[grow] == "A") {
- map[grow] = "B";
- }
- // Stage 2 -> 3
- else if (map[grow] == "B") {
- map[grow] = "C";
- }
- // Stage 3 -> 4
- else if (map[grow] == "C") {
- map[grow] = "D";
- }
- // Stage 4 -> 5
- else if (map[grow] == "D") {
- map[grow] = "E";
- }
- // Plant harvested, spot regrowing...
- else if (map[grow] == "E") {
- map[grow] = "*";
- cout << "Plant harvested, " << abcde[2] << "$ will be added to balance." << endl;
- money = money + abcde[2];
- }
- // Plant spot Regrown
- else if (map[grow] == "*") {
- map[grow] = "#";
- }
- }
- // Allowing FGHIJ seeds to grow
- for (int grow = 0; grow < 50; grow = grow + 1) {
- // Stage 1 -> 2
- if (map[grow] == "F") {
- map[grow] = "G";
- }
- // Stage 2 -> 3
- else if (map[grow] == "G") {
- map[grow] = "H";
- }
- // Stage 3 -> 4
- else if (map[grow] == "H") {
- map[grow] = "I";
- }
- // Stage 4 -> 5
- else if (map[grow] == "I") {
- map[grow] = "J";
- }
- // Plant harvested, spot regrowing...
- else if (map[grow] == "J") {
- map[grow] = "*";
- cout << "Plant harvested, " << fghij[2] << "$ will be added to balance." << endl;
- money = money + fghij[2];
- }
- // Plant spot Regrown
- else if (map[grow] == "*") {
- map[grow] = "#";
- }
- }
- // Allowing KLMNOP seeds to grow
- for (int grow = 0; grow < 50; grow = grow + 1) {
- // Stage 1 -> 2
- if (map[grow] == "K") {
- map[grow] = "L";
- }
- // Stage 2 -> 3
- else if (map[grow] == "L") {
- map[grow] = "M";
- }
- // Stage 3 -> 4
- else if (map[grow] == "M") {
- map[grow] = "N";
- }
- // Stage 4 -> 5
- else if (map[grow] == "N") {
- map[grow] = "O";
- }
- // Stage 5 -> 6
- else if (map[grow] == "O") {
- map[grow] = "P";
- }
- // Plant harvested, spot regrowing...
- else if (map[grow] == "P") {
- map[grow] = "*";
- cout << "Plant harvested, " << klmnop[2] << "$ will be added to balance." << endl;
- money = money + klmnop[2];
- }
- // Plant spot Regrown
- else if (map[grow] == "*") {
- map[grow] = "#";
- }
- }
- // Allowing QRSTUVW seeds to grow
- for (int grow = 0; grow < 50; grow = grow + 1) {
- // Stage 1 -> 2
- if (map[grow] == "Q") {
- map[grow] = "R";
- }
- // Stage 2 -> 3
- else if (map[grow] == "R") {
- map[grow] = "S";
- }
- // Stage 3 -> 4
- else if (map[grow] == "S") {
- map[grow] = "T";
- }
- // Stage 4 -> 5
- else if (map[grow] == "T") {
- map[grow] = "U";
- }
- // Stage 5 -> 6
- else if (map[grow] == "U") {
- map[grow] = "V";
- }
- else if (map[grow] == "V") {
- map[grow] = "W";
- }
- // Plant harvested, spot regrowing...
- else if (map[grow] == "W") {
- map[grow] = "*";
- cout << "Plant harvested, " << qrstuvw[2] << "$ will be added to balance." << endl;
- money = money + qrstuvw[2];
- }
- // Plant spot Regrown
- else if (map[grow] == "*") {
- map[grow] = "#";
- }
- }
- // Allowing XYZ seeds to grow
- for (int grow = 0; grow < 50; grow = grow + 1) {
- // Stage 1 -> 2
- if (map[grow] == "X") {
- map[grow] = "Y";
- }
- // Stage 2 -> 3
- else if (map[grow] == "Y") {
- map[grow] = "Z";
- }
- // Plant harvested, spot regrowing...
- else if (map[grow] == "Z") {
- map[grow] = "*";
- cout << "Plant harvested, " << xyz[2] << "$ will be added to balance." << endl;
- money = money + xyz[2];
- }
- // Plant spot Regrown
- else if (map[grow] == "*") {
- map[grow] = "#";
- }
- }
- }
- int main() {
- // Create variables on startup
- createSpaces();
- createMyBag();
- system("color 82");
- // Ready?
- #pragma region start
- cout << "(y/n) READY PLAYER ONE ";
- cin >> choice;
- if (choice = 'y') {
- cout << endl;
- }
- else {
- return 0;
- }
- system("cls");
- #pragma endregion
- // Entire Game
- for (days = 1; (days < 366) && (money > 0); days = days + 1) {
- // Printing daily farm upkeep fine
- if (days > 1) {
- cout << "0.25$ removed from balance for farm upkeep" << endl;
- }
- // Print the Day
- cout << "Day " << days << endl;
- // Print the Money
- cout << money << "$ total balance" << endl;
- // Print the Board
- createBoard();
- // Grow Seeds
- growingSeeds();
- // Print character's Options
- characterChoice();
- // Win state: Earn 1,000$
- if (money >= 1000) {
- system("cls");
- cout << "(y/n) Congratulations! You have earned 1000$! Would you like to continue?" << endl;
- cin >> choice;
- if (choice == 'n') {
- return 0;
- }
- }
- // Daily farm upkeep fine
- money = money - 0.25;
- // Press any key to continue
- system("pause");
- // Clear the console
- system("cls");
- }
- system("cls");
- cout << "GAME OVER" << endl;
- cout << "Total ending money: " << money << "$" << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment