Skip to content

Commit

Permalink
Changed sellable fish to low-value ones, fixed year and newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
firefish111 committed May 15, 2023
1 parent 4c15b51 commit ddba1b7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 36 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
main
main
ext/
40 changes: 20 additions & 20 deletions destruct.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
if (argc > 1 && strcmp(argv[1], "/d") == 0) {
printf("Gone Fishing v%zu.%zu.%zu savefile destructurer. Copyright firefish 2022.\n\n", VER / 100, (VER / 10) % 10, VER % 10);

savefile = fopen("GONEFISH.SAV", "rb");
if (!savefile) {
printf("Savefile does not exist. Cannot destructure.\n");
return 1;
}

tempBuf = calloc(sizeof(size_t), LEN + 4);
fread(tempBuf, sizeof(size_t), LEN + 4, savefile);
printf("Save version %zu.%zu.%zu.\nTier %d (%s), $%d in bank, %d bait.\nFish:\n", tempBuf[0] / 100, (tempBuf[0] / 10) % 10, tempBuf[0] % 10, tempBuf[1], rodname[tempBuf[1]], tempBuf[2], tempBuf[LEN + 3]);

for (i = 0; i < LEN; ++i) {
printf("\t%zu %s,\n", tempBuf[i + 3], fish[i < 5 ? i : i + 1]);
}

printf("\n\nText-based save: %01x$%zu[%zu:%zu:%zu:%zu:%zu][%zu:%zu:%zu:%zu]%zu\n", tempBuf[1], tempBuf[2], tempBuf[3], tempBuf[4], tempBuf[5], tempBuf[6], tempBuf[7], tempBuf[8], tempBuf[9], tempBuf[10], tempBuf[11], tempBuf[LEN + 3]);
return 0;
}
if (argc > 1 && strcmp(argv[1], "/d") == 0) {
printf("Gone Fishing v%zu.%zu.%zu savefile destructurer. Copyright firefish %d.\n\n", VER / 100, (VER / 10) % 10, VER % 10, YEAR);

savefile = fopen("GONEFISH.SAV", "rb");
if (!savefile) {
printf("Savefile does not exist. Cannot destructure.\n");
return 1;
}

tempBuf = calloc(sizeof(size_t), LEN + 4);
fread(tempBuf, sizeof(size_t), LEN + 4, savefile);
printf("Save version %zu.%zu.%zu.\nTier %d (%s), $%d in bank, %d bait.\nFish:\n", tempBuf[0] / 100, (tempBuf[0] / 10) % 10, tempBuf[0] % 10, tempBuf[1], rodname[tempBuf[1]], tempBuf[2], tempBuf[LEN + 3]);

for (i = 0; i < LEN; ++i) {
printf("\t%zu %s,\n", tempBuf[i + 3], fish[i < 5 ? i : i + 1]);
}

printf("\n\nText-based save: %01x$%zu[%zu:%zu:%zu:%zu:%zu][%zu:%zu:%zu:%zu]%zu\n", tempBuf[1], tempBuf[2], tempBuf[3], tempBuf[4], tempBuf[5], tempBuf[6], tempBuf[7], tempBuf[8], tempBuf[9], tempBuf[10], tempBuf[11], tempBuf[LEN + 3]);
return 0;
}
5 changes: 3 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
#include "table.h"

// semver version; insert dots after each digit
const size_t VER = 203;
const size_t VER = 204;

unsigned char tier = 0x0;
const int LEN = 9;
const int COST = 21;
const int YEAR = 2023;
int choice;
int i;
size_t money = 0;
Expand All @@ -29,7 +30,7 @@ int main(int argc, char** argv) {

srand(time(NULL));

printf("Gone Fishing v%zu.%zu.%zu. Copyright @firefish 2022.\nRun with /d flag to destructure the save file.\n\n", VER / 100, (VER / 10) % 10, VER % 10);
printf("Gone Fishing v%zu.%zu.%zu. Copyright @firefish %d.\nRun with /d flag to destructure the save file.\n\n", VER / 100, (VER / 10) % 10, VER % 10, YEAR);

i = access("GONEFISH.SAV", 0); // F_OK ain't defined, so we use good ol' fashioned 0
start:
Expand Down
25 changes: 13 additions & 12 deletions market.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
double total;
int to_buy, to_sell, i;
bool has_some = false;
bool unlocked = false;

void market() {
for (i = 0; i < 5; ++i) {
Expand All @@ -24,39 +24,40 @@ void market() {
if (to_buy <= total) {
money -= to_buy * COST;
bait += to_buy;
unlocked = true;
} else {
printf("Unfortunately, you can't afford that much bait.\n\tEither try buying less, or try selling some of your fish.\n");
}
} else {
printf("You can't afford any bait. Bait costs $21 per piece. You currently have $%zu.\n", money);
}

for (i = 5, has_some = false; i < 9; ++i) {
/*for (i = 5, has_some = false; i < 9; ++i) {
if (data[i] != 0) {
has_some = true;
}
}
}*/

if (has_some) {
printf("\nIt seems as if you have some big fish to sell.\n");
if (unlocked) {
printf("\nYou can now sell some of your less-valued fish.\n");

printf("What would you like to sell?\n");

for (i = 7; i < 11; ++i) {
printf("\tPress %d to sell %s,\n", i - 6, fish[i-1]);
for (i = 0; i < 5; ++i) {
printf("\tPress %d to sell %s,\n", i + 1, fish[i]);
}
printf("Or press 0 to not sell anything.\n> ");

scanf("%d", &choice);
if (choice > 0 && choice < 5) {
printf("How much %s would you like to sell? (you currently have %zu) ", fish[choice + 5], data[choice + 4]);
if (choice > 0 && choice <= 5) {
printf("How much %s would you like to sell? (you currently have %zu) ", fish[choice - 1], data[choice - 1]);
scanf("%d", &to_sell);

if (to_sell > data[choice + 4]) {
printf("You don't have that much %s!\n", fish[choice + 5]);
if (to_sell > data[choice - 1]) {
printf("You don't have that much %s!\n", fish[choice - 1]);
return;
} else {
data[choice + 4] -= to_sell;
data[choice - 1] -= to_sell;
money += sale[choice - 1] * to_sell;
}
} else {
Expand Down
4 changes: 3 additions & 1 deletion table.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ const float lv15[12] = {0, 0.06, 0.12, 0.17, 0.25, 0.3, 0.1, 0.25, 0.25, 0.25, 0

const float * clump[16] = {lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7, lv8, lv9, lv10, lv11, lv12, lv13, lv14, lv15};

const int sale[4] = {15, 25, 40, 70};
// for high-value: pre 2.0.4 mechanic
// const int sale[4] = {15, 25, 40, 70};
const int sale[5] = {15, 12, 10, 8, 8};

0 comments on commit ddba1b7

Please sign in to comment.