[gnome-nibbles/arnaudb/modernize-code: 10/58] Use internal more.



commit 82d99e985d9581ac70bc3500ae5a35e8badd7d4f
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Tue May 26 18:01:00 2020 +0200

    Use internal more.

 src/boni.vala               |  72 +++++++++++-----------
 src/gnome-nibbles.vala      |  68 ++++++++++-----------
 src/nibbles-game.vala       | 125 +++++++++++++++++++-------------------
 src/nibbles-view.vala       | 143 +++++++++++++++++++++-----------------------
 src/preferences-dialog.vala |  18 +++---
 src/warp.vala               |  41 ++++++-------
 src/worm.vala               | 130 ++++++++++++++++++++--------------------
 7 files changed, 289 insertions(+), 308 deletions(-)
---
diff --git a/src/boni.vala b/src/boni.vala
index ace1ee1..8a09eb7 100644
--- a/src/boni.vala
+++ b/src/boni.vala
@@ -19,50 +19,46 @@
 // This is a fairly literal translation of the GPLv2+ original by
 // Sean MacIsaac, Ian Peters, Guillaume Béland.
 
-public enum BonusType
+private enum BonusType
 {
     REGULAR,
     HALF,
     DOUBLE,
     LIFE,
     REVERSE,
-    WARP
+    WARP;
 }
 
-public class Bonus : Object
+private class Bonus : Object
 {
-    public int x;
-    public int y;
-    public BonusType type;
-    public bool fake;
-    public int countdown;
+    public int x                { internal get; protected construct; }
+    public int y                { internal get; protected construct; }
+    public BonusType bonus_type { internal get; protected construct; }
+    public bool fake            { internal get; protected construct; }
+    public int countdown        { internal get; internal construct set; }
 
-    public Bonus (int x, int y, BonusType type, bool fake, int countdown)
+    internal Bonus (int x, int y, BonusType bonus_type, bool fake, int countdown)
     {
-        this.x = x;
-        this.y = y;
-        this.type = type;
-        this.fake = fake;
-        this.countdown = countdown;
+        Object (x: x, y: y, bonus_type: bonus_type, fake: fake, countdown: countdown);
     }
 }
 
