Beispiel #1
0
    def load(self, file):

        parser = libtcod.parser_new()
        tile_struc = libtcod.parser_new_struct(parser, "tile")
        libtcod.struct_add_property(tile_struc, "id", libtcod.TYPE_INT, True)
        libtcod.struct_add_property(tile_struc, "chara", libtcod.TYPE_CHAR,
                                    True)

        libtcod.struct_add_property(tile_struc, "path", libtcod.TYPE_BOOL,
                                    True)
        libtcod.struct_add_property(tile_struc, "view", libtcod.TYPE_BOOL,
                                    True)

        libtcod.struct_add_property(tile_struc, "ccolor", libtcod.TYPE_COLOR,
                                    True)
        libtcod.struct_add_property(tile_struc, "bcgcolor", libtcod.TYPE_COLOR,
                                    True)

        libtcod.parser_run(parser, file, TilesetListener(self))

        self.empty = 0

        print "ended"

        libtcod.parser_delete(parser)
Beispiel #2
0
	def init_parser(self):
		parser = libtcod.parser_new()
		prefix_type_struct = libtcod.parser_new_struct(parser, 'prefix_type')
		libtcod.struct_add_property(prefix_type_struct, 'type', libtcod.TYPE_STRING, True)
		libtcod.struct_add_property(prefix_type_struct, 'cost_multiplier', libtcod.TYPE_FLOAT, True)
		libtcod.struct_add_property(prefix_type_struct, 'level', libtcod.TYPE_INT, True)
		libtcod.struct_add_property(prefix_type_struct, 'quality', libtcod.TYPE_INT, False)
		libtcod.struct_add_flag(prefix_type_struct, 'armor')
		libtcod.struct_add_flag(prefix_type_struct, 'robe')
		libtcod.struct_add_flag(prefix_type_struct, 'cloak')
		libtcod.struct_add_flag(prefix_type_struct, 'shield')
		libtcod.struct_add_flag(prefix_type_struct, 'weapon')
		libtcod.struct_add_flag(prefix_type_struct, 'ring')
		libtcod.struct_add_flag(prefix_type_struct, 'potion')
		libtcod.struct_add_flag(prefix_type_struct, 'leather')
		libtcod.struct_add_flag(prefix_type_struct, 'metal')
		libtcod.struct_add_flag(prefix_type_struct, 'damage_bonus1')
		libtcod.struct_add_flag(prefix_type_struct, 'damage_bonus2')
		libtcod.struct_add_flag(prefix_type_struct, 'damage_bonus3')
		libtcod.struct_add_flag(prefix_type_struct, 'ar_bonus1')
		libtcod.struct_add_flag(prefix_type_struct, 'ar_bonus2')
		libtcod.struct_add_flag(prefix_type_struct, 'ar_bonus3')
		libtcod.struct_add_flag(prefix_type_struct, 'fire_bonus1')
		libtcod.struct_add_flag(prefix_type_struct, 'fire_bonus2')
		libtcod.struct_add_flag(prefix_type_struct, 'fire_bonus3')
		libtcod.struct_add_flag(prefix_type_struct, 'cold_bonus1')
		libtcod.struct_add_flag(prefix_type_struct, 'cold_bonus2')
		libtcod.struct_add_flag(prefix_type_struct, 'cold_bonus3')
		libtcod.parser_run(parser, 'data/prefix.txt', PrefixListener())
