]> git.cworth.org Git - rrsolve/commitdiff
* src/Makefile.am (rrsolve_LDFLAGS): Fix to not ovverride user main
authorCarl Worth <cworth@cworth.org>
Sun, 11 Jan 2004 05:15:06 +0000 (05:15 +0000)
committerCarl Worth <cworth@cworth.org>
Sun, 11 Jan 2004 05:15:06 +0000 (05:15 +0000)
        variables.

        * src/rrsolve.c (handle_events): Speed up rrsolve robot movement
        slightly.
        (handle_events): Keep track of users in the game and their scores.
        (handle_events): Implement "pity points". If another user with a
        lower score than rrsolve matches its bid, then rrsolve will revoke
        its bid (and immediately make it again), to give the other user
        the first chance to demonstrate the solution. This behavior makes
        solitaire play against rrsolve much more enjoyable.

        * configure.in: Now require librr >= 0.1.1

ChangeLog
configure.in
src/Makefile.am
src/rrsolve.c

index 34e11a524b674cbedfccd3624f4116cc4639cdb2..827d86476d83c6b774fe81adfc836cfb55ce3464 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2004-01-10  Carl Worth  <cworth@isi.edu>
+
+       * src/Makefile.am (rrsolve_LDFLAGS): Fix to not ovverride user
+       variables.
+
+       * src/rrsolve.c (handle_events): Speed up rrsolve robot movement
+       slightly.
+       (handle_events): Keep track of users in the game and their scores.
+       (handle_events): Implement "pity points". If another user with a
+       lower score than rrsolve matches its bid, then rrsolve will revoke
+       its bid (and immediately make it again), to give the other user
+       the first chance to demonstrate the solution. This behavior makes
+       solitaire play against rrsolve much more enjoyable.
+
+       * configure.in: Now require librr >= 0.1.1
+
 2003-07-09  Carl Worth  <cworth@isi.edu>
 
        * src/rrsolve.c (main): Added an error message for board parse
index 99bb91bc671605f1f32bcd98d3b904b8a2e90ab3..8edbd1a54ea50dbfa1cc4fd4639d0695c48a0124 100644 (file)
@@ -18,7 +18,7 @@ AC_STDC_HEADERS
 
 dnl ===========================================================================
 
-PKG_CHECK_MODULES(rrsolve, librr)
+PKG_CHECK_MODULES(rrsolve, librr >= 0.1.1)
 AC_SUBST(rrsolve_CFLAGS)
 AC_SUBST(rrsolve_LIBS)
 
index 46a53637c1a24626d5a97b5213f585a6ce55fa5e..94dfe946070ec3983a7c8a87d131d0f32ea4ef03 100644 (file)
@@ -7,5 +7,5 @@ rrsolve_SOURCES = \
        rrs_state_buf.c \
        rrs_solution.c
 
-INCLUDES = $(rrsolve_CFLAGS)
-LDFLAGS = $(rrsolve_LIBS)
+rrsolve_INCLUDES = $(rrsolve_CFLAGS)
+rrsolve_LDFLAGS = $(rrsolve_LIBS)
index 5e92cbb94a5edb16cbb996e96e9ee7fbf6ed0b1d..6441e46b8fc6be2c63387d0ff4be852bea72923b 100644 (file)
@@ -39,7 +39,7 @@
 #define RRS_STATE_GET_ROBOT(s, ri, x, y) { (y) = ((s) >> ((ri)<<3)) & 0xf; (x) = ((s) >> (((ri)<<3) + 4)) & 0xf; }
 
 static void
-handle_events (rr_client_t *client);
+handle_events (rr_client_t *client, char *name);
 
 static rrs_state_t
 rrs_state_get_from_board (rr_board_t *board);
@@ -111,7 +111,7 @@ main (int argc, char *argv[])
            return 1;
        }
 
-       handle_events (client);
+       handle_events (client, args.user);
 
        rr_client_destroy (client);
     }
@@ -120,7 +120,7 @@ main (int argc, char *argv[])
 }
 
 static void
-handle_events (rr_client_t *client)
+handle_events (rr_client_t *client, char *name)
 {
     int i;
     rr_status_t status;
@@ -128,7 +128,10 @@ handle_events (rr_client_t *client)
     rrs_solution_t solution;
     rr_board_t *board;
     char *diagram;
-    struct timespec move_delay = { 1, 200000000l };
+    struct timespec move_delay = { 0, 800000000l };
+    rr_players_t *players;
+
+    rr_client_players (client, &players);
 
     /* XXX: This block of code can go away when add a NOTICE BOARD
        for new users joining a game. */
@@ -212,23 +215,38 @@ handle_events (rr_client_t *client)
                }
            }
            break;
+       case RR_NOTICE_BID:
+           /* rrsolve is kind enought to offer pity points */
+           if (notice->u.bid.number == solution.num_moves &&
+               strcmp (notice->u.bid.username, name) &&
+               rr_players_get_score (players, notice->u.bid.username) < rr_players_get_score (players, name))
+           {
+               rr_client_revoke (client);
+               rr_client_bid (client, solution.num_moves);
+           }
+           break;
+       case RR_NOTICE_JOIN:
+           rr_players_add (players, notice->u.string);
+           break;
+       case RR_NOTICE_PART:
+           rr_players_remove (players, notice->u.string);
+           break;
+       case RR_NOTICE_SCORE:
+           rr_players_set_score (players, notice->u.bid.username, notice->u.bid.number);
+           break;
        case RR_NOTICE_GAMEOVER:
        case RR_NOTICE_GAME:
        case RR_NOTICE_USER:
-       case RR_NOTICE_JOIN:
        case RR_NOTICE_QUIT:
        case RR_NOTICE_DISPOSE:
        case RR_NOTICE_MESSAGE:
        case RR_NOTICE_WATCH:
-       case RR_NOTICE_PART:
-       case RR_NOTICE_BID:
        case RR_NOTICE_REVOKE:
        case RR_NOTICE_TIMER:
        case RR_NOTICE_ACTIVE:
        case RR_NOTICE_MOVE:
        case RR_NOTICE_UNDO:
        case RR_NOTICE_RESET:
-       case RR_NOTICE_SCORE:
            /* Ignore these notices */
            break;
        }