-public class Boni : Object
+private class Boni : Object
 {
-    public Gee.LinkedList<Bonus> bonuses;
+    internal Gee.LinkedList<Bonus> bonuses;
 
-    public int missed;
-    public int numleft;
-    public int numboni;
-    public int numbonuses;
+    internal int missed;
+    internal int numleft;
+    internal int numboni;
+    private  int numbonuses;
 
-    public const int MAX_BONUSES = 100;
-    public const int MAX_MISSED = 2;
+    private const int MAX_BONUSES = 100;
+    internal const int MAX_MISSED = 2;
 
-    public signal void bonus_added ();
-    public signal void bonus_removed (Bonus bonus);
+    internal signal void bonus_added ();
+    internal signal void bonus_removed (Bonus bonus);
 
-    public Boni (int numworms)
+    internal Boni (int numworms)
     {
         bonuses = new Gee.LinkedList<Bonus> ();
         missed = 0;
@@ -71,22 +67,22 @@ public class Boni : Object
         numleft = numboni;
     }
 
-    public void add_bonus (int[,] board, int x, int y, BonusType type, bool fake, int countdown)
+    internal void add_bonus (int[,] board, int x, int y, BonusType bonus_type, bool fake, int countdown)
     {
         if (numbonuses == MAX_BONUSES)
             return;
 
-        var bonus = new Bonus (x, y, type, fake, countdown);
+        var bonus = new Bonus (x, y, bonus_type, fake, countdown);
         bonuses.add (bonus);
-        board[x, y] = type + 'A';
-        board[x + 1, y] = type + 'A';
-        board[x, y + 1] = type + 'A';
-        board[x + 1, y + 1] = type + 'A';
+        board[x, y] = bonus_type + 'A';
+        board[x + 1, y] = bonus_type + 'A';
+        board[x, y + 1] = bonus_type + 'A';
+        board[x + 1, y + 1] = bonus_type + 'A';
         bonus_added ();
         numbonuses++;
     }
 
-    public void remove_bonus (int[,] board, Bonus bonus)
+    internal void remove_bonus (int[,] board, Bonus bonus)
     {
         board[bonus.x, bonus.y] = NibblesGame.EMPTYCHAR;
         board[bonus.x + 1, bonus.y] = NibblesGame.EMPTYCHAR;
@@ -96,7 +92,7 @@ public class Boni : Object
         bonus_removed (bonus);
     }
 
-    public void reset (int numworms)
+    internal void reset (int numworms)
     {
         bonuses.clear ();
         missed = 0;
@@ -105,14 +101,14 @@ public class Boni : Object
         numleft = numboni;
     }
 
-    public Bonus? get_bonus (int[,] board, int x, int y)
+    internal Bonus? get_bonus (int[,] board, int x, int y)
     {
         foreach (var bonus in bonuses)
         {
-            if ((x == bonus.x && y == bonus.y)
-                || (x == bonus.x + 1 && y == bonus.y)
-                || (x == bonus.x && y == bonus.y + 1)
-                || (x == bonus.x + 1 && y == bonus.y + 1))
+            if ((x == bonus.x     && y == bonus.y)
+             || (x == bonus.x + 1 && y == bonus.y)
+             || (x == bonus.x     && y == bonus.y + 1)
+             || (x == bonus.x + 1 && y == bonus.y + 1))
             {
                 return bonus;
             }
diff --git a/src/gnome-nibbles.vala b/src/gnome-nibbles.vala
index 0f77d33..2827e21 100644
--- a/src/gnome-nibbles.vala
+++ b/src/gnome-nibbles.vala
@@ -18,7 +18,7 @@
 
 using Gtk;
 
-public class Nibbles : Gtk.Application
+private class Nibbles : Gtk.Application
 {
     /* Translators: name of the program, as seen in the headerbar, in GNOME Shell, or in the about dialog */
     private const string PROGRAM_NAME = _("Nibbles");
@@ -109,7 +109,17 @@ public class Nibbles : Gtk.Application
         {}
     };
 
-    public Nibbles ()
+    internal static int main (string[] args)
+    {
+        Intl.setlocale (LocaleCategory.ALL, "");
+        Intl.bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+        Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+        Intl.textdomain (GETTEXT_PACKAGE);
+
+        return new Nibbles ().run (args);
+    }
+
+    private Nibbles ()
     {
         Object (application_id: "org.gnome.Nibbles", flags: ApplicationFlags.FLAGS_NONE);
 
@@ -141,7 +151,7 @@ public class Nibbles : Gtk.Application
 
         Window.set_default_icon_name ("org.gnome.Nibbles");
 
-        Gtk.Settings.get_default ().set ("gtk-application-prefer-dark-theme", true);
+        Gtk.Settings.get_default ().@set ("gtk-application-prefer-dark-theme", true);
 
         var css_provider = new CssProvider ();
         css_provider.load_from_resource ("/org/gnome/nibbles/ui/nibbles.css");
@@ -211,7 +221,8 @@ public class Nibbles : Gtk.Application
         add_window (window);
 
         /* Create game */
-        game = new NibblesGame (settings);
+        game = new NibblesGame ();
+        game.load_properties (settings);
         game.log_score.connect (log_score_cb);
         game.level_completed.connect (level_completed_cb);
         game.notify["is-paused"].connect (() => {
@@ -380,7 +391,7 @@ public class Nibbles : Gtk.Application
         scoreboard.clear ();
         foreach (var worm in game.worms)
         {
-            var color = game.worm_props.get (worm).color;
+            var color = game.worm_props.@get (worm).color;
             scoreboard.register (worm, NibblesView.colorval_name (color), scoreboard_life);
             worm.notify["lives"].connect (scoreboard.update);
             worm.notify["score"].connect (scoreboard.update);
@@ -512,7 +523,7 @@ public class Nibbles : Gtk.Application
             return;
 
         var worm = game.worms[id];
-        var properties = game.worm_props.get (worm);
+        var properties = game.worm_props.@get (worm);
 
         switch (key)
         {
@@ -533,7 +544,7 @@ public class Nibbles : Gtk.Application
                 break;
         }
 
-        game.worm_props.set (worm, properties);
+        game.worm_props.@set (worm, properties);
     }
 
     /*\
@@ -618,7 +629,7 @@ public class Nibbles : Gtk.Application
         {
             if (worm.is_human)
             {
-                var grid = new ControlsGrid (worm.id, game.worm_props.get (worm), arrow_pixbuf, 
arrow_key_pixbuf);
+                var grid = new ControlsGrid (worm.id, game.worm_props.@get (worm), arrow_pixbuf, 
arrow_key_pixbuf);
                 grids_box.add (grid);
             }
         }
@@ -1129,29 +1140,14 @@ public class Nibbles : Gtk.Application
                            "website", "https://wiki.gnome.org/Apps/Nibbles/";
                            );
     }
-
-    public static int main (string[] args)
-    {
-        Intl.setlocale (LocaleCategory.ALL, "");
-        Intl.bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
-        Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-        Intl.textdomain (GETTEXT_PACKAGE);
-
-        return new Nibbles ().run (args);
-    }
 }
 
 [GtkTemplate (ui = "/org/gnome/nibbles/ui/scoreboard.ui")]
 private class Scoreboard : Box
 {
-    private Gee.HashMap<PlayerScoreBox, Worm> boxes;
+    private Gee.HashMap<PlayerScoreBox, Worm> boxes = new Gee.HashMap<PlayerScoreBox, Worm> ();
 
-    public Scoreboard ()
-    {
-        boxes = new Gee.HashMap<PlayerScoreBox, Worm> ();
-    }
-
-    public void register (Worm worm, string color_name, Gdk.Pixbuf life_pixbuf)
+    internal void register (Worm worm, string color_name, Gdk.Pixbuf life_pixbuf)
     {
         var color = Pango.Color ();
         color.parse (color_name);
@@ -1160,22 +1156,22 @@ private class Scoreboard : Box
          * It's set to "Player %d" for now to avoid a string change for 3.20.
          */
         var box = new PlayerScoreBox (_("Player %d").printf (worm.id + 1), color, worm.score, worm.lives, 
life_pixbuf); // TODO document for translators where this string appears 1/2
-        boxes.set (box, worm);
+        boxes.@set (box, worm);
         add (box);
     }
 
-    public void update ()
+    internal void update ()
     {
         foreach (var entry in boxes.entries)
         {
             var box = entry.key;
-            var worm = entry.value;
+            var worm = entry.@value;
 
             box.update (worm.score, worm.lives);
         }
     }
 
-    public void clear ()
+    internal void clear ()
     {
         foreach (var entry in boxes.entries)
         {
@@ -1193,15 +1189,13 @@ private class PlayerScoreBox : Box
     [GtkChild] private Label score_label;
     [GtkChild] private Grid lives_grid;
 
-    private Gee.LinkedList<Image> life_images;
+    private Gee.LinkedList<Image> life_images = new Gee.LinkedList<Image> ();
 
-    public PlayerScoreBox (string name, Pango.Color color, int score, int lives_left, Gdk.Pixbuf life_pixbuf)
+    internal PlayerScoreBox (string name, Pango.Color color, int score, int lives_left, Gdk.Pixbuf 
life_pixbuf)
     {
         name_label.set_markup ("<span color=\"" + color.to_string () + "\">" + name + "</span>");
         score_label.set_label (score.to_string ());
 
-        life_images = new Gee.LinkedList<Image> ();
-
         for (int i = 0; i < Worm.MAX_LIVES; i++)
         {
             var life = new Image.from_pixbuf (life_pixbuf);
@@ -1215,18 +1209,18 @@ private class PlayerScoreBox : Box
         }
     }
 
-    public void update (int score, int lives_left)
+    internal void update (int score, int lives_left)
     {
         update_score (score);
         update_lives (lives_left);
     }
 
-    public void update_score (int score)
+    internal inline void update_score (int score)
     {
         score_label.set_label (score.to_string ());
     }
 
-    public void update_lives (int lives_left)
+    internal void update_lives (int lives_left)
     {
         /* Remove lost lives - if any */
         for (int i = life_images.size - 1; i >= lives_left; i--)
@@ -1255,7 +1249,7 @@ private class ControlsGrid : Grid
     [GtkChild] private Overlay move_right;
     [GtkChild] private Label move_right_label;
 
-    public ControlsGrid (int worm_id, WormProperties worm_props, Gdk.Pixbuf arrow, Gdk.Pixbuf arrow_key)
+    internal ControlsGrid (int worm_id, WormProperties worm_props, Gdk.Pixbuf arrow, Gdk.Pixbuf arrow_key)
     {
         var color = Pango.Color ();
         color.parse (NibblesView.colorval_name (worm_props.color));
diff --git a/src/nibbles-game.vala b/src/nibbles-game.vala
index 97b959b..285ebf0 100644
--- a/src/nibbles-game.vala
+++ b/src/nibbles-game.vala
@@ -19,71 +19,71 @@
 // This is a fairly literal translation of the GPLv2+ original by
 // Sean MacIsaac, Ian Peters, Guillaume Béland.
 
-public enum GameStatus
+private enum GameStatus
 {
     GAMEOVER,
     VICTORY,
-    NEWROUND
+    NEWROUND;
 }
 
-public class NibblesGame : Object
+private class NibblesGame : Object
 {
-    public const int MINIMUM_TILE_SIZE = 7;
+    internal const int MINIMUM_TILE_SIZE = 7;
 
-    public const int GAMEDELAY = 35;
-    public const int BONUSDELAY = 100;
+    internal const int GAMEDELAY = 35;
+    private const int BONUSDELAY = 100;
 
-    public const int MAX_HUMANS = 4;
-    public const int MAX_AI = 5;
-    public const int MAX_WORMS = 6;
+    internal const int MAX_HUMANS = 4;
+    internal const int MAX_AI = 5;
+    internal const int MAX_WORMS = 6;
 
-    public const int MAX_SPEED = 4;
+    internal const int MAX_SPEED = 4;
 
-    public const int WIDTH = 92;
-    public const int HEIGHT = 66;
-    public const int CAPACITY = WIDTH * HEIGHT;
+    internal const int WIDTH = 92;
+    internal const int HEIGHT = 66;
+    internal const int CAPACITY = WIDTH * HEIGHT;
 
-    public const char EMPTYCHAR = 'a';
-    public const char WORMCHAR = 'w';
-    public const char WARPCHAR = 'W';
+    internal const char EMPTYCHAR = 'a';
+    internal const char WORMCHAR = 'w';     // only used in worm.vala
+    internal const char WARPCHAR = 'W';     // only used in warp.vala
 
-    public const int MAX_LEVEL = 26;
+    internal const int MAX_LEVEL = 26;
 
-    public int start_level { get; private set; }
-    public int current_level { get; private set; }
-    public int speed { get; set; }
+    internal int start_level    { internal get; private set; }
+    internal int current_level  { internal get; private set; }
+    internal int speed          { internal get; internal set; }
 
     /* Board data */
-    public int tile_size { get; set; }
-    public int[,] board;
+    internal int tile_size      { internal get; internal set; }
+    internal int[,] board;
 
     /* Worms data */
-    public int numhumans { get; set; }
-    public int numai { get; set; }
-    public int numworms { get; private set; }
+    internal int numhumans      { internal get; internal set; }
+    internal int numai          { internal get; internal set; }
+    internal int numworms       { internal get; private set; }
 
     /* Game models */
-    public Gee.LinkedList<Worm> worms { get; private set; }
-    public Boni boni { get; private set; }
-    public WarpManager warp_manager { get; private set; }
-    public Gee.HashMap<Worm, WormProperties?> worm_props { get; private set; }
+    internal Gee.LinkedList<Worm> worms { get; private set; }
+    internal Boni boni { get; private set; }
+    internal WarpManager warp_manager { get; private set; }
+    internal Gee.HashMap<Worm, WormProperties?> worm_props { get; private set; }
 
     /* Game controls */
-    public bool is_running { get; private set; default = false; }
-    public bool is_paused { get; private set; }
+    internal bool is_running    { internal get; private set; default = false; }
+    internal bool is_paused     { internal get; private set; default = false; }
 
     private uint main_id = 0;
     private uint add_bonus_id = 0;
 
-    public bool fakes { get; set; }
+    internal bool fakes         { internal get; internal set; }
 
-    public signal void worm_moved (Worm worm);
-    public signal void bonus_applied (Bonus bonus, Worm worm);
-    public signal void log_score (int score, int level_reached);
-    public signal void animate_end_game ();
-    public signal void level_completed ();
+    internal signal void worm_moved (Worm worm);
+    internal signal void bonus_applied (Bonus bonus, Worm worm);
+    internal signal void log_score (int score, int level_reached);
+    internal signal void animate_end_game ();
+    internal signal void level_completed ();
 
-    public NibblesGame (Settings settings)
+    internal NibblesGame ()
     {
         boni = new Boni (numworms);
         warp_manager = new WarpManager ();
@@ -91,18 +91,14 @@ public class NibblesGame : Object
         worms = new Gee.LinkedList<Worm> ();
         worm_props = new Gee.HashMap<Worm, WormProperties?> ();
 
-        is_paused = false;
-
         Random.set_seed ((uint32) time_t ());
-        load_properties (settings);
-        current_level = start_level;
     }
 
     /*\
     * * Game controls
     \*/
 
-    public void start ()
+    internal void start ()
     {
         is_running = true;
 
@@ -113,7 +109,7 @@ public class NibblesGame : Object
         Source.set_name_by_id (add_bonus_id, "[Nibbles] add_bonus_cb");
     }
 
-    public void stop ()
+    internal void stop ()
     {
         is_running = false;
 
@@ -130,19 +126,19 @@ public class NibblesGame : Object
         }
     }
 
-    public void pause ()
+    internal void pause ()
     {
         is_paused = true;
         stop ();
     }
 
-    public void unpause ()
+    internal void unpause ()
     {
         is_paused = false;
         start ();
     }
 
-    public void reset ()
+    internal inline void reset ()
     {
         current_level = start_level;
     }
@@ -153,7 +149,7 @@ public class NibblesGame : Object
         animate_end_game ();
     }
 
-    public bool main_loop_cb ()
+    internal bool main_loop_cb ()
     {
         var status = get_game_status ();
 
@@ -200,7 +196,7 @@ public class NibblesGame : Object
     * * Handling worms
     \*/
 
-    public void create_worms ()
+    internal void create_worms ()
     {
         worms.clear ();
 
@@ -215,7 +211,7 @@ public class NibblesGame : Object
         }
     }
 
-    public void add_worms ()
+    internal void add_worms ()
     {
         foreach (var worm in worms)
         {
@@ -228,7 +224,7 @@ public class NibblesGame : Object
         }
     }
 
-    public void move_worms ()
+    internal void move_worms ()
     {
         if (boni.missed > Boni.MAX_MISSED)
         {
@@ -246,7 +242,7 @@ public class NibblesGame : Object
         {
             if (bonus.countdown-- == 0)
             {
-                if (bonus.type == BonusType.REGULAR && !bonus.fake)
+                if (bonus.bonus_type == BonusType.REGULAR && !bonus.fake)
                 {
                     found.add (bonus);
                     boni.remove_bonus (board, bonus);
@@ -320,7 +316,7 @@ public class NibblesGame : Object
     * * Handling bonuses
     \*/
 
-    public void add_bonus (bool regular)
+    internal void add_bonus (bool regular)
     {
         bool good = false;
         int x = 0, y = 0;
@@ -416,7 +412,7 @@ public class NibblesGame : Object
         }
     }
 
-    public void apply_bonus (Bonus bonus, Worm worm)
+    internal void apply_bonus (Bonus bonus, Worm worm)
     {
         if (bonus.fake)
         {
@@ -453,14 +449,14 @@ public class NibblesGame : Object
         }
     }
 
-    public bool add_bonus_cb ()
+    internal bool add_bonus_cb ()
     {
         add_bonus (false);
 
         return Source.CONTINUE;
     }
 
-    public void bonus_found_cb (Worm worm)
+    internal void bonus_found_cb (Worm worm)
     {
         var bonus = boni.get_bonus (board, worm.head.x, worm.head.y);
         if (bonus == null)
@@ -486,7 +482,7 @@ public class NibblesGame : Object
         }
     }
 
-    public void warp_found_cb (Worm worm)
+    internal void warp_found_cb (Worm worm)
     {
         var warp = warp_manager.get_warp (worm.head.x, worm.head.y);
         if (warp == null)
@@ -495,7 +491,7 @@ public class NibblesGame : Object
         worm.warp (warp);
     }
 
-    public GameStatus? get_game_status ()
+    internal GameStatus? get_game_status ()
     {
         var worms_left = 0;
         foreach (var worm in worms)
@@ -523,7 +519,7 @@ public class NibblesGame : Object
         return null;
     }
 
-    public Worm? get_winner ()
+    internal Worm? get_winner ()
     {
         foreach (var worm in worms)
         {
@@ -538,15 +534,16 @@ public class NibblesGame : Object
     * * Saving / Loading properties
     \*/
 
-    public void load_properties (Settings settings)
+    internal void load_properties (Settings settings)
     {
         tile_size = settings.get_int ("tile-size");
         start_level = settings.get_int ("start-level");
         speed = settings.get_int ("speed");
         fakes = settings.get_boolean ("fakes");
+        current_level = start_level;
     }
 
-    public void save_properties (Settings settings)
+    internal void save_properties (Settings settings)
     {
         // settings is already in delay mode, and apply is managed
         settings.set_int ("tile-size", tile_size);
@@ -555,7 +552,7 @@ public class NibblesGame : Object
         settings.set_boolean ("fakes", fakes);
     }
 
-    public void load_worm_properties (Gee.ArrayList<Settings> worm_settings)
+    internal void load_worm_properties (Gee.ArrayList<Settings> worm_settings)
     {
         worm_props.clear ();
         foreach (var worm in worms)
@@ -567,11 +564,11 @@ public class NibblesGame : Object
             properties.left = worm_settings[worm.id].get_int ("key-left");
             properties.right = worm_settings[worm.id].get_int ("key-right");
 
-            worm_props.set (worm, properties);
+            worm_props.@set (worm, properties);
         }
     }
 
-    public bool handle_keypress (uint keyval)
+    internal bool handle_keypress (uint keyval)
     {
         if (!is_running)
             return false;
diff --git a/src/nibbles-view.vala b/src/nibbles-view.vala
index d76617e..4133081 100644
--- a/src/nibbles-view.vala
+++ b/src/nibbles-view.vala
@@ -18,7 +18,7 @@
 
 private class WormActor : Clutter.Actor
 {
-    public override void show ()
+    protected override void show ()
     {
         base.show ();
 
@@ -34,7 +34,7 @@ private class WormActor : Clutter.Actor
         restore_easing_state ();
     }
 
-    public override void hide ()
+    protected override void hide ()
     {
         save_easing_state ();
         set_easing_mode (Clutter.AnimationMode.EASE_IN_QUAD);
@@ -47,9 +47,9 @@ private class WormActor : Clutter.Actor
 
 private class BonusTexture : GtkClutter.Texture
 {
-    public const float SIZE_MULTIPLIER = 2;
+    private const float SIZE_MULTIPLIER = 2;
 
-    public override void show ()
+    protected override void show ()
     {
         base.show ();
 
@@ -65,7 +65,7 @@ private class BonusTexture : GtkClutter.Texture
         restore_easing_state ();
     }
 
-    public new void set_size (float width, float height)
+    internal new void set_size (float width, float height)
     {
         base.set_size (SIZE_MULTIPLIER * width, SIZE_MULTIPLIER * height);
     }
@@ -73,9 +73,9 @@ private class BonusTexture : GtkClutter.Texture
 
 private class WarpTexture: GtkClutter.Texture
 {
-    public const float SIZE_MULTIPLIER = 2;
+    private const float SIZE_MULTIPLIER = 2;
 
-    public override void show ()
+    protected override void show ()
     {
         base.show ();
 
@@ -91,7 +91,7 @@ private class WarpTexture: GtkClutter.Texture
         restore_easing_state ();
     }
 
-    public override void hide ()
+    protected override void hide ()
     {
         save_easing_state ();
         set_easing_mode (Clutter.AnimationMode.EASE_IN_QUAD);
@@ -102,13 +102,13 @@ private class WarpTexture: GtkClutter.Texture
         restore_easing_state ();
     }
 
-    public new void set_size (float width, float height)
+    internal new void set_size (float width, float height)
     {
         base.set_size (SIZE_MULTIPLIER * width, SIZE_MULTIPLIER * height);
     }
 }
 
-public class NibblesView : GtkClutter.Embed
+private class NibblesView : GtkClutter.Embed
 {
     /* Pixmaps */
     private Gdk.Pixbuf wall_pixmaps[11];
@@ -118,18 +118,18 @@ public class NibblesView : GtkClutter.Embed
     /* Actors */
     private Clutter.Stage stage;
     private Clutter.Actor level;
-    public Clutter.Actor name_labels { get; private set; }
+    internal Clutter.Actor name_labels { get; private set; }
 
-    private Gee.HashMap<Worm, WormActor> worm_actors;
-    private Gee.HashMap<Bonus, BonusTexture> bonus_actors;
-    private Gee.HashMap<Warp, WarpTexture> warp_actors;
+    private Gee.HashMap<Worm,  WormActor>    worm_actors  = new Gee.HashMap<Worm,  WormActor> ();
+    private Gee.HashMap<Bonus, BonusTexture> bonus_actors = new Gee.HashMap<Bonus, BonusTexture> ();
+    private Gee.HashMap<Warp,  WarpTexture>  warp_actors  = new Gee.HashMap<Warp,  WarpTexture> ();
 
     /* Game being played */
     private NibblesGame _game;
     public NibblesGame game
     {
-        get { return _game; }
-        set
+        internal get { return _game; }
+        protected construct
         {
             if (_game != null)
                 SignalHandler.disconnect_matched (_game, SignalMatchType.DATA, 0, 0, null, null, this);
@@ -147,20 +147,20 @@ public class NibblesView : GtkClutter.Embed
     }
 
     /* Colors */
-    public const int NUM_COLORS = 6;
-    public static string[] color_lookup =
-    {
-      N_("red"),
-      N_("green"),
-      N_("blue"),
-      N_("yellow"),
-      N_("cyan"),
-      N_("purple")
+    internal const int NUM_COLORS = 6;      // only used in preferences-dialog.vala
+    internal static string[] color_lookup =
+    {
+        N_("red"),
+        N_("green"),
+        N_("blue"),
+        N_("yellow"),
+        N_("cyan"),
+        N_("purple")
     };
 
-    public NibblesView (NibblesGame game)
+    internal NibblesView (NibblesGame game)
     {
-        this.game = game;
+        Object (game: game);
 
         stage = (Clutter.Stage) get_stage ();
         Clutter.Color stage_color = { 0x00, 0x00, 0x00, 0xff };
@@ -169,10 +169,6 @@ public class NibblesView : GtkClutter.Embed
         set_size_request (NibblesGame.MINIMUM_TILE_SIZE * NibblesGame.WIDTH,
                           NibblesGame.MINIMUM_TILE_SIZE * NibblesGame.HEIGHT);
 
-        worm_actors = new Gee.HashMap<Worm, WormActor> ();
-        bonus_actors = new Gee.HashMap<Bonus, BonusTexture> ();
-        warp_actors = new Gee.HashMap<Warp, WarpTexture> ();
-
         load_pixmap ();
     }
 
@@ -180,15 +176,10 @@ public class NibblesView : GtkClutter.Embed
     * * Level creationg and loading
     \*/
 
-    public void new_level (int level)
+    internal void new_level (int level)
     {
-        string level_name;
-        string filename;
-        string tmpboard;
-        int count = 0;
-
-        level_name = "level%03d.gnl".printf (level);
-        filename = Path.build_filename (PKGDATADIR, "levels", level_name, null);
+        string level_name = "level%03d.gnl".printf (level);
+        string filename = Path.build_filename (PKGDATADIR, "levels", level_name, null);
 
         FileStream file;
         if ((file = FileStream.open (filename, "r")) == null)
@@ -209,6 +200,8 @@ public class NibblesView : GtkClutter.Embed
         game.boni.reset (game.numworms);
         game.warp_manager.warps.clear ();
 
+        string tmpboard;
+        int count = 0;
         for (int i = 0; i < NibblesGame.HEIGHT; i++)
         {
             if ((tmpboard = file.read_line ()) == null)
@@ -216,7 +209,7 @@ public class NibblesView : GtkClutter.Embed
 
             for (int j = 0; j < NibblesGame.WIDTH; j++)
             {
-                game.board[j, i] = tmpboard.get(j);
+                game.board[j, i] = tmpboard.@get(j);
                 switch (game.board[j, i])
                 {
                     case 'm':
@@ -227,7 +220,7 @@ public class NibblesView : GtkClutter.Embed
 
                             var actors = new WormActor ();
                             stage.add_child (actors);
-                            worm_actors.set (game.worms[count], actors);
+                            worm_actors.@set (game.worms[count], actors);
                             count++;
                         }
                         break;
@@ -239,7 +232,7 @@ public class NibblesView : GtkClutter.Embed
 
                             var actors = new WormActor ();
                             stage.add_child (actors);
-                            worm_actors.set (game.worms[count], actors);
+                            worm_actors.@set (game.worms[count], actors);
                             count++;
                         }
                         break;
@@ -251,7 +244,7 @@ public class NibblesView : GtkClutter.Embed
 
                             var actors = new WormActor ();
                             stage.add_child (actors);
-                            worm_actors.set (game.worms[count], actors);
+                            worm_actors.@set (game.worms[count], actors);
                             count++;
                         }
                         break;
@@ -263,7 +256,7 @@ public class NibblesView : GtkClutter.Embed
 
                             var actors = new WormActor ();
                             stage.add_child (actors);
-                            worm_actors.set (game.worms[count], actors);
+                            worm_actors.@set (game.worms[count], actors);
                             count++;
                         }
                         break;
@@ -412,7 +405,7 @@ public class NibblesView : GtkClutter.Embed
     * * Pixmaps loading
     \*/
 
-    public Gdk.Pixbuf load_pixmap_file (string pixmap, int xsize, int ysize)
+    internal Gdk.Pixbuf load_pixmap_file (string pixmap, int xsize, int ysize)
     {
         var filename = Path.build_filename (PKGDATADIR, "pixmaps", pixmap, null);
         if (filename == null)
@@ -487,7 +480,7 @@ public class NibblesView : GtkClutter.Embed
         }
     }
 
-    public void connect_worm_signals ()
+    internal void connect_worm_signals ()
     {
         foreach (var worm in game.worms)
         {
@@ -502,7 +495,7 @@ public class NibblesView : GtkClutter.Embed
                 uint8 opacity;
                 opacity = worm.is_materialized ? 0xff : 0x50;
 
-                var actors = worm_actors.get (worm);
+                var actors = worm_actors.@get (worm);
 
                 actors.save_easing_state ();
                 actors.set_easing_duration (NibblesGame.GAMEDELAY * 10);
@@ -512,7 +505,7 @@ public class NibblesView : GtkClutter.Embed
         }
     }
 
-    public void board_rescale (int tile_size)
+    internal void board_rescale (int tile_size)
     {
         int board_width, board_height;
         float x_pos, y_pos;
@@ -555,10 +548,10 @@ public class NibblesView : GtkClutter.Embed
     private void animate_end_game_cb ()
     {
         foreach (var worm in game.worms)
-            worm_actors.get (worm).hide ();
+            worm_actors.@get (worm).hide ();
 
         foreach (var warp in game.warp_manager.warps)
-            warp_actors.get (warp).hide ();
+            warp_actors.@get (warp).hide ();
 
         level.save_easing_state ();
         level.set_easing_mode (Clutter.AnimationMode.EASE_IN_QUAD);
@@ -569,12 +562,12 @@ public class NibblesView : GtkClutter.Embed
         level.restore_easing_state ();
     }
 
-    public void create_name_labels ()
+    internal void create_name_labels ()
     {
         name_labels = new Clutter.Actor ();
         foreach (var worm in game.worms)
         {
-            var color = game.worm_props.get (worm).color;
+            var color = game.worm_props.@get (worm).color;
 
             /* Translators: the player's number, e.g. "Player 1" or "Player 2". */
             var player_id = _("Player %d").printf (worm.id + 1);
@@ -608,7 +601,7 @@ public class NibblesView : GtkClutter.Embed
         var actor = new GtkClutter.Texture ();
         try
         {
-            actor.set_from_pixbuf (worm_pixmaps[game.worm_props.get (worm).color]);
+            actor.set_from_pixbuf (worm_pixmaps[game.worm_props.@get (worm).color]);
         }
         catch (Clutter.TextureError e)
         {
@@ -621,13 +614,13 @@ public class NibblesView : GtkClutter.Embed
         actor.set_size (game.tile_size, game.tile_size);
         actor.set_position (worm.list.first ().x * game.tile_size, worm.list.first ().y * game.tile_size);
 
-        var actors = worm_actors.get (worm);
+        var actors = worm_actors.@get (worm);
         actors.add_child (actor);
     }
 
     private void worm_finish_added_cb (Worm worm)
     {
-        var actors = worm_actors.get (worm);
+        var actors = worm_actors.@get (worm);
 
         actors.set_opacity (0);
         actors.set_scale (3.0, 3.0);
@@ -650,7 +643,7 @@ public class NibblesView : GtkClutter.Embed
 
     private void worm_moved_cb (Worm worm)
     {
-        var actors = worm_actors.get (worm);
+        var actors = worm_actors.@get (worm);
 
         var tail_actor = actors.first_child;
         actors.remove_child (tail_actor);
@@ -660,7 +653,7 @@ public class NibblesView : GtkClutter.Embed
     private void worm_rescaled_cb (Worm worm, int tile_size)
     {
         float x_pos, y_pos;
-        var actors = worm_actors.get (worm);
+        var actors = worm_actors.@get (worm);
         if (actors == null)
             return;
 
@@ -677,11 +670,11 @@ public class NibblesView : GtkClutter.Embed
     {
         float x, y;
         var group = new Clutter.Actor ();
-        var actors = worm_actors.get (worm);
+        var actors = worm_actors.@get (worm);
         foreach (var actor in actors.get_children ())
         {
             GtkClutter.Texture texture = new GtkClutter.Texture ();
-            var color = game.worm_props.get (worm).color;
+            var color = game.worm_props.@get (worm).color;
             try
             {
                 texture.set_from_pixbuf (worm_pixmaps[color]);
@@ -721,8 +714,8 @@ public class NibblesView : GtkClutter.Embed
     {
         float x, y;
         var group = new Clutter.Actor ();
-        var worm_actors = worm_actors.get (worm);
-        var color = game.worm_props.get (worm).color;
+        var worm_actors = worm_actors.@get (worm);
+        var color = game.worm_props.@get (worm).color;
         for (int i = 0; i < erase_size; i++)
         {
             var texture = new GtkClutter.Texture ();
@@ -757,7 +750,7 @@ public class NibblesView : GtkClutter.Embed
 
     private void worm_reversed_cb (Worm worm)
     {
-        var actors = worm_actors.get (worm);
+        var actors = worm_actors.@get (worm);
 
         var count = 0;
         foreach (var actor in actors.get_children ())
@@ -778,7 +771,7 @@ public class NibblesView : GtkClutter.Embed
         var actor = new BonusTexture ();
         try
         {
-            actor.set_from_pixbuf (boni_pixmaps[bonus.type]);
+            actor.set_from_pixbuf (boni_pixmaps[bonus.bonus_type]);
         }
         catch (Clutter.TextureError e)
         {
@@ -793,15 +786,15 @@ public class NibblesView : GtkClutter.Embed
         actor.set_position (bonus.x * game.tile_size, bonus.y * game.tile_size);
 
         level.add_child (actor);
-        if (bonus.type != BonusType.REGULAR)
+        if (bonus.bonus_type != BonusType.REGULAR)
             play_sound ("appear");
 
-        bonus_actors.set (bonus, actor);
+        bonus_actors.@set (bonus, actor);
     }
 
     private void bonus_removed_cb (Bonus bonus)
     {
-        var bonus_actor = bonus_actors.get (bonus);
+        var bonus_actor = bonus_actors.@get (bonus);
         bonus_actors.unset (bonus);
         bonus_actor.hide ();
         level.remove_child (bonus_actor);
@@ -809,7 +802,7 @@ public class NibblesView : GtkClutter.Embed
 
     private void bonus_applied_cb (Bonus bonus, Worm worm)
     {
-        var actors = worm_actors.get (worm);
+        var actors = worm_actors.@get (worm);
         var actor = actors.last_child;
 
         actor.save_easing_state ();
@@ -819,7 +812,7 @@ public class NibblesView : GtkClutter.Embed
         actor.set_pivot_point (0.5f, 0.5f);
         actor.restore_easing_state ();
 
-        switch (bonus.type)
+        switch (bonus.bonus_type)
         {
             case BonusType.REGULAR:
                 play_sound ("gobble");
@@ -841,11 +834,11 @@ public class NibblesView : GtkClutter.Embed
         }
     }
 
-    public void boni_rescale (int tile_size)
+    internal void boni_rescale (int tile_size)
     {
         foreach (var bonus in game.boni.bonuses)
         {
-            var actor = bonus_actors.get (bonus);
+            var actor = bonus_actors.@get (bonus);
             actor.set_size (tile_size, tile_size);
         }
     }
@@ -875,14 +868,14 @@ public class NibblesView : GtkClutter.Embed
 
         level.add_child (actor);
 
-        warp_actors.set (warp, actor);
+        warp_actors.@set (warp, actor);
     }
 
-    public void warps_rescale (int tile_size)
+    internal void warps_rescale (int tile_size)
     {
         foreach (var warp in game.warp_manager.warps)
         {
-            var actor = warp_actors.get (warp);
+            var actor = warp_actors.@get (warp);
             actor.set_size (tile_size, tile_size);
         }
     }
@@ -900,7 +893,7 @@ public class NibblesView : GtkClutter.Embed
     {
         INITIAL,
         WORKING,
-        ERRORED
+        ERRORED;
     }
 
     private void init_sound ()
@@ -949,7 +942,7 @@ public class NibblesView : GtkClutter.Embed
     * * Utility
     \*/
 
-    public static string colorval_name (int colorval)
+    internal static string colorval_name (int colorval)
     {
         return _(color_lookup[colorval]);
     }
diff --git a/src/preferences-dialog.vala b/src/preferences-dialog.vala
index f7f3d02..9016355 100644
--- a/src/preferences-dialog.vala
+++ b/src/preferences-dialog.vala
@@ -51,7 +51,7 @@ private class PreferencesDialog : Dialog
     private Gee.ArrayList<TreeView>         tree_views;
     private Gee.ArrayList<ComboBoxText>     combo_boxes;
 
-    public PreferencesDialog (ApplicationWindow window, GLib.Settings settings, Gee.ArrayList<GLib.Settings> 
worm_settings)
+    internal PreferencesDialog (ApplicationWindow window, GLib.Settings settings, 
Gee.ArrayList<GLib.Settings> worm_settings)
     {
         Object (use_header_bar: 1);
 
@@ -109,19 +109,19 @@ private class PreferencesDialog : Dialog
             list_store.append (out iter);
             var keyval = worm_settings[id].get_int ("key-up");
             /* Translators: in the Preferences dialog, label of an option (available for each playable worm) 
for changing the key to move the given worm up */
-            list_store.set (iter, 0, "key-up", 1, _("Move up"), 2, keyval);
+            list_store.@set (iter, 0, "key-up", 1, _("Move up"), 2, keyval);
             list_store.append (out iter);
             keyval = worm_settings[id].get_int ("key-down");
             /* Translators: in the Preferences dialog, label of an option (available for each playable worm) 
for changing the key to move the given worm down */
-            list_store.set (iter, 0, "key-down", 1, _("Move down"), 2, keyval);
+            list_store.@set (iter, 0, "key-down", 1, _("Move down"), 2, keyval);
             list_store.append (out iter);
             keyval = worm_settings[id].get_int ("key-left");
             /* Translators: in the Preferences dialog, label of an option (available for each playable worm) 
for changing the key to move the given worm left */
-            list_store.set (iter, 0, "key-left", 1, _("Move left"), 2, keyval);
+            list_store.@set (iter, 0, "key-left", 1, _("Move left"), 2, keyval);
             list_store.append (out iter);
             keyval = worm_settings[id].get_int ("key-right");
             /* Translators: in the Preferences dialog, label of an option (available for each playable worm) 
for changing the key to move the given worm right */
-            list_store.set (iter, 0, "key-right", 1, _("Move right"), 2, keyval);
+            list_store.@set (iter, 0, "key-right", 1, _("Move right"), 2, keyval);
 
             var label_renderer = new CellRendererText ();
             /* Translators: in the Preferences dialog, label of a column in a table for changing the keys to 
move the given worm (available for each playable worm); are listed there all the actions a player can do with 
its worm; the other column is "Key" */
@@ -193,7 +193,7 @@ private class PreferencesDialog : Dialog
             return;
 
         string? key = null;
-        list_store.get (it, 0, out key);
+        list_store.@get (it, 0, out key);
         if (key == null)
             return;
 
@@ -226,7 +226,7 @@ private class PreferencesDialog : Dialog
 
         if (valid)
         {
-            list_store.set (it, 2, keyval);
+            list_store.@set (it, 2, keyval);
             worm_settings[id].set_int (key, (int) keyval);
         }
     }
@@ -245,11 +245,11 @@ private class PreferencesDialog : Dialog
             return;
 
         string? key = null;
-        list_store.get (it, 0, out key);
+        list_store.@get (it, 0, out key);
         if (key == null)
             return;
 
-        list_store.set (it, 2, 0);
+        list_store.@set (it, 2, 0);
         worm_settings[id].set_int (key, 0);
     }
 
diff --git a/src/warp.vala b/src/warp.vala
index 4836a4f..207947a 100644
--- a/src/warp.vala
+++ b/src/warp.vala
@@ -19,38 +19,41 @@
 // This is a fairly literal translation of the GPLv2+ original by
 // Sean MacIsaac, Ian Peters, Guillaume Béland.
 
-public class Warp : Object
+private class Warp : Object
 {
-    public int x;
-    public int y;
+    public int x    { internal get; protected construct set; }
+    public int y    { internal get; protected construct set; }
 
-    public int wx;
-    public int wy;
+    public int wx   { internal get; protected construct set; }
+    public int wy   { internal get; protected construct set; }
 
-    public Warp (int x, int y, int wx, int wy)
+    internal Warp (int x, int y, int wx, int wy)
+    {
+        Object (x: x, y: y, wx: wx, wy: wy);
+    }
+
+    internal void set_x_and_y (int x, int y)
     {
         this.x = x;
         this.y = y;
+    }
 
+    internal void set_wx_and_wy (int wx, int wy)
+    {
         this.wx = wx;
         this.wy = wy;
     }
 }
 
-public class WarpManager: Object
+private class WarpManager: Object
 {
     private const int MAX_WARPS = 200;
 
-    public Gee.LinkedList<Warp> warps;
-
-    public signal void warp_added (Warp warp);
+    internal Gee.LinkedList<Warp> warps = new Gee.LinkedList<Warp> ();
 
-    public WarpManager ()
-    {
-        warps = new Gee.LinkedList<Warp> ();
-    }
+    internal signal void warp_added (Warp warp);
 
-    public void add_warp (int[,] board, int x, int y, int wx, int wy)
+    internal void add_warp (int[,] board, int x, int y, int wx, int wy)
     {
         bool add = true;
 
@@ -60,8 +63,7 @@ public class WarpManager: Object
             {
                 if (warp.wx == x)
                 {
-                    warp.wx = wx;
-                    warp.wy = wy;
+                    warp.set_wx_and_wy (wx, wy);
                     return;
                 }
             }
@@ -77,8 +79,7 @@ public class WarpManager: Object
             {
                 if (warp.x == wx)
                 {
-                    warp.x = x;
-                    warp.y = y;
+                    warp.set_x_and_y (x, y);
                     add = false;
 
                     warp_added (warp);
@@ -103,7 +104,7 @@ public class WarpManager: Object
         }
     }
 
-    public Warp? get_warp (int x, int y)
+    internal Warp? get_warp (int x, int y)
     {
         foreach (var warp in warps)
         {
diff --git a/src/worm.vala b/src/worm.vala
index d8ed0fb..d802e7d 100644
--- a/src/worm.vala
+++ b/src/worm.vala
@@ -19,22 +19,22 @@
 // This is a fairly literal translation of the GPLv2+ original by
 // Sean MacIsaac, Ian Peters, Guillaume Béland.
 
-public enum WormDirection
+private enum WormDirection
 {
     NONE,
     RIGHT,
     DOWN,
     LEFT,
-    UP
+    UP;
 }
 
-public struct Position
+private struct Position
 {
     int x;
     int y;
 }
 
-public struct WormProperties
+private struct WormProperties
 {
     int color;
     uint up;
@@ -43,35 +43,34 @@ public struct WormProperties
     uint right;
 }
 
-public class Worm : Object
+private class Worm : Object
 {
-    public const int STARTING_LENGTH = 5;
-    public const int STARTING_LIVES = 6;
-    public const int MAX_LIVES = 12;
+    private const int STARTING_LENGTH = 5;
+    internal const int STARTING_LIVES = 6;
+    internal const int MAX_LIVES = 12;
 
-    public const int GROW_FACTOR = 4;
+    internal const int GROW_FACTOR = 4;
 
-    public Position starting_position { get; private set; }
+    internal Position starting_position { internal get; private set; }
 
-    public int id { get; private set; }
+    internal int id { internal get; private set; }
 
-    public bool is_human;
-    public bool keypress = false;
-    public bool is_stopped = false;
-    public bool is_materialized { get; private set; default = true; }
+    internal bool is_human;
+    internal bool keypress = false;
+    internal bool is_stopped = false;
+    internal bool is_materialized { internal get; private set; default = true; }
     private int rounds_dematerialized;
 
-    public int lives { get; set; }
-    public int change;
-    public int score { get; set; }
+    internal int lives { get; set; }
+    internal int change;
+    internal int score { get; set; }
 
-    public int length
+    internal int length
     {
         get { return list.size; }
-        set {}
     }
 
-    public Position head
+    internal Position head
     {
         get
         {
@@ -80,30 +79,30 @@ public class Worm : Object
         }
         private set
         {
-            list.set (0, value);
+            list.@set (0, value);
         }
     }
 
-    public WormDirection direction;
+    internal WormDirection direction { internal get; private set; }
 
-    public WormDirection starting_direction;
+    private WormDirection starting_direction;
 
     private Gee.ArrayQueue<WormDirection> key_queue;
 
-    public Gee.LinkedList<Position?> list { get; private set; }
+    internal Gee.LinkedList<Position?> list { get; private set; }
 
-    public signal void added ();
-    public signal void finish_added ();
-    public signal void moved ();
-    public signal void rescaled (int tile_size);
-    public signal void died ();
-    public signal void tail_reduced (int erase_size);
-    public signal void reversed ();
+    internal signal void added ();
+    internal signal void finish_added ();
+    internal signal void moved ();
+    internal signal void rescaled (int tile_size);
+    internal signal void died ();
+    internal signal void tail_reduced (int erase_size);
+    internal signal void reversed ();
 
-    public signal void bonus_found ();
-    public signal void warp_found ();
+    internal signal void bonus_found ();
+    internal signal void warp_found ();
 
-    public Worm (int id)
+    internal Worm (int id)
     {
         this.id = id;
         lives = STARTING_LIVES;
@@ -113,7 +112,7 @@ public class Worm : Object
         key_queue = new Gee.ArrayQueue<WormDirection> ();
     }
 
-    public void set_start (int xhead, int yhead, WormDirection direction)
+    internal void set_start (int xhead, int yhead, WormDirection direction)
     {
         list.clear ();
 
@@ -130,7 +129,7 @@ public class Worm : Object
         key_queue.clear ();
     }
 
-    public void move (int[,] board)
+    internal void move (int[,] board)
     {
         if (is_human)
             keypress = false;
@@ -197,20 +196,20 @@ public class Worm : Object
             materialize (board);
     }
 
-    public void reduce_tail (int[,] board, int erase_size)
+    internal void reduce_tail (int[,] board, int erase_size)
     {
-        if (erase_size > 0)
+        if (erase_size <= 0)
+            return;
+
+        for (int i = 0; i < erase_size; i++)
         {
-            for (int i = 0; i < erase_size; i++)
-            {
-                board[list.last ().x, list.last ().y] = NibblesGame.EMPTYCHAR;
-                list.poll_tail ();
-            }
-            tail_reduced (erase_size);
+            board[list.last ().x, list.last ().y] = NibblesGame.EMPTYCHAR;
+            list.poll_tail ();
         }
+        tail_reduced (erase_size);
     }
 
-    public void reverse (int[,] board)
+    internal void reverse (int[,] board)
     {
         var reversed_list = new Gee.LinkedList<Position?> ();
         foreach (var pos in list)
@@ -226,12 +225,12 @@ public class Worm : Object
             direction = (list[0].y > list[1].y) ? WormDirection.DOWN : WormDirection.UP;
     }
 
-    public void warp (Warp warp)
+    internal inline void warp (Warp warp)
     {
         head = Position () { x = warp.wx, y = warp.wy };
     }
 
-    public bool can_move_to (int[,] board, int numworms)
+    internal bool can_move_to (int[,] board, int numworms)
     {
         var position = position_move ();
         int next_position = board[position.x, position.y];
@@ -247,7 +246,7 @@ public class Worm : Object
         return true;
     }
 
-    public bool will_collide_with_head (Worm other_worm)
+    internal bool will_collide_with_head (Worm other_worm)
     {
         if (!is_materialized || !other_worm.is_materialized)
             return false;
@@ -261,7 +260,7 @@ public class Worm : Object
         return false;
     }
 
-    public void spawn (int[,] board)
+    internal void spawn (int[,] board)
     {
         change = STARTING_LENGTH - 1;
         for (int i = 0; i < STARTING_LENGTH; i++)
@@ -284,7 +283,7 @@ public class Worm : Object
         rounds_dematerialized = 0;
     }
 
-    public void dematerialize (int [,] board, int rounds)
+    internal void dematerialize (int [,] board, int rounds)
     {
         rounds_dematerialized = rounds;
         is_materialized = false;
@@ -295,7 +294,7 @@ public class Worm : Object
         }
     }
 
-    public void add_life ()
+    internal void add_life ()
     {
         if (lives > MAX_LIVES)
             return;
@@ -303,12 +302,12 @@ public class Worm : Object
         lives++;
     }
 
-    private void lose_life ()
+    private inline void lose_life ()
     {
         lives--;
     }
 
-    public void reset (int[,] board)
+    internal void reset (int[,] board)
     {
         is_stopped = true;
         is_materialized = false;
@@ -389,6 +388,7 @@ public class Worm : Object
     /*\
     * * Keys and key presses
     \*/
+
     private uint upper_key (uint keyval)
     {
         if (keyval > 255)
@@ -396,12 +396,12 @@ public class Worm : Object
         return ((char) keyval).toupper ();
     }
 
-    public void handle_direction (WormDirection dir)
+    private void handle_direction (WormDirection dir)
     {
         direction_set (dir);
     }
 
-    public bool handle_keypress (uint keyval, Gee.HashMap<Worm, WormProperties?> worm_props)
+    internal bool handle_keypress (uint keyval, Gee.HashMap<Worm, WormProperties?> worm_props)
     {
         if (lives <= 0 || is_stopped)
             return false;
@@ -409,7 +409,7 @@ public class Worm : Object
         WormProperties properties;
         uint propsUp, propsDown, propsLeft, propsRight, keyvalUpper;
 
-        properties = worm_props.get (this);
+        properties = worm_props.@get (this);
         propsUp = upper_key (properties.up);
         propsLeft = upper_key (properties.left);
         propsDown = upper_key (properties.down);
@@ -440,7 +440,7 @@ public class Worm : Object
         return false;
     }
 
-    public void queue_keypress (WormDirection dir)
+    private void queue_keypress (WormDirection dir)
     {
         /* Ignore duplicates in normal movement mode. This resolves the key
          * repeat issue
@@ -451,8 +451,8 @@ public class Worm : Object
         key_queue.add (dir);
     }
 
-    public void dequeue_keypress ()
-                requires (!key_queue.is_empty)
+    private void dequeue_keypress ()
+        requires (!key_queue.is_empty)
     {
         direction_set (key_queue.poll ());
     }
@@ -474,10 +474,10 @@ public class Worm : Object
      * after 4 billion steps the entire board is likely to have been
      * overwritten anyway.
      */
-    static uint[,] deadend_board = new uint[NibblesGame.WIDTH, NibblesGame.HEIGHT];
-    static uint deadend_runnumber = 0;
+    private static uint[,] deadend_board = new uint[NibblesGame.WIDTH, NibblesGame.HEIGHT];
+    private static uint deadend_runnumber = 0;
 
-    static int ai_deadend (int[,] board, int numworms, int x, int y, int length_left)
+    private static int ai_deadend (int[,] board, int numworms, int x, int y, int length_left)
     {
         int cdir, cx, cy;
 
@@ -617,7 +617,7 @@ public class Worm : Object
      * that is, that it's within 3 in the direction we're going and within
      * 1 to the side.
      */
-    private bool ai_too_close (Gee.LinkedList<Worm> worms, int numworms)
+    private inline bool ai_too_close (Gee.LinkedList<Worm> worms, int numworms)
     {
         int i = numworms;
         int dx, dy;
@@ -711,7 +711,7 @@ public class Worm : Object
     }
 
     /* Determines the direction of the AI worm. */
-    public void ai_move (int[,] board, int numworms, Gee.LinkedList<Worm> worms)
+    internal void ai_move (int[,] board, int numworms, Gee.LinkedList<Worm> worms)
     {
         var opposite = (direction + 1) % 4 + 1;
 


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