[gnome-nibbles] Rename "walls" to "board"



commit 46af337c2189d1603f1fd9172813dd2dddf8d9a9
Author: Iulian Radu <iulian radu67 gmail com>
Date:   Thu Aug 20 19:56:26 2015 +0300

    Rename "walls" to "board"

 src/boni.vala         |   22 +++++++-------
 src/nibbles-game.vala |   60 +++++++++++++++++++++---------------------
 src/nibbles-view.vala |   20 +++++++-------
 src/warp.vala         |   10 +++---
 src/worm.vala         |   70 ++++++++++++++++++++++++------------------------
 5 files changed, 91 insertions(+), 91 deletions(-)
---
diff --git a/src/boni.vala b/src/boni.vala
index 9151891..890467c 100644
--- a/src/boni.vala
+++ b/src/boni.vala
@@ -43,27 +43,27 @@ public class Boni : Object
         numleft = numboni;
     }
 
-    public void add_bonus (int[,] walls, int x, int y, BonusType type, bool fake, int countdown)
+    public void add_bonus (int[,] board, int x, int y, BonusType type, bool fake, int countdown)
     {
         if (numbonuses == MAX_BONUSES)
             return;
 
         var bonus = new Bonus (x, y, type, fake, countdown);
         bonuses.add (bonus);
-        walls[x, y] = type + 'A';
-        walls[x + 1, y] = type + 'A';
-        walls[x, y + 1] = type + 'A';
-        walls[x + 1, y + 1] = type + 'A';
+        board[x, y] = type + 'A';
+        board[x + 1, y] = type + 'A';
+        board[x, y + 1] = type + 'A';
+        board[x + 1, y + 1] = type + 'A';
         bonus_added ();
         numbonuses++;
     }
 
-    public void remove_bonus (int[,] walls, Bonus bonus)
+    public void remove_bonus (int[,] board, Bonus bonus)
     {
-        walls[bonus.x, bonus.y] = NibblesGame.EMPTYCHAR;
-        walls[bonus.x + 1, bonus.y] = NibblesGame.EMPTYCHAR;
-        walls[bonus.x, bonus.y + 1] = NibblesGame.EMPTYCHAR;
-        walls[bonus.x + 1, bonus.y + 1] = NibblesGame.EMPTYCHAR;
+        board[bonus.x, bonus.y] = NibblesGame.EMPTYCHAR;
+        board[bonus.x + 1, bonus.y] = NibblesGame.EMPTYCHAR;
+        board[bonus.x, bonus.y + 1] = NibblesGame.EMPTYCHAR;
+        board[bonus.x + 1, bonus.y + 1] = NibblesGame.EMPTYCHAR;
 
         bonus_removed (bonus);
     }
@@ -77,7 +77,7 @@ public class Boni : Object
         numleft = numboni;
     }
 
-    public Bonus? get_bonus (int[,] walls, int x, int y)
+    public Bonus? get_bonus (int[,] board, int x, int y)
     {
         foreach (var bonus in bonuses)
         {
diff --git a/src/nibbles-game.vala b/src/nibbles-game.vala
index c087f48..d211de3 100644
--- a/src/nibbles-game.vala
+++ b/src/nibbles-game.vala
@@ -45,7 +45,7 @@ public class NibblesGame : Object
     public const int MAX_LEVEL = 26;
 
     public int current_level;
-    public int[,] walls;
+    public int[,] board;
 
     public Gee.LinkedList<Worm> worms;
 
@@ -79,7 +79,7 @@ public class NibblesGame : Object
     {
         boni = new Boni (numworms);
         warp_manager = new WarpManager ();
-        walls = new int[WIDTH, HEIGHT];
+        board = new int[WIDTH, HEIGHT];
         worms = new Gee.LinkedList<Worm> ();
         worm_props = new Gee.HashMap<Worm, WormProperties?> ();
 
@@ -209,7 +209,7 @@ public class NibblesGame : Object
              */
             worm.added ();
 
-            worm.spawn (walls);
+            worm.spawn (board);
         }
     }
 
@@ -234,7 +234,7 @@ public class NibblesGame : Object
                 if (bonus.type == BonusType.REGULAR && !bonus.fake)
                 {
                     found.add (bonus);
-                    boni.remove_bonus (walls, bonus);
+                    boni.remove_bonus (board, bonus);
                     boni.missed++;
 
                     add_bonus (true);
@@ -242,7 +242,7 @@ public class NibblesGame : Object
                 else
                 {
                     found.add (bonus);
-                    boni.remove_bonus (walls, bonus);
+                    boni.remove_bonus (board, bonus);
                 }
             }
         }
