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


Python IDataHolder.quantity方法代码示例

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


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

示例1: startConstruction

# 需要导入模块: from ige.IDataHolder import IDataHolder [as 别名]
# 或者: from ige.IDataHolder.IDataHolder import quantity [as 别名]
	def startConstruction(self, tran, obj, techID, quantity, targetID, isShip, reportFinished,
		demolishStruct):
		if len(obj.prodQueue) > Rules.maxProdQueueLen:
			raise GameException('Queue is full.')
		if quantity < 1:
			raise GameException("Quantity must be greater than 0")
		player = tran.db[obj.owner]
		if not player.techs.has_key(techID) and isShip == 0:
			raise GameException('You do not own this kind of technology.')
		if not player.shipDesigns.has_key(techID) and isShip == 1:
			raise GameException('You do not own this ship design.')
		if targetID not in tran.db[obj.compOf].planets:
			raise GameException('You can build only in the same system.')
		if isShip:
			tech = player.shipDesigns[techID]
			if tech.upgradeTo:
				raise GameException("You cannot build obsolete ship design.")
		else:
			tech = Rules.techs[techID]
			if not (tech.isStructure or tech.isProject):
				raise GameException('You cannot construct this technology.')
			if not tech.validateConstrHandler(tran, obj, tran.db[targetID], tech):
				raise GameException('Conditions for construction are not satisfied.')
		neededSR = {}
		for sr in tech.buildSRes:
			if player.stratRes.get(sr, 0) < neededSR.get(sr, 0) + quantity:
				raise GameException("You do not own required strategic resource(s)")
			neededSR[sr] = neededSR.get(sr, 0) + quantity
		# consume strategic resources
		for sr in neededSR:
			player.stratRes[sr] -= neededSR[sr]
		# start construction
		item = IDataHolder()
		item.techID = techID
		item.currProd = 0
		item.currTurn = 0
		item.quantity = int(quantity)
		item.targetID = targetID
		item.changePerc = 0
		item.isShip = bool(isShip)
		item.reportFin = bool(reportFinished)
		item.demolishStruct = demolishStruct
		item.type = T_TASK
		obj.prodQueue.append(item)
		return obj.prodQueue, player.stratRes
开发者ID:OuterDeepSpace,项目名称:OuterDeepSpace,代码行数:47,代码来源:IPlanet.py

示例2: startGlobalConstruction

# 需要导入模块: from ige.IDataHolder import IDataHolder [as 别名]
# 或者: from ige.IDataHolder.IDataHolder import quantity [as 别名]
	def startGlobalConstruction(self, tran, player, techID, quantity, isShip, reportFinished, queue):
		if len(player.prodQueues) <= queue:
			raise GameException('Invalid queue.')		
		if len(player.prodQueues[queue]) > Rules.maxProdQueueLen:
			raise GameException('Queue is full.')
		if quantity < 1:
			raise GameException("Quantity must be greater than 0")
		if not player.techs.has_key(techID) and isShip == 0:
			raise GameException('You do not own this kind of technology.')
		if not player.shipDesigns.has_key(techID) and isShip == 1:
			raise GameException('You do not own this ship design.')
		if isShip:
			tech = player.shipDesigns[techID]
			if tech.upgradeTo:
				raise GameException("You cannot build obsolete ship design.")
		else:
			tech = Rules.techs[techID]
			if tech.isStructure or not tech.isProject:
				raise GameException('You cannot construct this technology.')
			elif tech.globalDisabled:
				raise GameException('You cannot construct targeted project.')
		neededSR = {}
		for sr in tech.buildSRes:
			if player.stratRes.get(sr, 0) < neededSR.get(sr, 0) + quantity:
				raise GameException("You do not own required strategic resource(s)")
			neededSR[sr] = neededSR.get(sr, 0) + quantity
		# consume strategic resources
		for sr in neededSR:
			player.stratRes[sr] -= neededSR[sr]
		# start construction
		item = IDataHolder()
		item.techID = techID
		item.quantity = int(quantity)
		item.changePerc = 0
		item.isShip = bool(isShip)
		item.reportFin = bool(reportFinished)
		item.type = T_TASK
		player.prodQueues[queue].append(item)
		return player.prodQueues[queue], player.stratRes
开发者ID:Lukc,项目名称:ospace-lukc,代码行数:41,代码来源:IPlayer.py


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