本文整理汇总了Python中World.mortal方法的典型用法代码示例。如果您正苦于以下问题:Python World.mortal方法的具体用法?Python World.mortal怎么用?Python World.mortal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类World
的用法示例。
在下文中一共展示了World.mortal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_clients
# 需要导入模块: import World [as 别名]
# 或者: from World import mortal [as 别名]
#.........这里部分代码省略.........
if CLIENT_DATA[clientDataID].authSuccess == False:
if CLIENT_DATA[clientDataID].numTries == 2:
client.send("Last attempt is final before kick.\n")
elif CLIENT_DATA[clientDataID].numTries > 2:
CLIENT_DATA[clientDataID].numTries = 0
client.send("Too many failed passwords. Goodbye.\n")
print "-- Disconnected " + str(clientDataID) + " (too many failed pw)"
client.active = False
client.send("Incorrect password. Please try again.\n")
CLIENT_DATA[clientDataID].numTries += 1
CLIENT_DATA[clientDataID].lastCmd = str(msg)
return
if CLIENT_DATA[clientDataID].authSuccess == True and CLIENT_DATA[clientDataID].loadFinish == False:
for cli in CLIENT_DATA:
# print CLIENT_DATA[cli].name
# print CLIENT_DATA[cli].clientDataID
# print CLIENT_DATA[clientDataID].name
# print CLIENT_DATA[clientDataID].clientDataID
# print "****"
if CLIENT_DATA[cli].name == CLIENT_DATA[clientDataID].name and CLIENT_DATA[cli].clientDataID != CLIENT_DATA[clientDataID].clientDataID:
CLIENT_DATA[cli].client.send("You have been kicked because your username logged in again.\n")
print "-- Kicked " + CLIENT_DATA[cli].clientDataID + " " + CLIENT_DATA[cli].name + " (duplicate login)"
kickTimer = World.Timer(Globals.TIMERS, 1, None, actionArgs = [], attachedTo = None, respawns = False)
kickTimer.actionFunction = timerActions.kick(CLIENT_DATA[cli].client, kickTimer, Globals.TIMERS)
print "** " + str(client.addrport()) + " identified as " + str(CLIENT_DATA[clientDataID].name)
# client.send(prompt)
mortalComponent = World.mortal(hp=100,maxHp=100,pp=10,maxPp=10,level=1,exp=0,money=0,offense=1,defense=1,speed=1,guts=1,luck=1,vitality=1,IQ=1,inventory=[])
if os.path.isfile('data/client/'+str(CLIENT_DATA[clientDataID].name) + '/' + str(CLIENT_DATA[clientDataID].name)):
#print "cl:" + str(CLIENT_LIST)
#CLIENT_DATA[clientDataID].avatar = World.Player(description='Just another traveler.', currentRoom = Globals.startingRoom, name=CLIENT_DATA[clientDataID].name, client=client, clientDataID = clientDataID, kind=mortalComponent)
SysInit.clientDataLoad(client, CLIENT_LIST, CLIENT_DATA, Globals.TIMERS, mortalComponent)
#Globals.startingRoom.players.remove(CLIENT_DATA[clientDataID].avatar)
# print 'sp:' + str(Globals.startingRoom.players) + " sr:" + str(Globals.startingRoom.name) + ' ' + str(Globals.startingRoom)
# print 'ava:' + str(CLIENT_DATA[clientDataID].avatar.currentRoom.name)+ ' asrp:'+ str(CLIENT_DATA[clientDataID].avatar.currentRoom.players)
# print 'avacr:' + str(CLIENT_DATA[clientDataID].avatar.currentRoom)
#print "cl2:" + str(CLIENT_LIST)
else:
os.mkdir('data/client/'+str(CLIENT_DATA[clientDataID].name) + '/')
CLIENT_DATA[clientDataID].avatar = World.Player(description='Just another traveler.', currentRoom = Globals.startingRoom, name=CLIENT_DATA[clientDataID].name, client=client, clientDataID = clientDataID, kind=mortalComponent)
Globals.startingRoom.players.append(CLIENT_DATA[clientDataID].avatar)
# print 'starting;' + str(Globals.startingRoom.players)
with open(path, 'w') as f:
f.write(str(CLIENT_DATA[clientDataID].password) + '\n')
# print CLIENT_DATA[clientDataID].password
player = CLIENT_DATA[clientDataID].avatar
for playerName in OPList:
#print str(CLIENT_DATA[clientDataID].name)
#print str(playerName)
if playerName.endswith('\n'):
playerName = playerName[:-1]
if str(CLIENT_DATA[clientDataID].name) == str(playerName):
CLIENT_DATA[clientDataID].op = True
#print "op true"
#print CLIENT_DATA[clientDataID].op
cMove.alert(client, CLIENT_DATA, ("\n^g^!%s appeared.^~\n" %player.name))
示例2: loadMobFromFile
# 需要导入模块: import World [as 别名]
# 或者: from World import mortal [as 别名]
def loadMobFromFile(file):
'''
handles loading a single mob from a given mob definition file into the world
'''
print file
if str(file).endswith('~'):
print '\n'
return
path = 'blueprints/mob/' + file
with open(path, 'r') as f:
fileData = f.readlines()
newMob = World.Mob('none', 'none', 'none')
newMob.mobID = ''
print fileData
splitFile = file.split("/")
mobID = None
name = 'none'
species = None
currentRoom = None
region = None
description = ''
longDescription = ''
hp = 0
exp = 0
inventory = []
inventorySize = 0
equipment = {}
kind = None
expirator = None
inventoryItems = []
currentRoomString = ''
moveAI = None
battleAI = None
newMob.kind = World.mortal(hp=0,maxHp=0,pp=0,maxPp=0,level=0,exp=0,money=0,offense=0,defense=0,speed=0,guts=0,luck=0,vitality=0,IQ=0,inventory=[],inventorySize=0,equipment={})
newMob.region = splitFile[0]
for Data in fileData:
if Data.startswith('mobID='):
IDstring = Data[6:-1]
if IDstring != '':
newMob.mobID = int(IDstring)
if Data.startswith('name='):
newMob.name = Data[5:-1]
if Data.startswith('species='):
newMob.species = Data[8:-1]
if Data.startswith('currentRoom='):
currentRoomString = Data[12:-1]
if Data.startswith('description='):
newMob.description = Data[12:-1]
if Data.startswith('longDescription='):
newMob.longDescription = Data[16:-1]
if Data.startswith('speech='):
newMob.speech = Data[7:-1]
if Data.startswith('expirator='):
expirator = Data[10:-1]
if expirator != '':
expirator = int(expirator)
if Data.startswith('moveAI='):
text = Data[7:-1]
moveAI = text.split(":")
if Data.startswith('battleAI='):
text = Data[9:-1]
if text == 'basicBash':
battleAI = aiBattle.basicBash
else:
battleAI = ''
if Data.startswith('kind.hp='):
newMob.kind.hp = int(Data[8:-1])
if Data.startswith('kind.maxHp='):
newMob.kind.maxHp = int(Data[11:-1])
if Data.startswith('kind.pp='):
newMob.kind.pp = int(Data[8:-1])
if Data.startswith('kind.maxPp='):
newMob.kind.maxPp = int(Data[11:-1])
if Data.startswith('kind.level='):
newMob.kind.level = int(Data[11:-1])
if Data.startswith('kind.exp='):
newMob.kind.exp = int(Data[9:-1])
if Data.startswith('kind.money='):
newMob.kind.money = int(Data[11:-1])
if Data.startswith('kind.offense='):
newMob.kind.offense = int(Data[13:-1])
if Data.startswith('kind.defense='):
newMob.kind.defense = int(Data[13:-1])
if Data.startswith('kind.speed='):
#.........这里部分代码省略.........