Stock Market Simulator main e8c3612
A game that provides a realistic stock buying experience with unpredictable trends to test investment strategies.
|
file with the main() function More...
#include "controls.h"
#include "draw.h"
#include "events.h"
#include "file_io.h"
#include "format.h"
#include "graph.h"
#include "random_price.h"
#include "stock.h"
#include "nonstdlibs/VariadicTable.h"
#include <cmath>
#include <fstream>
#include <numeric>
Go to the source code of this file.
Macros | |
#define | enableWindowsVTProcessing() |
Enumerations | |
enum | mode { normal , dev } |
hiding mean/sd/uplim/lowlim/event_id columns in the table More... | |
Functions | |
void | get_hsi (std::vector< Stock > stocks_list, std::vector< float > &hsi_history) |
std::vector< Stock_event > | get_ongoing_events (std::vector< Stock > stocks_list) |
Get all the ongoing events. | |
void | initializePlayerSaves (std::vector< Stock > &stocks_list, std::vector< float > &hsi_history) |
int | main (void) |
void | new_events_next_round (std::vector< Stock > &stocks_list) |
Generate new events and apply them to the stocks. | |
void | next_round_routine (unsigned int &_rounds, std::vector< Stock > &stocks_list) |
void | print_table (std::vector< Stock > stocks_list, float _playerBal, mode m=dev) |
Print the table of stocks. | |
std::string | vectorToString (const std::vector< unsigned int > &vec) |
Variables | |
float | balance = 1000.0f |
Player's balance. | |
std::string | playerName |
Player's name. | |
unsigned int | rounds_played = 1 |
Number of rounds played. | |
const float | trading_fees_percent = 0.1 / 100 |
/ 100 means charging % more/portion of the money involved in stock operations. | |
enum mode |
void get_hsi | ( | std::vector< Stock > | stocks_list, |
std::vector< float > & | hsi_history ) |
Definition at line 82 of file main.cpp.
References playerName, SAVE_FILE_EXTENSION_TXT, and SAVE_FOLDER_PREFIX.
Referenced by main().
std::vector< Stock_event > get_ongoing_events | ( | std::vector< Stock > | stocks_list | ) |
Get all the ongoing events.
stocks_list | A vector of stocks. |
Definition at line 202 of file main.cpp.
Referenced by main(), and new_events_next_round().
void initializePlayerSaves | ( | std::vector< Stock > & | stocks_list, |
std::vector< float > & | hsi_history ) |
Definition at line 290 of file main.cpp.
References balance, checkValidInput(), createplayer(), USER_SAVE_OPTION::DELETE_GAME, delsave(), USER_SAVE_OPTION::EXIT_GAME, USER_SAVE_OPTION::LOAD_GAME, loadstatus(), USER_SAVE_OPTION::NEW_GAME, playerName, rounds_played, savestatus(), and USER_SAVE_OPTION_PROMPT.
Referenced by main().
int main | ( | void | ) |
Definition at line 320 of file main.cpp.
References ascending, assertion_check_mutual_exclusivity(), assertion_check_uniq_events(), balance, by_category, drawButton(), drawEventBar(), drawLogo(), drawRoundInfo(), enableWindowsVTProcessing, fetchConsoleDimensions(), get_hsi(), get_ongoing_events(), graph_plotting(), initial_stock_count, initializePlayerSaves(), integerInput(), next_round_routine(), optionsInput(), playerName, print_table(), rounds_played, savestatus(), setCursorPosition(), time::sleep(), sleepLong, sleepMedium, sortStocksList(), textClear, and trading_fees_percent.
void new_events_next_round | ( | std::vector< Stock > & | stocks_list | ) |
Generate new events and apply them to the stocks.
Should be called at the beginning of each round.
stocks_list | A vector of stocks. Pass by reference to modify the stocks. |
Definition at line 228 of file main.cpp.
References Stock::add_event(), all_stock_events, all_stocks, Stock::can_add_event(), category, Stock::get_name(), get_ongoing_events(), pick_events(), pick_random_stock, random_integer(), rounds_played, and Stock_event::text.
Referenced by next_round_routine().
void next_round_routine | ( | unsigned int & | _rounds, |
std::vector< Stock > & | stocks_list ) |
Definition at line 281 of file main.cpp.
References new_events_next_round().
Referenced by main().
Print the table of stocks.
We put it in a function so we can call it multiple times.
stocks_list | A vector of stocks. The stocks to be printed. |
_playerBal | How much money the player has. |
m | mode to hide mean/sd/uplim/lowlim/event_id columns in the table |
Definition at line 111 of file main.cpp.
References dev, getProcessedModifiers(), lower_limit, mean, setCursorPosition(), standard_deviation, textGreen, textRed, textWhite, trading_fees_percent, upper_limit, and vectorToString().
Referenced by main().
std::string vectorToString | ( | const std::vector< unsigned int > & | vec | ) |
Definition at line 75 of file main.cpp.
Referenced by print_table().
float balance = 1000.0f |
Player's balance.
Definition at line 68 of file main.cpp.
Referenced by buyStocks(), drawRoundInfo(), initializePlayerSaves(), loadstatus(), main(), Stock::num_stocks_affordable(), optionsInput(), Stock::purchase(), savestatus(), Stock::sell(), and sellStocks().
std::string playerName |
Player's name.
Definition at line 73 of file main.cpp.
Referenced by createplayer(), get_hsi(), initializePlayerSaves(), Stock::load(), load_hsi(), loadstatus(), main(), Stock::save(), and savestatus().
unsigned int rounds_played = 1 |
Number of rounds played.
Definition at line 70 of file main.cpp.
Referenced by initializePlayerSaves(), loadstatus(), main(), new_events_next_round(), and savestatus().
const float trading_fees_percent = 0.1 / 100 |
/ 100 means charging % more/portion of the money involved in stock operations.
Definition at line 65 of file main.cpp.
Referenced by Stock::calculateStockValue(), Stock::calculateTradingFeesLost(), main(), Stock::num_stocks_affordable(), print_table(), Stock::purchase(), and Stock::sell().