home · contact · privacy
Add field of view.
[plomrogue2] / rogue_chat_curses.py
index 203f3eaefec758c879b3b7bc9edc451f2e385113..defc2724840ae41127b20748669288e8c5bbf73c 100755 (executable)
@@ -104,6 +104,10 @@ def cmd_MAP(game, geometry, size, content):
         }
 cmd_MAP.argtypes = 'string:map_geometry yx_tuple:pos string'
 
+def cmd_FOV(game, content):
+    game.fov = content
+cmd_FOV.argtypes = 'string'
+
 def cmd_MAP_CONTROL(game, content):
     game.map_control_content = content
 cmd_MAP_CONTROL.argtypes = 'string'
@@ -178,6 +182,7 @@ class Game(GameBase):
         self.register_command(cmd_GAME_ERROR)
         self.register_command(cmd_PLAY_ERROR)
         self.register_command(cmd_TASKS)
+        self.register_command(cmd_FOV)
         self.map_content = ''
         self.player_id = -1
         self.info_db = {}
@@ -261,6 +266,7 @@ class TUI:
         self.disconnected = True
         self.force_instant_connect = True
         self.input_lines = []
+        self.fov = ''
         curses.wrapper(self.loop)
 
     def flash(self):
@@ -418,18 +424,20 @@ class TUI:
             if not self.game.turn_complete:
                 return
             pos_i = self.explorer.y * self.game.map_geometry.size.x + self.explorer.x
-            info = 'TERRAIN: %s\n' % self.game.map_content[pos_i]
-            for t in self.game.things:
-                if t.position == self.explorer:
-                    info += 'PLAYER @: %s\n' % t.name
-            if self.explorer in self.game.portals:
-                info += 'PORTAL: ' + self.game.portals[self.explorer] + '\n'
-            else:
-                info += 'PORTAL: (none)\n'
-            if self.explorer in self.game.info_db:
-                info += 'ANNOTATION: ' + self.game.info_db[self.explorer]
-            else:
-                info += 'ANNOTATION: waiting …'
+            info = 'outside field of view'
+            if self.game.fov[pos_i] == '.':
+                info = 'TERRAIN: %s\n' % self.game.map_content[pos_i]
+                for t in self.game.things:
+                    if t.position == self.explorer:
+                        info += 'PLAYER @: %s\n' % t.name
+                if self.explorer in self.game.portals:
+                    info += 'PORTAL: ' + self.game.portals[self.explorer] + '\n'
+                else:
+                    info += 'PORTAL: (none)\n'
+                if self.explorer in self.game.info_db:
+                    info += 'ANNOTATION: ' + self.game.info_db[self.explorer]
+                else:
+                    info += 'ANNOTATION: waiting …'
             lines = msg_into_lines_of_width(info, self.window_width)
             height_header = 2
             for i in range(len(lines)):