[gnome-nibbles/arnaudb/fix-level-25: 7/8] Allow changing number of regular bonuses.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-nibbles/arnaudb/fix-level-25: 7/8] Allow changing number of regular bonuses.
- Date: Mon, 29 Jun 2020 17:09:17 +0000 (UTC)
commit 5c2fa848ad7a21715150eb5419a74e95f429535d
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Fri Jun 26 01:09:13 2020 +0200
Allow changing number of regular bonuses.
src/boni.vala | 6 +++---
src/nibbles-game.vala | 4 ++--
src/nibbles-test.vala | 2 +-
src/nibbles-view.vala | 2 +-
4 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/src/boni.vala b/src/boni.vala
index e7b1e8f..05cbf01 100644
--- a/src/boni.vala
+++ b/src/boni.vala
@@ -80,13 +80,13 @@ private class Boni : Object
bonuses.remove (bonus);
}
- internal void reset (int numworms)
+ internal void reset (uint8 regular_bonus)
{
bonuses.clear ();
reset_missed ();
- regular_bonus_maxi = 8 + numworms;
+ regular_bonus_maxi = regular_bonus;
+ regular_bonus_left = regular_bonus;
total_bonus_number = 0;
- regular_bonus_left = regular_bonus_maxi;
}
internal Bonus? get_bonus (int[,] board, int x, int y)
diff --git a/src/nibbles-game.vala b/src/nibbles-game.vala
index 31a03d7..368e574 100644
--- a/src/nibbles-game.vala
+++ b/src/nibbles-game.vala
@@ -92,12 +92,12 @@ private class NibblesGame : Object
Random.set_seed (no_random ? 42 : (uint32) time_t ());
}
- internal bool load_board (string [] future_board)
+ internal bool load_board (string [] future_board, uint8 regular_bonus)
{
if (future_board.length != height)
return false;
- boni.reset (numworms);
+ boni.reset (regular_bonus);
warp_manager.warps.clear ();
string tmpboard;
diff --git a/src/nibbles-test.vala b/src/nibbles-test.vala
index 4fca8a8..d28445b 100644
--- a/src/nibbles-test.vala
+++ b/src/nibbles-test.vala
@@ -47,7 +47,7 @@ namespace NibblesTest
game.numai = 4;
game.create_worms ();
- game.load_board (level_008);
+ game.load_board (level_008, /* regular bonus = 8 + numworms */ 12);
assert_true (game.numworms == 4);
assert_true (game.worms.size == 4);
diff --git a/src/nibbles-view.vala b/src/nibbles-view.vala
index c626395..2518639 100644
--- a/src/nibbles-view.vala
+++ b/src/nibbles-view.vala
@@ -236,7 +236,7 @@ private class NibblesView : GtkClutter.Embed
string [] board = {};
while ((line = file.read_line ()) != null)
board += (!) line;
- if (!game.load_board (board))
+ if (!game.load_board (board, 8 + game.numworms))
error ("Level file appears to be damaged: %s", filename);
foreach (Worm worm in game.worms)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]