def box(self, txt): """Center text and display border around it.""" in_width = width - 2 # inside width tpl = border.vertical + '%s' + border.vertical topline = border.tl + border.horiz * in_width + border.tr btmline = border.bl + border.horiz * in_width + border.br padline = tpl % (space * in_width) wrapped = [line for line in wrap(txt, width - 10)] wrapped = [tpl % l.center(in_width) for l in wrapped] lines = [topline, padline] + wrapped + [padline, btmline] print(nl.join(space + l for l in lines))
def box(self, txt): """Center text and display border around it.""" in_width = width - 2 # inside width tpl = border.vertical + '%s' + border.vertical topline = border.tl + border.horiz * in_width + border.tr btmline = border.bl + border.horiz * in_width + border.br padline = tpl % (space * in_width) wrapped = [line for line in wrap(txt, width - 10)] wrapped = [tpl % l.center(in_width) for l in wrapped] lines = [topline, padline] + wrapped + [padline, btmline] print( nl.join(space+l for l in lines) )
def move(self, ndir): if not self.dir.doors[ndir]: print(Msg.bump_wall) return M = [Msg.ent_room] # messages for the player self.dir.update(ndir) newloc = board.nextloc(self, self.dir.absdir) self.room = Room(newloc) if board.empty(newloc) else board[newloc] board.move(self, newloc) self.dir.update_doors() self.roomview(M) if self.room.shaky_floor and any(i.anvil for i in self.items): self.next_level(M) print(nl.join(M))
def get_badges(self, level): level = iround(level*badge_modifier) lines = self.advanced_badges(level) + [ self.basic_badges(level) ] lines = [space.join(line) for line in lines] return nl.join(l.center(16) for l in lines if l)
def look(self): print(nl*5) print(nl.join(self.roomview()))
def look(self): print(nl * 5) print(nl.join(self.roomview()))