@@ -259,7 +259,7 @@ public class NibblesGame : Object
                 continue;
 
             if (!worm.is_human)
-                worm.ai_move (walls, numworms, worms);
+                worm.ai_move (board, numworms, worms);
 
             foreach (var other_worm in worms)
             {
@@ -275,13 +275,13 @@ public class NibblesGame : Object
                     }
             }
 
-            if (!worm.can_move_to (walls, numworms))
+            if (!worm.can_move_to (board, numworms))
             {
                 dead_worms.add (worm);
                 continue;
             }
 
-            worm.move (walls);
+            worm.move (board);
         }
 
         foreach (var worm in dead_worms)
@@ -290,7 +290,7 @@ public class NibblesGame : Object
                 worm.score = worm.score * 7 / 10;
 
             if (worm.lives > 0)
-                worm.reset (walls);
+                worm.reset (board);
         }
     }
 
@@ -298,7 +298,7 @@ public class NibblesGame : Object
     {
         foreach (var other_worm in worms)
             if (worm != other_worm)
-                other_worm.reverse (walls);
+                other_worm.reverse (board);
     }
 
     /*\
@@ -322,20 +322,20 @@ public class NibblesGame : Object
             x = Random.int_range (0, WIDTH - 1);
             y = Random.int_range (0, HEIGHT - 1);
 
-            if (walls[x, y] != EMPTYCHAR)
+            if (board[x, y] != EMPTYCHAR)
                 good = false;
-            if (walls[x + 1, y] != EMPTYCHAR)
+            if (board[x + 1, y] != EMPTYCHAR)
                 good = false;
-            if (walls[x, y + 1] != EMPTYCHAR)
+            if (board[x, y + 1] != EMPTYCHAR)
                 good = false;
-            if (walls[x + 1, y + 1] != EMPTYCHAR)
+            if (board[x + 1, y + 1] != EMPTYCHAR)
                 good = false;
         } while (!good);
 
         if (regular)
         {
             if ((Random.int_range (0, 7) == 0) && fakes)
-                boni.add_bonus (walls, x, y, BonusType.REGULAR, true, 300);
+                boni.add_bonus (board, x, y, BonusType.REGULAR, true, 300);
 
             good = false;
             while (!good)
@@ -344,16 +344,16 @@ public class NibblesGame : Object
 
                 x = Random.int_range (0, WIDTH - 1);
                 y = Random.int_range (0, HEIGHT - 1);
-                if (walls[x, y] != EMPTYCHAR)
+                if (board[x, y] != EMPTYCHAR)
                     good = false;
-                if (walls[x + 1, y] != EMPTYCHAR)
+                if (board[x + 1, y] != EMPTYCHAR)
                     good = false;
-                if (walls[x, y + 1] != EMPTYCHAR)
+                if (board[x, y + 1] != EMPTYCHAR)
                     good = false;
-                if (walls[x + 1, y + 1] != EMPTYCHAR)
+                if (board[x + 1, y + 1] != EMPTYCHAR)
                     good = false;
             }
-            boni.add_bonus (walls, x, y, BonusType.REGULAR, false, 300);
+            boni.add_bonus (board, x, y, BonusType.REGULAR, false, 300);
         }
         else if (boni.missed <= Boni.MAX_MISSED)
         {
@@ -377,17 +377,17 @@ public class NibblesGame : Object
                 case 7:
                 case 8:
                 case 9:
-                    boni.add_bonus (walls, x, y, BonusType.HALF, good, 200);
+                    boni.add_bonus (board, x, y, BonusType.HALF, good, 200);
                     break;
                 case 10:
                 case 11:
                 case 12:
                 case 13:
                 case 14:
-                    boni.add_bonus (walls, x, y, BonusType.DOUBLE, good, 150);
+                    boni.add_bonus (board, x, y, BonusType.DOUBLE, good, 150);
                     break;
                 case 15:
-                    boni.add_bonus (walls, x, y, BonusType.LIFE, good, 100);
+                    boni.add_bonus (board, x, y, BonusType.LIFE, good, 100);
                     break;
                 case 16:
                 case 17:
@@ -395,7 +395,7 @@ public class NibblesGame : Object
                 case 19:
                 case 20:
                     if (numworms > 1)
-                        boni.add_bonus (walls, x, y, BonusType.REVERSE, good, 150);
+                        boni.add_bonus (board, x, y, BonusType.REVERSE, good, 150);
                     break;
             }
         }
@@ -409,7 +409,7 @@ public class NibblesGame : Object
             return;
         }
 
-        switch (walls[worm.head.x, worm.head.y] - 'A')
+        switch (board[worm.head.x, worm.head.y] - 'A')
         {
             case BonusType.REGULAR:
                 boni.numleft--;
@@ -424,7 +424,7 @@ public class NibblesGame : Object
                 if (worm.length + worm.change > 2)
                 {
                     worm.score += ((worm.length + worm.change / 2) * current_level);
-                    worm.reduce_tail (walls, (worm.length + worm.change) / 2);
+                    worm.reduce_tail (board, (worm.length + worm.change) / 2);
                     worm.change -= (worm.length + worm.change) /2;
                 }
                 break;
@@ -446,17 +446,17 @@ public class NibblesGame : Object
 
     public void bonus_found_cb (Worm worm)
     {
-        var bonus = boni.get_bonus (walls, worm.head.x, worm.head.y);
+        var bonus = boni.get_bonus (board, worm.head.x, worm.head.y);
         if (bonus == null)
             return;
         apply_bonus (bonus, worm);
         bonus_applied (worm);
 
-        if (walls[worm.head.x, worm.head.y] == BonusType.REGULAR + 'A'
+        if (board[worm.head.x, worm.head.y] == BonusType.REGULAR + 'A'
             && !bonus.fake)
         {
             // FIXME: 2/3
-            boni.remove_bonus (walls, bonus);
+            boni.remove_bonus (board, bonus);
             boni.bonuses.remove (bonus);
 
             if (boni.numleft != 0)
@@ -465,7 +465,7 @@ public class NibblesGame : Object
         else
         {
             // FIXME: 3/3
-            boni.remove_bonus (walls, bonus);
+            boni.remove_bonus (board, bonus);
             boni.bonuses.remove (bonus);
         }
     }
diff --git a/src/nibbles-view.vala b/src/nibbles-view.vala
index d905d45..e4f78dc 100644
--- a/src/nibbles-view.vala
+++ b/src/nibbles-view.vala
@@ -133,11 +133,11 @@ public class NibblesView : GtkClutter.Embed
 
             for (int j = 0; j < NibblesGame.WIDTH; j++)
             {
-                game.walls[j, i] = tmpboard.get(j);
-                switch (game.walls[j, i])
+                game.board[j, i] = tmpboard.get(j);
+                switch (game.board[j, i])
                 {
                     case 'm':
-                        game.walls[j, i] = NibblesGame.EMPTYCHAR;
+                        game.board[j, i] = NibblesGame.EMPTYCHAR;
                         if (count < game.numworms)
                         {
                             game.worms[count].set_start (j, i, WormDirection.UP);
@@ -149,7 +149,7 @@ public class NibblesView : GtkClutter.Embed
                         }
                         break;
                     case 'n':
-                        game.walls[j, i] = NibblesGame.EMPTYCHAR;
+                        game.board[j, i] = NibblesGame.EMPTYCHAR;
                         if (count < game.numworms)
                         {
                             game.worms[count].set_start (j, i, WormDirection.LEFT);
@@ -161,7 +161,7 @@ public class NibblesView : GtkClutter.Embed
                         }
                         break;
                     case 'o':
-                        game.walls[j, i] = NibblesGame.EMPTYCHAR;
+                        game.board[j, i] = NibblesGame.EMPTYCHAR;
                         if (count < game.numworms)
                         {
                             game.worms[count].set_start (j, i, WormDirection.DOWN);
@@ -173,7 +173,7 @@ public class NibblesView : GtkClutter.Embed
                         }
                         break;
                     case 'p':
-                        game.walls[j, i] = NibblesGame.EMPTYCHAR;
+                        game.board[j, i] = NibblesGame.EMPTYCHAR;
                         if (count < game.numworms)
                         {
                             game.worms[count].set_start (j, i, WormDirection.RIGHT);
@@ -194,7 +194,7 @@ public class NibblesView : GtkClutter.Embed
                     case 'X':
                     case 'Y':
                     case 'Z':
-                        game.warp_manager.add_warp (game.walls, j - 1, i - 1, -(game.walls[j, i]), 0);
+                        game.warp_manager.add_warp (game.board, j - 1, i - 1, -(game.board[j, i]), 0);
                         break;
                     case 'r':
                     case 's':
@@ -205,8 +205,8 @@ public class NibblesView : GtkClutter.Embed
                     case 'x':
                     case 'y':
                     case 'z':
-                        game.warp_manager.add_warp (game.walls, -(game.walls[j, i] - 'a' + 'A'), 0, j, i);
-                        game.walls[j, i] = NibblesGame.EMPTYCHAR;
+                        game.warp_manager.add_warp (game.board, -(game.board[j, i] - 'a' + 'A'), 0, j, i);
+                        game.board[j, i] = NibblesGame.EMPTYCHAR;
                         break;
                     default:
                         break;
@@ -240,7 +240,7 @@ public class NibblesView : GtkClutter.Embed
                 is_wall = true;
                 try
                 {
-                    switch (game.walls[j, i])
+                    switch (game.board[j, i])
                     {
                         case 'a': // empty space
                             is_wall = false;
diff --git a/src/warp.vala b/src/warp.vala
index a626c7b..437c612 100644
--- a/src/warp.vala
+++ b/src/warp.vala
@@ -50,7 +50,7 @@ public class WarpManager: Object
         warps = new Gee.LinkedList<Warp> ();
     }
 
-    public void add_warp (int[,] walls, int x, int y, int wx, int wy)
+    public void add_warp (int[,] board, int x, int y, int wx, int wy)
     {
         bool add = true;
 
@@ -96,10 +96,10 @@ public class WarpManager: Object
                 warp_added (warp);
             }
 
-            walls[x, y] = NibblesGame.WARPCHAR;
-            walls[x + 1, y] = NibblesGame.WARPCHAR;
-            walls[x, y + 1] = NibblesGame.WARPCHAR;
-            walls[x + 1, y + 1] = NibblesGame.WARPCHAR;
+            board[x, y] = NibblesGame.WARPCHAR;
+            board[x + 1, y] = NibblesGame.WARPCHAR;
+            board[x, y + 1] = NibblesGame.WARPCHAR;
+            board[x + 1, y + 1] = NibblesGame.WARPCHAR;
         }
     }
 
diff --git a/src/worm.vala b/src/worm.vala
index 455d1f4..2bc191c 100644
--- a/src/worm.vala
+++ b/src/worm.vala
@@ -103,7 +103,7 @@ public class Worm : Object
         key_queue.clear ();
     }
 
-    public void move (int[,] walls)
+    public void move (int[,] board)
     {
         if (is_human)
             keypress = false;
@@ -138,7 +138,7 @@ public class Worm : Object
         /* Add a new body piece */
         list.offer_head (position);
 
