#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);
return 1;
}
- handle_events (client);
+ handle_events (client, args.user);
rr_client_destroy (client);
}
}
static void
-handle_events (rr_client_t *client)
+handle_events (rr_client_t *client, char *name)
{
int i;
rr_status_t status;
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. */
}
}
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;
}