コード例 #1
0
    def removeItem(self, item, topOrBottom):
        avId = self.air.getAvatarIdFromSender()

        if avId != self.furnitureMgr.ownerId:
            self.air.writeServerEvent('suspicious', avId, 'Tried to remove item from someone else\'s closet!')
            return

        if not self.verifyCustomer(avId):
            self.air.writeServerEvent('suspicious', avId, 'Tried to remove item while not interacting with closet!')
            return

        av = self.air.doId2do.get(avId)
        if not av:
            self.air.writeServerEvent('suspicious', avId, 'Tried to interact with a closet from another shard!')
            return

        tempDna = ToonDNA()
        if not tempDna.isValidNetString(item):
            self.air.writeServerEvent('suspicious', avId, 'Sent an invalid DNA string!')
            return

        tempDna.makeFromNetString(item)

        if topOrBottom == ClosetGlobals.SHIRT:
            self.removedTops.append([tempDna.topTex, tempDna.topTexColor, tempDna.sleeveTex, tempDna.sleeveTexColor])
        elif topOrBottom == ClosetGlobals.SHORTS:
            self.removedBottoms.append([tempDna.botTex, tempDna.botTexColor])
        else:
            self.air.writeServerEvent('suspicious', avId, 'Set an invalid topOrBottom value!')
コード例 #2
0
 def enterCreateAvatar(self):
     dna = ToonDNA()
     dna.makeFromNetString(self.dna)
     colorString = TTLocalizer.NumToColor[dna.headColor]
     animalType = TTLocalizer.AnimalToSpecies[dna.getAnimal()]
     name = (' ').join((colorString, animalType))
     if self.name != '':
         toonFields = {
             'setName': (self.name, ),
             'WishNameState': ('LOCKED', ),
             'WishName': ('', ),
             'setDNAString': (self.dna, ),
             'setDISLid': (self.target, ),
             'setNametagStyle': (100, )
         }
     else:
         toonFields = {
             'setName': (name, ),
             'WishNameState': ('OPEN', ),
             'WishName': ('', ),
             'setDNAString': (self.dna, ),
             'setDISLid': (self.target, ),
             'setNametagStyle': (100, )
         }
     self.gameServicesManager.air.dbInterface.createObject(
         self.gameServicesManager.air.dbId,
         self.gameServicesManager.air.dclassesByName['DistributedToonUD'],
         toonFields, self.__handleCreate)
コード例 #3
0
 def removeItem(self, item, topOrBottom):
     avId = self.air.getAvatarIdFromSender()
     if avId != self.furnitureMgr.ownerId:
         self.air.writeServerEvent(
             'suspicious', avId,
             'Tried to remove item from someone else\'s closet!')
         return
     if avId != self.avId:
         self.air.writeServerEvent(
             'suspicious', avId,
             'Tried to remove item while not interacting with closet!')
         return
     av = self.air.doId2do.get(avId)
     if not av:
         self.air.writeServerEvent(
             'suspicious', avId,
             'Tried to interact with a closet from another shard!')
         return
     tempDna = ToonDNA()
     if not tempDna.isValidNetString(item):
         self.air.writeServerEvent('suspicious', avId,
                                   'Sent an invalid DNA string!')
         return
     tempDna.makeFromNetString(item)
     if topOrBottom == ClosetGlobals.SHIRT:
         self.removedTops.append([
             tempDna.topTex, tempDna.topTexColor, tempDna.sleeveTex,
             tempDna.sleeveTexColor
         ])
     elif topOrBottom == ClosetGlobals.SHORTS:
         self.removedBottoms.append([tempDna.botTex, tempDna.botTexColor])
     else:
         self.air.writeServerEvent('suspicious', avId,
                                   'Set an invalid topOrBottom value!')
         return
コード例 #4
0
 def enterLoadHouse(self):
     dna = ToonDNA()
     dna.makeFromNetString(self.toon['setDNAString'][0])
     gender = 1 if dna.getGender() == 'm' else 0
     self.mgr.air.sendActivate(self.houseId, self.mgr.air.districtId, self.estate.zoneId, self.mgr.air.dclassesByName['DistributedHouseAI'], {'setHousePos': [self.houseIndex],
      'setColor': [self.houseIndex],
      'setName': [self.toon['setName'][0]],
      'setAvatarId': [self.toon['ID']],
      'setGender': [gender]})
     self.acceptOnce('generate-%d' % self.houseId, self.__gotHouse)
コード例 #5
0
    def start(self, avDNA, avPosition):
        if avPosition >= 6:
            # TODO: Kill the connection
            return

        dna = ToonDNA()
        valid = dna.isValidNetString(avDNA)
        if not valid:
            # TODO: Kill the connection
            return

        self.avPosition = avPosition
        self.avDNA = avDNA

        self.__handleRetrieveAccount()
コード例 #6
0
    def __handleCreateAvatar(self):
        dna = ToonDNA()
        dna.makeFromNetString(self.avDNA)
        colorString = TTLocalizer.NumToColor[dna.headColor]
        animalType = TTLocalizer.AnimalToSpecies[dna.getAnimal()]
        name = ' '.join((colorString, animalType))
        toonFields = {'setName': (name,),
                      'WishNameState': ('OPEN',),
                      'WishName': ('',),
                      'setDNAString': (self.avDNA,),
                      'setDISLid': (self.sender,)}

        self.loginManager.air.dbInterface.createObject(self.loginManager.air.dbId,
                                                       self.loginManager.air.dclassesByName['DistributedToonUD'],
                                                       toonFields, self.__handleToonCreated)
    def createToon(self):
        self.toon = Toon()

        dna = ToonDNA()
        dna.newToonFromProperties(*self.toonInfo[self.DNA_INDEX])

        self.toon.setDNA(dna)

        self.toon.pose(*self.toonInfo[self.POSE_INDEX])
        self.toon.setScale(0.3)
        self.toon.setH(200)

        self.toon.getGeomNode().setDepthWrite(1)
        self.toon.getGeomNode().setDepthTest(1)

        self.toon.reparentTo(self)