-        if (walls[head.x, head.y] == NibblesGame.WARPCHAR)
+        if (board[head.x, head.y] == NibblesGame.WARPCHAR)
             warp_found ();
 
         if (change > 0)
@@ -148,41 +148,41 @@ public class Worm : Object
         }
         else
         {
-            walls[list.last ().x, list.last ().y] = NibblesGame.EMPTYCHAR;
+            board[list.last ().x, list.last ().y] = NibblesGame.EMPTYCHAR;
             list.poll_tail ();
             moved ();
         }
 
         /* Check for bonus before changing tile */
-        if (walls[head.x, head.y] != NibblesGame.EMPTYCHAR)
+        if (board[head.x, head.y] != NibblesGame.EMPTYCHAR)
             bonus_found ();
 
         /* Mark the tile as occupied by the worm's body */
-        walls[head.x, head.y] = NibblesGame.WORMCHAR + id;
+        board[head.x, head.y] = NibblesGame.WORMCHAR + id;
 
         if (!key_queue.is_empty)
             dequeue_keypress ();
     }
 
-    public void reduce_tail (int[,] walls, int erase_size)
+    public void reduce_tail (int[,] board, int erase_size)
     {
         if (erase_size > 0)
         {
             if (length <= erase_size)
             {
-                reset (walls);
+                reset (board);
             }
 
             for (int i = 0; i < erase_size; i++)
             {
-                walls[list.last ().x, list.last ().y] = NibblesGame.EMPTYCHAR;
+                board[list.last ().x, list.last ().y] = NibblesGame.EMPTYCHAR;
                 list.poll_tail ();
             }
             tail_reduced (erase_size);
         }
     }
 
