當前位置: 首頁>>代碼示例>>Python>>正文


Python ToonDNA.getSpeciesName方法代碼示例

本文整理匯總了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]),
                }
            })
開發者ID:Toonerz,項目名稱:Toontown-World-Online-Leaked-Source,代碼行數:29,代碼來源:ToontownRPCHandler.py

示例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
開發者ID:Toonerz,項目名稱:Toontown-World-Online-Leaked-Source,代碼行數:34,代碼來源:ToontownRPCHandler.py

示例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
開發者ID:Toonerz,項目名稱:Toontown-World-Online-Leaked-Source,代碼行數:32,代碼來源:ToontownRPCHandler.py

示例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
開發者ID:Teku16,項目名稱:ToontownPlanet,代碼行數:37,代碼來源:ToontownRPCHandler.py


注:本文中的toontown.toon.ToonDNA.getSpeciesName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。