コード例 #8
0
 def __gotOwner(self, dclass, fields):
     if dclass != self.air.dclassesByName['DistributedToonAI']:
         return
     self.botList = fields['setClothesBottomsList'][0]
     self.topList = fields['setClothesTopsList'][0]
     dna = ToonDNA(str=fields['setDNAString'][0])
     self.gender = dna.gender
コード例 #9
0
    def createToon(self):
        self.toon = Toon()

        dna = ToonDNA()
        dna.newToonFromProperties(*self.toonInfo[self.DNA_INDEX])

        self.toon.setDNA(dna)

        self.toon.pose(*self.toonInfo[self.POSE_INDEX])
        self.toon.setScale(0.3)
        self.toon.setH(200)

        self.toon.getGeomNode().setDepthWrite(1)
        self.toon.getGeomNode().setDepthTest(1)

        self.toon.reparentTo(self)
コード例 #10
0
 def __gotOwner(self, dclass, fields):
     if dclass != self.air.dclassesByName['DistributedToonAI']:
         self.notify.warning('Got object of wrong type!')
         return
     self.botList = fields['setClothesBottomsList'][0]
     self.topList = fields['setClothesTopsList'][0]
     dna = ToonDNA(str=fields['setDNAString'][0])
     self.gender = dna.gender
コード例 #11
0
 def enterCreateAvatar(self):
     dna = ToonDNA()
     dna.makeFromNetString(self.dna)
     colorString = TTLocalizer.ColorfulToon
     animalType = TTLocalizer.AnimalToSpecies[dna.getAnimal()]
     name = ' '.join((colorString, animalType))
     toonFields = {
         'setName': (name, ),
         'setWishNameState': ('OPEN', ),
         'setWishName': ('', ),
         'setDNAString': (self.dna, ),
         'setDISLid': (self.target, ),
     }
     self.csm.air.dbInterface.createObject(
         self.csm.air.dbId,
         self.csm.air.dclassesByName['DistributedToonUD'], toonFields,
         self.__handleCreate)
コード例 #12
0
    def enterCreateAvatar(self):
        # We will now construct a new Toon with the given values.
        dna = ToonDNA()
        dna.makeFromNetString(self.dna)
        colorString = TTLocalizer.NumToColor[dna.headColor]
        animalType = TTLocalizer.AnimalToSpecies[dna.getAnimal()]
        name = ' '.join((colorString, animalType))
        toonFields = {'setName': (name,),
                      'WishNameState': ('OPEN',),
                      'WishName': ('',),
                      'setDNAString': (self.dna,),
                      'setDISLid': (self.target,)}

        # Create this new Toon object in the database. self.__handleCreate is the
        # callback that will be called upon the completion of createObject.
        self.gameServicesManager.air.dbInterface.createObject(self.gameServicesManager.air.dbId,
                                                              self.gameServicesManager.air.dclassesByName[
                                                                  'DistributedToonUD'], toonFields, self.__handleCreate)
コード例 #13
0
    def enterLoadHouse(self):
        # Quickly parse DNA and get gender.
        dna = ToonDNA()
        dna.makeFromNetString(self.toon['setDNAString'][0])
        gender = 1 if dna.getGender() == 'm' else 0

        # Activate the house:
        self.mgr.air.sendActivate(self.houseId, self.mgr.air.districtId, self.estate.zoneId,
                                  self.mgr.air.dclassesByName['DistributedHouseAI'],
                                  {'setHousePos': [self.houseIndex],
                                   'setColor': [self.houseIndex],
                                   'setName': [self.toon['setName'][0]],
                                   'setAvatarId': [self.toon['ID']],
                                   'setGender': [gender]})

        # Now we wait for the house to show up... We do this by hanging a messenger
        # hook which the DistributedHouseAI throws once it spawns.
        self.acceptOnce('generate-%d' % self.houseId, self.__gotHouse)
コード例 #14
0
 def enterCreateAvatar(self):
     dna = ToonDNA()
     dna.makeFromNetString(self.dna)
     colorString = TTLocalizer.NumToColor[dna.headColor]
     animalType = TTLocalizer.AnimalToSpecies[dna.getAnimal()]
     name = ' '.join((colorString, animalType))
     toonFields = {
         'setName': (name,),
         'WishNameState': ('OPEN',),
         'WishName': ('',),
         'setDNAString': (self.dna,),
         'setDISLid': (self.target,)
     }
     self.csm.air.dbInterface.createObject(
         self.csm.air.dbId,
         self.csm.air.dclassesByName['DistributedToonUD'],
         toonFields,
         self.__handleCreate)
コード例 #15
0
    def enterCreateAvatar(self):
        dna = ToonDNA()
        dna.makeFromNetString(self.dna)
        colorstring = TTLocalizer.NumToColor[dna.headColor]
        animaltype = TTLocalizer.AnimalToSpecies[dna.getAnimal()]
        name = colorstring + " " + animaltype

        toonFields = {
            "setName": (name,),
            "WishNameState": WISHNAME_OPEN,
            "WishName": "",
            "setDNAString": (self.dna,),
            "setDISLid": (self.target,),
        }

        self.csm.air.dbInterface.createObject(
            self.csm.air.dbId, self.csm.air.dclassesByName["DistributedToonUD"], toonFields, self.__handleCreate
        )
