X-Git-Url: https://git.cworth.org/git?p=loudgame;a=blobdiff_plain;f=lg-loa.c;fp=lg-loa.c;h=174914307f71ca72faf74a496b08ce00e2a2d336;hp=4bf623076442ea9d8c9d7e7369fb8a3226f3f355;hb=88c5b7fb802cd1eab050dc67289d86dcb37dec6c;hpb=8666f33e3f4037ecad58d27897eb7ce74aec0685 diff --git a/lg-loa.c b/lg-loa.c index 4bf6230..1749143 100644 --- a/lg-loa.c +++ b/lg-loa.c @@ -37,7 +37,7 @@ typedef struct _loa_game { static void loa_game_new_game (loa_game_t *game) { - loa_board_init (&game->board); + loa_board_reset (&game->board); } static loa_bool_t @@ -143,6 +143,17 @@ loa_game_handle_move (loa_game_t *game, loudgame_broadcastf (&game->lg, "%s wins", peer); } +static void +loa_game_handle_history (loa_game_t *game, + const char *peer) +{ + int i; + + for (i = 0; i < game->board.num_moves; i++) + loudgame_sendf (&game->lg, peer, "%s", + loa_move_to_string (&game->board.moves[i])); +} + static void loa_game_handle_pass (loa_game_t *game, const char *peer) { @@ -168,6 +179,7 @@ loa_game_handle_help (loa_game_t *game, const char *peer) "\tmove aNbN\tMove a piece, (eg. 'move b1d3')\n" "\tpass \t\tSkip a turn (only legal if no moves are possible)\n" "\tnew \t\tBegin a new game\n" + "\thistory \t\tShow the move history of the game\n" "\thelp \t\tThis help message\n" "\trules \t\tA description of the Lines of Action rules\n" "\n" @@ -244,6 +256,8 @@ loa_game_handle_message (loudgame_t *lg, loa_game_handle_pass (game, peer); else if (strcmp (message, "new") == 0) loa_game_handle_new (game, peer); + else if (strcmp (message, "history") == 0) + loa_game_handle_history (game, peer); else if (strcmp (message, "help") == 0) loa_game_handle_help (game, peer); else if (strcmp (message, "rules") == 0) @@ -261,6 +275,8 @@ loa_game_init (loa_game_t *game, int argc, char *argv[]) if (err) return err; + loa_board_init (&game->board); + loa_game_new_game (game); return 0;