symbol = '@'
elif type_ == 'monster':
symbol = 'm'
+ elif type_ == 'item':
+ symbol = 'i'
return symbol
terrain_as_list = list(self.tui.game.world.map_.terrain[:])
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_)
+ symbol = self.tui.game.symbol_for_type(t.type_)
+ if symbol in {'i'} and terrain_as_list[pos_i] in {'@', 'm'}:
+ continue
+ terrain_as_list[pos_i] = symbol
return ''.join(terrain_as_list)
def pad_or_cut_x(lines):
for c in ''.join(lines):
if c in {'@', 'm'}:
chars_with_attrs += [(c, curses.color_pair(1))]
+ elif c == 'i':
+ chars_with_attrs += [(c, curses.color_pair(4))]
elif c == '.':
chars_with_attrs += [(c, curses.color_pair(2))]
elif c in {'x', 'X', '#'}:
curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_RED)
curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_GREEN)
curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_BLUE)
+ curses.init_pair(4, curses.COLOR_BLACK, curses.COLOR_YELLOW)
curses.curs_set(False) # hide cursor
self.to_send = []
self.edit = EditWidget(self, (0, 6), (1, 14), check_tui = ['edit'])
from plomrogue.parser import Parser
from plomrogue.io import GameIO
from plomrogue.misc import quote, stringify_yx
-from plomrogue.things import Thing, ThingMonster, ThingHuman
+from plomrogue.things import Thing, ThingMonster, ThingHuman, ThingItem
npc = self.game.thing_types['monster'](self, 1)
npc.position = [random.randint(0, yx[0] -1),
random.randint(0, yx[1] -1)]
- self.things = [player, npc]
+ item = self.game.thing_types['item'](self, 2)
+ item.position = [random.randint(0, yx[0] -1),
+ random.randint(0, yx[1] -1)]
+ self.things = [player, npc, item]
return 'success'
self.world_type = World
self.world = self.world_type(self)
self.thing_type = Thing
- self.thing_types = {'human': ThingHuman, 'monster': ThingMonster}
+ self.thing_types = {'human': ThingHuman,
+ 'monster': ThingMonster,
+ 'item': ThingItem}
def get_string_options(self, string_option_type):
if string_option_type == 'direction':
if self.thing.world.map_[test_pos] != '.':
raise GameError('%s would move into illegal terrain' % self.thing.id_)
for t in self.thing.world.things:
- if t.position == test_pos:
+ if t.blocking and t.position == test_pos:
raise GameError('%s would move into other thing' % self.thing.id_)
def do(self):
class Thing(ThingBase):
+ blocking = False
+
+ def proceed(self):
+ pass
+
+
+
+class ThingItem(Thing):
+ type_ = 'item'
+
+
+
+class ThingAnimate(Thing):
+ blocking = True
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
-class ThingHuman(Thing):
+class ThingHuman(ThingAnimate):
type_ = 'human'
-class ThingMonster(Thing):
+class ThingMonster(ThingAnimate):
type_ = 'monster'