Beispiel #3
0
	def init_parser(self):
		parser = libtcod.parser_new()
		suffix_type_struct = libtcod.parser_new_struct(parser, 'suffix_type')
		libtcod.struct_add_property(suffix_type_struct, 'icon_color', libtcod.TYPE_COLOR, False)
		libtcod.struct_add_property(suffix_type_struct, 'cost_multiplier', libtcod.TYPE_FLOAT, True)
		libtcod.struct_add_property(suffix_type_struct, 'level', libtcod.TYPE_INT, True)
		libtcod.struct_add_property(suffix_type_struct, 'dices', libtcod.TYPE_DICE, False)
		libtcod.struct_add_property(suffix_type_struct, 'bonus', libtcod.TYPE_INT, False)
		libtcod.struct_add_flag(suffix_type_struct, 'armor')
		libtcod.struct_add_flag(suffix_type_struct, 'robe')
		libtcod.struct_add_flag(suffix_type_struct, 'cloak')
		libtcod.struct_add_flag(suffix_type_struct, 'shield')
		libtcod.struct_add_flag(suffix_type_struct, 'weapon')
		libtcod.struct_add_flag(suffix_type_struct, 'ring')
		libtcod.struct_add_flag(suffix_type_struct, 'potion')
		libtcod.struct_add_flag(suffix_type_struct, 'heal_health')
		libtcod.struct_add_flag(suffix_type_struct, 'heal_mana')
		libtcod.struct_add_flag(suffix_type_struct, 'heal_stamina')
		libtcod.struct_add_flag(suffix_type_struct, 'protect')
		libtcod.struct_add_flag(suffix_type_struct, 'regenerate')
		libtcod.struct_add_flag(suffix_type_struct, 'resist_fire')
		libtcod.struct_add_flag(suffix_type_struct, 'resist_ice')
		libtcod.struct_add_flag(suffix_type_struct, 'resist_poison')
		libtcod.struct_add_flag(suffix_type_struct, 'health_bonus1')
		libtcod.struct_add_flag(suffix_type_struct, 'mana_bonus1')
		libtcod.struct_add_flag(suffix_type_struct, 'stamina_bonus1')
		libtcod.struct_add_flag(suffix_type_struct, 'str_bonus')
		libtcod.struct_add_flag(suffix_type_struct, 'dex_bonus')
		libtcod.struct_add_flag(suffix_type_struct, 'int_bonus')
		libtcod.struct_add_flag(suffix_type_struct, 'wis_bonus')
		libtcod.struct_add_flag(suffix_type_struct, 'end_bonus')
		libtcod.parser_run(parser, 'data/suffix.txt', SuffixListener())
 def __init__(self, logger):
     self.parser = libtcod.parser_new()
     self.object_type = libtcod.parser_new_struct(self.parser, 'object_type')
     self.option_struct = libtcod.parser_new_struct(self.parser, 'option_struct')
     self.object_list = []
     self.logger = logger
     self.logger.log.info('Creating content parser.')
Beispiel #5
0
	def init_parser(self):
		parser = libtcod.parser_new()
		monster_type_struct = libtcod.parser_new_struct(parser, 'monster_type')
		libtcod.struct_add_property(monster_type_struct, 'type', libtcod.TYPE_STRING, True)
		libtcod.struct_add_property(monster_type_struct, 'unidentified_name', libtcod.TYPE_STRING, True)
		libtcod.struct_add_property(monster_type_struct, 'icon', libtcod.TYPE_STRING, True)
		libtcod.struct_add_property(monster_type_struct, 'icon_color', libtcod.TYPE_COLOR, True)
		libtcod.struct_add_property(monster_type_struct, 'icon_color2', libtcod.TYPE_COLOR, False)
		libtcod.struct_add_property(monster_type_struct, 'icon_color3', libtcod.TYPE_COLOR, False)
		libtcod.struct_add_property(monster_type_struct, 'icon_color4', libtcod.TYPE_COLOR, False)
		libtcod.struct_add_property(monster_type_struct, 'icon_color5', libtcod.TYPE_COLOR, False)
		libtcod.struct_add_property(monster_type_struct, 'dark_color', libtcod.TYPE_COLOR, True)
		libtcod.struct_add_property(monster_type_struct, 'level', libtcod.TYPE_INT, True)
		libtcod.struct_add_property(monster_type_struct, 'health', libtcod.TYPE_DICE, True)
		libtcod.struct_add_property(monster_type_struct, 'attack_rating', libtcod.TYPE_INT, True)
		libtcod.struct_add_property(monster_type_struct, 'defense_rating', libtcod.TYPE_INT, True)
		libtcod.struct_add_property(monster_type_struct, 'damage', libtcod.TYPE_DICE, True)
		libtcod.struct_add_property(monster_type_struct, 'article', libtcod.TYPE_STRING, True)
		libtcod.struct_add_property(monster_type_struct, 'weight', libtcod.TYPE_INT, False)
		libtcod.struct_add_property(monster_type_struct, 'corpse', libtcod.TYPE_INT, False)
		libtcod.struct_add_flag(monster_type_struct, 'ai_friendly')
		libtcod.struct_add_flag(monster_type_struct, 'ai_neutral')
		libtcod.struct_add_flag(monster_type_struct, 'ai_hostile')
		libtcod.struct_add_flag(monster_type_struct, 'identified')
		libtcod.struct_add_flag(monster_type_struct, 'all')
		libtcod.struct_add_flag(monster_type_struct, 'overworld')
		libtcod.struct_add_flag(monster_type_struct, 'underground')
		libtcod.struct_add_flag(monster_type_struct, 'dungeon')
		libtcod.struct_add_flag(monster_type_struct, 'cave')
		libtcod.struct_add_flag(monster_type_struct, 'maze')
		libtcod.struct_add_flag(monster_type_struct, 'land')
		libtcod.struct_add_flag(monster_type_struct, 'flying')
		libtcod.struct_add_flag(monster_type_struct, 'aquatic')
		libtcod.parser_run(parser, 'data/monsters.txt', MonsterListener())
