home
·
contact
·
privacy
projects
/
plomrogue2-experiments
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
11f8d50
)
Add coloring to map in ncurses client.
author
Christian Heller
<c.heller@plomlompom.de>
Thu, 24 Jan 2019 01:52:34 +0000
(
02:52
+0100)
committer
Christian Heller
<c.heller@plomlompom.de>
Thu, 24 Jan 2019 01:52:34 +0000
(
02:52
+0100)
client-curses.py
patch
|
blob
|
history
diff --git
a/client-curses.py
b/client-curses.py
index a79afa0bf557574d6416e35b35fd9daa63aabec9..a18d8af59a8435fa2a9b553a55a0874192ee1ecb 100755
(executable)
--- a/
client-curses.py
+++ b/
client-curses.py
@@
-205,9
+205,9
@@
class MapWidget(Widget):
for t in self.tui.game.world.things:
pos_i = self.tui.game.world.map_.get_position_index(t.position)
terrain_as_list[pos_i] = self.tui.game.symbol_for_type(t.type_)
for t in self.tui.game.world.things:
pos_i = self.tui.game.world.map_.get_position_index(t.position)
terrain_as_list[pos_i] = self.tui.game.symbol_for_type(t.type_)
-
text
= self.tui.game.world.map_.list_terrain_to_lines(terrain_as_list)
+
lines
= self.tui.game.world.map_.list_terrain_to_lines(terrain_as_list)
line_width = self.size[1]
line_width = self.size[1]
- for line in
text
:
+ for line in
lines
:
if line_width > len(line):
to_pad = line_width - (len(line) % line_width)
to_join += [line + '0' * to_pad]
if line_width > len(line):
to_pad = line_width - (len(line) % line_width)
to_join += [line + '0' * to_pad]
@@
-216,7
+216,19
@@
class MapWidget(Widget):
if len(to_join) < self.size[0]:
to_pad = self.size[0] - len(to_join)
to_join += to_pad * ['0' * self.size[1]]
if len(to_join) < self.size[0]:
to_pad = self.size[0] - len(to_join)
to_join += to_pad * ['0' * self.size[1]]
- self.safe_write(''.join(to_join))
+ text = ''.join(to_join)
+ text_as_list = []
+ for c in text:
+ if c in {'@', 'm'}:
+ text_as_list += [(c, curses.color_pair(1))]
+ elif c == '.':
+ text_as_list += [(c, curses.color_pair(2))]
+ elif c in {'x', 'X', '#'}:
+ text_as_list += [(c, curses.color_pair(3))]
+ else:
+ text_as_list += [c]
+ #self.safe_write(''.join(to_join))
+ self.safe_write(text_as_list)
class TurnWidget(Widget):
class TurnWidget(Widget):