diff --git a/include/events.h b/include/events.h index b85888e..2375206 100644 --- a/include/events.h +++ b/include/events.h @@ -49,10 +49,10 @@ enum stock_modifiers { }; /// @brief Multiplier for mean -constexpr float meanMultiplier = 0.3f; +constexpr float meanMultiplier = 0.6f; /// @brief Multiplier for standard deviation -const float sdMultiplier = 15.0; +const float sdMultiplier = 7.5f; /// @brief Lower limit multiplier const float lowerLimitMultiplier = 0.2; diff --git a/src/file_io.cpp b/src/file_io.cpp index 1724c59..cccf593 100644 --- a/src/file_io.cpp +++ b/src/file_io.cpp @@ -209,17 +209,6 @@ void delsave(string & mode) { else { cout << "The deletion has been cancelled." << endl; } - - // choosing mode again - std::cout << USER_SAVE_OPTION_PROMPT; - std::cin >> mode; - while (!checkValidInput(mode)) { - std::cout << "Invalid input. " + USER_SAVE_OPTION_PROMPT; - std::cin >> mode; // choose new file or load previous file - } - if (mode.compare(USER_SAVE_OPTION::DELETE_GAME) == 0) { - delsave(mode); - } } vector get_saves(void) { diff --git a/src/main.cpp b/src/main.cpp index 8cf8565..c2f8918 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -281,7 +281,36 @@ void next_round_routine(unsigned int & _rounds, std::vector & stocks_list } } -/** Main function, the entry point of the program */ +void initializePlayerSaves(std::vector & stocks_list, + std::vector & hsi_history) { + std::string EMPTY_INPUT = ""; + std::string loadsave = EMPTY_INPUT; + while (loadsave.compare(EMPTY_INPUT) == 0) { + std::cout << USER_SAVE_OPTION_PROMPT; + std::cin >> loadsave; + while (!checkValidInput(loadsave)) { + std::cout << "Invalid input.\n" << USER_SAVE_OPTION_PROMPT; + std::cin >> loadsave; // choose new file or load previous file + } + if (loadsave.compare(USER_SAVE_OPTION::NEW_GAME) == 0) { + createplayer(playerName); + savestatus(rounds_played, stocks_list, balance, playerName); + } + if (loadsave.compare(USER_SAVE_OPTION::LOAD_GAME) == 0) { + loadstatus(rounds_played, stocks_list, balance, playerName, hsi_history); + } + if (loadsave.compare(USER_SAVE_OPTION::DELETE_GAME) == 0) { + delsave(loadsave); + loadsave = EMPTY_INPUT; + } + if (loadsave.compare(USER_SAVE_OPTION::EXIT_GAME) == 0) { + std::cout << "Goodbye! Hope you had a good luck in the stock market!" + << std::endl; + exit(EXIT_SUCCESS); + } + } +} + int main(void) { enableWindowsVTProcessing(); std::cout << "The game was compiled on " << __DATE__ << " at " << __TIME__ @@ -299,7 +328,7 @@ int main(void) { std::vector stocks_list; stocks_list.reserve(initial_stock_count); for (int i = 0; i < initial_stock_count; i++) { - stocks_list.emplace_back(); // Add the stock to the vector + stocks_list.emplace_back(); } sortStocksList(stocks_list, by_category, ascending); @@ -313,30 +342,8 @@ int main(void) { time::sleep(sleepMedium); std::vector hsi_history; - { - std::string loadsave; - std::cout << USER_SAVE_OPTION_PROMPT; - std::cin >> loadsave; - while (!checkValidInput(loadsave)) { - std::cout << "Invalid input.\n" << USER_SAVE_OPTION_PROMPT; - std::cin >> loadsave; // choose new file or load previous file - } - if (loadsave.compare(USER_SAVE_OPTION::NEW_GAME) == 0) { - createplayer(playerName); - savestatus(rounds_played, stocks_list, balance, playerName); - } - if (loadsave.compare(USER_SAVE_OPTION::LOAD_GAME) == 0) { - loadstatus(rounds_played, stocks_list, balance, playerName, hsi_history); - } - if (loadsave.compare(USER_SAVE_OPTION::DELETE_GAME) == 0) { - delsave(loadsave); // delete existing file - } - if (loadsave.compare(USER_SAVE_OPTION::EXIT_GAME) == 0) { - std::cout << "Goodbye! Hope you had a good luck in the stock market!" - << std::endl; - return EXIT_SUCCESS; - } - } + initializePlayerSaves(stocks_list, hsi_history); + get_hsi(stocks_list, hsi_history); // Done loading/creating a new file. std::cout << "Current trading fees are charged at " << trading_fees_percent * 100 @@ -383,5 +390,5 @@ int main(void) { time::sleep(sleepLong); } } - return 0; + return EXIT_SUCCESS; }