From: Carl Worth Date: Thu, 26 Jun 2003 01:19:40 +0000 (+0000) Subject: Added support for RR_NOTICE_GAMEOVER. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=1ce9df4b8865ac2995524272a1c2ab4071d9921d;p=grrobot Added support for RR_NOTICE_GAMEOVER. Tracked some librr changes --- diff --git a/.gitignore b/.gitignore index d88a325..43b89a7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ config.log config.status config.sub configure -INSTALL install-sh Makefile Makefile.in diff --git a/TODO b/TODO index 27ce059..12c0e33 100644 --- 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. diff --git a/src/grr_board_view.c b/src/grr_board_view.c index f29ec9b..e06f279 100644 --- a/src/grr_board_view.c +++ b/src/grr_board_view.c @@ -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; } diff --git a/src/grrobot.c b/src/grrobot.c index 2b6292a..98f14f2 100644 --- a/src/grrobot.c +++ b/src/grrobot.c @@ -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); }