GNOME Bugzilla – Bug 731646
Puzzle difficulty changes as values are filled
Last modified: 2014-06-25 17:36:33 UTC
Created attachment 278437 [details] Empty puzzle on the left, almost filled on the right Please see the screenshot attached. When the puzzle is empty, its difficulty label showed 'Easy Difficulty'. As I went on filling values in the board, the label changed - 'Easy' -> 'Medium' -> 'Hard' -> 'Very Hard'
Created attachment 278476 [details] [review] Show board's saved difficulty rating label as the Headerbar subtitle A board's rating was private, but since the saved difficulty rating is read by SudokuSaver, I've made it public for now. If we want to let it remain private, we'll have to create a string from the saved board values, append the float rating at its end, and call SudokuBoard's set_from_string (). Let me know if you prefer the second way, I'll update this patch.
Also, there are 2 methods which could be made static - - board.get_difficulty_category () -> DifficultyRating.get_category (float rating) - difficulty_category.to_string () -> DifficultyRating.get_category_string (DifficultyCategory) but a couple of functions not related to this bug call them, so I haven't changed this for now, and I'll post it as a separate patch.
Review of attachment 278476 [details] [review]: I think this is alright for now. I think I'll need a bit of time to think about a proper way to do all that. I think to solver/generator might be this issue, why we can't have that in a nice way.
Review of attachment 278476 [details] [review]: ::: src/gnome-sudoku.vala @@ +241,2 @@ var rater = new SudokuRater(ref completed_board); var rating = rater.get_difficulty (); I think you don't need the rating variable anymore, right?
(In reply to comment #2) > Also, there are 2 methods which could be made static - > > - board.get_difficulty_category () -> DifficultyRating.get_category (float > rating) > - difficulty_category.to_string () -> DifficultyRating.get_category_string > (DifficultyCategory) > > but a couple of functions not related to this bug call them, so I haven't > changed this for now, and I'll post it as a separate patch. Well, they could be, but is there really value in changing this? It's easier/cleaner to call them as member functions.
Michael, for your info: I advised for methods where the transformation part of the method can be written as a pure function, we'd want to do that. We can still have a member accessor but the transformation should be extracted in a pure fashion.
(In reply to comment #4) > Review of attachment 278476 [details] [review]: > > ::: src/gnome-sudoku.vala > @@ +241,2 @@ > var rater = new SudokuRater(ref completed_board); > var rating = rater.get_difficulty (); > > I think you don't need the rating variable anymore, right? nah, we need it for the debug output https://git.gnome.org/browse/gnome-sudoku/tree/src/gnome-sudoku.vala#n201
shall I push the patch ?
Comment on attachment 278476 [details] [review] Show board's saved difficulty rating label as the Headerbar subtitle I'm fine with it
Comment on attachment 278476 [details] [review] Show board's saved difficulty rating label as the Headerbar subtitle Pushed as 78bd8b5