Skip to content

Commit

Permalink
program now saves credits!
Browse files Browse the repository at this point in the history
  • Loading branch information
phoebe-leong authored Jun 12, 2021
1 parent 0dae4cb commit 207baaf
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ std::ifstream fileRead;
void init();
int close();
void decrypt();
void encrypt();
void usernameSelect();
void mainMenu();
void jobMenu();
Expand All @@ -35,13 +34,11 @@ void InsufficientFunds();
void startScreen();
void endgame();

void encrypt() {
}

void decrypt() {
usr.username = cryptor::decrypt(usr.username);
jobs.currentJobStatus = cryptor::decrypt(jobs.currentJobStatus);
difficultyLvl = cryptor::decrypt(difficultyLvl);
usr.creditstr = cryptor::decrypt(usr.creditstr);
}

void startScreen() {
Expand All @@ -50,6 +47,7 @@ void startScreen() {
getline(fileRead, usr.username);
getline(fileRead, jobs.currentJobStatus);
getline(fileRead, difficultyLvl);
getline(fileRead, usr.creditstr);
fileRead.close();

decrypt();
Expand Down Expand Up @@ -84,7 +82,11 @@ void init() {
}

if (difficultyLvl == "Easy" || difficultyLvl == "easy") {
usr.credits = usr.starterCredits * 2;
if (!(usr.creditstr.empty())) {
usr.credits = stoi(usr.creditstr);
} else {
usr.credits *= 2;
}
pwrUps.maxPowerUpCommands *= 2;
pwrUps.powerUpMultiplier *= 2;

Expand All @@ -95,9 +97,16 @@ void init() {

uni.UniFee -= 100;
} else if (difficultyLvl == "Normal" || difficultyLvl == "normal") {
usr.credits = usr.starterCredits;
if (!(usr.creditstr.empty())) {
usr.credits = stoi(usr.creditstr);
}
} else if (difficultyLvl == "Impossible" || difficultyLvl == "impossible") {
usr.credits = 0;
if (!(usr.creditstr.empty())) {
usr.credits = stoi(usr.creditstr);
} else {
usr.credits = 0;
}

shop.item1Amount *= 100;
shop.item2Amount *= 50;
shop.item3Amount *= 50;
Expand All @@ -108,8 +117,6 @@ void init() {
pwrUps.maxPowerUpCommands /= 2;

uni.UniFee *= 100;
} else if (difficultyLvl.empty()) {
usr.credits = usr.starterCredits;
}
}

Expand Down Expand Up @@ -152,7 +159,8 @@ int close() {
file.open("data.txt");
file << cryptor::encrypt(usr.username) << "\n";
file << cryptor::encrypt(jobs.currentJobStatus) << "\n";
file << cryptor::encrypt(difficultyLvl);
file << cryptor::encrypt(difficultyLvl) << "\n";
file << cryptor::encrypt(std::to_string(usr.credits));
file.close();

return 0;
Expand Down

0 comments on commit 207baaf

Please sign in to comment.