diff --git a/resources/parsers/accessories.py b/resources/parsers/accessories.py index e2603c02a9b9de190df8964ac42b037ba9373ceb..22a44ad2bd7b7626a77d60f3c392706d207544ed 100644 --- a/resources/parsers/accessories.py +++ b/resources/parsers/accessories.py @@ -7,7 +7,7 @@ import json # User Imports. from resources import logging as init_logging -from resources.data.value_dictionary import filter_dict +from resources.data.value_dictionary import display_dict, filter_dict from resources.parsers.templates import FilterTemplates @@ -43,7 +43,7 @@ class AccessoryParser(): self.parse_belts() self.parse_rings() - def handle_accessory(self, item, exception_list): + def handle_accessory(self, item, exception_list, background_color): """ Creates filtering for passed accessory. :param item: Accessory item to determine filtering on. @@ -71,9 +71,18 @@ class AccessoryParser(): if self.debug: logger.info('Not hidden: {0}'.format(item['Name'])) - self.template.rare_item(base_text=item['Name']) - self.template.uncommon_item(base_text=item['Name']) - self.template.common_item(base_text=item['Name']) + self.template.rare_item( + base_text=item['Name'], + background_color=background_color, + ) + self.template.uncommon_item( + base_text=item['Name'], + background_color=background_color, + ) + self.template.common_item( + base_text=item['Name'], + background_color=background_color, + ) else: # Accessory set to always hide. @@ -87,14 +96,17 @@ class AccessoryParser(): self.template.rare_item( base_text=item['Name'], item_level='<= {0}'.format(item['DropLevel'] + rare_drop_modifier), + background_color=background_color, ) self.template.uncommon_item( base_text=item['Name'], item_level='<= {0}'.format(item['DropLevel'] + magic_drop_modifier), + background_color=background_color, ) self.template.common_item( base_text=item['Name'], item_level='<= {0}'.format(item['DropLevel'] + normal_drop_modifier), + background_color=background_color, ) def parse_amulets(self): @@ -114,10 +126,28 @@ class AccessoryParser(): logger.info('Handling amulets.') with open('resources/data/accessories/amulets.json', 'r') as json_file: + # Loop through all items in json. json_data = json.load(json_file) for item in json_data: - self.handle_accessory(item, ['Coral Amulet', 'Paua Amulet']) + + # Determine if item should get special background color, based on item type. + background_color = display_dict['standard_background'] + if item['Name'] == 'Amber Amulet': + background_color = display_dict['A'] + elif item['Name'] == 'Jade Amulet': + background_color = display_dict['Ev'] + elif item['Name'] == 'Lapis Amulet': + background_color = display_dict['En'] + elif item['Name'] == 'Agate Amulet': + background_color = display_dict['En/A'] + elif item['Name'] == 'Citrine Amulet': + background_color = display_dict['A/Ev'] + elif item['Name'] == 'Turquoise Amulet': + background_color = display_dict['Ev/En'] + + # Create filter for item. + self.handle_accessory(item, ['Coral Amulet', 'Paua Amulet'], background_color) def parse_belts(self): """ @@ -136,10 +166,26 @@ class AccessoryParser(): logger.info('Handling belts.') with open('resources/data/accessories/belts.json', 'r') as json_file: + # Loop through all items in json. json_data = json.load(json_file) for item in json_data: - self.handle_accessory(item, ['Chain Belt', 'Rustic Sash', 'Leather Belt']) + + # Determine if item should get special background color, based on item type. + background_color = display_dict['standard_background'] + if item['Name'] == 'Chain Belt': + background_color = display_dict['En'] + elif item['Name'] == 'Rustic Sash': + background_color = display_dict['En/A'] + elif item['Name'] == 'Heavy Belt': + background_color = display_dict['A'] + elif item['Name'] == 'Vanguard Belt': + background_color = display_dict['A/Ev'] + elif item['Name'] == 'Crystal Belt': + background_color = display_dict['En'] + + # Create filter for item. + self.handle_accessory(item, ['Chain Belt', 'Rustic Sash', 'Leather Belt'], background_color) def parse_rings(self): """ @@ -158,10 +204,27 @@ class AccessoryParser(): logger.info('Handling rings.') with open('resources/data/accessories/rings.json', 'r') as json_file: + # Loop through all items in json. json_data = json.load(json_file) for item in json_data: + + # Determine if item should get special background color, based on item type. + background_color = display_dict['standard_background'] + if item['Name'] == 'Sapphire Ring': + background_color = display_dict['En'] + elif item['Name'] == 'Topaz Ring': + background_color = display_dict['A/Ev'] + elif item['Name'] == 'Ruby Ring': + background_color = display_dict['A'] + elif item['Name'] == 'Moonstone Ring': + background_color = display_dict['En'] + elif item['Name'] == 'Amethyst Ring': + background_color = display_dict['Ev'] + + # Create filter for item. self.handle_accessory( item, - ['Coral Ring', 'Sapphire Ring', 'Topaz Ring', 'Ruby Ring', 'Two-Stone Ring'] + ['Coral Ring', 'Sapphire Ring', 'Topaz Ring', 'Ruby Ring', 'Two-Stone Ring'], + background_color, )