本文整理汇总了Python中toontown.toon.ToonDNA.getSpeciesName方法的典型用法代码示例。如果您正苦于以下问题:Python ToonDNA.getSpeciesName方法的具体用法?Python ToonDNA.getSpeciesName怎么用?Python ToonDNA.getSpeciesName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类toontown.toon.ToonDNA
的用法示例。
在下文中一共展示了ToonDNA.getSpeciesName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: callback
# 需要导入模块: from toontown.toon import ToonDNA [as 别名]
# 或者: from toontown.toon.ToonDNA import getSpeciesName [as 别名]
def callback(dclass, fields):
if dclass is None:
return request.result(None)
if dclass.getName() is None:
return request.result(None)
name = fields['setName'][0]
hp = fields['setHp'][0]
maxHp = fields['setMaxHp'][0]
dnaString = fields['setDNAString'][0]
lastSeen = fields.get('setLastSeen', [0])[0]
dna = ToonDNA.ToonDNA()
dna.makeFromNetString(dnaString)
return request.result({
'name': name,
'hp': hp,
'maxHp': maxHp,
'lastSeen': lastSeen,
'dna': {
'species': ToonDNA.getSpeciesName(dna.head),
'headType': dna.head,
'headColor': list(ToonDNA.allColorsList[dna.headColor]),
}
})
示例2: rpc_getAvatarDetailsByName
# 需要导入模块: from toontown.toon import ToonDNA [as 别名]
# 或者: from toontown.toon.ToonDNA import getSpeciesName [as 别名]
def rpc_getAvatarDetailsByName(self, request, name):
"""Fetch a list of avatars that match the provided name.
Each element is a dict containing their hp/maxHp, lastSeen and
a few DNA attributes.
This list can be empty (meaning no avatars matched).
"""
self.air.mongodb.astron.objects.ensure_index('fields.setName')
avatars = self.air.mongodb.astron.objects.find({'fields.setName':{'name':name}})
result = []
for avatar in avatars:
fields = avatar['fields']
dna = ToonDNA.ToonDNA()
dna.makeFromNetString(fields['setDNAString']['dnaString'])
# In this case, we don't need to return the name, as that was already
# a parameter should already be considered "known".
result.append({
'id': avatar['_id'], # Instead of a name, return the avId.
'hp': fields['setHp']['hp'], # WTF did we do here?? hp and hitPoints, pls?
'maxHp': fields['setMaxHp']['hitPoints'],
'lastSeen': fields.get('setLastSeen',{}).get('timestamp',0),
'dna': {
'species': ToonDNA.getSpeciesName(dna.head),
'headType': dna.head,
'headColor': list(ToonDNA.allColorsList[dna.headColor]),
}
})
return result
示例3: rpc_listPendingNames
# 需要导入模块: from toontown.toon import ToonDNA [as 别名]
# 或者: from toontown.toon.ToonDNA import getSpeciesName [as 别名]
def rpc_listPendingNames(self, request, count=50):
"""Returns up to 50 pending names, sorted by time spent in the queue.
It is recommended that the name moderation app call this periodically
to update its database, in order to ensure that no names got lost.
"""
cursor = self.air.mongodb.astron.objects.find({'fields.WishNameState': WISHNAME_PENDING})
cursor.sort('fields.WishNameTimestamp', pymongo.ASCENDING)
cursor.limit(count)
result = []
for item in cursor:
dna = ToonDNA.ToonDNA()
dna.makeFromNetString(item['fields']['setDNAString']['dnaString'])
obj = {
'avId': item['_id'],
'name': item['fields']['WishName'],
'time': item['fields']['WishNameTimestamp'],
'dna': {
'species': ToonDNA.getSpeciesName(dna.head),
'headType': dna.head,
'headColor': list(ToonDNA.allColorsList[dna.headColor]),
}
}
result.append(obj)
return result
示例4: rpc_getAvatarDetails
# 需要导入模块: from toontown.toon import ToonDNA [as 别名]
# 或者: from toontown.toon.ToonDNA import getSpeciesName [as 别名]
def rpc_getAvatarDetails(self, avId):
"""
Summary:
Responds with basic details on the avatar associated with the
provided [avId].
Parameters:
[int avId] = The ID of the avatar to query basic details on.
Example response:
On success:
{
'name': 'Toon Name',
'species': 'cat',
'head-color': 'Red',
'max-hp': 15,
'online': True
}
On failure: None
"""
dclassName, fields = self.rpc_queryObject(avId)
if dclassName == 'DistributedToon':
result = {}
result['name'] = fields['setName'][0]
dna = ToonDNA.ToonDNA()
dna.makeFromNetString(fields['setDNAString'][0])
result['species'] = ToonDNA.getSpeciesName(dna.head)
result['head-color'] = TTLocalizer.NumToColor[dna.headColor]
result['max-hp'] = fields['setMaxHp'][0]
result['online'] = (avId in self.air.friendsManager.onlineToons)
return result