home · contact · privacy
dd annotation hints view.
[plomrogue2] / rogue_chat_nocanvas_monochrome.html
index a5b2d69d81913938ba42c2ec4b9bee549e7779df..88b66723d9ee6f5f54aa2a06dada0214f22a80f4 100644 (file)
@@ -29,7 +29,7 @@ terminal columns: <input id="n_cols" type="number" step=4 min=80 value=80 />
 <button id="switch_to_password">change tile editing password</button>
 <button id="switch_to_annotate">annotate tile</button>
 <button id="switch_to_portal">edit portal link</button>
-<button id="toggle_map_mode">toggle terrain/control view</button>
+<button id="toggle_map_mode">toggle terrain/annotations/control view</button>
 </div>
 <h3>edit keybindings</h3> (see <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values">here</a> for non-obvious available values):<br />
 <ul>
@@ -55,7 +55,7 @@ terminal columns: <input id="n_cols" type="number" step=4 min=80 value=80 />
 <li>enter tile password (from play mode): <input id="key_switch_to_password" type="text" value="P" />
 <li>annotate tile (from play mode): <input id="key_switch_to_annotate" type="text" value="M" />
 <li>annotate portal (from play mode): <input id="key_switch_to_portal" type="text" value="T" />
-<li>toggle terrain/control view (from study mode): <input id="key_toggle_map_mode" type="text" value="M" />
+<li>toggle terrain/annotations/control view (from study mode): <input id="key_toggle_map_mode" type="text" value="M" />
 </ul>
 </div>
 <script>
@@ -223,6 +223,7 @@ let server = {
         let tokens = parser.tokenize(event.data);
         if (tokens[0] === 'TURN') {
             game.turn_complete = false;
+            explorer.empty_info_db();
             game.things = {};
             game.portals = {};
             game.turn = parseInt(tokens[1]);
@@ -257,7 +258,6 @@ let server = {
             game.map_control = tokens[1]
         } else if (tokens[0] === 'GAME_STATE_COMPLETE') {
             game.turn_complete = true;
-            explorer.empty_info_db();
             if (tui.mode == mode_post_login_wait) {
                 tui.switch_mode(mode_play);
             } else if (tui.mode == mode_study) {
@@ -274,6 +274,9 @@ let server = {
         } else if (tokens[0] === 'PORTAL') {
             let position = parser.parse_yx(tokens[1]);
             game.portals[position] = tokens[2];
+        } else if (tokens[0] === 'ANNOTATION_HINT') {
+            let position = parser.parse_yx(tokens[1]);
+            explorer.info_hints = explorer.info_hints.concat([position]);
         } else if (tokens[0] === 'ANNOTATION') {
             let position = parser.parse_yx(tokens[1]);
             explorer.update_info_db(position, tokens[2]);
@@ -532,7 +535,11 @@ let tui = {
         line.push(map_content[i] + ' ');
     };
     map_lines_split.push(line);
-    if (this.map_mode == 'terrain') {
+    if (this.map_mode == 'annotations') {
+        for (const coordinate of explorer.info_hints) {
+            map_lines_split[coordinate[0]][coordinate[1]] = 'A ';
+        }
+    } else if (this.map_mode == 'terrain') {
         for (const p in game.portals) {
             let coordinate = p.split(',')
             map_lines_split[coordinate[0]][coordinate[1]] = 'P ';
@@ -655,7 +662,7 @@ let tui = {
       } else if (this.mode == mode_study) {
           content += "Available actions:\n";
           content += '[' + movement_keys_desc + '] – move question mark\n';
-          content += '[' + this.keys.toggle_map_mode + '] – toggle view between terrain, and password protection areas\n';
+          content += '[' + this.keys.toggle_map_mode + '] – toggle view between terrain, annotations, and password protection areas\n';
           content += '\nOther modes available from here:\n';
           content += '[' + this.keys.switch_to_chat + '] – chat mode\n';
           content += '[' + this.keys.switch_to_play + '] – play mode\n';
@@ -780,6 +787,7 @@ server.init(websocket_location);
 let explorer = {
     position: [0,0],
     info_db: {},
+    info_hints: [],
     move: function(direction) {
         let target = game.move(this.position, direction);
         if (target) {
@@ -797,6 +805,7 @@ let explorer = {
     },
     empty_info_db: function() {
         this.info_db = {};
+        this.info_hints = [];
         if (tui.mode == mode_study) {
             tui.full_refresh();
         }
@@ -962,6 +971,8 @@ tui.inputEl.addEventListener('keydown', (event) => {
             explorer.move(tui.movement_keys[event.key]);
         } else if (event.key == tui.keys.toggle_map_mode) {
             if (tui.map_mode == 'terrain') {
+                tui.map_mode = 'annotations';
+            } else if (tui.map_mode == 'annotations') {
                 tui.map_mode = 'control';
             } else {
                 tui.map_mode = 'terrain';
@@ -1039,6 +1050,8 @@ document.getElementById("switch_to_portal").onclick = function() {
 };
 document.getElementById("toggle_map_mode").onclick = function() {
     if (tui.map_mode == 'terrain') {
+        tui.map_mode = 'annotations';
+    } else if (tui.map_mode == 'annotations') {
         tui.map_mode = 'control';
     } else {
         tui.map_mode = 'terrain';