Beispiel #6
0
 def __init__(self, logger):
     self.parser = libtcod.parser_new()
     self.object_type = libtcod.parser_new_struct(self.parser,
                                                  'object_type')
     self.option_struct = libtcod.parser_new_struct(self.parser,
                                                    'option_struct')
     self.object_list = []
     self.logger = logger
     self.logger.log.info('Creating content parser.')
def loadObjectData():
	'''LOAD OBJECT DATA reads the CFG files in the data folder to build dictionaries
	of monsters, items, and name generation data.'''
	parser = libtcod.parser_new()

	#Use the parser to read data for monsters.
	monsterStruct = libtcod.parser_new_struct(parser, "monster")
	libtcod.struct_add_property(monsterStruct, "name", libtcod.TYPE_STRING, True)
	libtcod.struct_add_property(monsterStruct, "glyph", libtcod.TYPE_CHAR, True)
	libtcod.struct_add_property(monsterStruct, "col", libtcod.TYPE_COLOR, True)
	libtcod.struct_add_property(monsterStruct, "dsc", libtcod.TYPE_STRING, True)
	libtcod.struct_add_property(monsterStruct, "tier", libtcod.TYPE_INT, True)
	libtcod.struct_add_property(monsterStruct, "hp", libtcod.TYPE_INT, True)
	libtcod.struct_add_property(monsterStruct, "atk", libtcod.TYPE_INT, True)
	libtcod.struct_add_property(monsterStruct, "dfn", libtcod.TYPE_INT, True)
	libtcod.struct_add_property(monsterStruct, "min", libtcod.TYPE_INT, True)
	libtcod.struct_add_property(monsterStruct, "max", libtcod.TYPE_INT, True)
	libtcod.struct_add_property(monsterStruct, "xp", libtcod.TYPE_INT, True)
	libtcod.struct_add_property(monsterStruct, "deathEffect", libtcod.TYPE_STRING, False)

	libtcod.parser_run(parser, os.path.join('data', 'monster.cfg'), MonsterReader())
	if option_debug:
		print "The current contents of rawMonsterData, outside of the parsing operation, are..."
		print rawMonsterData.items()

	#Use the parser to read data for items.
	itemStruct = libtcod.parser_new_struct(parser, "item")
	libtcod.struct_add_property(itemStruct, "name", libtcod.TYPE_STRING, True)
	libtcod.struct_add_property(itemStruct, "kind", libtcod.TYPE_STRING, True)
	libtcod.struct_add_property(itemStruct, "col", libtcod.TYPE_COLOR, True)
	libtcod.struct_add_property(itemStruct, "dsc", libtcod.TYPE_STRING, True)
	libtcod.struct_add_property(itemStruct, "bloat", libtcod.TYPE_INT, False)
	libtcod.struct_add_property(itemStruct, "rarity", libtcod.TYPE_INT, True)
	libtcod.struct_add_property(itemStruct, "useEffect", libtcod.TYPE_STRING, False)
	#libtcod.struct_add_property(itemStruct, "slot", libtcod.TYPE_STRING, False)

	libtcod.parser_run(parser, os.path.join('data', 'item.cfg'), ItemReader())
	if option_debug:
		print "The current contents of rawItemData, outside of the parsing operation, are..."
		print rawItemData.items()

	#Load the name generation data.
	for file in os.listdir('data/name'):
		if file.find('.cfg') > 0:
			libtcod.namegen_parse(os.path.join('data', 'name', file))
	rawNameSets = libtcod.namegen_get_sets()
