Commit 6fe9a1bc authored by John Ward's avatar John Ward

Fix for incorrect preview shape when difficult blocks is selected

parent e5861c34
Pipeline #214027 passed with stages
in 3 minutes and 30 seconds
......@@ -308,7 +308,7 @@ public class Game : Object
this.pick_difficult_blocks = pick_difficult_blocks;
blocks = new Block[columns, lines];
/* Start with some pre-filled spaces */
/* Start with some shape_landed-filled spaces */
for (var y = 0; y < height; y++)
{
/* Pick at least one column to be empty */
......@@ -363,6 +363,7 @@ public class Game : Object
public void start ()
{
has_started = true;
make_next_shape();
add_shape ();
setup_drop_timer ();
started ();
......@@ -500,18 +501,23 @@ public class Game : Object
return true;
}
private void add_shape ()
private void make_next_shape ()
{
if (pick_difficult_blocks) {
var difficult_shapes = pick_difficult_shapes ();
shape = difficult_shapes[0];
next_shape = difficult_shapes[1];
if (pick_difficult_blocks)
{
next_shape = pick_difficult_shapes ();
}
else
{
shape = (owned) next_shape;
next_shape = pick_random_shape ();
}
}
private void add_shape ()
{
shape = (owned) next_shape;
make_next_shape();
foreach (var b in shape.blocks)
{
......@@ -541,7 +547,7 @@ public class Game : Object
return make_shape (Random.int_range (0, NCOLORS), Random.int_range (0, 4));
}
private Shape[] pick_difficult_shapes ()
private Shape pick_difficult_shapes ()
{
/* The algorithm comes from Federico Poloni's "bastet" game */
var metrics = new int[NCOLORS];
......@@ -622,24 +628,22 @@ public class Game : Object
}
}
var new_shape = new Shape();
/* Actually choose a piece */
var rnd = Random.int_range (0, 99);
if (rnd < 75)
shape = make_shape (possible_types[0], Random.int_range (0, 4));
new_shape = make_shape (possible_types[0], Random.int_range (0, 4));
else if (rnd < 92)
shape = make_shape (possible_types[1], Random.int_range (0, 4));
new_shape = make_shape (possible_types[1], Random.int_range (0, 4));
else if (rnd < 98)
shape = make_shape (possible_types[2], Random.int_range (0, 4));
new_shape = make_shape (possible_types[2], Random.int_range (0, 4));
else
shape = make_shape (possible_types[3], Random.int_range (0, 4));
new_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));
/* 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;
return new_shape;
}
private Shape make_shape (int type, int rotation)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment