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


Python Engine.selector方法代码示例

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


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

示例1: spawn

# 需要导入模块: import Engine [as 别名]
# 或者: from Engine import selector [as 别名]
	def spawn(self):

		winner = Engine.selector(self.oddsList)

		if winner[0]:

			#print "winner"

			for mob in Globals.mobsFromFile:
				if mob.name == self.mob:
					refmob = mob.name
					ob = mob
				elif hasattr(self.mob, 'name') and mob.name == self.mob.name:
					refmob = mob.name
					ob = mob

			if self.mode == 'pack':		# spawns a group of mobs, the maximum size of which is determined by self.cycles. Always spawns at least one mob.
				iters = 0
				maxNum = random.randint(1, self.cycles)
				#print str(iters) + ":" + str(maxNum)
				while iters < maxNum:
					#print str(iters) + ":" + str(maxNum)
					newMortal = mortal(hp=int(ob.kind.hp), maxHp=int(ob.kind.maxHp), pp=int(ob.kind.pp), maxPp=int(ob.kind.maxPp), level=int(ob.kind.level), exp=int(ob.kind.exp), money=int(ob.kind.money), offense=int(ob.kind.offense), defense=int(ob.kind.defense), speed=int(ob.kind.speed), guts=int(ob.kind.guts), luck=int(ob.kind.luck), vitality=int(ob.kind.vitality), IQ=int(ob.kind.IQ), inventory=[], inventorySize=int(ob.kind.inventorySize), equipment={})
					newMob = Mob(ob.description, ob.currentRoom, ob.name, ob.region, ob.longDescription, ob.speech, newMortal, ob.species, None)
					if hasattr(ob, 'aiMove'):
						newAIComponent = aiMove.movementAI(newMob, ob.aiMove.time)
						if ob.aiMove.Timer.actionFunction == ob.aiMove.basicRandom:
							newAIComponent.Timer.actionFunction = newAIComponent.basicRandom
						if ob.aiMove.Timer.actionFunction == ob.aiMove.introvertRandom:
							newAIComponent.Timer.actionFunction = newAIComponent.introvertRandom
						if ob.aiMove.Timer.actionFunction == ob.aiMove.extrovertRandom:
							newAIComponent.Timer.actionFunction = newAIComponent.extrovertRandom
						if ob.aiMove.Timer.actionFunction == ob.aiMove.doNotMove:
							newAIComponent.Timer.actionFunction = newAIComponent.doNotMove
					newMob.aiMove = newAIComponent

					if hasattr(ob, 'aiBattle'):
						newMob.aiBattle = ob.aiBattle

					if hasattr(ob, 'expirator') and ob.expirator != None:
						newExpirator = expirator(newMob, ob.expirator.startingTime)
						newMob.expirator = newExpirator
					self.owner.currentRoom.mobs.append(newMob)
					newMob.currentRoom = self.owner.currentRoom
					print "$m " +str(newMob) + " " + newMob.name + " @ " + "[" +newMob.currentRoom.region + ":" + newMob.currentRoom.name + "] (pack)"
					for client in Globals.CLIENT_LIST:
						if Globals.CLIENT_DATA[str(client.addrport())].avatar is not None:
							if Globals.CLIENT_DATA[str(client.addrport())].avatar.currentRoom == newMob.currentRoom:      # if a client is in the room object just appeared in, let it know
								client.send_cc("^yA %s appeared.^~\n" %newMob.name)
					iters += 1

			elif self.mode == 'cont':	 	# always spawns exactly one mob
				newMortal = newMortal = mortal(hp=int(ob.kind.hp), maxHp=int(ob.kind.maxHp), pp=int(ob.kind.pp), maxPp=int(ob.kind.maxPp), level=int(ob.kind.level), exp=int(ob.kind.exp), money=int(ob.kind.money), offense=int(ob.kind.offense), defense=int(ob.kind.defense), speed=int(ob.kind.speed), guts=int(ob.kind.guts), luck=int(ob.kind.luck), vitality=int(ob.kind.vitality), IQ=int(ob.kind.IQ), inventory=[], inventorySize=int(ob.kind.inventorySize), equipment={})
				newMob = Mob(ob.description, ob.currentRoom, ob.name, ob.region, ob.longDescription, ob.speech, newMortal, ob.species, None)
				if hasattr(ob, 'aiMove'):
					newAIComponent = aiMove.movementAI(newMob, ob.aiMove.time)
					if ob.aiMove.Timer.actionFunction == ob.aiMove.basicRandom:
						newAIComponent.Timer.actionFunction = newAIComponent.basicRandom
					if ob.aiMove.Timer.actionFunction == ob.aiMove.introvertRandom:
						newAIComponent.Timer.actionFunction = newAIComponent.introvertRandom
					if ob.aiMove.Timer.actionFunction == ob.aiMove.extrovertRandom:
						newAIComponent.Timer.actionFunction = newAIComponent.extrovertRandom
					if ob.aiMove.Timer.actionFunction == ob.aiMove.doNotMove:
						newAIComponent.Timer.actionFunction = newAIComponent.doNotMove
				newMob.aiMove = newAIComponent

				if hasattr(ob, 'aiBattle'):
					newMob.aiBattle = ob.aiBattle

				if hasattr(ob, 'expirator') and ob.expirator != None:
					newExpirator = expirator(newMob, ob.expirator.startingTime)
					newMob.expirator = newExpirator
				self.owner.currentRoom.mobs.append(newMob)
				newMob.currentRoom = self.owner.currentRoom
				print "$m " +str(newMob) + " " + newMob.name + " @ " + "[" + newMob.currentRoom.region + ":" + newMob.currentRoom.name + "] (cont)"
				for client in Globals.CLIENT_LIST:
					if Globals.CLIENT_DATA[str(client.addrport())].avatar is not None:
						if Globals.CLIENT_DATA[str(client.addrport())].avatar.currentRoom == newMob.currentRoom:      # if a client is in the room object just appeared in, let it know
							client.send_cc("^yA %s appeared.^~\n" %newMob.name)

			elif self.mode == 'thresh':		# spawns mobs until the number of mobs in the room equals self.cycles
				resultsList = []
				for mob in self.owner.currentRoom.mobs:
					if mob.name == self.mob:
						resultsList.append(mob)
				numPresent = len(resultsList)
				#print numPresent
				if numPresent < self.cycles:
					newMortal = newMortal = mortal(hp=int(ob.kind.hp), maxHp=int(ob.kind.maxHp), pp=int(ob.kind.pp), maxPp=int(ob.kind.maxPp), level=int(ob.kind.level), exp=int(ob.kind.exp), money=int(ob.kind.money), offense=int(ob.kind.offense), defense=int(ob.kind.defense), speed=int(ob.kind.speed), guts=int(ob.kind.guts), luck=int(ob.kind.luck), vitality=int(ob.kind.vitality), IQ=int(ob.kind.IQ), inventory=[], inventorySize=int(ob.kind.inventorySize), equipment={})
					newMob = Mob(ob.description, ob.currentRoom, ob.name, ob.region, ob.longDescription, ob.speech, newMortal, ob.species, None)
					if hasattr(ob, 'aiMove'):
						newAIComponent = aiMove.movementAI(newMob, ob.aiMove.time)
						if ob.aiMove.Timer.actionFunction == ob.aiMove.basicRandom:
							newAIComponent.Timer.actionFunction = newAIComponent.basicRandom
						if ob.aiMove.Timer.actionFunction == ob.aiMove.introvertRandom:
							newAIComponent.Timer.actionFunction = newAIComponent.introvertRandom
						if ob.aiMove.Timer.actionFunction == ob.aiMove.extrovertRandom:
							newAIComponent.Timer.actionFunction = newAIComponent.extrovertRandom
						if ob.aiMove.Timer.actionFunction == ob.aiMove.doNotMove:
							newAIComponent.Timer.actionFunction = newAIComponent.doNotMove
#.........这里部分代码省略.........
开发者ID:buckets1337,项目名称:MotherMUD,代码行数:103,代码来源:World.py


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