当前位置: 首页>>代码示例>>Python>>正文


Python CraftItemAction.consumematerial方法代码示例

本文整理汇总了Python中system.makemenus.CraftItemAction.consumematerial方法的典型用法代码示例。如果您正苦于以下问题:Python CraftItemAction.consumematerial方法的具体用法?Python CraftItemAction.consumematerial怎么用?Python CraftItemAction.consumematerial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在system.makemenus.CraftItemAction的用法示例。


在下文中一共展示了CraftItemAction.consumematerial方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: consumematerial

# 需要导入模块: from system.makemenus import CraftItemAction [as 别名]
# 或者: from system.makemenus.CraftItemAction import consumematerial [as 别名]
	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
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:30,代码来源:tailoring.py

示例2: consumematerial

# 需要导入模块: from system.makemenus import CraftItemAction [as 别名]
# 或者: from system.makemenus.CraftItemAction import consumematerial [as 别名]
    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
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:34,代码来源:cooking.py

示例3: consumematerial

# 需要导入模块: from system.makemenus import CraftItemAction [as 别名]
# 或者: from system.makemenus.CraftItemAction import consumematerial [as 别名]
	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
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:17,代码来源:cooking.py

示例4: consumematerial

# 需要导入模块: from system.makemenus import CraftItemAction [as 别名]
# 或者: from system.makemenus.CraftItemAction import consumematerial [as 别名]
	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
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:18,代码来源:inscription.py


注:本文中的system.makemenus.CraftItemAction.consumematerial方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。