Beispiel #8
0
	def init_parser(self):
		parser = libtcod.parser_new()
		item_type_struct = libtcod.parser_new_struct(parser, 'item_type')
		libtcod.struct_add_property(item_type_struct, 'type', libtcod.TYPE_STRING, True)
		libtcod.struct_add_property(item_type_struct, 'plural', libtcod.TYPE_STRING, True)
		libtcod.struct_add_property(item_type_struct, 'icon', libtcod.TYPE_STRING, True)
		libtcod.struct_add_property(item_type_struct, 'icon_color', libtcod.TYPE_COLOR, True)
		libtcod.struct_add_property(item_type_struct, 'dark_color', libtcod.TYPE_COLOR, True)
		libtcod.struct_add_property(item_type_struct, 'level', libtcod.TYPE_INT, True)
		libtcod.struct_add_property(item_type_struct, 'weight', libtcod.TYPE_FLOAT, False)
		libtcod.struct_add_property(item_type_struct, 'cost', libtcod.TYPE_INT, False)
		libtcod.struct_add_property(item_type_struct, 'dices', libtcod.TYPE_DICE, False)
		libtcod.struct_add_property(item_type_struct, 'article', libtcod.TYPE_STRING, True)
		libtcod.struct_add_property(item_type_struct, 'charge', libtcod.TYPE_INT, False)
		libtcod.struct_add_property(item_type_struct, 'duration', libtcod.TYPE_INT, False)
		libtcod.struct_add_property(item_type_struct, 'expiration', libtcod.TYPE_INT, False)
		libtcod.struct_add_property(item_type_struct, 'hunger', libtcod.TYPE_INT, False)
		libtcod.struct_add_flag(item_type_struct, 'healing')
		libtcod.struct_add_flag(item_type_struct, 'mana_healing')
		libtcod.struct_add_flag(item_type_struct, 'stamina_healing')
		libtcod.struct_add_flag(item_type_struct, 'usable')
		libtcod.struct_add_flag(item_type_struct, 'equippable')
		libtcod.struct_add_flag(item_type_struct, 'consumable')
		libtcod.struct_add_flag(item_type_struct, 'torchlight')
		libtcod.struct_add_flag(item_type_struct, 'identified')
		libtcod.struct_add_flag(item_type_struct, 'ranged')
		libtcod.struct_add_flag(item_type_struct, 'weapon_dagger')
		libtcod.struct_add_flag(item_type_struct, 'weapon_sword')
		libtcod.struct_add_flag(item_type_struct, 'weapon_mace')
		libtcod.struct_add_flag(item_type_struct, 'weapon_axe')
		libtcod.struct_add_flag(item_type_struct, 'weapon_staff')
		libtcod.struct_add_flag(item_type_struct, 'weapon_polearm')
		libtcod.struct_add_flag(item_type_struct, 'weapon_bow')
		libtcod.struct_add_flag(item_type_struct, 'weapon_missile')
		libtcod.struct_add_flag(item_type_struct, 'armor_shield')
		libtcod.struct_add_flag(item_type_struct, 'armor_head')
		libtcod.struct_add_flag(item_type_struct, 'armor_cloak')
		libtcod.struct_add_flag(item_type_struct, 'armor_body')
		libtcod.struct_add_flag(item_type_struct, 'armor_hands')
		libtcod.struct_add_flag(item_type_struct, 'armor_feet')
		libtcod.struct_add_flag(item_type_struct, 'armor_ring')
		libtcod.struct_add_flag(item_type_struct, 'missile_arrow')
		libtcod.struct_add_flag(item_type_struct, 'missile_stone')
		libtcod.struct_add_flag(item_type_struct, 'corpse')
		libtcod.parser_run(parser, 'data/items.txt', BaseItemListener())