コード例 #16
0
    def enterCreateAvatar(self):
        dna = ToonDNA()
        dna.makeFromNetString(self.dna)
        colorstring = TTLocalizer.NumToColor[dna.headColor]
        animaltype = TTLocalizer.AnimalToSpecies[dna.getAnimal()]
        name = colorstring + ' ' + animaltype

        toonFields = {
            'setName': (name, ),
            'WishNameState': WISHNAME_OPEN,
            'WishName': '',
            'setDNAString': (self.dna, ),
            'setDISLid': (self.target, )
        }

        self.csm.air.dbInterface.createObject(
            self.csm.air.dbId,
            self.csm.air.dclassesByName['DistributedToonUD'], toonFields,
            self.__handleCreate)
コード例 #17
0
 def __gotOwner(self, dclass, fields):
     if dclass != self.air.dclassesByName['DistributedToonAI']:
         self.notify.warning('Got object of wrong type!')
         return
     self.hatList = fields['setHatList'][0]
     self.glassesList = fields['setGlassesList'][0]
     self.backpackList = fields['setBackpackList'][0]
     self.shoesList = fields['setShoesList'][0]
     dna = ToonDNA(str=fields['setDNAString'][0])
     self.gender = dna.gender
コード例 #18
0
 def enterStart(self, dna, name, index):
     if index >= 6:
         self.demand('Kill', 'Invalid index specified!')
         return
     if not ToonDNA().isValidNetString(dna):
         self.demand('Kill', 'Invalid DNA specified!')
         return
     self.index = index
     self.dna = dna
     self.name = name
     self.demand('RetrieveAccount')
コード例 #19
0
 def requestPolarBearTransformation(self):
     avId = self.air.getAvatarIdFromSender()
     av = self.air.doId2do.get(avId)
     if not av:
         return
     if av.dna.getAnimal() == 'bear' and av.dna.headColor != 0:
         newDNA = ToonDNA()
         newDNA.makeFromNetString(av.getDNAString())
         newDNA.headColor = 0
         newDNA.armColor = 0
         newDNA.legColor = 0
         taskMgr.doMethodLater(1.0, lambda task: av.b_setDNAString(newDNA.makeNetString()), 'transform-%d' % avId)
     self.sendUpdate('doPolarBearTransformation', [avId])
コード例 #20
0
    def enterLoadHouse(self):
        # Quickly parse DNA and get gender.
        dna = ToonDNA()
        dna.makeFromNetString(self.toon['setDNAString'][0])
        gender = 1 if dna.getGender() == 'm' else 0

        # Activate the house:
        self.mgr.air.sendActivate(
            self.houseId, self.mgr.air.districtId, self.estate.zoneId,
            self.mgr.air.dclassesByName['DistributedHouseAI'], {
                'setHousePos': [self.houseIndex],
                'setColor': [self.houseIndex],
                'setName': [self.toon['setName'][0]],
                'setAvatarId': [self.toon['ID']],
                'setGender': [gender]
            })

        # Now we wait for the house to show up... We do this by hanging a messenger
        # hook which the DistributedHouseAI throws once it spawns.
        self.acceptOnce('generate-%d' % self.houseId, self.__gotHouse)
コード例 #21
0
    def __handleAvatar(self, dclass, fields):
        if dclass != self.csm.air.dclassesByName['DistributedToonUD']:
            self.demand('Kill', "One of the account's avatars is invalid!")
            return

        if fields['WishNameState'][0] != 'OPEN':
            self.demand('Kill', 'Avatar is not in a namable state!')
            return

        self.dna = ToonDNA(fields['setDNAString'][0])
        self.demand('JudgeName')
コード例 #22
0
 def enterStart(self, dna, index, skipTutorial):
     if index >= 7:
         self.demand('Kill', 'Invalid index (%d) specified!' % index)
         return
     if not ToonDNA().isValidNetString(dna):
         self.demand('Kill', 'Invalid DNA specified!')
         return
     self.index = index
     self.dna = dna
     self.skipTutorial = skipTutorial
     self.demand('RetrieveAccount')
コード例 #23
0
 def requestTransformation(self):
     avId = self.air.getAvatarIdFromSender()
     av = self.air.doId2do.get(avId)
     if av is None:
         return
     if not hasattr(av, 'dna'):
         return
     if (av.dna.getAnimal() == 'bear') and (av.dna.headColor != 0x00):
         newDNA = ToonDNA()
         newDNA.makeFromNetString(av.getDNAString())
         newDNA.headColor = 0x00
         newDNA.armColor = 0x00
         newDNA.legColor = 0x00
         taskMgr.doMethodLater(1.0, lambda task: av.b_setDNAString(newDNA.makeNetString()), 'transform-%d' % avId)
         self.sendUpdate('doTransformation', [avId])
コード例 #24
0
    def enterStart(self, dna, index):
        # Basic sanity-checking:
        if index >= 6:
            self.demand('Kill', 'Invalid index specified!')
            return

        if not ToonDNA().isValidNetString(dna):
            self.demand('Kill', 'Invalid DNA specified!')
            return

        self.index = index
        self.dna = dna

        # Okay, we're good to go, let's query their account.
        self.demand('RetrieveAccount')
