+let explorer = {
+ position: [0,0],
+ info_db: {},
+ move: function(direction) {
+ let try_pos = [0,0];
+ try_pos[0] = this.position[0];
+ try_pos[1] = this.position[1];
+ if (direction == 'left') {
+ try_pos[1] -= 1;
+ } else if (direction == 'right') {
+ try_pos[1] += 1;
+ } else if (direction == 'up') {
+ try_pos[0] -= 1;
+ } else if (direction == 'down') {
+ try_pos[0] += 1;
+ };
+ if (!(try_pos[0] < 0) &&
+ !(try_pos[1] < 0) &&
+ !(try_pos[0] >= game.map_size[0])
+ && !(try_pos[1] >= game.map_size[1])) {
+ this.position = try_pos;
+ this.query_info();
+ tui.draw_map();
+ tui.draw_info();
+ tui.refresh();
+ }
+ },
+ update_info_db: function(yx, str) {
+ this.info_db[yx] = str;
+ if (tui.mode == 'study') {
+ tui.draw_info();
+ tui.refresh();
+ }
+ },
+ empty_info_db: function() {
+ this.info_db = {};
+ if (tui.mode == 'study') {
+ tui.draw_info();
+ tui.refresh();
+ }
+ },
+ query_info: function() {
+ websocket.send("GET_ANNOTATION Y:" + explorer.position[0] + ",X:" + explorer.position[1]);
+ },
+ get_info: function() {
+ if (this.position in this.info_db) {
+ return this.info_db[this.position];
+ } else {
+ return 'waiting …';
+ }
+ },
+ annotate: function(msg) {
+ if (msg.length == 0) {
+ msg = " "; // triggers annotation deletion
+ }
+ websocket.send("ANNOTATE Y:" + explorer.position[0] + ",X:" + explorer.position[1] + " " + quote(msg));
+ }
+}
+