Skip to content

Conversation

dogukanteber
Copy link

Resolves #47. Now the users can save the game and quit. If the game is saved, the next time they open nudoku, a pop-up asks them to resume where they left off or create a new game. Currently, there is no coloring in the pop-up. If there is a necessity to add colors, it is not a difficult task. It can be added easily as long as which colors is going to be used are provided.

@jubalh jubalh self-requested a review June 30, 2022 15:51
@jubalh
Copy link
Owner

jubalh commented Jun 30, 2022

Thanks! I'll try to review it soon!

Copy link
Owner

@jubalh jubalh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good! Thank you!
I made some comments about where I think there need to be changes.
Sorry for the long delay! :(

@@ -71,7 +73,17 @@ static char* g_outputFilename = NULL; /* in case -p/-i flag we get a filename p
static int g_sudokuCount = 1; /* in case of -n we can the numbers of sudoku that should end up in the PDf (-p) */
static bool g_outIsPDF;
static DIFFICULTY g_level = D_EASY;
static WINDOW *grid, *infobox, *status;
static WINDOW *grid, *infobox, *status, *resume;
static bool is_board_solved = false; /* if the board is solved, we do not save the state */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would propose to remove this variable and not check if the user solved/not ask him if he wants to save.
I would like to just have an option "lets save". And the user can do this when he wants but don't add the overhead of tracking this and asking him.

@@ -333,6 +345,8 @@ static void init_windows(void)
wprintw(infobox, _(" r - Redraw\n"));
wprintw(infobox, _(" S - Solve puzzle\n"));
wprintw(infobox, _(" x - Delete number\n"));
wprintw(infobox, _(" g - Save\n"));
wprintw(infobox, _(" G - Save and quit\n"));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think save is enough. The user can use save and then quit.

const char* home_path = getenv("HOME");
size_t len_home_path = strlen(home_path);

const char* dir_name = "/.nudoku/";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use something like: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
Most likely: $XDG_STATE_HOME defines the base directory relative to which user-specific state files should be stored. If $XDG_STATE_HOME is either not set or empty, a default equal to $HOME/.local/state should be used.

strcat(file_path, file_name);

free(dir_path);
return file_path;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When is this file removed again? I think in is_game_saved you test for the presence of it. But I don't see where it get's removed when the game is finished.

@jubalh
Copy link
Owner

jubalh commented Dec 20, 2023

@dogukanteber ping

@dogukanteber
Copy link
Author

Wow! It has been quite some time. I completely forgot about this PR @jubalh. My apologies. I will try to allocate some time to finish up this PR.

@merv1n34k
Copy link
Contributor

@dogukanteber @jubalh Do you mind if I try to finish up this PR? (will create a new one though)
I have more free time than usual for a few days, and with the help of @dogukanteber's code it looks doable for me.

@jubalh
Copy link
Owner

jubalh commented Aug 7, 2024

Sure! Go for it :)

@merv1n34k merv1n34k mentioned this pull request Aug 13, 2024
@jubalh jubalh closed this in #65 Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow pausing game
3 participants