コード例 #25
0
    def requestBlackCatTransformation(self):
        avId = self.air.getAvatarIdFromSender()
        av = self.air.doId2do.get(avId)
        if not av: return

        if av.dna.getAnimal() == 'cat' and av.dna.headColor != 0x1a:
            newDNA = ToonDNA()
            newDNA.makeFromNetString(av.getDNAString())
            newDNA.headColor = 0x1a
            newDNA.armColor = 0x1a
            newDNA.legColor = 0x1a
            taskMgr.doMethodLater(1.0, lambda task: av.b_setDNAString(newDNA.makeNetString()), 'transform-%d' % avId)

            self.sendUpdate('doBlackCatTransformation', [avId])
コード例 #26
0
ファイル: DistributedNPCYinAI.py プロジェクト: CoolFangs/src
 def requestTransformation(self):
     avId = self.air.getAvatarIdFromSender()
     av = self.air.doId2do.get(avId)
     if av is None:
         return
     if not hasattr(av, "dna"):
         return
     if (av.dna.getAnimal() == "cat") and (av.dna.headColor != 0x1A):
         newDNA = ToonDNA()
         newDNA.makeFromNetString(av.getDNAString())
         newDNA.headColor = 0x1A
         newDNA.armColor = 0x1A
         newDNA.legColor = 0x1A
         taskMgr.doMethodLater(1.0, lambda task: av.b_setDNAString(newDNA.makeNetString()), "transform-%d" % avId)
         self.sendUpdate("doTransformation", [avId])
コード例 #27
0
 def requestTransformation(self):
     avId = self.air.getAvatarIdFromSender()
     av = self.air.doId2do.get(avId)
     if av is None:
         return
     if not hasattr(av, 'dna'):
         return
     if (av.dna.headColor != 0x00):
         newDNA = ToonDNA()
         newDNA.makeFromNetString(av.getDNAString())
         newDNA.headColor = 0x00
         newDNA.armColor = 0x00
         newDNA.legColor = 0x00
         taskMgr.doMethodLater(1.0, lambda task: av.b_setDNAString(newDNA.makeNetString()), 'transform-%d' % avId)
         self.sendUpdate('doTransformation', [avId])
コード例 #28
0
    def enterStart(self, dna, index):
        # First, perform some basic sanity checking.
        if index >= 6:
            # This index is invalid! Kill the connection.
            self.demand('Kill', 'Invalid index specified!')
            return

        if not ToonDNA().isValidNetString(dna):
            # This DNA string is invalid! Kill the connection.
            self.demand('Kill', 'Invalid DNA specified!')
            return

        # Store these values.
        self.index = index
        self.dna = dna

        # Now we can query their account.
        self.demand('RetrieveAccount')
    def requestBlackCatTransformation(self):
        avId = self.air.getAvatarIdFromSender()
        av = self.air.doId2do.get(avId)
        if not av:
            return

        if not simbase.air.wantHalloween and not simbase.air.holidayManager.isHolidayRunning(
                HALLOWEEN):
            return

        if av.dna.getAnimal() == 'cat' and av.dna.headColor != 0x1a:
            newDNA = ToonDNA()
            newDNA.makeFromNetString(av.getDNAString())
            newDNA.headColor = 0x1a
            newDNA.armColor = 0x1a
            newDNA.legColor = 0x1a
            taskMgr.doMethodLater(
                1.0, lambda task: av.b_setDNAString(newDNA.makeNetString()),
                'transform-%d' % avId)

            self.sendUpdate('doBlackCatTransformation', [avId])
コード例 #30
0
    def enterStart(self, dna, index, uber, tracks, pg):
        if index >= 6:
            self.demand('Kill', 'Invalid index specified!')
            return
        if not ToonDNA().isValidNetString(dna):
            self.demand('Kill', 'Invalid DNA specified!')
            return
        self.index = index
        self.dna = dna
        self.uber = uber
        self.pg = pg
        self.trackAccess = [0, 0, 0, 0, 1, 1, 0, 0]
        if pg == 1:
            self.trackAccess[tracks[0]] = 1
        elif pg == 2:
            for track in tracks:
                self.trackAccess[track] = 1

        self.demand('RetrieveAccount')
コード例 #31
0
    def enterStart(self, dna, name, index, tf, hood, trackChoice):
        # Basic sanity-checking:
        if index >= 6:
            self.demand('Kill', 'Invalid index specified!')
            return

        if not ToonDNA().isValidNetString(dna):
            self.demand('Kill', 'Invalid DNA specified!')
            return

        self.index = index
        self.dna = dna
        self.name = name
        self.tf = tf
        self.hood = hood
        self.trackChoice = trackChoice
        self.__pendingName = ""
        
        # Okay, we're good to go, let's query their account.
        self.demand('RetrieveAccount')
コード例 #32
0
    def requestBlackCatTransformation(self):
        if not self.air.newsManager.isHolidayRunning(ToontownGlobals.BLACK_CAT_DAY):
            return

        avId = self.air.getAvatarIdFromSender()
        av = self.air.doId2do.get(avId)

        if not av or av.getTutorialAck() or av.dna.getAnimal() != "cat" or av.dna.headColor == 0x1A:
            return

        newDNA = ToonDNA()
        newDNA.makeFromNetString(av.getDNAString())
        newDNA.updateToonProperties(armColor=26, legColor=26, headColor=26)
        taskMgr.doMethodLater(1.0, lambda task: av.b_setDNAString(newDNA.makeNetString()), "transform-%d" % avId)
        self.sendUpdateToAvatarId(avId, "doBlackCatTransformation", [])