-    public void reverse (int[,] walls)
+    public void reverse (int[,] board)
     {
         var reversed_list = new Gee.LinkedList<Position?> ();
         foreach (var pos in list)
@@ -203,12 +203,12 @@ public class Worm : Object
         head = Position () { x = warp.wx, y = warp.wy };
     }
 
-    public bool can_move_to (int[,] walls, int numworms)
+    public bool can_move_to (int[,] board, int numworms)
     {
         var position = position_move ();
 
-        if (walls[position.x, position.y] > NibblesGame.EMPTYCHAR
-            && walls[position.x, position.y] < 'z' + numworms)
+        if (board[position.x, position.y] > NibblesGame.EMPTYCHAR
+            && board[position.x, position.y] < 'z' + numworms)
         {
             return false;
         }
@@ -227,11 +227,11 @@ public class Worm : Object
         return false;
     }
 
-    public void spawn (int[,] walls)
+    public void spawn (int[,] board)
     {
         change = STARTING_LENGTH - 1;
         for (int i = 0; i < STARTING_LENGTH; i++)
-            move (walls);
+            move (board);
     }
 
     public void add_life ()
@@ -247,14 +247,14 @@ public class Worm : Object
         lives--;
     }
 
-    public void reset (int[,] walls)
+    public void reset (int[,] board)
     {
         is_stopped = true;
         lose_life ();
 
         died ();
         foreach (var pos in list)
-            walls[pos.x, pos.y] = NibblesGame.EMPTYCHAR;
+            board[pos.x, pos.y] = NibblesGame.EMPTYCHAR;
 
         list.clear ();
         list.add (starting_position);
@@ -262,7 +262,7 @@ public class Worm : Object
 
         direction = starting_direction;
         change = 0;
-        spawn (walls);
+        spawn (board);
 
         key_queue.clear ();
 
@@ -413,7 +413,7 @@ public class Worm : Object
     static uint[,] deadend_board = new uint[NibblesGame.WIDTH, NibblesGame.HEIGHT];
     static uint deadend_runnumber = 0;
 
-    static int ai_deadend (int[,] walls, int numworms, int x, int y, int length_left)
+    static int ai_deadend (int[,] board, int numworms, int x, int y, int length_left)
     {
         int cdir, cx, cy;
 
@@ -459,12 +459,12 @@ public class Worm : Object
             if (cy < 0)
                 cy = NibblesGame.HEIGHT - 1;
 
-            if ((walls[cx, cy] <= NibblesGame.EMPTYCHAR
-                || walls[x, y] >= 'z' + numworms)
+            if ((board[cx, cy] <= NibblesGame.EMPTYCHAR
+                || board[x, y] >= 'z' + numworms)
                 && deadend_board[cx, cy] != deadend_runnumber)
             {
                 deadend_board[cx, cy] = deadend_runnumber;
-                length_left = ai_deadend (walls, numworms, cx, cy, length_left - 1);
+                length_left = ai_deadend (board, numworms, cx, cy, length_left - 1);
                 if (length_left <= 0)
                     return 0;
             }
@@ -482,7 +482,7 @@ public class Worm : Object
      * least BOARDWIDTH, so that on the levels with long thin paths a worm
      * won't start down the path if it'll crash at the other end.
      */
-    private static int ai_deadend_after (int[,] walls, Gee.LinkedList<Worm> worms, int numworms, int x, int 
y, int dir, int length)
+    private static int ai_deadend_after (int[,] board, Gee.LinkedList<Worm> worms, int numworms, int x, int 
y, int dir, int length)
     {
         int cx, cy, cl, i;
 
@@ -546,7 +546,7 @@ public class Worm : Object
         cl = (length * length) / 16;
         if (cl < NibblesGame.WIDTH)
             cl = NibblesGame.WIDTH;
-        return Worm.ai_deadend (walls, numworms, cx, cy, cl);
+        return Worm.ai_deadend (board, numworms, cx, cy, cl);
     }
 
     /* Check to see if another worm's head is too close in front of us;
@@ -586,7 +586,7 @@ public class Worm : Object
         return false;
     }
 
-    private static bool ai_wander (int[,] walls, int numworms, int x, int y, int dir, int ox, int oy)
+    private static bool ai_wander (int[,] board, int numworms, int x, int y, int dir, int ox, int oy)
     {
         if (dir > 4)
             dir = 1;
@@ -618,7 +618,7 @@ public class Worm : Object
         if (y < 0)
             y = NibblesGame.HEIGHT - 1;
 
-        switch (walls[x, y] - 'A')
+        switch (board[x, y] - 'A')
         {
             case BonusType.REGULAR:
                 return true;
@@ -631,8 +631,8 @@ public class Worm : Object
             case BonusType.HALF:
                 return false;
             default:
-                if (walls[x, y] > NibblesGame.EMPTYCHAR
-                    && walls[x, y] < 'z' + numworms)
+                if (board[x, y] > NibblesGame.EMPTYCHAR
+                    && board[x, y] < 'z' + numworms)
                 {
                         return false;
                 }
@@ -641,19 +641,19 @@ public class Worm : Object
                     if (ox == x && oy == y)
                         return false;
 
-                    return Worm.ai_wander (walls, numworms, x, y, dir, ox, oy);
+                    return Worm.ai_wander (board, numworms, x, y, dir, ox, oy);
                 }
         }
     }
 
     /* Determines the direction of the AI worm. */
-    public void ai_move (int[,] walls, int numworms, Gee.LinkedList<Worm> worms)
+    public void ai_move (int[,] board, int numworms, Gee.LinkedList<Worm> worms)
     {
         var opposite = (direction + 1) % 4 + 1;
 
-        var front = Worm.ai_wander (walls, numworms, head.x, head.y, direction, head.x, head.y);
-        var left = Worm.ai_wander (walls, numworms, head.x, head.y, direction - 1, head.x, head.y);
-        var right = Worm.ai_wander (walls, numworms, head.x, head.y, direction + 1, head.x, head.y);
+        var front = Worm.ai_wander (board, numworms, head.x, head.y, direction, head.x, head.y);
+        var left = Worm.ai_wander (board, numworms, head.x, head.y, direction - 1, head.x, head.y);
+        var right = Worm.ai_wander (board, numworms, head.x, head.y, direction + 1, head.x, head.y);
 
         int dir;
         if (!front)
@@ -719,13 +719,13 @@ public class Worm : Object
                 continue;
             this_len = 0;
 
-            if (!can_move_to (walls, numworms))
+            if (!can_move_to (board, numworms))
                 this_len += NibblesGame.CAPACITY;
 
             if (ai_too_close (worms, numworms))
                 this_len += 4;
 
-            this_len += ai_deadend_after (walls, worms, numworms, head.x, head.y, dir, length + change);
+            this_len += ai_deadend_after (board, worms, numworms, head.x, head.y, dir, length + change);
 
             if (dir == old_dir && this_len <= 0)
                 this_len -= 100;
@@ -754,7 +754,7 @@ public class Worm : Object
             if (dir == opposite)
                 continue;
 
-            if (!can_move_to (walls, numworms))
+            if (!can_move_to (board, numworms))
                 direction = (WormDirection) dir;
             else
                 continue;


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