After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 731646 - Puzzle difficulty changes as values are filled
Puzzle difficulty changes as values are filled
Status: RESOLVED FIXED
Product: gnome-sudoku
Classification: Applications
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gnome-sudoku-maint
gnome-sudoku-maint
Depends on:
Blocks:
 
 
Reported: 2014-06-14 09:41 UTC by Parin Porecha
Modified: 2014-06-25 17:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Empty puzzle on the left, almost filled on the right (110.07 KB, image/jpeg)
2014-06-14 09:41 UTC, Parin Porecha
  Details
Show board's saved difficulty rating label as the Headerbar subtitle (3.10 KB, patch)
2014-06-15 10:19 UTC, Parin Porecha
committed Details | Review

Description Parin Porecha 2014-06-14 09:41:47 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'
Comment 1 Parin Porecha 2014-06-15 10:19:59 UTC
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.
Comment 2 Parin Porecha 2014-06-15 10:27:23 UTC
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.
Comment 3 Mario Wenzel 2014-06-16 20:01:04 UTC
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.
Comment 4 Michael Catanzaro 2014-06-17 16:12:15 UTC
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?
Comment 5 Michael Catanzaro 2014-06-17 16:13:51 UTC
(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.
Comment 6 Mario Wenzel 2014-06-17 16:27:22 UTC
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.
Comment 7 Parin Porecha 2014-06-24 17:37:25 UTC
(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
Comment 8 Parin Porecha 2014-06-24 17:42:20 UTC
shall I push the patch ?
Comment 9 Michael Catanzaro 2014-06-24 22:52:58 UTC
Comment on attachment 278476 [details] [review]
Show board's saved difficulty rating label as the Headerbar subtitle

I'm fine with it
Comment 10 Parin Porecha 2014-06-25 17:36:23 UTC
Comment on attachment 278476 [details] [review]
Show board's saved difficulty rating label as the Headerbar subtitle

Pushed as 78bd8b5