コード例 #33
0
    def requestBlackCatTransformation(self):
        if not self.air.newsManager.isHolidayRunning(
                ToontownGlobals.BLACK_CAT_DAY):
            return

        avId = self.air.getAvatarIdFromSender()
        av = self.air.doId2do.get(avId)

        if not av or av.getTutorialAck(
        ) or av.dna.getAnimal() != 'cat' or av.dna.headColor == 0x1a:
            return

        newDNA = ToonDNA()
        newDNA.makeFromNetString(av.getDNAString())
        newDNA.updateToonProperties(armColor=26, legColor=26, headColor=26)
        taskMgr.doMethodLater(
            1.0, lambda task: av.b_setDNAString(newDNA.makeNetString()),
            'transform-%d' % avId)
        self.sendUpdateToAvatarId(avId, 'doBlackCatTransformation', [])
コード例 #34
0
    def enterStart(self, dna, index, uber, tracks, pg):
        # Basic sanity-checking:
        if index >= 6:
            self.demand('Kill', 'Invalid index specified!')
            return

        if not ToonDNA().isValidNetString(dna):
            self.demand('Kill', 'Invalid DNA specified!')
            return

        self.index = index
        self.dna = dna
        self.uber = uber
        self.pg = pg
        self.trackAccess = [0, 0, 0, 0, 1, 1, 0, 0]
        if pg == 1:
            self.trackAccess[tracks[0]] = 1
        elif pg == 2:
            for track in tracks:
                self.trackAccess[track] = 1

        # Okay, we're good to go, let's query their account.
        self.demand('RetrieveAccount')
コード例 #35
0
    def __handleToon(self, avId, dclass, fields):
        if avId not in self.__waiting:
            return

        if dclass != self.mgr.air.dclassesByName['DistributedToonUD']:
            self.__failures += 1
            self.notify.warning('%d query failed!' % avId)
            del self.__waiting[avId]
            if not self.__waiting:
                self.demand('QueryAvatars')
            return

        name = fields['setName'][0]
        hp = fields['setMaxHp'][0]

        dna = ToonDNA(fields['setDNAString'][0])
        species = getSpeciesName(dna.head)
        color = dna.headColor

        if species == 'pig':
            dna = 'pig'

        else:
            if species == 'cat' and color == 26:
                dna = 'blackcat'

            else:
                if color > 23:
                    color = 0

                dna = '%s_%s_%d' % (species, dna.head[1:], color)

        self.__responses[avId] = ((name, dna, hp), self.__waiting.pop(avId))

        if not self.__waiting:
            self.demand('QueryAvatars')
コード例 #36
0
    def enterCreateAvatar(self):
        name = self.name
        if not isNamePattern(self.name):
            dna = ToonDNA()
            dna.makeFromNetString(self.dna)
            colorstring = TTLocalizer.NumToColor[dna.headColor]
            animaltype = TTLocalizer.AnimalToSpecies[dna.getAnimal()]
            name = colorstring + ' ' + animaltype

        toonFields = {
            'setName': (name,),
            'WishNameState': ('PENDING' if not isNamePattern(self.name) else '',),
            'WishName': (self.name if not isNamePattern(self.name) else '',),
            'setDNAString': (self.dna,),
            'setDISLid': (self.target,)
        }
        
        if not self.tf and not self.hood:
            toonFields['setTutorialAck'] = (1,)
            toonFields['setQuests'] = ([163, 1000, 1000, 100, 3],)
            
        if self.hood:
            hqZones = []
            
            if self.hood == 1: # dd
                if not -1 in self.trackChoice:
                    self.demand('Kill', 'Invalid track choice for DD!')
                    return
                    
                jarsize = 50
                gaglimit = 25
                hoodId = 1000
                prevZones = [2000]
                questlimit = 2
                tier = 4
                hp = 25
                expm = 1500
                
            elif self.hood == 2: # dg
                if -1 in self.trackChoice:
                    self.demand('Kill', 'Invalid track choice for DG!')
                    return
                    
                jarsize = 60
                gaglimit = 30
                hoodId = 5000
                prevZones = [1000, 2000]
                questlimit = 2
                tier = 7
                hp = 34
                expm = 2300
                
            elif self.hood == 3 and config.GetBool('csp-want-mm', False): # mm (MIGHT BE DISABLED)
                if-1 in self.trackChoice:
                    self.demand('Kill', 'Invalid track choice for MM!')
                    return
                    
                jarsize = 80
                gaglimit = 35
                hoodId = 4000
                prevZones = [1000, 2000, 5000]
                questlimit = 3
                tier = 8
                hp = 43
                expm = 4000
                hqZones = [11000]
                toonFields['setCogParts'] = ((0, 0, 0, 1),)
                
            else:
                self.demand('Kill', 'Invalid hood!')
                return
                
            ta = [0, 0, 0, 0, 1, 1, 0]
            for t in self.trackChoice:
                if t != -1:
                    ta[t] = 1
                
            toonFields['setMaxMoney'] = (jarsize,)
            toonFields['setMaxCarry'] = (gaglimit,)
            toonFields['setTrackAccess'] = (ta,)
            toonFields['setDefaultZone'] = (hoodId,)
            toonFields['setHoodsVisited'] = (prevZones + hqZones + [hoodId],)
            toonFields['setZonesVisited'] = (prevZones + hqZones + [hoodId],)
            toonFields['setTeleportAccess'] = (prevZones,)
            toonFields['setQuestCarryLimit'] = (questlimit,)
            toonFields['setRewardHistory'] = (tier, [])
            toonFields['setHp'] = (hp,)
            toonFields['setMaxHp'] = (hp,)
            toonFields['setTutorialAck'] = (1,)
            
            e = Experience()
            e.makeExpRegular(expm)
            
            for i, t in enumerate(ta):
                if not t:
                    e.experience[i] = 0
                    
            toonFields['setExperience'] = (e.makeNetString(),)

        self.csm.air.dbInterface.createObject(
            self.csm.air.dbId,
            self.csm.air.dclassesByName['DistributedToonUD'],
            toonFields,
            self.__handleCreate)
