diff options
| author | info@mode42.com <info@mode42.com> | 2026-08-09 12:22:53 +0000 |
|---|---|---|
| committer | info@mode42.com <info@mode42.com> | 2026-08-09 12:22:53 +0000 |
| commit | e1730d8012fca0a712de588285342f7ad10dd804 (patch) | |
| tree | b351ae5da04fe10a211be772636b2bf8de6d49dd /plugins/entertain/entertain_chess.h | |
| parent | a989bd16c40e04bba5a5404b0ef0cd22f19d2707 (diff) | |
now including entertain/chess
Diffstat (limited to 'plugins/entertain/entertain_chess.h')
| -rw-r--r-- | plugins/entertain/entertain_chess.h | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/plugins/entertain/entertain_chess.h b/plugins/entertain/entertain_chess.h index 9d7026c..55731b3 100644 --- a/plugins/entertain/entertain_chess.h +++ b/plugins/entertain/entertain_chess.h @@ -1,22 +1,24 @@ /* - * Entertain plugin — chess.h (internal) - * Chess game engine for HyBBX Entertain area. + * Entertain plugin — chess (internal) + * Chess for HyBBX Entertain area (Main only). */ #ifndef ENTERTAIN_CHESS_H #define ENTERTAIN_CHESS_H #include "hybbx/types.h" +#include <stddef.h> + struct hybbx_session; struct hybbx_service; #define CHESS_BOARD_SIZE 8 #define CHESS_GAME_MAX 16 #define CHESS_SPECTATOR_MAX 32 -#define CHESS_REFRESH_SEC 15 -#define CHESS_DEFAULT_MAX 8 +#define CHESS_REFRESH_SEC 30u +#define CHESS_DEFAULT_MAX 8u #define CHESS_NAME_MAX 32 -#define CHESS_SAN_MAX 8 +#define CHESS_SAN_MAX 16 #define CHESS_EMPTY '.' typedef enum { @@ -52,6 +54,7 @@ typedef struct chess_game { char last_move_san[CHESS_SAN_MAX]; unsigned tick_counter; char game_id[8]; + chess_color_t draw_offered_by; /* NONE = no pending offer */ } chess_game_t; /* Lifecycle */ @@ -64,25 +67,26 @@ chess_game_t *chess_create_game(struct hybbx_session *white, const char *name); chess_game_t *chess_find_open_game(void); chess_game_t *chess_find_game_by_id(const char *id); chess_game_t *chess_get_game(unsigned index); +chess_game_t *chess_find_player_game(const struct hybbx_session *s); int chess_join_game(chess_game_t *g, struct hybbx_session *black, const char *name); int chess_add_spectator(chess_game_t *g, struct hybbx_session *spec); void chess_remove_spectator(chess_game_t *g, struct hybbx_session *spec); int chess_is_player(const chess_game_t *g, const struct hybbx_session *s); int chess_is_spectator(const chess_game_t *g, const struct hybbx_session *s); chess_color_t chess_player_color(const chess_game_t *g, const struct hybbx_session *s); - -/* Session slot (for future use) */ -unsigned chess_session_slot(const struct hybbx_session *s); -void chess_session_set_slot(struct hybbx_session *s, unsigned slot); +void chess_release_game(chess_game_t *g); +unsigned chess_clear_finished(void); /* Moves + display */ int chess_make_move(chess_game_t *g, const char *from, const char *to, char promote, char *err, size_t errlen); void chess_send_board(chess_game_t *g, struct hybbx_session *s); +void chess_broadcast_board(chess_game_t *g); void chess_resign(chess_game_t *g, struct hybbx_session *who); -void chess_offer_draw(chess_game_t *g, struct hybbx_session *who); +/** Returns 1 if draw agreed, 0 if offer pending / rejected. */ +int chess_offer_draw(chess_game_t *g, struct hybbx_session *who); -/* Tick — call from plugin tick every 1s */ +/* Tick — call from plugin tick every ~1s */ void chess_tick(struct hybbx_service *service); #endif /* ENTERTAIN_CHESS_H */ |
