[gnome-nibbles/arnaudb/modernize-code] Reduce access to a variable
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-nibbles/arnaudb/modernize-code] Reduce access to a variable
- Date: Wed, 27 May 2020 16:09:12 +0000 (UTC)
commit a2d70d715fb1511e81126ea9b5aea6efaa2a344c
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed May 27 14:48:24 2020 +0200
Reduce access to a variable
src/boni.vala | 25 ++++++++++++-------------
src/nibbles-game.vala | 2 --
2 files changed, 12 insertions(+), 15 deletions(-)
---
diff --git a/src/boni.vala b/src/boni.vala
index 4bc7512..62a360b 100644
--- a/src/boni.vala
+++ b/src/boni.vala
@@ -79,6 +79,7 @@ private class Boni : Object
board[bonus.x + 1, bonus.y + 1] = NibblesGame.EMPTYCHAR;
bonus_removed (bonus);
+ bonuses.remove (bonus);
}
internal void reset (int numworms)
@@ -110,26 +111,24 @@ private class Boni : Object
{
missed_bonuses_to_replace = 0;
- // FIXME Use an iterator instead of a second list and
- // remove from the bonuses list inside remove_bonus()
+ // FIXME Use an iterator instead of a second list
var found = new Gee.LinkedList<Bonus> ();
foreach (var bonus in bonuses)
- {
if (bonus.countdown-- == 0)
- {
- bool real_bonus = bonus.bonus_type == BonusType.REGULAR && !bonus.fake;
-
found.add (bonus);
- remove_bonus (board, bonus);
- if (real_bonus)
- {
- increase_missed ();
- missed_bonuses_to_replace++;
- }
+ foreach (var bonus in found)
+ {
+ bool real_bonus = bonus.bonus_type == BonusType.REGULAR && !bonus.fake;
+
+ remove_bonus (board, bonus);
+
+ if (real_bonus)
+ {
+ increase_missed ();
+ missed_bonuses_to_replace++;
}
}
- bonuses.remove_all (found);
}
/*\
diff --git a/src/nibbles-game.vala b/src/nibbles-game.vala
index deb6635..8b07866 100644
--- a/src/nibbles-game.vala
+++ b/src/nibbles-game.vala
@@ -446,9 +446,7 @@ private class NibblesGame : Object
bool real_bonus = board[worm.head.x, worm.head.y] == BonusType.REGULAR + 'A'
&& !bonus.fake;
- // FIXME: see Boni.on_worms_move()
boni.remove_bonus (board, bonus);
- boni.bonuses.remove (bonus);
if (real_bonus && boni.numleft != 0)
add_bonus (true);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]