コード例 #37
0
    def enterCreateAvatar(self):
        dna = ToonDNA()
        dna.makeFromNetString(self.dna)
            
        dg = PyDatagram(self.name)
        dgi = PyDatagramIterator(dg)
        isPattern, name = isNamePattern(dgi, self.csm.namePattern, dna.gender)
        
        if not name:
            self.demand('Kill', 'There\'s an issue with your name request!')
            return
        
        if not isPattern:
            self.__pendingName = name
            colorstring = TTLocalizer.NumToColor[dna.headColor]
            animaltype = TTLocalizer.AnimalToSpecies[dna.getAnimal()]
            name = colorstring + ' ' + animaltype

        toonFields = {
            'setName': (name,),
            'WishNameState': ('PENDING' if not isPattern else '',),
            'WishName': (self.__pendingName,),
            'setDNAString': (self.dna,),
            'setDISLid': (self.target,)
        }
        
        if not self.tf and not self.hood:
            toonFields['setTutorialAck'] = (1,)
            toonFields['setQuests'] = ([163, 1000, 1000, 100, 3],)
            
        if self.hood:
            hqZones = []
            
            if self.hood == 1: # dd
                if not -1 in self.trackChoice:
                    self.demand('Kill', 'Invalid track choice for DD!')
                    return
                    
                jarsize = 50
                gaglimit = 25
                hoodId = 1000
                prevZones = [2000]
                questlimit = 2
                tier = 4
                hp = 25
                expm = 1500
                
            elif self.hood == 2: # dg
                if -1 in self.trackChoice:
                    self.demand('Kill', 'Invalid track choice for DG!')
                    return
                    
                jarsize = 60
                gaglimit = 30
                hoodId = 5000
                prevZones = [1000, 2000]
                questlimit = 2
                tier = 7
                hp = 34
                expm = 2300
                
            elif self.hood == 3 and config.GetBool('csp-want-mm', False): # mm (MIGHT BE DISABLED)
                if -1 in self.trackChoice:
                    self.demand('Kill', 'Invalid track choice for MM!')
                    return
                    
                jarsize = 80
                gaglimit = 35
                hoodId = 4000
                prevZones = [1000, 2000, 5000]
                questlimit = 3
                tier = 8
                hp = 43
                expm = 4000
                hqZones = [11000]
                toonFields['setCogParts'] = ((0, 0, 0, 1),)
                
            else:
                self.demand('Kill', 'Invalid hood!')
                return
                
            ta = [0, 0, 0, 0, 1, 1, 0]
            for t in self.trackChoice:
                if t != -1:
                    ta[t] = 1
                
            toonFields['setMaxMoney'] = (jarsize,)
            toonFields['setMaxCarry'] = (gaglimit,)
            toonFields['setTrackAccess'] = (ta,)
            toonFields['setDefaultZone'] = (hoodId,)
            toonFields['setHoodsVisited'] = (prevZones + hqZones + [hoodId],)
            toonFields['setZonesVisited'] = (prevZones + hqZones + [hoodId],)
            toonFields['setTeleportAccess'] = (prevZones,)
            toonFields['setQuestCarryLimit'] = (questlimit,)
            toonFields['setRewardHistory'] = (tier, [])
            toonFields['setHp'] = (hp,)
            toonFields['setMaxHp'] = (hp,)
            toonFields['setTutorialAck'] = (1,)
            
            e = Experience()
            e.makeExpRegular(expm)
            
            for i, t in enumerate(ta):
                if not t:
                    e.experience[i] = 0
                    
            toonFields['setExperience'] = (e.makeNetString(),)

        self.csm.air.dbInterface.createObject(
            self.csm.air.dbId,
            self.csm.air.dclassesByName['DistributedToonUD'],
            toonFields,
            self.__handleCreate)
