this.websocket = new WebSocket(this.url);
this.websocket.onopen = function(event) {
window.setInterval(function() { server.send(['PING']) }, 30000);
+ this.send('TASKS');
tui.log_msg("@ server connected! :)");
tui.switch_mode(mode_login);
};
game.get_thing(tokens[1], true).position = parser.parse_yx(tokens[2]);
} else if (tokens[0] === 'THING_NAME') {
game.get_thing(tokens[1], true).name_ = tokens[2];
+ } else if (tokens[0] === 'TASKS') {
+ game.tasks = tokens[1].split(',')
} else if (tokens[0] === 'MAP') {
game.map_geometry = tokens[1];
tui.init_keys();
this.log_msg(" /" + this.keys.switch_to_play + " or /play - switch to play mode");
this.log_msg(" /" + this.keys.switch_to_study + " or /study - switch to study mode");
this.log_msg("commands common to study and play mode:");
- this.log_msg(" " + movement_keys_desc + " - move");
+ if (game.tasks.includes('MOVE')) {
+ this.log_msg(" " + movement_keys_desc + " - move");
+ }
this.log_msg(" " + this.keys.switch_to_chat + " - switch to chat mode");
this.log_msg("commands specific to play mode:");
- this.log_msg(" " + this.keys.switch_to_edit + " - write following ASCII character");
- this.log_msg(" " + this.keys.flatten + " - flatten surroundings");
+ if (game.tasks.includes('WRITE')) {
+ this.log_msg(" " + this.keys.switch_to_edit + " - write following ASCII character");
+ }
+ if (game.tasks.includes('FLATTEN_SURROUNDINGS')) {
+ this.log_msg(" " + this.keys.flatten + " - flatten surroundings");
+ }
this.log_msg(" " + this.keys.switch_to_study + " - switch to study mode");
this.log_msg("commands specific to study mode:");
+ if (!game.tasks.includes('MOVE')) {
+ this.log_msg(" " + movement_keys_desc + " - move");
+ }
this.log_msg(" " + this.keys.switch_to_annotate + " - annotate terrain");
this.log_msg(" " + this.keys.switch_to_play + " - switch to play mode");
},
this.map_size = [0,0];
this.player_id = -1;
this.portals = {};
+ this.tasks = {};
},
get_thing: function(id_, create_if_not_found=false) {
if (id_ in game.things) {
tui.log_help();
} else if (tokens[0].slice(1) == 'nick') {
if (tokens.length > 1) {
- server.send(['LOGIN', tokens[1]]);
+ server.send(['NICK', tokens[1]]);
} else {
- tui.log_msg('? need login name');
+ tui.log_msg('? need new name');
}
} else if (tokens[0].slice(1) == 'msg') {
if (tokens.length > 2) {
if (event.key === tui.keys.switch_to_chat) {
event.preventDefault();
tui.switch_mode(mode_chat);
- } else if (event.key === tui.keys.switch_to_edit) {
+ } else if (event.key === tui.keys.switch_to_edit
+ && game.tasks.includes('WRITE')) {
event.preventDefault();
tui.switch_mode(mode_edit);
} else if (event.key === tui.keys.switch_to_study) {
tui.switch_mode(mode_study);
- } else if (event.key === tui.keys.flatten) {
+ } else if (event.key === tui.keys.flatten
+ && game.tasks.includes('FLATTEN_SURROUNDINGS')) {
server.send(["TASK:FLATTEN_SURROUNDINGS"]);
- } else if (event.key in tui.movement_keys) {
+ } else if (event.key in tui.movement_keys
+ && game.tasks.includes('MOVE')) {
server.send(['TASK:MOVE', tui.movement_keys[event.key]]);
};
} else if (tui.mode == mode_study) {