summaryrefslogtreecommitdiff
path: root/plugins/entertain/entertain_chess.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/entertain/entertain_chess.h')
-rw-r--r--plugins/entertain/entertain_chess.h26
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 */
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com