[quadrapassel/lr/difficult-mode-fixes: 7/7] game: restore the preview in difficult mode
- From: Jeremy Bicha <jbicha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [quadrapassel/lr/difficult-mode-fixes: 7/7] game: restore the preview in difficult mode
- Date: Sat, 5 Jan 2019 21:06:35 +0000 (UTC)
commit 1c18243dcf6a4fdcb0d2d8a50c667b287c749c1e
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Tue Dec 18 22:47:08 2018 +0100
game: restore the preview in difficult mode
It was removed without a good reason. The point of the preview in the
difficult mode is to frustrate the user even more with a preview of an
useful piece that they're not going to get.
Fixes: bd2180af6f3347a81a4c2378b8d112a4e258f79b
src/game.vala | 25 ++++++++++++++++++-------
src/quadrapassel.vala | 15 +++------------
2 files changed, 21 insertions(+), 19 deletions(-)
---
diff --git a/src/game.vala b/src/game.vala
index a1c6987..256d1fe 100644
--- a/src/game.vala
+++ b/src/game.vala
@@ -502,8 +502,11 @@ public class Game : Object
private void add_shape ()
{
- if (pick_difficult_blocks)
- shape = pick_difficult_shape ();
+ if (pick_difficult_blocks) {
+ var difficult_shapes = pick_difficult_shapes ();
+ shape = difficult_shapes[0];
+ next_shape = difficult_shapes[1];
+ }
else
{
shape = (owned) next_shape;
@@ -538,7 +541,7 @@ public class Game : Object
return make_shape (Random.int_range (0, NCOLORS), Random.int_range (0, 4));
}
- private Shape pick_difficult_shape ()
+ private Shape[] pick_difficult_shapes ()
{
/* The algorithm comes from Federico Poloni's "bastet" game */
var metrics = new int[NCOLORS];
@@ -622,13 +625,21 @@ public class Game : Object
/* Actually choose a piece */
var rnd = Random.int_range (0, 99);
if (rnd < 75)
- return make_shape (possible_types[0], Random.int_range (0, 4));
+ shape = make_shape (possible_types[0], Random.int_range (0, 4));
else if (rnd < 92)
- return make_shape (possible_types[1], Random.int_range (0, 4));
+ shape = make_shape (possible_types[1], Random.int_range (0, 4));
else if (rnd < 98)
- return make_shape (possible_types[2], Random.int_range (0, 4));
+ shape = make_shape (possible_types[2], Random.int_range (0, 4));
else
- return make_shape (possible_types[3], Random.int_range (0, 4));
+ shape = make_shape (possible_types[3], Random.int_range (0, 4));
+
+ /* Look, this one is a great fit. It would be a shame if it wouldn't be given next */
+ next_shape = make_shape (possible_types[NCOLORS - 1], Random.int_range (0, 4));
+
+ var shapes = new Shape[2];
+ shapes[0] = shape;
+ shapes[1] = next_shape;
+ return shapes;
}
private Shape make_shape (int type, int rotation)
diff --git a/src/quadrapassel.vala b/src/quadrapassel.vala
index 77c5a4e..6ecb047 100644
--- a/src/quadrapassel.vala
+++ b/src/quadrapassel.vala
@@ -346,7 +346,6 @@ public class Quadrapassel : Gtk.Application
do_preview_toggle = new Gtk.CheckButton.with_mnemonic (_("_Preview next block"));
do_preview_toggle.set_active (settings.get_boolean ("do-preview"));
- do_preview_toggle.set_sensitive (!settings.get_boolean ("pick-difficult-blocks"));
do_preview_toggle.toggled.connect (do_preview_toggle_toggled_cb);
grid.attach (do_preview_toggle, 0, 5, 2, 1);
@@ -456,22 +455,14 @@ public class Quadrapassel : Gtk.Application
private void do_preview_toggle_toggled_cb ()
{
- settings.set_boolean ("do-preview", do_preview_toggle.get_active ());
- update_preview_settings ();
+ var preview_enabled = do_preview_toggle.get_active ();
+ settings.set_boolean ("do-preview", preview_enabled);
+ preview.enabled = preview_enabled;
}
private void difficult_blocks_toggled_cb ()
{
settings.set_boolean ("pick-difficult-blocks", difficult_blocks_toggle.get_active ());
- do_preview_toggle.set_sensitive (!settings.get_boolean ("pick-difficult-blocks"));
- update_preview_settings ();
- }
-
- private void update_preview_settings ()
- {
- var do_preview = do_preview_toggle.get_active ();
- var difficult_block_mode = difficult_blocks_toggle.get_active ();
- preview.enabled = do_preview && !difficult_block_mode;
}
private void set_rotate_counter_clock_wise ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]