コード例 #38
0
 def setDNA(self, dnaString, finished, whichItem):
     avId = self.air.getAvatarIdFromSender()
     if avId != self.avId:
         self.air.writeServerEvent(
             'suspicious', avId,
             'Tried to set DNA from closet while not using it!')
         return
     av = self.air.doId2do.get(avId)
     if not av:
         self.air.writeServerEvent(
             'suspicious', avId,
             'Interacted with a closet from another shard!')
         return
     if not self.__verifyAvatarInMyZone(av):
         self.air.writeServerEvent(
             'suspicious', avId, 'Tried to setDNA while in another zone!')
         return
     testDna = ToonDNA()
     if not testDna.isValidNetString(dnaString):
         self.air.writeServerEvent('suspicious', avId,
                                   'Tried to set invalid DNA at a closet!')
         return
     if not finished:
         testDna.makeFromNetString(dnaString)
         if not self.__checkValidDNAChange(av, testDna):
             self.air.writeServerEvent(
                 'suspicious', avId,
                 'Tried to change their DNA temporarily!')
             return
         self.sendUpdate('setCustomerDNA', [avId, dnaString])
         return
     elif finished == 1:
         self.d_setMovie(ClosetGlobals.CLOSET_MOVIE_COMPLETE, avId,
                         globalClockDelta.getRealNetworkTime())
         self.resetMovie()
         self.d_setState(ClosetGlobals.CLOSED, 0, self.furnitureMgr.ownerId,
                         self.gender, self.topList, self.botList)
         av.b_setDNAString(self.customerDNA.makeNetString())
         self.removedBottoms = []
         self.removedTops = []
         self.customerDNA = None
         self.avId = None
     elif finished == 2:
         if avId != self.furnitureMgr.ownerId:
             self.air.writeServerEvent(
                 'suspicious', avId,
                 'Tried to set their clothes from somebody else\'s closet!')
             return
         testDna.makeFromNetString(dnaString)
         if whichItem & ClosetGlobals.SHIRT:
             success = av.replaceItemInClothesTopsList(
                 testDna.topTex, testDna.topTexColor, testDna.sleeveTex,
                 testDna.sleeveTexColor, self.customerDNA.topTex,
                 self.customerDNA.topTexColor, self.customerDNA.sleeveTex,
                 self.customerDNA.sleeveTexColor)
             if success:
                 self.customerDNA.topTex = testDna.topTex
                 self.customerDNA.topTexColor = testDna.topTexColor
                 self.customerDNA.sleeveTex = testDna.sleeveTex
                 self.customerDNA.sleeveTexColor = testDna.sleeveTexColor
             else:
                 self.air.writeServerEvent(
                     'suspicious', avId,
                     'Tried to set their shirt to a shirt they don\'t own!')
         if whichItem & ClosetGlobals.SHORTS:
             success = av.replaceItemInClothesBottomsList(
                 testDna.botTex, testDna.botTexColor,
                 self.customerDNA.botTex, self.customerDNA.botTexColor)
             if success:
                 self.customerDNA.botTex = testDna.botTex
                 self.customerDNA.botTexColor = testDna.botTexColor
                 if self.customerDNA.torso != testDna.torso:
                     if self.customerDNA.gender == 'm':
                         self.air.writeServerEvent(
                             'suspicious', avId,
                             'Tried to change their torso size!')
                         return
                     elif self.customerDNA.torso[0] != testDna.torso[0]:
                         self.air.writeServerEvent(
                             'suspicious', avId,
                             'Tried to change their torso size!')
                         return
                 self.customerDNA.torso = testDna.torso
             else:
                 self.air.writeServerEvent(
                     'suspicious', avId,
                     'Tried to set their shorts to a pair they don\'t own!')
         for bottom in self.removedBottoms:
             botTex, botTexColor = bottom
             success = av.removeItemInClothesBottomsList(
                 botTex, botTexColor)
             if not success:
                 self.air.writeServerEvent(
                     'suspicious', avId,
                     'Tried to remove a bottom they didn\'t have!')
         for top in self.removedTops:
             topTex, topTexColor, sleeveTex, sleeveTexColor = top
             success = av.removeItemInClothesTopsList(
                 topTex, topTexColor, sleeveTex, sleeveTexColor)
             if not success:
                 self.air.writeServerEvent(
                     'suspicious', avId,
                     'Tried to remove a top they didn\'t have!')
         av.b_setDNAString(self.customerDNA.makeNetString())
         av.b_setClothesTopsList(av.getClothesTopsList())
         av.b_setClothesBottomsList(av.getClothesBottomsList())
         self.topList = av.getClothesTopsList()
         self.botList = av.getClothesBottomsList()
         self.removedBottoms = []
         self.removedTops = []
         self.d_setMovie(ClosetGlobals.CLOSET_MOVIE_COMPLETE, avId,
                         globalClockDelta.getRealNetworkTime())
         self.resetMovie()
         self.d_setState(ClosetGlobals.CLOSED, 0, self.furnitureMgr.ownerId,
                         self.gender, self.topList, self.botList)
         self.customerDNA = None
         self.avId = None
    def enterCreateAvatar(self):
        dna = ToonDNA()
        dna.makeFromNetString(self.dna)
        colorString = TTLocalizer.NumToColor[dna.headColor]
        animalType = TTLocalizer.AnimalToSpecies[dna.getAnimal()]
        name = ' '.join((colorString, animalType))
		
        toonFields = {
            'setName': (name,),
            'WishNameState': ('OPEN',),
            'WishName': ('',),
            'setDNAString': (self.dna,),
            'setDISLid': (self.target,),
            'setUber': (self.uber,)
        }
		
        if self.pg > 0:
            if self.pg == 1:
                maxMoney = 50
                maxCarry = 25
                startingHood = 1000
                prevZones = [2000]
                questLimit = 3
                questTier = 4
                if self.uber == 1:
                    hp = 15
                else:
                    hp = 25
                experience = [600, 800]
                
            elif self.pg == 2: 
                maxMoney = 60
                maxCarry = 30
                startingHood = 5000
                prevZones = [1000, 2000]
                questLimit = 3
                questTier = 7
                if self.uber == 1:
                    hp = 15
                elif self.uber == 2:
                    hp = 25
                else:
                    hp = 34
                experience = [1000, 2400]
			
            exp = Experience()
            
            for i, t in enumerate(self.trackAccess):
                if t:
                    chosenExp = random.randint(experience[0], experience[1])
                    exp.setExp(i, chosenExp)

            toonFields['setExperience'] = (exp.makeNetString(),)
			
            toonFields['setMaxMoney'] = (maxMoney,)
            toonFields['setMaxCarry'] = (maxCarry,)
            toonFields['setTrackAccess'] = (self.trackAccess,)
            toonFields['setDefaultZone'] = (startingHood,)
            toonFields['setHoodsVisited'] = (prevZones + [startingHood],)
            toonFields['setZonesVisited'] = (prevZones + [startingHood],)
            toonFields['setTeleportAccess'] = (prevZones,)
            toonFields['setQuestCarryLimit'] = (questLimit,)
            toonFields['setRewardHistory'] = (questTier, [])
            toonFields['setHp'] = (hp,)
            toonFields['setMaxHp'] = (hp,)
            toonFields['setTutorialAck'] = (1,)
				
        self.csm.air.dbInterface.createObject(
            self.csm.air.dbId,
            self.csm.air.dclassesByName['DistributedToonUD'],
            toonFields,
            self.__handleCreate)
