toggle terrain/annotations/control view (from study mode):
@@ -325,24 +329,53 @@ let unparser = {
}
class Mode {
- constructor(name, help_intro, has_input_prompt=false, shows_info=false, is_intro=false) {
+ constructor(name, help_intro, has_input_prompt=false, shows_info=false,
+ is_intro=false, is_single_char_entry=false) {
this.name = name;
this.has_input_prompt = has_input_prompt;
this.shows_info= shows_info;
this.is_intro = is_intro;
this.help_intro = help_intro;
+ this.is_single_char_entry = is_single_char_entry;
}
}
-let mode_waiting_for_server = new Mode('waiting_for_server', 'Waiting for a server response.', false, false, true);
-let mode_login = new Mode('login', 'Pick your player name.', true, false, true);
-let mode_post_login_wait = new Mode('waiting for game world', 'Waiting for a server response.', false, false, true);
-let mode_chat = new Mode('chat', 'This mode allows you to engage in chit-chat with other users. Any line you enter into the input prompt that does not start with a "/" will be sent out to nearby players â but barriers and distance will reduce what they can read, so stand close to them to ensure they get your message. Lines that start with a "/" are used for commands like:', true, false);
- let mode_annotate = new Mode('annotate', 'This mode allows you to add/edit a comment on the tile you are currently standing on (provided your map editing password authorizes you so). Hit Return to leave.', true, true);
-let mode_play = new Mode('play', 'This mode allows you to interact with the map.', false, false);
-let mode_study = new Mode('study', 'This mode allows you to study the map and its tiles in detail. Move the question mark over a tile, and the right half of the screen will show detailed information on it.', false, true);
-let mode_edit = new Mode('edit', 'This mode allows you to change the map tile you currently stand on (if your map editing password authorizes you so). Just enter any printable ASCII character to imprint it on the ground below you.', false, false);
-let mode_portal = new Mode('portal', 'This mode allows you to imprint/edit/remove a teleportation target on the ground you are currently standing on (provided your map editing password authorizes you so). Enter or edit a URL to imprint a teleportation target; enter emptiness to remove a pre-existing teleportation target. Hit Return to leave.', true, true);
-let mode_password = new Mode('password', 'This mode allows you to change the password that you send to authorize yourself for editing password-protected map tiles. Hit return to confirm and leave.', true, false, false);
+ let mode_waiting_for_server = new Mode('waiting_for_server',
+ 'Waiting for a server response.',
+ false, false, true);
+ let mode_login = new Mode('login',
+ 'Pick your player name.',
+ true, false, true);
+ let mode_post_login_wait = new Mode('waiting for game world',
+ 'Waiting for a server response.')
+ let mode_chat = new Mode('chat',
+ 'This mode allows you to engage in chit-chat with other users. Any line you enter into the input prompt that does not start with a "/" will be sent out to nearby players â but barriers and distance will reduce what they can read, so stand close to them to ensure they get your message. Lines that start with a "/" are used for commands like:',
+ true);
+ let mode_annotate = new Mode('annotate',
+ 'This mode allows you to add/edit a comment on the tile you are currently standing on (provided your map editing password authorizes you so). Hit Return to leave.',
+ true, true);
+ let mode_play = new Mode('play',
+ 'This mode allows you to interact with the map.')
+ let mode_study = new Mode('study',
+ 'This mode allows you to study the map and its tiles in detail. Move the question mark over a tile, and the right half of the screen will show detailed information on it.',
+ false, true);
+ let mode_edit = new Mode('edit',
+ 'This mode allows you to change the map tile you currently stand on (if your map editing password authorizes you so). Just enter any printable ASCII character to imprint it on the ground below you.',
+ false, false, false, true);
+ let mode_control_pw_type = new Mode('control_pw_type',
+ 'This mode is the first of two steps to change the password for a tile control character. First enter the tile control character for which you want to change the password!',
+ false, false, false, true);
+ let mode_portal = new Mode('portal',
+ 'This mode allows you to imprint/edit/remove a teleportation target on the ground you are currently standing on (provided your map editing password authorizes you so). Enter or edit a URL to imprint a teleportation target; enter emptiness to remove a pre-existing teleportation target. Hit Return to leave.',
+ true, true);
+ let mode_password = new Mode('password',
+ 'This mode allows you to change the password that you send to authorize yourself for editing password-protected map tiles. Hit return to confirm and leave.',
+ true);
+ let mode_admin = new Mode('admin',
+ 'This mode allows you to become admin if you know an admin password.',
+ true);
+ let mode_control_pw_pw = new Mode('control_pw_pw',
+ 'This mode is the second of two steps to change the password for a tile control character. Enter the new password for the tile control character you chose.',
+ true);
let tui = {
mode: mode_waiting_for_server,
@@ -387,7 +420,7 @@ let tui = {
},
switch_mode: function(mode) {
this.inputEl.focus();
- this.show_help = false;
+ //this.show_help = false;
this.map_mode = 'terrain';
if (mode.shows_info && game.player_id in game.things) {
explorer.position = game.things[game.player_id].position;
@@ -408,6 +441,8 @@ let tui = {
document.getElementById("switch_to_portal").disabled = true;
document.getElementById("switch_to_annotate").disabled = true;
document.getElementById("switch_to_password").disabled = true;
+ document.getElementById("switch_to_admin").disabled = true;
+ document.getElementById("switch_to_control_pw").disabled = true;
document.getElementById("move_left").disabled = true;
document.getElementById("move_upleft").disabled = true;
document.getElementById("move_up").disabled = true;
@@ -461,10 +496,16 @@ let tui = {
document.getElementById("switch_to_edit").disabled = false;
document.getElementById("switch_to_portal").disabled = false;
document.getElementById("switch_to_password").disabled = false;
+ document.getElementById("switch_to_admin").disabled = false;
+ document.getElementById("switch_to_control_pw").disabled = false;
} else if (mode == mode_study) {
document.getElementById("toggle_map_mode").disabled = false;
- } else if (mode == mode_edit) {
+ } else if (mode.is_single_char_entry) {
this.show_help = true;
+ } else if (mode == mode_admin) {
+ this.log_msg('@ enter admin password:')
+ } else if (mode == mode_control_pw_pw) {
+ this.log_msg('@ enter tile control password for "' + this.tile_control_char + '":');
}
this.full_refresh();
},
@@ -659,6 +700,8 @@ let tui = {
content += '[' + this.keys.switch_to_portal + '] â portal edit mode\n';
content += '[' + this.keys.switch_to_annotate + '] â annotation mode\n';
content += '[' + this.keys.switch_to_password + '] â password input mode\n';
+ content += '[' + this.keys.switch_to_admin + '] â become admin\n';
+ content += '[' + this.keys.switch_to_control_pw + '] â change tile control password\n';
} else if (this.mode == mode_study) {
content += "Available actions:\n";
content += '[' + movement_keys_desc + '] â move question mark\n';
@@ -825,6 +868,11 @@ let explorer = {
terrain_desc = game.terrains[terrain_char];
};
info += 'TERRAIN: "' + terrain_char + '" / ' + terrain_desc + "\n";
+ let protection = game.map_control[position_i];
+ if (protection == '.') {
+ protection = 'unprotected';
+ };
+ info += 'PROTECTION: ' + protection + '\n';
for (let t_id in game.things) {
let t = game.things[t_id];
if (t.position[0] == this.position[0] && t.position[1] == this.position[1]) {
@@ -873,6 +921,9 @@ tui.inputEl.addEventListener('input', (event) => {
} else if (tui.mode == mode_edit && tui.inputEl.value.length > 0) {
server.send(["TASK:WRITE", tui.inputEl.value[0], tui.password]);
tui.switch_mode(mode_play);
+ } else if (tui.mode == mode_control_pw_type && tui.inputEl.value.length > 0) {
+ tui.tile_control_char = tui.inputEl.value[0];
+ tui.switch_mode(mode_control_pw_pw);
}
tui.full_refresh();
}, false);
@@ -885,12 +936,21 @@ tui.inputEl.addEventListener('keydown', (event) => {
tui.show_help = true;
tui.empty_input();
tui.restore_input_values();
- } else if (!tui.mode.has_input_prompt && event.key == tui.keys.help) {
+ } else if (!tui.mode.has_input_prompt && event.key == tui.keys.help
+ && !tui.mode.is_single_char_entry) {
tui.show_help = true;
} else if (tui.mode == mode_login && event.key == 'Enter') {
tui.login_name = tui.inputEl.value;
server.send(['LOGIN', tui.inputEl.value]);
tui.empty_input();
+ } else if (tui.mode == mode_control_pw_pw && event.key == 'Enter') {
+ if (tui.inputEl.value.length == 0) {
+ tui.log_msg('@ aborted');
+ } else {
+ server.send(['SET_MAP_CONTROL_PASSWORD',
+ tui.tile_control_char, tui.inputEl.value]);
+ }
+ tui.switch_mode(mode_play);
} else if (tui.mode == mode_portal && event.key == 'Enter') {
explorer.set_portal(tui.inputEl.value);
tui.switch_mode(mode_play);
@@ -903,6 +963,9 @@ tui.inputEl.addEventListener('keydown', (event) => {
}
tui.password = tui.inputEl.value
tui.switch_mode(mode_play);
+ } else if (tui.mode == mode_admin && event.key == 'Enter') {
+ server.send(['BECOME_ADMIN', tui.inputEl.value]);
+ tui.switch_mode(mode_play);
} else if (tui.mode == mode_chat && event.key == 'Enter') {
let tokens = parser.tokenize(tui.inputEl.value);
if (tokens.length > 0 && tokens[0].length > 0) {
@@ -937,6 +1000,12 @@ tui.inputEl.addEventListener('keydown', (event) => {
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.switch_to_admin) {
+ event.preventDefault();
+ tui.switch_mode(mode_admin);
+ } else if (event.key === tui.keys.switch_to_control_pw) {
+ event.preventDefault();
+ tui.switch_mode(mode_control_pw_type);
} else if (event.key === tui.keys.switch_to_password) {
event.preventDefault();
tui.switch_mode(mode_password);
@@ -1048,6 +1117,14 @@ document.getElementById("switch_to_portal").onclick = function() {
tui.switch_mode(mode_portal);
tui.full_refresh();
};
+document.getElementById("switch_to_admin").onclick = function() {
+ tui.switch_mode(mode_admin);
+ tui.full_refresh();
+};
+document.getElementById("switch_to_control_pw").onclick = function() {
+ tui.switch_mode(mode_control_pw_type);
+ tui.full_refresh();
+};
document.getElementById("toggle_map_mode").onclick = function() {
if (tui.map_mode == 'terrain') {
tui.map_mode = 'annotations';