diff options
| author | info@mode42.com <info@mode42.com> | 2026-08-09 11:54:17 +0000 |
|---|---|---|
| committer | info@mode42.com <info@mode42.com> | 2026-08-09 11:54:17 +0000 |
| commit | a989bd16c40e04bba5a5404b0ef0cd22f19d2707 (patch) | |
| tree | 604a0439c7d8c022cbd483d62bdc2cfc1c8d18f8 /plugins/entertain/entertain.c | |
| parent | a72e5ea7558e5172c08d397d6f1e0e0f9273e694 (diff) | |
now including entertain/chess
Diffstat (limited to 'plugins/entertain/entertain.c')
| -rw-r--r-- | plugins/entertain/entertain.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/plugins/entertain/entertain.c b/plugins/entertain/entertain.c new file mode 100644 index 0000000..cf3e123 --- /dev/null +++ b/plugins/entertain/entertain.c @@ -0,0 +1,67 @@ +/* + * Entertain plugin — entertain.c + * Plugin registration: init, shutdown, tick, on_command. + * Chess is the first entertainment feature; more can be added. + */ +#include "hybbx/plugin.h" +#include "hybbx/service.h" +#include "hybbx/command.h" +#include "hybbx/log.h" +#include "entertain_chess.h" + +#include <string.h> + +static struct hybbx_service *g_service; + +/* Forward declarations from chess_cmd.c */ +extern hybbx_result_t entertain_cmd_chess(struct hybbx_service *service, + struct hybbx_session *session, + const struct hybbx_parsed_command *cmd); + +static hybbx_result_t entertain_init(struct hybbx_service *service) +{ + g_service = service; + chess_init(CHESS_DEFAULT_MAX); + hybbx_log_info("[entertain] plugin loaded — chess_max_games=%u", (unsigned)CHESS_DEFAULT_MAX); + return HYBBX_OK; +} + +static void entertain_shutdown(void) +{ + chess_shutdown(); + g_service = NULL; + hybbx_log_info("[entertain] plugin unloaded"); +} + +static void entertain_tick(struct hybbx_service *service) +{ + chess_tick(service); +} + +static hybbx_result_t entertain_on_command(struct hybbx_service *service, + struct hybbx_session *session, + const struct hybbx_parsed_command *cmd) +{ + if (cmd == NULL || cmd->verb == NULL) { + return HYBBX_ERR_NOT_FOUND; + } + + if (strcmp(cmd->verb, "chess") == 0 || strcmp(cmd->verb, "play") == 0) { + return entertain_cmd_chess(service, session, cmd); + } + + return HYBBX_ERR_NOT_FOUND; +} + +const hybbx_transport_plugin_t hybbx_plugin_entertain = { + .name = "entertain", + .kind = 0, /* not a transport — feature plugin */ + .version = 1, + .init = entertain_init, + .shutdown = entertain_shutdown, + .start = NULL, + .stop = NULL, + .write = NULL, + .tick = entertain_tick, + .on_command = entertain_on_command, +}; |
