#include <iostream>
#include <string>
#include <fstream>
#include <ctime>
using namespace std;
//globala variabler
double money = 100;
int playerID = 1;
string name;
bool storeHave = false;
string shop;
//funktioner
void read();
void write();
void store();
void clean();
void admin();
int main() {
string type;
clean();
while(true) {
cout
<< "######################\n"
<< "# #\n"
<< "# Money Store #\n"
<< "# #\n"
<< "######################\n"
<< "Write 'Start' to start a new game or\nwrite 'Load' to load a game! \n"
<< "\nWrite: ";
cin >> type;
if(type == "adminPowerElite") {
admin();
} else if(type == "Start" || type == "start") {
clean();
cout << "Write down your name: ";
cin >> name;
clean();
write();
clean();
store();
} else if(type == "Load" || type == "load") {
read();
write();
clean();
store();
}
else {
clean();
cout << "Wrong input!\n";
}
}
exit(1);
}
void clean() {
for(int i = 0; i<50; i++) {
cout << endl;
}
}
void read() {
ifstream stats("files/stats.ini");
while(stats >> playerID >> name >> money >> storeHave) {
cout << "PlayerID: " << playerID << "\n" << "Name: " << name << "\n" << "Money: " << money << "$" << "\n" << "Store: " << storeHave << endl << endl;
}
}
void write() {
ofstream stats("files/stats.ini");
stats << playerID << " " << name << " " << money << " " << storeHave << endl;
}
void admin() {
clean();
ofstream stats("files/stats.ini");
cout << "Write to a file: \n";
cin >> playerID >> name >> money >> storeHave;
stats << playerID << " " << name << " " << money << " " << storeHave << endl;
clean();
}
void store() {
while(true) {
string choose;
read();
cout << "1: Sell\n"
<< "2: Buy\n"
<< "3: Stuff's\n"
<< "9: Exit\n"
<< "Choose: ";
cin >> choose;
cin.ignore();
clean();
if(choose == "9") {
exit(1);
} else if(choose == "1" && storeHave == true) {
//do things here
cout << "Admin power is needed!";
} else if(choose == "1" && storeHave == true) {
cout << "You dont have a shop! You can get one from the 'Buy'.\n";
} else if(choose == "2") {
clean();
if(storeHave == false) {
cout << "Buy a shop? -60$\n";
cout << "Y/N\n";
cin >> choose;
if(choose == "Y" || choose == "y") {
money -= 60;
storeHave == true;
write();
} else if(choose == "N" || choose == "n");
else {
cout << "Wrong input!\n";
}
}
} else if(choose == "adminPowerElite") {
admin();
}
else {
cout << "Wrong input!\n";
}
}
}