From 875e12b88f55250c4adb0a5304b150ac00ce4efd Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 5 Mar 2022 11:32:38 +0100 Subject: Add query/reply API to server and modules. --- public/common/play.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'public') diff --git a/public/common/play.js b/public/common/play.js index e58ca04..0fa432a 100644 --- a/public/common/play.js +++ b/public/common/play.js @@ -376,12 +376,18 @@ function connect_play() { case 'state': view = arg; on_update_header(); - on_update(); + if (typeof on_update === 'function') + on_update(); on_update_log(); if (view.game_over) on_game_over(); break; + case 'reply': + if (typeof on_reply === 'function') + on_reply(arg[0], arg[1]); + break; + case 'save': window.localStorage[params.title_id + "/save"] = arg; break; @@ -547,6 +553,13 @@ function send_action(verb, noun) { return false; } +function send_query(q, param) { + if (param !== undefined) + send_message("query", [q, param]); + else + send_message("query", q); +} + function confirm_resign() { if (window.confirm("Are you sure that you want to resign?")) send_message("resign"); -- cgit v1.2.3