コード例 #40
0
 def setDNA(self, dnaString, finished, whichItem):
     avId = self.air.getAvatarIdFromSender()
     if avId != self.avId:
         self.air.writeServerEventMessage('suspicious', avId, 'Tried to set DNA from closet while not using it!')
         return
     av = self.air.doId2do.get(avId)
     if not av:
         self.air.writeServerEventMessage('suspicious', avId, 'Interacted with a closet from another shard!')
         return
     if not self.__verifyAvatarInMyZone(av):
         self.air.writeServerEventMessage('suspicious', avId, 'Tried to setDNA while in another zone!')
         return
     testDna = ToonDNA()
     if not testDna.isValidNetString(dnaString):
         self.air.writeServerEventMessage('suspicious', avId, 'Tried to set invalid DNA at a closet!')
         return
     if not finished:
         testDna.makeFromNetString(dnaString)
         if not self.__checkValidDNAChange(av, testDna):
                 self.air.writeServerEventMessage('suspicious', avId, 'Tried to change their DNA temporarily!')
                 return
         self.sendUpdate('setCustomerDNA', [avId, dnaString])
         return
     elif finished == 1:
         self.d_setMovie(ClosetGlobals.CLOSET_MOVIE_COMPLETE, avId, globalClockDelta.getRealNetworkTime())
         self.resetMovie()
         self.d_setState(ClosetGlobals.CLOSED, 0, self.furnitureMgr.ownerId, self.gender, self.topList, self.botList)
         av.b_setDNAString(self.customerDNA.makeNetString())
         self.removedBottoms = []
         self.removedTops = []
         self.customerDNA = None
         self.avId = None
     elif finished == 2:
         if avId != self.furnitureMgr.ownerId:
             self.air.writeServerEventMessage('suspicious', avId, 'Tried to set their clothes from somebody else\'s closet!')
             return
         testDna.makeFromNetString(dnaString)
         if whichItem & ClosetGlobals.SHIRT:
             success = av.replaceItemInClothesTopsList(testDna.topTex, testDna.topTexColor, testDna.sleeveTex, testDna.sleeveTexColor, self.customerDNA.topTex, self.customerDNA.topTexColor, self.customerDNA.sleeveTex, self.customerDNA.sleeveTexColor)
             if success:
                 self.customerDNA.topTex = testDna.topTex
                 self.customerDNA.topTexColor = testDna.topTexColor
                 self.customerDNA.sleeveTex = testDna.sleeveTex
                 self.customerDNA.sleeveTexColor = testDna.sleeveTexColor
             else:
                 self.air.writeServerEventMessage('suspicious', avId, 'Tried to set their shirt to a shirt they don\'t own!')
         if whichItem & ClosetGlobals.SHORTS:
             success = av.replaceItemInClothesBottomsList(testDna.botTex, testDna.botTexColor, self.customerDNA.botTex, self.customerDNA.botTexColor)
             if success:
                 self.customerDNA.botTex = testDna.botTex
                 self.customerDNA.botTexColor = testDna.botTexColor
                 if self.customerDNA.torso != testDna.torso:
                         if self.customerDNA.gender == 'm':
                             self.air.writeServerEventMessage('suspicious', avId, 'Tried to change their torso size!')
                             return
                         elif self.customerDNA.torso[0] != testDna.torso[0]:
                             self.air.writeServerEventMessage('suspicious', avId, 'Tried to change their torso size!')
                             return
                 self.customerDNA.torso = testDna.torso
             else:
                 self.air.writeServerEventMessage('suspicious', avId, 'Tried to set their shorts to a pair they don\'t own!')
         for bottom in self.removedBottoms:
             botTex, botTexColor = bottom
             success = av.removeItemInClothesBottomsList(botTex, botTexColor)
             if not success:
                 self.air.writeServerEventMessage('suspicious', avId, 'Tried to remove a bottom they didn\'t have!')
         for top in self.removedTops:
             topTex, topTexColor, sleeveTex, sleeveTexColor = top
             success = av.removeItemInClothesTopsList(topTex, topTexColor, sleeveTex, sleeveTexColor)
             if not success:
                 self.air.writeServerEventMessage('suspicious', avId, 'Tried to remove a top they didn\'t have!')
         av.b_setDNAString(self.customerDNA.makeNetString())
         av.b_setClothesTopsList(av.getClothesTopsList())
         av.b_setClothesBottomsList(av.getClothesBottomsList())
         self.topList = av.getClothesTopsList()
         self.botList = av.getClothesBottomsList()
         self.removedBottoms = []
         self.removedTops = []
         self.d_setMovie(ClosetGlobals.CLOSET_MOVIE_COMPLETE, avId, globalClockDelta.getRealNetworkTime())
         self.resetMovie()
         self.d_setState(ClosetGlobals.CLOSED, 0, self.furnitureMgr.ownerId, self.gender, self.topList, self.botList)
         self.customerDNA = None
         self.avId = None