def processnode(self, node, menu): global CLOTH if node.name == 'cloth': amount = hex2dec(node.getattribute('amount', '1')) if amount > 0: self.cloth = amount else: CraftItemAction.processnode(self, node, menu)
def processnode(self, node, menu): if node.name == 'needoven': self.needoven = True elif node.name == 'needheat': self.needheat = True elif node.name == 'water': self.water = True else: CraftItemAction.processnode(self, node, menu)
def __init__(self, parent, title, itemid, definition): CraftItemAction.__init__(self, parent, title, itemid, definition) self.needheat = False self.needoven = False self.water = False self.useallres = False self.flour = False self.flouramount = 0 self.markable = 1 # All cooking items are markable, exceptions handled through <nomark /> tag
def __init__(self, parent): CraftItemAction.__init__(self, parent, tr('Runebook'), 0x22c5, '22c5') self.markable = True self.runes = 8 # Add the other requirements self.materials.append([['1f60'], 1, tr('Gate Travel Scrolls')]) self.materials.append([['1f4c'], 1, tr('Recall Scrolls')]) self.skills[INSCRIPTION] = [450, 1250, 250]
def consumematerial(self, player, arguments, half=0): result = CraftItemAction.consumematerial(self, player, arguments, half) if not result: return False if self.flour: result = False content = player.getbackpack().content flours = [] for item in content: if item.baseid in flour and item.hastag('quantity'): flours.append(item) toconsume = self.flouramount while toconsume > 0: for flou in flours: amount = consume(flou, toconsume) toconsume -= amount if toconsume == 0: break # break out of for loop # Check if we have enough water in our backpack if self.water: content = player.getbackpack().content for item in content: if item.hasscript('beverage') and item.gettag( 'fluid') == 'water' and item.hastag('quantity'): if beverage.consume(item): return True player.socket.clilocmessage( 1044253) # You don't have the components needed to make that. return False return result
def consumematerial(self, player, arguments, half=0): result = CraftItemAction.consumematerial(self, player, arguments, half) if result and self.cloth > 0: if half: needed = int(math.ceil(self.cloth / 2)) else: needed = self.cloth assert (len(arguments) >= 2) cloth = wolfpack.finditem(arguments[1]) if not player.canreach(cloth, -1): player.socket.clilocmessage( 1044456) # You don't have any ready cloth... return False elif cloth.amount < needed: player.socket.clilocmessage( 1044287) # You don't have enough... return False # Replace the second argument with the color of the cloth arguments[1] = cloth.color if needed == cloth.amount: cloth.delete() else: cloth.amount -= needed cloth.update() return result
def make(self, player, arguments, nodelay=0): assert(len(arguments) > 0, 'Arguments has to contain a tool reference.') if not checktool(player, wolfpack.finditem(arguments[0])): return False return CraftItemAction.make(self, player, arguments, nodelay)
def make(self, player, arguments, nodelay=0, clothitem=None): global CLOTH # We have not been passed a cloth reference. # Try to statisfy it automatically if self.cloth > 0: if not clothitem: backpack = player.getbackpack() count = 0 # Valid piles of cloth for item in backpack.content: if item.baseid in CLOTH and item.amount >= self.cloth: clothitem = item count += 1 # This makes the user select a pile of cloth if count > 1: player.socket.clilocmessage( 502928) # Which material would you like to work ... player.socket.attachtarget( 'skills.tailoring.ClothSelectResponse', [self, arguments]) return elif count < 1: player.socket.clilocmessage( 1044456) # You don't have any ready cloth return # Pass the clothitem on to the next function as an argument if len(arguments) < 2: arguments.append(clothitem.serial) else: arguments[1] = clothitem.serial return CraftItemAction.make(self, player, arguments, nodelay)
def getmaterialshtml(self, player, arguments): materialshtml = CraftItemAction.getmaterialshtml(self, player, arguments) if self.water: materialshtml += tr("Water: 1<br>") return materialshtml
def consumematerial(self, player, arguments, half = 0): result = CraftItemAction.consumematerial(self, player, arguments, half) if result and self.cloth > 0: if half: needed = int(math.ceil(self.cloth / 2)) else: needed = self.cloth assert(len(arguments) >= 2) cloth = wolfpack.finditem(arguments[1]) if not player.canreach(cloth, -1): player.socket.clilocmessage(1044456) # You don't have any ready cloth... return False elif cloth.amount < needed: player.socket.clilocmessage(1044287) # You don't have enough... return False # Replace the second argument with the color of the cloth arguments[1] = cloth.color if needed == cloth.amount: cloth.delete() else: cloth.amount -= needed cloth.update() return result
def consumematerial(self, player, arguments, half=0): result = CraftItemAction.consumematerial(self, player, arguments, half) if not result: return False if self.flour: result = False content = player.getbackpack().content flours = [] for item in content: if item.baseid in flour and item.hastag("quantity"): flours.append(item) toconsume = self.flouramount while toconsume > 0: for flou in flours: amount = consume(flou, toconsume) toconsume -= amount if toconsume == 0: break # break out of for loop # Check if we have enough water in our backpack if self.water: content = player.getbackpack().content for item in content: if item.hasscript("beverage") and item.gettag("fluid") == "water" and item.hastag("quantity"): if beverage.consume(item): return True player.socket.clilocmessage(1044253) # You don't have the components needed to make that. return False return result
def getmaterialshtml(self, player, arguments): materialshtml = CraftItemAction.getmaterialshtml(self, player, arguments) if self.cloth > 0: materialshtml += "%s: %u<br>" % (tr('Cloth'), self.cloth) return materialshtml
def make(self, player, arguments, nodelay=0, clothitem = None): global CLOTH # We have not been passed a cloth reference. # Try to statisfy it automatically if self.cloth > 0: if not clothitem: backpack = player.getbackpack() count = 0 # Valid piles of cloth for item in backpack.content: if item.baseid in CLOTH and item.amount >= self.cloth: clothitem = item count += 1 # This makes the user select a pile of cloth if count > 1: player.socket.clilocmessage(502928) # Which material would you like to work ... player.socket.attachtarget('skills.tailoring.ClothSelectResponse', [self, arguments]) return elif count < 1: player.socket.clilocmessage(1044456) # You don't have any ready cloth return # Pass the clothitem on to the next function as an argument if len(arguments) < 2: arguments.append(clothitem.serial) else: arguments[1] = clothitem.serial return CraftItemAction.make(self, player, arguments, nodelay)
def getmaterialshtml(self, player, arguments): materialshtml = CraftItemAction.getmaterialshtml(self, player, arguments) if self.runes > 0: materialshtml += "%s: %u<br>" % (tr('Unmarked Runes'), self.runes) return materialshtml
def getmaterialshtml(self, player, arguments): materialshtml = CraftItemAction.getmaterialshtml( self, player, arguments) if self.cloth > 0: materialshtml += "%s: %u<br>" % (tr('Cloth'), self.cloth) return materialshtml
def getmaterialshtml(self, player, arguments): materialshtml = CraftItemAction.getmaterialshtml(self, player, arguments) if self.water: materialshtml += tr("Water: 1<br>") if self.flour: materialshtml += tr("Flour: %i<br>" % self.flouramount) return materialshtml
def checkmaterial(self, player, arguments, silent=0): result = CraftItemAction.checkmaterial(self, player, arguments, silent) if not result: return False if self.flour: found = False backpack = player.getbackpack() amount = 0 for item in backpack.content: if item.baseid in flour and item.hastag('quantity'): quantity = int(item.gettag('quantity')) if quantity > 0: amount += quantity found = True if not found: if not silent: player.socket.clilocmessage( 1044253 ) # You don't have the components needed to make that. return False if amount < self.flouramount: player.socket.sysmessage( tr("You don't have enough material to make that.")) return False # Check if we have enough water in our backpack if self.water: found = False # Found at least one unit of water? backpack = player.getbackpack() for item in backpack.content: if item.hasscript('beverage') and item.gettag( 'fluid') == 'water' and item.hastag('quantity'): quantity = int(item.gettag('quantity')) if quantity > 0: found = True break if not found: if not silent: player.socket.clilocmessage( 1044253 ) # You don't have the components needed to make that. return False if self.needheat and not find(player, fires): player.socket.clilocmessage( 1044487) # You must be near a fire source to cook. return False if self.needoven and not find(player, ovens): player.socket.clilocmessage( 1044493) # You must be near an oven to bake that. return False return result
def make(self, player, arguments, nodelay=0): if self.useallres: found = False for item in player.getbackpack().content: if item.baseid == self.materials[0][0][0]: found = True nodelay = True # stop if making fails if not CraftItemAction.make(self, player, arguments, nodelay): break if not found: # we have no material, but call make method do display error message # and reopen the crafting dialog return CraftItemAction.make(self, player, arguments, nodelay) else: return CraftItemAction.make(self, player, arguments, nodelay)
def getmaterialshtml(self, player, arguments): materialshtml = CraftItemAction.getmaterialshtml( self, player, arguments) if self.water: materialshtml += tr("Water: 1<br>") if self.flour: materialshtml += tr("Flour: %i<br>" % self.flouramount) return materialshtml
def processnode(self, node, menu): if node.name == "needoven": self.needoven = True elif node.name == "needheat": self.needheat = True elif node.name == "water": self.water = True elif node.name == "nomark": self.markable = 0 elif node.name == "useallres": self.useallres = True elif node.name == "flour": amount = 1 if node.hasattribute("amount"): amount = hex2dec(node.getattribute("amount", "1")) self.flour = True self.flouramount = amount else: CraftItemAction.processnode(self, node, menu)
def processnode(self, node, menu): if node.name == 'needoven': self.needoven = True elif node.name == 'needheat': self.needheat = True elif node.name == 'water': self.water = True elif node.name == 'nomark': self.markable = 0 elif node.name == 'useallres': self.useallres = True elif node.name == 'flour': amount = 1 if node.hasattribute('amount'): amount = hex2dec(node.getattribute('amount', '1')) self.flour = True self.flouramount = amount else: CraftItemAction.processnode(self, node, menu)
def make(self, player, arguments, nodelay=0): assert(len(arguments) > 0, 'Arguments has to contain a tool reference.') # Look for forge and anvil if not checkanvilandforge(player): player.socket.clilocmessage(1044267) return False if not checktool(player, wolfpack.finditem(arguments[0])): return False return CraftItemAction.make(self, player, arguments, nodelay)
def checkmaterial(self, player, arguments, silent = 0): result = CraftItemAction.checkmaterial(self, player, arguments, silent) if result: # Check for mana if self.mana > 0 and player.mana < self.mana: player.socket.clilocmessage(1044380) # You don't have enough mana to inscribe that spell. return False # Check for availability of spell if self.spellid > 0 and not magic.utilities.hasSpell(player, self.spellid - 1, False): return False return result
def checkmaterial(self, player, arguments, silent = 0): result = CraftItemAction.checkmaterial(self, player, arguments, silent) if result: # Check for mana if self.mana > 0 and player.mana < self.mana: player.socket.clilocmessage(1044380) # You don't have enough mana to inscribe that spell. return False # Check for availability of spell if self.spellid > 0 and not hasSpell(player, self.spellid - 1, False): return False return result
def checkmaterial(self, player, arguments, silent=0): result = CraftItemAction.checkmaterial(self, player, arguments, silent) if not result: return False if self.flour: found = False backpack = player.getbackpack() amount = 0 for item in backpack.content: if item.baseid in flour and item.hastag("quantity"): quantity = int(item.gettag("quantity")) if quantity > 0: amount += quantity found = True if not found: if not silent: player.socket.clilocmessage(1044253) # You don't have the components needed to make that. return False if amount < self.flouramount: player.socket.sysmessage(tr("You don't have enough material to make that.")) return False # Check if we have enough water in our backpack if self.water: found = False # Found at least one unit of water? backpack = player.getbackpack() for item in backpack.content: if item.hasscript("beverage") and item.gettag("fluid") == "water" and item.hastag("quantity"): quantity = int(item.gettag("quantity")) if quantity > 0: found = True break if not found: if not silent: player.socket.clilocmessage(1044253) # You don't have the components needed to make that. return False if self.needheat and not find(player, fires): player.socket.clilocmessage(1044487) # You must be near a fire source to cook. return False if self.needoven and not find(player, ovens): player.socket.clilocmessage(1044493) # You must be near an oven to bake that. return False return result
def consumematerial(self, player, arguments, half = 0): result = CraftItemAction.consumematerial(self, player, arguments, half) # Check if we have enough water in our backpack if result and self.water: content = player.getbackpack().content for item in content: if item.hasscript('beverage') and item.gettag('fluid') == 'water' and item.hastag('quantity'): if beverage.consume(item): return True player.socket.clilocmessage(1044253) # You don't have the components needed to make that. return False return result
def checkmaterial(self, player, arguments, silent = 0): result = CraftItemAction.checkmaterial(self, player, arguments, silent) # Check for cloth if result and self.cloth > 0: assert(len(arguments) >= 2) cloth = wolfpack.finditem(arguments[1]) if not player.canreach(cloth, -1): player.socket.clilocmessage(1044456) # You don't have any ready cloth... return False elif cloth.amount < self.cloth: player.socket.clilocmessage(1044287) # You don't have enough... return False return result
def consumematerial(self, player, arguments, half = 0): result = CraftItemAction.consumematerial(self, player, arguments, half) if result and self.mana > 0: if half: needed = int(math.ceil(self.mana / 2)) else: needed = self.mana if player.mana >= needed: player.mana -= needed player.updatemana() else: return False return result
def checkmaterial(self, player, arguments, silent = 0): result = CraftItemAction.checkmaterial(self, player, arguments, silent) # Check for runes backpack = player.getbackpack() if result and self.runes > 0: runes = 0 for item in backpack.content: if item.baseid in ['1f14', '1f15', '1f16', '1f17'] and not item.hastag('location') and item.gettag('marked') == 0: runes += 1 if runes >= self.runes: return True player.socket.clilocmessage(1044253) return False return result
def checkmaterial(self, player, arguments, silent=0): result = CraftItemAction.checkmaterial(self, player, arguments, silent) # Check for cloth if result and self.cloth > 0: assert (len(arguments) >= 2) cloth = wolfpack.finditem(arguments[1]) if not player.canreach(cloth, -1): player.socket.clilocmessage( 1044456) # You don't have any ready cloth... return False elif cloth.amount < self.cloth: player.socket.clilocmessage( 1044287) # You don't have enough... return False return result
def checkmaterial(self, player, arguments, silent = 0): result = CraftItemAction.checkmaterial(self, player, arguments, silent) # Check if we have enough water in our backpack if result and self.water: found = False # Found at laest one unit of water? backpack = player.getbackpack() for item in backpack.content: if item.hasscript('beverage') and item.gettag('fluid') == 'water' and item.hastag('quantity'): quantity = int(item.gettag('quantity')) if quantity > 0: found = True break if not found: if not silent: player.socket.clilocmessage(1044253) # You don't have the components needed to make that. return False return result
def consumematerial(self, player, arguments, half = 0): result = CraftItemAction.consumematerial(self, player, arguments, half) if result and self.runes > 0: if half: needed = int(math.ceil(self.runes / 2)) else: needed = self.runes backpack = player.getbackpack() for item in backpack.content: if item.baseid in ['1f14', '1f15', '1f16', '1f17'] and not item.hastag('location') and item.gettag('marked') == 0: item.delete() needed -= 1 if needed < 1: break if needed > 0: player.socket.clilocmessage(1044253) return False return result
def make(self, player, arguments, nodelay=0): assert(len(arguments) > 0, 'Arguments has to contain a tool reference.') return CraftItemAction.make(self, player, arguments, nodelay)
def __init__(self, parent, title, itemid, definition): CraftItemAction.__init__(self, parent, title, itemid, definition) self.markable = 1 # All carpentry items are markable self.stackable = 0 self.retaincolor = 1
def __init__(self, parent, title, itemid, definition): CraftItemAction.__init__(self, parent, title, itemid, definition) self.markable = 0 # All masonry items are not markable
def __init__(self, parent, title, itemid, definition): CraftItemAction.__init__(self, parent, title, itemid, definition) self.markable = 0 # All alchemy items are not markable self.bottled = True # Whatever we produce comes in bottles self.successmessage = 500279 # Custom Success Message self.failmessage = 500287 # Custom Fail Message
def __init__(self, parent, title, itemid, definition): CraftItemAction.__init__(self, parent, title, itemid, definition) self.markable = 1 # All blacksmith items are markable self.retaincolor = 1
def __init__(self, parent, title, itemid, definition): CraftItemAction.__init__(self, parent, title, itemid, definition) self.markable = True self.stackable = False
def __init__(self, parent, title, itemid, definition): CraftItemAction.__init__(self, parent, title, itemid, definition)
def __init__(self, parent, title, itemid, definition): CraftItemAction.__init__(self, parent, title, itemid, definition) self.markable = 1 self.retaincolor = 0 self.stackable = 0
def __init__(self, parent, title, itemid, definition): CraftItemAction.__init__(self, parent, title, itemid, definition) self.markable = False # Scrolls aren't markable self.requiretool = True # But Scrolls require a valid tool self.mana = 0 self.spellid = 0
def __init__(self, parent, title, itemid, definition): CraftItemAction.__init__(self, parent, title, itemid, definition) self.markable = False # Scrolls aren't markable self.mana = 0 self.spellid = 0
def __init__(self, parent, title, itemid, definition): CraftItemAction.__init__(self, parent, title, itemid, definition) self.markable = 0 # All glassblowing items are not markable
def __init__(self, parent, title, itemid, definition): CraftItemAction.__init__(self, parent, title, itemid, definition) self.markable = 1 # All tailoring items are markable self.cloth = 0 # How many cloth this part is using (Special processing because of color)
def __init__(self, parent, title, itemid, definition): CraftItemAction.__init__(self, parent, title, itemid, definition) self.markable = 1 # All carpentry items are not markable self.stackable = 0
def make(self, player, arguments, nodelay=0): assert (len(arguments) > 0, 'Arguments has to contain a tool reference.') return CraftItemAction.make(self, player, arguments, nodelay)