impl some more stuff

This commit is contained in:
Rusty Striker 2025-07-25 17:36:19 +03:00
parent 0d99649e56
commit 6e269c6b1f
Signed by: RustyStriker
GPG key ID: 87E4D691632DFF15
5 changed files with 23 additions and 1 deletions

View file

@ -5,11 +5,13 @@ class Tavern {
this.msgs = [];
this.connected = false;
this.loggedIn = false;
this.admin = false;
this.socket.onmessage = (m) => {
m = JSON.parse(m.data);
console.log(m);
if (m.login) {
this.socket.loggedIn = m.login.success;
this.admin = m.login.admin;
this.call(this.onlogin, this.socket.loggedIn);
}
if (m.message) {
@ -105,6 +107,22 @@ class Tavern {
if (!this.connected || this.loggedIn) { return; }
this.socket.send(JSON.stringify('get_scene_list'))
}
spawn_token = (scene, character, x, y, img_path, visible_to_players) => {
if (!this.connected || this.loggedIn) { return; }
this.socket.send(JSON.stringify({
spawn_token: {
map_id: scene, character: character, x: x, y: y, img_path: img_path, visible_to_players: visible_to_players
}
}));
}
create_scene = (title) => {
if (!this.connected || this.loggedIn) { return; }
this.socket.send(JSON.stringify({ create_scene: { title: title } }));
}
shutdown = () => {
if (!this.connected || this.loggedIn) { return; }
this.socket.send(JSON.stringify('shutdown'));
}
}
const tavern = new Tavern();