def loadMenu(id, parent = None): definition = wolfpack.getdefinition(WPDT_MENU, id) if not definition: if parent: console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id)) else: console.log(LOG_ERROR, "Unknown menu: %s.\n" % id) return name = definition.getattribute('name', '') menu = TailoringMenu(id, parent, name) # See if we have any submenus for i in range(0, definition.childcount): child = definition.getchild(i) # Submenu if child.name == 'menu': if not child.hasattribute('id'): console.log(LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id) else: loadMenu(child.getattribute('id'), menu) # Craft an item elif child.name in ['tailor', 'setailor']: if not child.hasattribute('definition'): console.log(LOG_ERROR, "Tailor action without definition in menu %s.\n" % menu.id) else: itemdef = child.getattribute('definition') try: # See if we can find an item id if it's not given if not child.hasattribute('itemid'): item = wolfpack.getdefinition(WPDT_ITEM, itemdef) itemid = 0 if item: itemchild = item.findchild('id') if itemchild: itemid = itemchild.value else: console.log(LOG_ERROR, "Tailor action with invalid definition %s in menu %s.\n" % (itemdef, menu.id)) else: itemid = hex2dec(child.getattribute('itemid', '0')) if child.hasattribute('name'): name = child.getattribute('name') else: name = generateNamefromDef(itemdef) if child.name == 'setailor': action = SeTailorItemAction(menu, name, int(itemid), itemdef) else: action = TailorItemAction(menu, name, int(itemid), itemdef) except: console.log(LOG_ERROR, "Tailor action with invalid item id in menu %s.\n" % menu.id) # Process subitems for j in range(0, child.childcount): subchild = child.getchild(j) action.processnode(subchild, menu) # Sort the menu. This is important for the makehistory to make. menu.sort()
def loadMenu(id, parent = None): definition = wolfpack.getdefinition(WPDT_MENU, id) if not definition: if parent: console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id)) else: console.log(LOG_ERROR, "Unknown menu: %s.\n" % id) return name = definition.getattribute('name', '') menu = GlassblowingMenu(id, parent, name) # See if we have any submenus for i in range(0, definition.childcount): child = definition.getchild(i) # Submenu if child.name == 'menu': if not child.hasattribute('id'): console.log(LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id) else: loadMenu(child.getattribute('id'), menu) # Craft an item elif child.name == 'glassblowing': if not child.hasattribute('definition'): console.log(LOG_ERROR, "Glassblowing action without definition in menu %s.\n" % menu.id) else: itemdef = child.getattribute('definition') try: # See if we can find an item id if it's not given if not child.hasattribute('itemid'): item = wolfpack.getdefinition(WPDT_ITEM, itemdef) itemid = 0 if item: itemchild = item.findchild('id') if itemchild: itemid = itemchild.value else: itemid = hex2dec(child.getattribute('itemid', '0')) if child.hasattribute('name'): name = child.getattribute('name') else: name = generateNamefromDef(itemdef) action = GlassblowerItemAction(menu, name, int(itemid), itemdef) except: console.log(LOG_ERROR, "Glassblowing action with invalid item id in menu %s.\n" % menu.id) # Process subitems for j in range(0, child.childcount): subchild = child.getchild(j) action.processnode(subchild, menu) # Sort the menu. This is important for the makehistory to make. menu.sort()
def loadMenu(id, parent = None): definition = wolfpack.getdefinition(WPDT_MENU, id) if not definition: if parent: console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id)) else: console.log(LOG_ERROR, "Unknown menu: %s.\n" % id) return name = definition.getattribute('name', '') menu = AlchemyMenu(id, parent, name) # See if we have any submenus for i in range(0, definition.childcount): child = definition.getchild(i) # Submenu if child.name == 'menu': if not child.hasattribute('id'): console.log(LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id) else: loadMenu(child.getattribute('id'), menu) # Craft an item elif child.name == 'craft': if not child.hasattribute('definition'): console.log(LOG_ERROR, "craft action without definition in menu %s.\n" % menu.id) else: itemdef = child.getattribute('definition') try: # See if we can find an item id if it's not given if not child.hasattribute('itemid'): item = wolfpack.getdefinition(WPDT_ITEM, itemdef) itemid = 0 if item: itemchild = item.findchild('id') if itemchild: itemid = itemchild.value else: itemid = hex2dec(child.getattribute('itemid', '0')) except Exception, e: console.log(LOG_ERROR, "Craft action with invalid item id in menu %s: %s\n" % (menu.id, str(e))) if child.hasattribute('name'): name = child.getattribute('name') else: name = generateNamefromDef(itemdef) action = BrewItemAction(menu, name, int(itemid), itemdef) # Process subitems for j in range(0, child.childcount): subchild = child.getchild(j) # Normal Material if subchild.name == 'material': if not subchild.hasattribute('id'): console.log(LOG_ERROR, "Material element without id list in menu %s.\n" % menu.id) break else: ids = subchild.getattribute('id').split(';') try: amount = hex2dec(subchild.getattribute('amount', '1')) materialname = subchild.getattribute('name', 'Unknown') except: console.log(LOG_ERROR, "Material element with invalid id list in menu %s.\n" % menu.id) break action.materials.append([ids, amount, materialname]) # Skill requirement elif subchild.name in skillnamesids: skill = skillnamesids[subchild.name] try: minimum = hex2dec(subchild.getattribute('min', '0')) except: console.log(LOG_ERROR, "%s element with invalid min value in menu %s.\n" % (subchild.name, menu.id)) try: maximum = hex2dec(subchild.getattribute('max', '1200')) except: console.log(LOG_ERROR, "%s element with invalid max value in menu %s.\n" % (subchild.name, menu.id)) action.skills[skill] = [minimum, maximum]
def loadMenu(id, parent=None): definition = wolfpack.getdefinition(WPDT_MENU, id) if not definition: if parent: console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id)) else: console.log(LOG_ERROR, "Unknown menu: %s.\n" % id) return name = definition.getattribute('name', '') menu = CartographyMenu(id, parent, name) # See if we have any submenus for i in range(0, definition.childcount): child = definition.getchild(i) # Submenu if child.name == 'menu': if not child.hasattribute('id'): console.log( LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id) else: loadMenu(child.getattribute('id'), menu) # Craft an item elif child.name == 'craft': if not child.hasattribute('definition'): console.log( LOG_ERROR, "craft action without definition in menu %s.\n" % menu.id) else: itemdef = child.getattribute('definition') try: # See if we can find an item id if it's not given if not child.hasattribute('itemid'): item = wolfpack.getdefinition(WPDT_ITEM, itemdef) itemid = 0 if item: itemchild = item.findchild('id') if itemchild: itemid = itemchild.value else: itemid = hex2dec(child.getattribute('itemid', '0')) except Exception, e: console.log( LOG_ERROR, "Craft action with invalid item id in menu %s: %s\n" % (menu.id, str(e))) if child.hasattribute('name'): name = child.getattribute('name') else: name = generateNamefromDef(itemdef) action = CartItemAction(menu, name, int(itemid), itemdef) # Process subitems for j in range(0, child.childcount): subchild = child.getchild(j) # Normal Material if subchild.name == 'material': if not subchild.hasattribute('id'): console.log( LOG_ERROR, "Material element without id list in menu %s.\n" % menu.id) break else: ids = subchild.getattribute('id').split(';') try: amount = hex2dec( subchild.getattribute('amount', '1')) materialname = subchild.getattribute( 'name', 'Unknown') except: console.log( LOG_ERROR, "Material element with invalid id list in menu %s.\n" % menu.id) break action.materials.append( [ids, amount, materialname]) # Skill requirement elif subchild.name in skillnamesids: skill = skillnamesids[subchild.name] try: minimum = hex2dec(subchild.getattribute( 'min', '0')) except: console.log( LOG_ERROR, "%s element with invalid min value in menu %s.\n" % (subchild.name, menu.id)) try: maximum = hex2dec( subchild.getattribute('max', '1200')) except: console.log( LOG_ERROR, "%s element with invalid max value in menu %s.\n" % (subchild.name, menu.id)) action.skills[skill] = [minimum, maximum]
def loadMenu(id, parent = None): definition = wolfpack.getdefinition(WPDT_MENU, id) if not definition: if parent: console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id)) else: console.log(LOG_ERROR, "Unknown menu: %s.\n" % id) return name = definition.getattribute('name', '') menu = CarpentryMenu(id, parent, name) # See if we have any submenus for i in range(0, definition.childcount): child = definition.getchild(i) # Submenu if child.name == 'menu': if not child.hasattribute('id'): console.log(LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id) else: menuid = child.getattribute('id') # Don't show boards menu for simple carpentry if extended_carpentry or menuid != 'CARPENTRY_BOARDS': loadMenu( menuid, menu ) # Craft an item elif child.name in ['carpenter', 'secarpenter']: if not child.hasattribute('definition'): console.log(LOG_ERROR, "Carpenter action without definition in menu %s.\n" % menu.id) else: itemdef = child.getattribute('definition') try: # See if we can find an item id if it's not given if not child.hasattribute('itemid'): item = wolfpack.getdefinition(WPDT_ITEM, itemdef) itemid = 0 if item: itemchild = item.findchild('id') if itemchild: itemid = itemchild.value else: console.log(LOG_ERROR, "Carpenter action with invalid definition %s in menu %s.\n" % (itemdef, menu.id)) else: itemid = hex2dec(child.getattribute('itemid', '0')) if child.hasattribute('name'): name = child.getattribute('name') else: name = generateNamefromDef(itemdef) if child.name == 'secarpenter': action = SeCarpItemAction(menu, name, int(itemid), itemdef) else: action = CarpItemAction(menu, name, int(itemid), itemdef) except: console.log(LOG_ERROR, "Carpenter action with invalid item id in menu %s.\n" % menu.id) # Process subitems for j in range(0, child.childcount): subchild = child.getchild(j) # How much of the primary resource should be consumed if subchild.name == 'boards': action.submaterial1 = hex2dec(subchild.getattribute('amount', '0')) # How much of the secondary resource should be consumed if subchild.name == 'ingots': action.submaterial2 = hex2dec(subchild.getattribute('amount', '0')) # Normal Material if subchild.name == 'wood' or subchild.name == 'cloth' or subchild.name == 'material': if not subchild.hasattribute('id'): console.log(LOG_ERROR, "Material element without id list in menu %s.\n" % menu.id) break else: ids = subchild.getattribute('id').split(';') try: amount = hex2dec(subchild.getattribute('amount', '1')) materialname = subchild.getattribute('name', 'Unknown') except: console.log(LOG_ERROR, "Material element with invalid id list in menu %s.\n" % menu.id) break action.materials.append([ids, amount, materialname]) # Consume all available materials scaled by the # amount of each submaterial elif subchild.name == 'stackable': action.stackable = True elif subchild.name == 'nomark': action.markable = False elif subchild.name == 'noretaincolor': action.retaincolor = False # Skill requirement elif subchild.name in skillnamesids: skill = skillnamesids[subchild.name] try: minimum = hex2dec(subchild.getattribute('min', '0')) except: console.log(LOG_ERROR, "%s element with invalid min value in menu %s.\n" % (subchild.name, menu.id)) try: maximum = hex2dec(subchild.getattribute('max', '1200')) except: console.log(LOG_ERROR, "%s element with invalid max value in menu %s.\n" % (subchild.name, menu.id)) action.skills[skill] = [minimum, maximum] # Sort the menu. This is important for the makehistory to make. menu.sort()
def loadMenu(id, parent=None): definition = getdefinition(WPDT_MENU, id) if not definition: if parent: console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id)) else: console.log(LOG_ERROR, "Unknown menu: %s.\n" % id) return name = definition.getattribute('name', '') menu = BowcraftMenu(id, parent, name) # See if we have any submenus for i in range(0, definition.childcount): child = definition.getchild(i) # Submenu if child.name == 'menu': if not child.hasattribute('id'): console.log( LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id) else: loadMenu(child.getattribute('id'), menu) # Craft an item elif child.name in ['fletch', 'sefletch']: if not child.hasattribute('definition'): console.log( LOG_ERROR, "Bowcraft action without definition in menu %s.\n" % menu.id) else: itemdef = child.getattribute('definition') try: # See if we can find an item id if it's not given if not child.hasattribute('itemid'): item = getdefinition(WPDT_ITEM, itemdef) itemid = 0 if item: itemchild = item.findchild('id') if itemchild: itemid = itemchild.value else: console.log( LOG_ERROR, "Bowcraft action with invalid definition %s in menu %s.\n" % (itemdef, menu.id)) else: itemid = hex2dec(child.getattribute('itemid', '0')) if child.hasattribute('name'): name = child.getattribute('name') else: name = generateNamefromDef(itemdef) if child.name == 'sefletch': action = SeFletchItemAction(menu, name, int(itemid), itemdef) else: action = FletchItemAction(menu, name, int(itemid), itemdef) except: console.log( LOG_ERROR, "Bowcraft action with invalid item id in menu %s.\n" % menu.id) # Process subitems for j in range(0, child.childcount): subchild = child.getchild(j) # How much of the primary resource should be consumed if subchild.name == 'logs': action.submaterial1 = hex2dec( subchild.getattribute('amount', '0')) # Normal Material if subchild.name == 'material': if not subchild.hasattribute('id'): console.log( LOG_ERROR, "Material element without id list in menu %s.\n" % menu.id) break else: ids = subchild.getattribute('id').split(';') try: amount = hex2dec( subchild.getattribute('amount', '1')) materialname = subchild.getattribute( 'name', 'Unknown') except: console.log( LOG_ERROR, "Material element with invalid id list in menu %s.\n" % menu.id) break action.materials.append( [ids, amount, materialname]) # Consume all available materials scaled by the # amount of each submaterial elif subchild.name == 'stackable': action.stackable = True # This item will never be exceptional elif subchild.name == 'nomark': action.markable = False # Skill requirement elif subchild.name in skillnamesids: skill = skillnamesids[subchild.name] try: minimum = hex2dec(subchild.getattribute( 'min', '0')) except: console.log( LOG_ERROR, "%s element with invalid min value in menu %s.\n" % (subchild.name, menu.id)) try: maximum = hex2dec( subchild.getattribute('max', '1200')) except: console.log( LOG_ERROR, "%s element with invalid max value in menu %s.\n" % (subchild.name, menu.id)) try: penalty = hex2dec( subchild.getattribute('penalty', '0')) except: console.log( LOG_ERROR, "%s element with invalid penalty value in menu %s.\n" % (subchild.name, menu.id)) action.skills[skill] = [minimum, maximum, penalty] # Sort the menu. This is important for the makehistory to make. menu.sort()
def loadMenu(id, parent = None): definition = wolfpack.getdefinition(WPDT_MENU, id) if not definition: if parent: console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id)) else: console.log(LOG_ERROR, "Unknown menu: %s.\n" % id) return name = definition.getattribute('name', '') menu = TinkeringMenu(id, parent, name) # See if we have any submenus for i in range(0, definition.childcount): child = definition.getchild(i) # Submenu if child.name == 'menu': if not child.hasattribute('id'): console.log(LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id) else: loadMenu(child.getattribute('id'), menu) # Craft an item elif child.name in ['tinker', 'setinker']: if not child.hasattribute('definition'): console.log(LOG_ERROR, "Tinker action without definition in menu %s.\n" % menu.id) else: itemdef = child.getattribute('definition') try: # See if we can find an item id if it's not given if not child.hasattribute('itemid'): item = wolfpack.getdefinition(WPDT_ITEM, itemdef) itemid = 0 if item: itemchild = item.findchild('id') if itemchild: itemid = itemchild.value else: itemid = hex2dec(child.getattribute('itemid', '0')) if child.hasattribute('name'): name = child.getattribute('name') else: name = generateNamefromDef(itemdef) if child.name == 'setinker': action = SeTinkerItemAction(menu, name, int(itemid), itemdef) else: action = TinkerItemAction(menu, name, int(itemid), itemdef) except: console.log(LOG_ERROR, "Tinker action with invalid item id in menu %s.\n" % menu.id) # Process subitems for j in range(0, child.childcount): subchild = child.getchild(j) # How much of the primary resource should be consumed if subchild.name == 'ingots': action.submaterial1 = hex2dec(subchild.getattribute('amount', '0')) elif subchild.name == 'gems': action.submaterial2 = hex2dec(subchild.getattribute('amount', '0')) # Standard material elif subchild.name == 'logs': amount = hex2dec(subchild.getattribute('amount', '0')) materialname = subchild.getattribute('name', 'Unknown') action.materials.append([['1bdd','1bde','1bdf','1be0','1be1','1be2','1bd7','1bd8','1bd9','1bda','1bdb','1bdc'], amount, 'Boards, Logs']) # Consume all available materials scaled by the # amount of each submaterial elif subchild.name == 'stackable': action.stackable = 1 elif subchild.name == 'nomark': action.markable = 0 elif subchild.name == 'retaincolor': action.retaincolor = 1 # Normal Material elif subchild.name == 'material': if not subchild.hasattribute('id'): console.log(LOG_ERROR, "Material element without id list in menu %s.\n" % menu.id) break else: ids = subchild.getattribute('id').split(';') try: amount = hex2dec(subchild.getattribute('amount', '1')) materialname = subchild.getattribute('name', 'Unknown') except: console.log(LOG_ERROR, "Material element with invalid id list in menu %s.\n" % menu.id) break action.materials.append([ids, amount, materialname]) # Skill requirement elif subchild.name in skillnamesids: skill = skillnamesids[subchild.name] try: minimum = hex2dec(subchild.getattribute('min', '0')) except: console.log(LOG_ERROR, "%s element with invalid min value in menu %s.\n" % (subchild.name, menu.id)) try: maximum = hex2dec(subchild.getattribute('max', '1200')) except: console.log(LOG_ERROR, "%s element with invalid max value in menu %s.\n" % (subchild.name, menu.id)) try: penalty = hex2dec(subchild.getattribute('penalty','0')) except: console.log(LOG_ERROR, "%s element with invalid max value in menu %s.\n" % (subchild.name, menu.id)) action.skills[skill] = [minimum, maximum, penalty] # Sort the menu. This is important for the makehistory to make. menu.sort()
def loadMenu(id, parent=None): definition = wolfpack.getdefinition(WPDT_MENU, id) if not definition: if parent: console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id)) else: console.log(LOG_ERROR, "Unknown menu: %s.\n" % id) return name = definition.getattribute('name', '') menu = CarpentryMenu(id, parent, name) # See if we have any submenus for i in range(0, definition.childcount): child = definition.getchild(i) # Submenu if child.name == 'menu': if not child.hasattribute('id'): console.log( LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id) else: menuid = child.getattribute('id') # Don't show boards menu for simple carpentry if extended_carpentry or menuid != 'CARPENTRY_BOARDS': loadMenu(menuid, menu) # Craft an item elif child.name in ['carpenter', 'secarpenter']: if not child.hasattribute('definition'): console.log( LOG_ERROR, "Carpenter action without definition in menu %s.\n" % menu.id) else: itemdef = child.getattribute('definition') try: # See if we can find an item id if it's not given if not child.hasattribute('itemid'): item = wolfpack.getdefinition(WPDT_ITEM, itemdef) itemid = 0 if item: itemchild = item.findchild('id') if itemchild: itemid = itemchild.value else: console.log( LOG_ERROR, "Carpenter action with invalid definition %s in menu %s.\n" % (itemdef, menu.id)) else: itemid = hex2dec(child.getattribute('itemid', '0')) if child.hasattribute('name'): name = child.getattribute('name') else: name = generateNamefromDef(itemdef) if child.name == 'secarpenter': action = SeCarpItemAction(menu, name, int(itemid), itemdef) else: action = CarpItemAction(menu, name, int(itemid), itemdef) except: console.log( LOG_ERROR, "Carpenter action with invalid item id in menu %s.\n" % menu.id) # Process subitems for j in range(0, child.childcount): subchild = child.getchild(j) # How much of the primary resource should be consumed if subchild.name == 'boards': action.submaterial1 = hex2dec( subchild.getattribute('amount', '0')) # How much of the secondary resource should be consumed if subchild.name == 'ingots': action.submaterial2 = hex2dec( subchild.getattribute('amount', '0')) # Normal Material if subchild.name == 'wood' or subchild.name == 'cloth' or subchild.name == 'material': if not subchild.hasattribute('id'): console.log( LOG_ERROR, "Material element without id list in menu %s.\n" % menu.id) break else: ids = subchild.getattribute('id').split(';') try: amount = hex2dec( subchild.getattribute('amount', '1')) materialname = subchild.getattribute( 'name', 'Unknown') except: console.log( LOG_ERROR, "Material element with invalid id list in menu %s.\n" % menu.id) break action.materials.append( [ids, amount, materialname]) # Consume all available materials scaled by the # amount of each submaterial elif subchild.name == 'stackable': action.stackable = True elif subchild.name == 'nomark': action.markable = False elif subchild.name == 'noretaincolor': action.retaincolor = False # Skill requirement elif subchild.name in skillnamesids: skill = skillnamesids[subchild.name] try: minimum = hex2dec(subchild.getattribute( 'min', '0')) except: console.log( LOG_ERROR, "%s element with invalid min value in menu %s.\n" % (subchild.name, menu.id)) try: maximum = hex2dec( subchild.getattribute('max', '1200')) except: console.log( LOG_ERROR, "%s element with invalid max value in menu %s.\n" % (subchild.name, menu.id)) action.skills[skill] = [minimum, maximum] # Sort the menu. This is important for the makehistory to make. menu.sort()