home
·
contact
·
privacy
projects
/
plomrogue2
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add terrain descriptions.
[plomrogue2]
/
rogue_chat_curses.py
diff --git
a/rogue_chat_curses.py
b/rogue_chat_curses.py
index 2207220dda4cf31f69a46c77e14683ff9cf5ca2c..b80a52ae28180d793b0b8d7276baa6f2b0802acf 100755
(executable)
--- a/
rogue_chat_curses.py
+++ b/
rogue_chat_curses.py
@@
-87,6
+87,12
@@
def cmd_THING_NAME(game, thing_id, name):
t.name = name
cmd_THING_NAME.argtypes = 'int:nonneg string'
t.name = name
cmd_THING_NAME.argtypes = 'int:nonneg string'
+def cmd_THING_CHAR(game, thing_id, c):
+ t = game.get_thing(thing_id)
+ if t:
+ t.player_char = c
+cmd_THING_CHAR.argtypes = 'int:nonneg char'
+
def cmd_MAP(game, geometry, size, content):
map_geometry_class = globals()['MapGeometry' + geometry]
game.map_geometry = map_geometry_class(size)
def cmd_MAP(game, geometry, size, content):
map_geometry_class = globals()['MapGeometry' + geometry]
game.map_geometry = map_geometry_class(size)
@@
-164,6
+170,10
@@
def cmd_THING_TYPE(game, thing_type, symbol_hint):
game.thing_types[thing_type] = symbol_hint
cmd_THING_TYPE.argtypes = 'string char'
game.thing_types[thing_type] = symbol_hint
cmd_THING_TYPE.argtypes = 'string char'
+def cmd_TERRAIN(game, terrain_char, terrain_desc):
+ game.terrains[terrain_char] = terrain_desc
+cmd_TERRAIN.argtypes = 'char string'
+
def cmd_PONG(game):
pass
cmd_PONG.argtypes = ''
def cmd_PONG(game):
pass
cmd_PONG.argtypes = ''
@@
-183,6
+193,8
@@
class Game(GameBase):
self.register_command(cmd_THING)
self.register_command(cmd_THING_TYPE)
self.register_command(cmd_THING_NAME)
self.register_command(cmd_THING)
self.register_command(cmd_THING_TYPE)
self.register_command(cmd_THING_NAME)
+ self.register_command(cmd_THING_CHAR)
+ self.register_command(cmd_TERRAIN)
self.register_command(cmd_MAP)
self.register_command(cmd_MAP_CONTROL)
self.register_command(cmd_PORTAL)
self.register_command(cmd_MAP)
self.register_command(cmd_MAP_CONTROL)
self.register_command(cmd_PORTAL)
@@
-197,6
+209,7
@@
class Game(GameBase):
self.player_id = -1
self.info_db = {}
self.portals = {}
self.player_id = -1
self.info_db = {}
self.portals = {}
+ self.terrains = {}
def get_string_options(self, string_option_type):
if string_option_type == 'map_geometry':
def get_string_options(self, string_option_type):
if string_option_type == 'map_geometry':
@@
-304,7
+317,9
@@
class TUI:
self.socket_thread.start()
self.disconnected = False
self.game.thing_types = {}
self.socket_thread.start()
self.disconnected = False
self.game.thing_types = {}
+ self.game.terrains = {}
self.socket.send('TASKS')
self.socket.send('TASKS')
+ self.socket.send('TERRAINS')
self.socket.send('THING_TYPES')
self.switch_mode('login')
except ConnectionRefusedError:
self.socket.send('THING_TYPES')
self.switch_mode('login')
except ConnectionRefusedError:
@@
-442,12
+457,19
@@
class TUI:
pos_i = self.explorer.y * self.game.map_geometry.size.x + self.explorer.x
info = 'outside field of view'
if self.game.fov[pos_i] == '.':
pos_i = self.explorer.y * self.game.map_geometry.size.x + self.explorer.x
info = 'outside field of view'
if self.game.fov[pos_i] == '.':
- info = 'TERRAIN: %s\n' % self.game.map_content[pos_i]
+ terrain_char = self.game.map_content[pos_i]
+ terrain_desc = '?'
+ if terrain_char in self.game.terrains:
+ terrain_desc = self.game.terrains[terrain_char]
+ info = 'TERRAIN: "%s" / %s\n' % (terrain_char, terrain_desc)
for t in self.game.things:
if t.position == self.explorer:
for t in self.game.things:
if t.position == self.explorer:
- info += 'THING: %s' % t.type_
+ info += 'THING: %s / %s' % (t.type_,
+ self.game.thing_types[t.type_])
+ if hasattr(t, 'player_char'):
+ info += t.player_char
if hasattr(t, 'name'):
if hasattr(t, 'name'):
- info += ' (
name:
%s)' % t.name
+ info += ' (%s)' % t.name
info += '\n'
if self.explorer in self.game.portals:
info += 'PORTAL: ' + self.game.portals[self.explorer] + '\n'
info += '\n'
if self.explorer in self.game.portals:
info += 'PORTAL: ' + self.game.portals[self.explorer] + '\n'
@@
-497,10
+519,12
@@
class TUI:
used_positions = []
for t in self.game.things:
symbol = self.game.thing_types[t.type_]
used_positions = []
for t in self.game.things:
symbol = self.game.thing_types[t.type_]
+ meta_char = ' '
+ if hasattr(t, 'player_char'):
+ meta_char = t.player_char
if t.position in used_positions:
if t.position in used_positions:
- map_lines_split[t.position.y][t.position.x] = symbol + '+'
- else:
- map_lines_split[t.position.y][t.position.x] = symbol + ' '
+ meta_char = '+'
+ map_lines_split[t.position.y][t.position.x] = symbol + meta_char
used_positions += [t.position]
if self.mode.shows_info:
map_lines_split[self.explorer.y][self.explorer.x] = '??'
used_positions += [t.position]
if self.mode.shows_info:
map_lines_split[self.explorer.y][self.explorer.x] = '??'
@@
-512,7
+536,7
@@
class TUI:
indent = 0 if indent else 1
else:
for line in map_lines_split:
indent = 0 if indent else 1
else:
for line in map_lines_split:
- map_lines += ['
'.join(line)]
+ map_lines += [''.join(line)]
window_center = YX(int(self.size.y / 2),
int(self.window_width / 2))
player = self.game.get_thing(self.game.player_id)
window_center = YX(int(self.size.y / 2),
int(self.window_width / 2))
player = self.game.get_thing(self.game.player_id)