Abdulg

Lobster Pots V2

Jul 26th, 2012
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 11.26 KB | None | 0 0
  1. //A REAL MAN NEVER COMMENTS HIS CODE
  2. #include<iostream>
  3. #include<time.h>
  4. #include<cstdlib>
  5. #include<fstream>
  6. #define _WIN32_WINNT  0x0500
  7. #include <windows.h>
  8. #include <Wincon.h>
  9. #include <string>
  10. #include <algorithm>
  11. #include <iostream>
  12. #include <iomanip>
  13. #include <algorithm>
  14. #include <cctype>
  15. #include <dos.h>
  16. #include <conio.h>
  17. #include "Objidl.h"
  18. #include <iostream>
  19. #include <string>
  20. #include "shlwapi.h"
  21. #include <dos.h>
  22. #define WIN32_LEAN_AND_MEAN
  23. #define WIN32_EXTRA_LEAN
  24. using namespace std;
  25.  
  26.  
  27. int Chance, YN, Money, LobsterPots, Inshore, Outshore, Profit, Buying, HMoney, PotPrice, Lobsters, LobsterPrice, LobsterCatch, Selling, TotalLobsters;
  28. int DaysG = 7;
  29. char Name[260], HName[260], Date[9],Time[10];
  30.  
  31.  
  32.  
  33. void PrintStuff()
  34. {
  35.     cout << "\t\t\t\t\t\t";
  36.     SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xE4 );
  37.     cout << "Days Left:" << DaysG << "  Money:" << Money << "  Pots:" << LobsterPots << "  Lobsters:" << Lobsters << "  Current high score: $" << HMoney << " (Held by " << HName<< ")";
  38.     SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x07 );
  39.     cout << "\t\t\t\t\t\t" << endl;
  40. }
  41.  
  42. void Pause()
  43. {
  44.     system("PAUSE");
  45. }
  46.  
  47.  
  48.  
  49. int main()
  50. {
  51.     HWND hWnd = GetConsoleWindow();
  52.     ShowWindow(hWnd,SW_SHOWMAXIMIZED);  
  53.     HANDLE hOut;
  54.     COORD NewSBSize;
  55.     SMALL_RECT Area = {0, 0, 0, 0};
  56.     hOut = GetStdHandle(STD_OUTPUT_HANDLE);
  57.     NewSBSize = GetLargestConsoleWindowSize(hOut);
  58.     SetConsoleScreenBufferSize(hOut, NewSBSize);
  59.     Area.Right = NewSBSize.X - 1;
  60.     Area.Bottom = NewSBSize.Y - 1;
  61.     SetConsoleWindowInfo(hOut, TRUE,  &Area);
  62.     Money = 50;
  63.     LobsterPots = 10;
  64.     TotalLobsters = 0;
  65.     srand ( time(NULL) );
  66.     ofstream FileO;
  67.     ifstream FileI;
  68.     FileI.open("HighScores.lob");
  69.     FileI >> HName >> HMoney;
  70.     FileI.close();
  71.     HANDLE hStdout;
  72.     hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  73.     cout << "Insert your name:" << endl << "> ";
  74.     cin.getline(Name,260);
  75.     system("CLS");
  76.     cout << endl << endl << endl << endl << endl << endl;
  77.     SetConsoleTextAttribute(hStdout, FOREGROUND_RED);
  78. cout << "\t\t\t\t\t\t /$$                 /$$                   /$$                        " << endl;
  79. cout << "\t\t\t\t\t\t| $$                | $$                  | $$                        " << endl;
  80. cout << "\t\t\t\t\t\t| $$        /$$$$$$ | $$$$$$$   /$$$$$$$ /$$$$$$    /$$$$$$   /$$$$$$ " << endl;
  81. cout << "\t\t\t\t\t\t| $$       /$$__  $$| $$__  $$ /$$_____/|_  $$_/   /$$__  $$ /$$__  $$" << endl;
  82. cout << "\t\t\t\t\t\t| $$      | $$  \\ $$| $$  \\ $$|  $$$$$$   | $$    | $$$$$$$$| $$  \\__/" << endl;
  83. cout << "\t\t\t\t\t\t| $$      | $$  | $$| $$  | $$ \\____  $$  | $$ /$$| $$_____/| $$      " << endl;
  84. cout << "\t\t\t\t\t\t| $$$$$$$$|  $$$$$$/| $$$$$$$/ /$$$$$$$/  |  $$$$/|  $$$$$$$| $$      " << endl;
  85. cout << "\t\t\t\t\t\t|________/ \\______/ |_______/ |_______/    \\___/   \\_______/|__/      " << endl;
  86. cout << "\t\t\t\t\t\t                                                                      " << endl;
  87. cout << "\t\t\t                                                                      " << endl;
  88. cout << "\t\t\t                                                                      " << endl;
  89. cout << "\t\t\t\t\t\t /$$$$$$$             /$$                                             " << endl;
  90. cout << "\t\t\t\t\t\t| $$__  $$           | $$                                             " << endl;
  91. cout << "\t\t\t\t\t\t| $$  \\ $$ /$$$$$$  /$$$$$$   /$$$$$$$                                " << endl;
  92. cout << "\t\t\t\t\t\t| $$$$$$$//$$__  $$|_  $$_/  /$$_____/                                " << endl;
  93. cout << "\t\t\t\t\t\t| $$____/| $$  \\ $$  | $$   |  $$$$$$                                 " << endl;
  94. cout << "\t\t\t\t\t\t| $$     | $$  | $$  | $$ /$$\\____  $$                                " << endl;
  95. cout << "\t\t\t\t\t\t| $$     |  $$$$$$/  |  $$$$//$$$$$$$/                                " << endl;
  96. cout << "\t\t\t\t\t\t|__/      \\______/    \\___/ |_______/                                 " << endl;
  97. cout << "\t\t\t\t\t\t                                                                      " << endl;
  98. cout << "\t\t\t\t\t\t /$$$$$$$                                                             " << endl;
  99. cout << "\t\t\t\t\t\t| $$__  $$                                                            " << endl;
  100. cout << "\t\t\t\t\t\t| $$  \\ $$ /$$   /$$                                                  " << endl;
  101. cout << "\t\t\t\t\t\t| $$$$$$$ | $$  | $$                                                  " << endl;
  102. cout << "\t\t\t\t\t\t| $$__  $$| $$  | $$                                                  " << endl;
  103. cout << "\t\t\t\t\t\t| $$  \\ $$| $$  | $$                                                  " << endl;
  104. cout << "\t\t\t\t\t\t| $$$$$$$/|  $$$$$$$                                                  " << endl;
  105. cout << "\t\t\t\t\t\t|_______/  \\____  $$                                                  " << endl;
  106. cout << "\t\t\t\t\t\t           /$$  | $$                                                  " << endl;
  107. cout << "\t\t\t\t\t\t          |  $$$$$$/                                                  " << endl;
  108. cout << "\t\t\t\t\t\t           \\______/                                                   " << endl;
  109. cout << "\t\t\t\t\t\t  /$$$$$$  /$$             /$$           /$$                          " << endl;
  110. cout << "\t\t\t\t\t\t /$$__  $$| $$            | $$          | $$                          " << endl;
  111. cout << "\t\t\t\t\t\t| $$  \\ $$| $$$$$$$   /$$$$$$$ /$$   /$$| $$                          " << endl;
  112. cout << "\t\t\t\t\t\t| $$$$$$$$| $$__  $$ /$$__  $$| $$  | $$| $$                          " << endl;
  113. cout << "\t\t\t\t\t\t| $$__  $$| $$  \\ $$| $$  | $$| $$  | $$| $$                          " << endl;
  114. cout << "\t\t\t\t\t\t| $$  | $$| $$  | $$| $$  | $$| $$  | $$| $$                          " << endl;
  115. cout << "\t\t\t\t\t\t| $$  | $$| $$$$$$$/|  $$$$$$$|  $$$$$$/| $$                          " << endl;
  116. cout << "\t\t\t\t\t\t|__/  |__/|_______/  \\_______/ \\______/ |__/                          " << endl;
  117. cout << "\t\t\t\t\t\t                                                                      " << endl;
  118. cout << "\t\t\t\t\t\t                                                                      " << endl;
  119. cout << "\t\t\t\t\t\t                                                                      " << endl;
  120. cout << "\t\t\t\t\t\t  /$$$$$$  /$$                           /$$                          " << endl;
  121. cout << "\t\t\t\t\t\t /$$__  $$| $$                          |__/                          " << endl;
  122. cout << "\t\t\t\t\t\t| $$  \\__/| $$$$$$$   /$$$$$$  /$$$$$$$  /$$                          " << endl;
  123. cout << "\t\t\t\t\t\t| $$ /$$$$| $$__  $$ |____  $$| $$__  $$| $$                          " << endl;
  124. cout << "\t\t\t\t\t\t| $$|_  $$| $$  \\ $$  /$$$$$$$| $$  \\ $$| $$                          " << endl;
  125. cout << "\t\t\t\t\t\t| $$  \\ $$| $$  | $$ /$$__  $$| $$  | $$| $$                          " << endl;
  126. cout << "\t\t\t\t\t\t|  $$$$$$/| $$  | $$ | $$$$$$$| $$  | $$| $$                          " << endl;
  127. cout << "\t\t\t\t\t\t \\______/ |__/  |__/ \\_______/|__/  |__/|__/                          " << endl;
  128. Sleep(5000);
  129.     Pause();
  130.     hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  131.     SetConsoleTextAttribute(hStdout, FOREGROUND_RED);
  132.     system("CLS");                                
  133.     for (int Days = 7; Days > 0; Days --)
  134.     {
  135.     PrintStuff();
  136.     Chance = rand ()  % 100 + 1;
  137.     YN = rand () % 100 + 1;
  138.     PotPrice = rand () % 15 + 10;
  139.     LobsterCatch = rand () % 4 + 5;
  140.     LobsterPrice = rand () % 15 + 10;
  141.     Choice:
  142.     if (Days == 1)
  143.     {
  144.         cout << "This is your last day! Use it wisely!" << endl;
  145.     }
  146.     cout << "There is a " << Chance << "% chance of a storm today." << endl;
  147.     cout << "How many pots do you want to put inshore?" << endl << "> ";
  148.     cin >> Inshore;
  149.     Outshore = LobsterPots - Inshore;
  150.     cout << "You are putting " << Inshore << " pots inshore and " << Outshore << " pots outshore." << endl;
  151.     Sleep(3246);
  152.     if (YN <= Chance)
  153.     {
  154.         if (Outshore == 0)
  155.         {
  156.             cout << "Good choice! It was stormy!" << endl;
  157.             goto Calc;
  158.             break;
  159.         }
  160.         cout << "It was stormy! You lost " << Outshore << " pots. Unlucky!" << endl;
  161.         LobsterPots = LobsterPots - Outshore;
  162.         Outshore = 0;
  163.     }
  164.     if (YN > Chance)
  165.     {
  166.         cout << "The weather was fine!";
  167.         if (Outshore == 0)
  168.         {
  169.             cout << " Should have put more outshore!";
  170.         }
  171.         cout << endl;
  172.     }
  173.     Calc:
  174.     Profit = (Inshore * 2) + (Outshore * LobsterCatch);
  175.     TotalLobsters = TotalLobsters + (Inshore * 2) + (Outshore * LobsterCatch);
  176.     Lobsters = Lobsters + Profit;
  177.     system("PAUSE");
  178.     system("CLS");
  179.     PrintStuff();
  180.     cout << "You caught " << Profit << " lobsters during that round. Your total amount of lobsters is " << Lobsters << endl;
  181.     Take2:
  182.     cout << "Today lobsters are selling at " << LobsterPrice << " a lobster. How many would you like to sell? (If you don't like the price, you can wait)" << endl << ">";
  183.     cin >> Selling;
  184.     if (Selling > Lobsters)
  185.     {
  186.         cout << endl << "You don't have that many lobsters, silly!";
  187.         goto Take2;
  188.     }
  189.     if (Selling == 0)
  190.     {
  191.         cout << "Prices not good enough for you then?" << endl;
  192.         goto Buy;
  193.     }
  194.        
  195.    
  196.     cout << "You sold " << Selling << " lobsters for " << LobsterPrice << " each, making " << (Selling * LobsterPrice) << "!" << endl << "You now have " << Lobsters - Selling << " lobsters and $" << Money + (Selling * LobsterPrice) << " dollars left." << endl;
  197.     Money = Money + (Selling * LobsterPrice);
  198.     Lobsters = Lobsters - Selling;
  199.    
  200.     Buy:
  201.     system("PAUSE");
  202.     system("CLS");
  203.     PrintStuff();
  204.     if (Days == 1)
  205.     {
  206.         break;
  207.     }
  208.     cout << "You can buy lobster pots at " << PotPrice <<  " a pot." << endl;
  209.     if (Money < PotPrice)
  210.     {
  211.         cout << "You don't have enough money to buy any pots. Lol!" << endl;
  212.         goto End;
  213.     }
  214.     cout << "How many would you like to buy? (You can buy " << Money/PotPrice << " pots)" << endl << "> ";
  215.     cin >> Buying;
  216.     if ((Buying * PotPrice) > Money)
  217.     {
  218.         cout << "Sorry, but you don't have enough money to do that" << endl;
  219.         goto Buy;
  220.     }
  221.     if (Buying == 0)
  222.     {
  223.         cout << "Well thanks for wasting my time!" << endl;
  224.         goto End;
  225.     }
  226.     Money = Money - (Buying * PotPrice);
  227.     LobsterPots = LobsterPots + Buying;
  228.     cout << "You bought " << Buying << " pots for $" << Buying * PotPrice << ". You have $" << Money << " left, and "<< LobsterPots << " pots." << endl;
  229.     End:
  230.     system("PAUSE");
  231.     system("CLS");
  232.     DaysG--;
  233.     }
  234.     system("CLS");
  235.     cout << "Thats your week! Your pots will sell for $5 each and your lobsters will sell for $7 each, which gives you $" << LobsterPots * 5 + (Lobsters * 7) << endl;
  236.     Money = Money + (LobsterPots * 5) + (Lobsters * 7);
  237.     cout << "You finish off with $" << Money << "." << endl;
  238.     if (Money > HMoney)
  239.     {
  240.         cout << endl << "You beat the high score!" << endl;
  241.         FileO.open("HighScores.lob");
  242.         FileO << Name << endl << Money;
  243.         FileO.close();
  244.     }
  245.     else
  246.     {
  247.         cout << endl << "Sorry, but you didn't beat the high score :(" << endl;
  248.     }
  249.     _strdate_s(Date);
  250.     _strtime(Time);
  251.     FileO.open("Log.txt", ios::app);
  252.     FileO << "Name: " << Name << endl << "Money: " << Money << endl << "Total amount of lobsters caught: " << TotalLobsters << endl << "Time and date: " << Date << ", " << Time << endl;
  253.     if (Money > HMoney)
  254.     {
  255.         FileO << "High score beaten! Previous high score: " << HMoney << ", new high score: " << Money;
  256.     }
  257.     FileO << endl << endl;
  258.     FileO.close();
  259.     system("PAUSE");
  260.     return 0; // done
  261. }
Advertisement
Add Comment
Please, Sign In to add comment