]> git.cworth.org Git - grrobot/commitdiff
Added support for RR_NOTICE_GAMEOVER.
authorCarl Worth <cworth@theworths.org>
Thu, 26 Jun 2003 01:19:40 +0000 (01:19 +0000)
committerCarl Worth <cworth@theworths.org>
Thu, 26 Jun 2003 01:19:40 +0000 (01:19 +0000)
Tracked some librr changes

.gitignore
TODO
src/grr_board_view.c
src/grrobot.c

index d88a325ea73f3e232f5e27fcdcc793a8f669acd4..43b89a7c57a3bdccf7a27bd979305f97e8be391b 100644 (file)
@@ -7,7 +7,6 @@ config.log
 config.status
 config.sub
 configure
-INSTALL
 install-sh
 Makefile
 Makefile.in
diff --git a/TODO b/TODO
index 27ce05947e9e51ba76364d614201c1fbff2b5c47..12c0e33bb1a1f65a9500377390ec6198c02875f0 100644 (file)
--- a/TODO
+++ b/TODO
@@ -4,9 +4,6 @@ Pre-render each SVG icon, (redo each time the board view size changes).
 
 Redraw only damaged portions of the board.
 
-Need to parse commands coming through the command entry box. This is
-so that a command like NEW can trigger a SHOW and a board update.
-
 Animate robot movement.
 
 Leave trails behind moving robots.
index f29ec9b76b4c10b445c9fcc4f13bcd085e2bfc10..e06f279b1594f2f9724b1c736c92ea632e271e98 100644 (file)
@@ -550,8 +550,7 @@ grr_board_view_button_release (GtkWidget      *widget,
                               GdkEventButton *event)
 {
     grr_board_view_t *view;
-    const char *dir;
-    const char *robot;
+    rr_direction_t dir;
     int x, y;
     int robot_x, robot_y;
     int dx, dy;
@@ -577,41 +576,17 @@ grr_board_view_button_release (GtkWidget      *widget,
 
     if (abs(dx) > abs(dy))
        if (x > robot_x)
-           dir = "east";
+           dir = RR_DIRECTION_EAST;
        else
-           dir = "west";
+           dir = RR_DIRECTION_WEST;
     else
        if (y > robot_y)
-           dir = "south";
+           dir = RR_DIRECTION_SOUTH;
        else
-           dir = "north";
+           dir = RR_DIRECTION_NORTH;
     
-    switch (view->drag_robot) {
-    case RR_ROBOT_BLUE:
-       robot = "blue";
-       break;
-    case RR_ROBOT_GREEN:
-       robot = "green";
-       break;
-    case RR_ROBOT_RED:
-       robot = "RED";
-       break;
-    case RR_ROBOT_YELLOW:
-       robot = "YELLOW";
-       break;
-    default:
-       return FALSE;
-    }
-    
-    if (view->client) {
-       char *move_str;
-       
-       grr_sprintf_alloc (&move_str, "%s %s", robot, dir);
-       if (move_str == NULL)
-           return FALSE;
-       rr_client_move (view->client, move_str);
-       free (move_str);
-    }
+    if (view->client)
+       rr_client_move (view->client, view->drag_robot, dir);
 
   return FALSE;
 }
index 2b6292ac9e11624dea568d345083601ea2cb4604..98f14f2582fad574e77c4317ed16a6fd2a13318b 100644 (file)
@@ -220,6 +220,22 @@ grr_game_read_notices (grr_game_t *game)
            grr_game_printf (game, "\nGame state changed to: %s.",
                             rr_gamestate_str (notice->u.gamestate));
            break;
+       case RR_NOTICE_TURN:
+           grr_game_print (game, "\nNew round!");
+           rr_board_set_goal_target (board, notice->u.target);
+           gtk_widget_queue_draw (GTK_WIDGET (game->window));
+           break;
+       case RR_NOTICE_GAMEOVER:
+       {
+           char *diagram;
+           grr_game_printf (game, "\nGame over. New game will begin now.");
+           /* XXX: Can drop this when the BOARD NOTICE is added in the server */
+           rr_client_show (game->client, &diagram);
+           rr_board_parse (board, diagram);
+           free (diagram);
+           gtk_widget_queue_draw (GTK_WIDGET (game->window));
+       }
+       break;
        case RR_NOTICE_JOIN:
            grr_game_printf (game, "\nUser %s has joined the game.",
                             notice->u.string);
@@ -291,11 +307,6 @@ grr_game_read_notices (grr_game_t *game)
                                     notice->u.position.x, notice->u.position.y);
            gtk_widget_queue_draw (GTK_WIDGET (game->window));
            break;
-       case RR_NOTICE_TURN:
-           grr_game_print (game, "\nNew round!");
-           rr_board_set_goal_target (board, notice->u.target);
-           gtk_widget_queue_draw (GTK_WIDGET (game->window));
-           break;
        }
        free (notice);
     }