本文整理汇总了Python中World.itemGrabHandler方法的典型用法代码示例。如果您正苦于以下问题:Python World.itemGrabHandler方法的具体用法?Python World.itemGrabHandler怎么用?Python World.itemGrabHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类World
的用法示例。
在下文中一共展示了World.itemGrabHandler方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: buildEquipmentFromFile
# 需要导入模块: import World [as 别名]
# 或者: from World import itemGrabHandler [as 别名]
def buildEquipmentFromFile(file, location):
print file
if str(file).endswith('~'):
print "\n"
return
path = location + file
with open(path, 'r') as f:
fileData = f.readlines()
newWeapon = None
newArmor = None
equipmentType = None
slot = None
durability = None
maxDurability = None
worth = None
description = None
longDescription = None
hp = None
pp = None
offense = None
defense = None
speed = None
guts = None
luck = None
vitality = None
IQ = None
battleCommands = None
statusEffect = None
onUse = None
isVisible = None
spawnContainer = None
isCarryable = None
respawns = None
itemGrabHandler = None
objectSpawner = None
notDroppable = None
container = None
spawnOdds = None
time = None
active = None
repeat = None
cycles = None
for Data in fileData:
if Data.startswith('type='):
equipmentType = Data[5:-1]
if Data.startswith('ID='):
ID = Data[3:-1]
if Data.startswith('name='):
name = Data[5:-1]
if Data.startswith('slot='):
slot = Data[5:-1]
if Data.startswith('durability='):
durability = Data[11:-1]
if Data.startswith('maxDurability='):
maxDurability = Data[14:-1]
if Data.startswith('worth='):
worth = Data[6:-1]
if Data.startswith('description='):
description = Data[12:-1]
if Data.startswith('longDescription='):
longDescription = Data[16:-1]
if Data.startswith('hp='):
hp = int(Data[3:-1])
if Data.startswith('pp='):
pp = int(Data[3:-1])
if Data.startswith('offense='):
offense = int(Data[8:-1])
if Data.startswith('defense='):
defense = int(Data[8:-1])
if Data.startswith('speed='):
speed = int(Data[6:-1])
if Data.startswith('guts='):
guts = int(Data[5:-1])
if Data.startswith('luck='):
luck = int(Data[5:-1])
if Data.startswith('vitality='):
vitality = int(Data[9:-1])
if Data.startswith('IQ='):
IQ = int(Data[3:-1])
if Data.startswith('battleCommands='):
battleCommands = Data[15:-1]
battleCommands = battleCommands.split(",")
if Data.startswith('statusEffect='):
statusEffect = Data[13:-1]
if Data.startswith('onUse='):
onUse = Data[6:-1]
if Data.startswith('isVisible='):
isVisible = Data[10:-1]
if isVisible == 'True':
isVisible = True
elif isVisible == 'False':
isVisible = False
if Data.startswith('kind.isCarryable='):
#.........这里部分代码省略.........
示例2: cmdSpawnObject
# 需要导入模块: import World [as 别名]
# 或者: from World import itemGrabHandler [as 别名]
def cmdSpawnObject(refobj, spawnLocation, active=False, alert=True, whereFrom='cmd', spawnContainer=None):
# creates a new object based on the attributes of the object fed to the function
obj = None
# if whereFrom == 'cmd':
# active = True
#print Objects.fromFileList[0].name
#print str(refobj)
for thing in Objects.fromFileList:
if thing.name == str(refobj):
obj = thing
#print obj
if obj == None:
print ("Unable to spawn, %s not found." %refobj)
return
newObject = World.Object(obj.name, obj.description)
newObject.currentRoom = spawnLocation
newObject.isVisible = obj.isVisible
if obj.spawnContainer:
newObject.spawnContainer = obj.spawnContainer
else:
newObject.spawnContainer = spawnContainer
newObject.longDescription = obj.longDescription
newObject.kind = obj.kind
if newObject.kind is not None and hasattr(newObject, 'kind'):
newObject.kind.owner = newObject
newObject.TIMERS = obj.TIMERS
if obj.mobSpawner is not None:
mobSpawner = obj.mobSpawner
else:
mobSpawner = None
# if newObject.TIMERS:
# newObject.TIMERS.owner = newObject
if newObject.kind is not None:
if isinstance(newObject.kind, World.item):
newObject.kind = World.item()
newObject.kind.owner = newObject
newObject.kind.isCarryable = obj.kind.isCarryable
newObject.kind.respawns = obj.kind.respawns
if hasattr(obj.kind, 'itemGrabHandler') and obj.kind.itemGrabHandler is not None:
newObject.kind.itemGrabHandler = World.itemGrabHandler()
else:
newObject.kind.itemGrabHandler = None
if newObject.kind.itemGrabHandler is not None:
newObject.kind.itemGrabHandler.owner = newObject.kind
newObject.kind.objectSpawner = obj.kind.objectSpawner
if newObject.kind.objectSpawner:
newObject.kind.objectSpawner.owner = newObject.kind
newObject.kind.onUse = obj.kind.onUse
# if newObject.kind.onUse:
# newObject.kind.onUse.owner = newObject.kind
if isinstance(newObject.kind, World.container):
newObject.kind = World.container()
newObject.kind.owner = newObject
newObject.kind.inventory = []
newObject.kind.isLocked = obj.kind.isLocked
newObject.kind.isCarryable = obj.kind.isCarryable
newObject.kind.respawns = obj.kind.respawns
newObject.kind.respawnContents = obj.kind.respawnContents
if hasattr(obj.kind, 'itemGrabHandler') and obj.kind.itemGrabHandler is not None:
newObject.kind.itemGrabHandler = World.itemGrabHandler()
else:
newObject.kind.itemGrabHandler = None
#print newObject.kind.itemGrabHandler
# newObject.kind.itemGrabHandler.owner = newObject.kind
if newObject.kind.itemGrabHandler is not None:
newObject.kind.itemGrabHandler.owner = newObject.kind
newObject.kind.objectSpawner = obj.kind.objectSpawner
if newObject.kind.objectSpawner:
newObject.kind.objectSpawner.owner = newObject.kind
if newObject.kind.itemGrabHandler is not None:
if obj.kind.itemGrabHandler.notDroppable is not None:
newObject.kind.itemGrabHandler.notDroppable = obj.kind.itemGrabHandler.notDroppable
else:
newObject.kind.itemGrabHandler.notDroppable = False
if newObject.kind.objectSpawner:
newObject.kind.objectSpawner = World.objectSpawner(newObject.kind)
newObject.kind.objectSpawner.TIMERS = obj.kind.objectSpawner.TIMERS
newObject.kind.objectSpawner.time = obj.kind.objectSpawner.time
newObject.kind.objectSpawner.obj = obj.kind.objectSpawner.obj
newObject.kind.objectSpawner.oddsList = obj.kind.objectSpawner.oddsList
newObject.kind.objectSpawner.container = obj.kind.objectSpawner.container
newObject.kind.objectSpawner.cycles = obj.kind.objectSpawner.cycles
newObject.kind.objectSpawner.repeat = obj.kind.objectSpawner.repeat
newObject.kind.objectSpawner.timer = World.Timer(newObject.kind.objectSpawner.TIMERS, newObject.kind.objectSpawner.time, newObject.kind.objectSpawner.spawn, [], newObject.kind.objectSpawner, newObject.kind.respawns)
newObject.kind.objectSpawner.startingLocation = spawnLocation,
if newObject.kind:
if newObject.kind.objectSpawner:
#.........这里部分代码省略.........
示例3: buildObjectFromFile
# 需要导入模块: import World [as 别名]
# 或者: from World import itemGrabHandler [as 别名]
def buildObjectFromFile(file):
'''
creates an object by constructing it out of details in a file
'''
print file
if str(file).endswith('~'):
print "\n"
return
path = 'blueprints/obj/' + file
with open(path, 'r') as f:
fileData = f.readlines()
newObject = World.Object('none', 'none')
print fileData
kind = None
isCarryable = None
isVisible = None
isLocked = False
respawns = None
objectSpawner = None
itemGrabHandler = None
repeat = None
time = None
spawnOdds = None
container = None
cycles = None
repeat = None
active = None
notDroppable = None
objectSpawnerComponent = None
itemGrabHandlerComponent = None
itemComponent = None
mobActive = None
mobCycles = None
mobMode = None
mobSpawnOdds = None
mobTime = None
mobFile = None
mobSpawner = None
onUse = None
for Data in fileData:
if Data.startswith('name='):
newObject.name = Data[6:-2]
if Data.startswith('description='):
newObject.description = Data[13:-2]
if Data.startswith('longDescription='):
newObject.longDescription = Data[17:-2]
if Data.startswith('isVisible='):
text = Data[10:-1]
if text == 'True':
newObject.isVisible = True
elif text == 'False':
newObject.isVisible = False
if Data.startswith('kind='):
text = Data[5:-1]
#print "kind:" + text
if text == 'item':
kind = 'item'
elif text == 'container':
kind = 'container'
if Data.startswith('kind.isCarryable='):
text = Data[17:-1]
#print "isCarryable:" +text
if text == 'True':
isCarryable = True
elif text == 'False':
isCarryable = False
if Data.startswith('kind.respawns='):
text = Data[14:-1]
if text == 'True':
respawns = True
elif text == 'False':
respawns = False
if Data.startswith('kind.isLocked='):
text = Data[14:-1]
if text == 'True':
isLocked = True
if text == 'False':
isLocked = False
if Data.startswith('kind.respawnContents='):
text = Data[21:-1]
if text == 'True':
respawnContents = True
elif text == 'False':
respawnContents = False
if Data.startswith('kind.objectSpawner='):
text = Data[19:-1]
if text == 'True':
objectSpawner = True
#.........这里部分代码省略.........