def get_assembled_parameter_equipslot(params): ''' Handle equipslot params: slotid item ''' slot_list = [] # Couple different otions: (str) for error case, # (int, str) for slot + param, or (int,int,int). # This has already been verified for us. if len(params) == 1: error_param = [p for t,p in params] return error_param elif len(params) == 2: slot, item = [p for t,p in params] check_slot_token(slot) # Decode the slot token. if decode_wow_slot(slot.data): slot.render_desc = decode_wow_slot(slot.data) slot_list = [TxtToken("as your"), slot] else: slot_list = [TxtToken("in equipment slot"), slot] # If we recognize this item, use wowhead to decode it's slot. # This can fail because wowhead data is spotty. if item.found() and item.attrs.param_data_obj.is_item(): # Make sure the slot we request is appropiate. # If not, keep the output as the slot requiested in the # macro, but display a warning with what slot the # item belongs in. if not item.attrs.param_data_obj.test_item_slotid(int(slot.data)): item.error_desc = item.get_render_desc() decoded = decode_wow_slot(slot.data) if not decoded: decoded = '' else: decoded = "(%s)" % decoded # Below changed for now for clarity. item.warn = (WARN_WRONG_SLOT, [item], [slot], [TxtToken(txt=decoded)]) #[TxtToken(txt="%s" % get_wow_slots_for_data(item.slot()))], #[TxtToken(txt="%s" % decode_data_slot(item.slot()))]) # Create and return the description return [TxtToken("your"), item] + slot_list else: slot, bag_id, bag_slot = [p for t,p in params] check_slot_token(slot) if decode_wow_slot(slot.data): slot.render_desc = decode_wow_slot(slot.data) slot_list = [TxtToken("as your"), slot] else: slot_list = [TxtToken("in equipment slot"), slot] bag_id.render_space_after = False return [TxtToken("item from bag"), bag_id, TxtToken(", bag slot"), bag_slot] + slot_list
def get_assembled_parameter_use(params): ''' Handle use params ''' # Couple different otions: (str), (int), (int,int). # This has already been verified for us. if len(params) == 2: bag, slot = [p for t,p in params] bag.render_space_after = False slot.render_space_after = False return [TxtToken("item in bag number"), bag, TxtToken(", bag slot number"), slot] else: item = [p for t,p in params][0] if item.data_type is int: if decode_wow_slot(item.data): item.render_desc = decode_wow_slot(item.data) return [TxtToken("your equipped"), item] else: check_slot_token(item) return [TxtToken("item in slot"), item] return [TxtToken("your"), item]
def get_assembled_parameter_show(params): ''' Handle parameters for #show* commands. ''' # Couple different otions: (str), (int), or (int,int). Parameter # correctness has already been verified for us. if len(params) == 2: bag_id, bag_slot = [p for t,p in params] bag_id.render_space_after = False return [TxtToken("item in bag"), bag_id, TxtToken(", bag slot"), bag_slot] else: param = params[0][1] if param.data_type is int: # Item slot--decode check_slot_token(param) if decode_wow_slot(param.data): param.render_desc = decode_wow_slot(param.data) return [TxtToken("item equipped as your"), param] else: return [TxtToken("item in equipment slot"), param] else: return [param]