def __init__(self, dimensions, floor, dude_layer, elements, dungeon, definition): """ Create a Level. dimensions - the actual dimensions of the Level, in (x, y) form. floor - the height of the Level in comparison to other Levels; an integer. dude_layer - a DudeLayer. (If None, a DudeLayer will be created.) elements - an array representing the elements of the Level: terrain features which are overlaid upon the regular terrain, but which cannot be picked up like items. dungeon - an array representing the dungeon: the walls, floors, and other terrain. definition - a FloorDefinition for this Level. """ if dude_layer is None: dude_layer = DudeLayer(None, dimensions) self.floor = floor self.dungeon = dungeon self.elements = elements self.dimensions = dimensions self.dudeLayer = dude_layer self.effects = effects.EffectsMap(dimensions) self.definition = definition self.player = None self.messages = msg.MessageBuffer(config.MESSAGES_DIMENSIONS) self.__composite_map = arrays.empty_str_array(dimensions) self.__height_map = numpy.zeros(dimensions, 'i') self.__are_maps_correct = False self.__queue = None self.events = [events.LevelTick(self)] self.time = 0
def getArray(self): """ Return an array representing this object's contents. """ ret_array = arrays.empty_str_array(self.dimensions) for i in self.__map: ret_array[i] == self.__map[i][0] return ret_array
def getArray(self): """ Return an array representing the last few messages, where "the last few messages" are the last dimensions[1] messages. """ ret_array = arrays.empty_str_array(self.dimensions) lines_to_use = self.message_list[-self.dimensions[1] :] # lines_to_use.reverse() for i in range(len(lines_to_use)): arrays.print_str_to_end_of_line((0, i), lines_to_use[i], ret_array) return ret_array
def display_main_screen(level_array, level_center, message_array, sidebar_array): """ Refresh the console with the three arrays provided. """ assert message_array.shape == config.MESSAGES_DIMENSIONS assert sidebar_array.shape == config.STATUS_DIMENSIONS disp_array = arrays.empty_str_array(config.DEFAULT_DIMENSIONS) arrays.copy_array_centered_at((0, 0), config.MAP_DIMENSIONS, level_center, level_array, disp_array) arrays.copy_entire_array((60, 0), sidebar_array, disp_array) arrays.copy_entire_array((0, 17), message_array, disp_array) display_array(disp_array) return
def __init__(self, name, floor, char_level, cur_HP, max_HP, deck, conditions): """ Initialize a Sidebar with the corresponding values. name - a string of the player's name. floor - an integer of the floor of the dungeon the player is on. char_level - an integer representing the player's character level. cur_HP - an integer; the player's current HP. max_HP - an integer; the player's maximum HP. deck - the deck containing the player's cards. conditions - a list (NOT A DICTIONARY) of the player's conditions. """ self.__array = arrays.empty_str_array(config.STATUS_DIMENSIONS) arrays.print_str_to_end_of_line((1, 0), name, self.__array) arrays.print_str_to_end_of_line((1, 1), "Floor %d" % floor, self.__array) arrays.print_str_to_end_of_line((1, 2), "Level %d" % char_level, self.__array) arrays.print_str_to_end_of_line((1, 4), "HP: %d(%d)" % (cur_HP, max_HP), self.__array) condition_names = "" for c in conditions: c_name = c.getDisplayName() if c_name != "": if condition_names == "": condition_names = c_name else: condition_names = " ".join((condition_names, c_name)) arrays.print_str_to_end_of_line((1, 5), condition_names, self.__array) arrays.print_str_to_end_of_line((1, 7), "Deck(%d):" % len(deck.library), self.__array) for i in range(len(deck.hand)): arrays.print_str_to_end_of_line((1, 8 + i), "(%d) %s" % (i+1, deck.hand[i].monster_name), self.__array) return
def empty_dungeon(dimensions): """ Return an empty dungeon with the dimensions specified. """ return arrays.empty_str_array(dimensions)
def getArray(self): array = arrays.empty_str_array(self.dimensions) for item in self: array[item.coords] = item.getCurGlyph() return array
def getArray(self): ret_array = arrays.empty_str_array(self.dimensions) for key in self: ret_array[key] = self[key] return ret_array