summaryrefslogtreecommitdiff
path: root/plugins/entertain/entertain.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/entertain/entertain.c')
-rw-r--r--plugins/entertain/entertain.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/plugins/entertain/entertain.c b/plugins/entertain/entertain.c
index cf3e123..f8dfa6a 100644
--- a/plugins/entertain/entertain.c
+++ b/plugins/entertain/entertain.c
@@ -1,7 +1,7 @@
/*
* Entertain plugin — entertain.c
- * Plugin registration: init, shutdown, tick, on_command.
- * Chess is the first entertainment feature; more can be added.
+ * Feature plugin (not a transport): init / tick / on_command.
+ * Chess is the first Entertain feature. Main / standalone Main only.
*/
#include "hybbx/plugin.h"
#include "hybbx/service.h"
@@ -13,16 +13,26 @@
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 int verb_is_chess(const char *verb)
+{
+ if (verb == NULL) {
+ return 0;
+ }
+ return strcmp(verb, "chess") == 0 ||
+ strcmp(verb, "play") == 0 ||
+ strcmp(verb, "mv") == 0;
+}
+
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);
+ hybbx_log_info("[entertain] plugin loaded — chess_max_games=%u",
+ (unsigned)CHESS_DEFAULT_MAX);
return HYBBX_OK;
}
@@ -46,7 +56,7 @@ static hybbx_result_t entertain_on_command(struct hybbx_service *service,
return HYBBX_ERR_NOT_FOUND;
}
- if (strcmp(cmd->verb, "chess") == 0 || strcmp(cmd->verb, "play") == 0) {
+ if (verb_is_chess(cmd->verb)) {
return entertain_cmd_chess(service, session, cmd);
}
@@ -54,14 +64,14 @@ static hybbx_result_t entertain_on_command(struct hybbx_service *service,
}
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,
+ .name = "entertain",
+ .kind = 0, /* feature plugin — not a wire transport */
+ .version = 1,
+ .init = entertain_init,
+ .shutdown = entertain_shutdown,
+ .start = NULL,
+ .stop = NULL,
+ .write = NULL,
+ .tick = entertain_tick,
+ .on_command = entertain_on_command,
};
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com