]> git.cworth.org Git - kub/commitdiff
Breakout new tile_init function from deck_init
authorCarl Worth <cworth@cworth.org>
Thu, 1 Mar 2007 14:48:55 +0000 (06:48 -0800)
committerCarl Worth <cworth@cworth.org>
Thu, 1 Mar 2007 14:48:55 +0000 (06:48 -0800)
kub.c

diff --git a/kub.c b/kub.c
index bad09fdb9ccaf3ba73150be4a6539efcb396b443..0f195740f64b4f0b156412961a312157ee3e3349 100644 (file)
--- a/kub.c
+++ b/kub.c
@@ -54,6 +54,13 @@ typedef struct game {
     RsvgHandle *blanktile;
 } game_t;
 
+static void
+tile_init (tile_t *tile, color_t color, int number)
+{
+    tile->color = color;
+    tile->number = number;
+}
+
 static void tile_print(tile_t tile)
 {
     printf("%6s %2d\n", colors[tile.color], tile.number + 1);
@@ -273,9 +280,7 @@ static void deck_init(deck_t *deck)
        {
            for (j = 0; j <= 12; ++j) 
            {
-               deck->tiles[j + (i * 13) + (h * 52)].color = i;
-               deck->tiles[j + (i * 13) + (h * 52)].number = j;
-               deck->num_tiles += 1;
+               tile_init (&deck->tiles[deck->num_tiles++], i, j);
                printf ("There are %d tiles in the deck\n", deck->num_tiles);
            }
        }