[gnome-nibbles/arnaudb/modernize-code: 21/58] Improve code.



commit 416df66bf7393eddbbbfbd929eb0abfcc7bdd2f3
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Wed May 27 14:40:37 2020 +0200

    Improve code.

 src/boni.vala         |  4 ++--
 src/nibbles-game.vala | 23 ++++++++---------------
 2 files changed, 10 insertions(+), 17 deletions(-)
---
diff --git a/src/boni.vala b/src/boni.vala
index 4e3459a..4bc7512 100644
--- a/src/boni.vala
+++ b/src/boni.vala
@@ -117,12 +117,12 @@ private class Boni : Object
         {
             if (bonus.countdown-- == 0)
             {
-                bool missed = bonus.bonus_type == BonusType.REGULAR && !bonus.fake;
+                bool real_bonus = bonus.bonus_type == BonusType.REGULAR && !bonus.fake;
 
                 found.add (bonus);
                 remove_bonus (board, bonus);
 
-                if (missed)
+                if (real_bonus)
                 {
                     increase_missed ();
                     missed_bonuses_to_replace++;
diff --git a/src/nibbles-game.vala b/src/nibbles-game.vala
index ed078d9..deb6635 100644
--- a/src/nibbles-game.vala
+++ b/src/nibbles-game.vala
@@ -443,22 +443,15 @@ private class NibblesGame : Object
         apply_bonus (bonus, worm);
         bonus_applied (bonus, worm);
 
-        if (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);
+        bool real_bonus = board[worm.head.x, worm.head.y] == BonusType.REGULAR + 'A'
+                       && !bonus.fake;
 
-            if (boni.numleft != 0)
-                add_bonus (true);
-        }
-        else
-        {
-            // FIXME: see Boni.on_worms_move()
-            boni.remove_bonus (board, bonus);
-            boni.bonuses.remove (bonus);
-        }
+        // FIXME: see Boni.on_worms_move()
+        boni.remove_bonus (board, bonus);
+        boni.bonuses.remove (bonus);
+
+        if (real_bonus && boni.numleft != 0)
+            add_bonus (true);
     }
 
     internal void warp_found_cb (Worm worm)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]