Beispiel #9
0
	def init_parser(self):
		parser = libtcod.parser_new()
		tile_type_struct = libtcod.parser_new_struct(parser, 'tile_type')
		libtcod.struct_add_property(tile_type_struct, 'type', libtcod.TYPE_STRING, True)
		libtcod.struct_add_property(tile_type_struct, 'icon', libtcod.TYPE_STRING, True)
		libtcod.struct_add_property(tile_type_struct, 'icon_color_h', libtcod.TYPE_COLOR, True)
		libtcod.struct_add_property(tile_type_struct, 'icon_color_l', libtcod.TYPE_COLOR, False)
		libtcod.struct_add_property(tile_type_struct, 'back_color_h', libtcod.TYPE_COLOR, False)
		libtcod.struct_add_property(tile_type_struct, 'back_color_l', libtcod.TYPE_COLOR, False)
		libtcod.struct_add_property(tile_type_struct, 'article', libtcod.TYPE_STRING, True)
		libtcod.struct_add_flag(tile_type_struct, 'blocked')
		libtcod.struct_add_flag(tile_type_struct, 'block_sight')
		libtcod.struct_add_flag(tile_type_struct, 'animate')
		libtcod.struct_add_flag(tile_type_struct, 'invisible')
		libtcod.struct_add_flag(tile_type_struct, 'locked')
		libtcod.struct_add_flag(tile_type_struct, 'trapped')
		libtcod.struct_add_flag(tile_type_struct, 'fx_teleport')
		libtcod.struct_add_flag(tile_type_struct, 'fx_stuck')
		libtcod.struct_add_flag(tile_type_struct, 'fx_poison_gas')
		libtcod.struct_add_flag(tile_type_struct, 'fx_sleep_gas')
		libtcod.struct_add_flag(tile_type_struct, 'fx_fireball')
		libtcod.struct_add_flag(tile_type_struct, 'fx_arrow')
		libtcod.struct_add_flag(tile_type_struct, 'fx_needle')
		libtcod.parser_run(parser, 'data/tiles.txt', TileListener())
                    for value in values:

                        setting_data[name][key] = value


    def error(self, msg):
        """ Reads out errors. """

        print('error : ', msg)

        return True


# Parser for game data.
# Create parser.
parser = roguelib.parser_new()

# Create structs
tile_type_struct = roguelib.parser_new_struct(parser, b'tile')

# Add properties.
# Tile properties.
roguelib.struct_add_property(tile_type_struct, b'IMAGE', roguelib.TYPE_CHAR, True)
roguelib.struct_add_property(tile_type_struct, b'SOLID', roguelib.TYPE_BOOL, True)
roguelib.struct_add_property(tile_type_struct, b'BLOCKS_SIGHT', roguelib.TYPE_BOOL, True)
roguelib.struct_add_property(tile_type_struct, b'ALWAYS_VISIBLE', roguelib.TYPE_BOOL, True)
roguelib.struct_add_property(tile_type_struct, b'COLOR', roguelib.TYPE_STRING, True)
roguelib.struct_add_property(tile_type_struct, b'DESCRIPTION', roguelib.TYPE_STRING, True)

# Reset listener properties.
CURRENT_PROPERTIES = []
Beispiel #11
0
                    for value in values:

                        setting_data[name][key] = value

    def error(self, msg):
        """ Reads out errors. """

        print('error : ', msg)

        return True


# Parser for game data.
# Create parser.
parser = roguelib.parser_new()

# Create structs
tile_type_struct = roguelib.parser_new_struct(parser, b'tile')

# Add properties.
# Tile properties.
roguelib.struct_add_property(tile_type_struct, b'IMAGE', roguelib.TYPE_CHAR,
                             True)
roguelib.struct_add_property(tile_type_struct, b'SOLID', roguelib.TYPE_BOOL,
                             True)
roguelib.struct_add_property(tile_type_struct, b'BLOCKS_SIGHT',
                             roguelib.TYPE_BOOL, True)
roguelib.struct_add_property(tile_type_struct, b'ALWAYS_VISIBLE',
                             roguelib.TYPE_BOOL, True)
roguelib.struct_add_property(tile_type_struct, b'COLOR', roguelib.TYPE_STRING,
Beispiel #12
0
        return True
        
    def error(self,msg):
        """ Reads out errors. """
        
        print 'error : ', msg
        return True
  
  
#############################################
# Data parser.
#############################################


# Create parser.
parser = lib.parser_new()

# Create structs
tile_type_struct = lib.parser_new_struct(parser, 'tile')
item_type_struct = lib.parser_new_struct(parser, 'item')
npc_type_struct = lib.parser_new_struct(parser, 'npc')
spell_type_struct = lib.parser_new_struct(parser, 'spell')
race_type_struct = lib.parser_new_struct(parser, 'race')
history_type_struct = lib.parser_new_struct(parser, 'history')
gender_type_struct = lib.parser_new_struct(parser, 'gender')
names_type_struct = lib.parser_new_struct(parser, 'names')
player_type_struct = lib.parser_new_struct(parser, 'player')

# Add flags.
lib.struct_add_flag(tile_type_struct, 'abstract')