示例#1
0
 def setProgressPercent(self, percent):
     percent = PythonUtil.clampScalar(percent / 100.0, 0.0, 1.0)
     steps = int(self.NUMSTEPS * percent)
     for x in range(steps, self.NUMSTEPS):
         self.spots[x].hide()
     
     for x in range(steps):
         self.spots[x].show()
示例#2
0
    def gotOwner(self, toon, pet):
        # this will request another pet if there are more to request
        # this is not called until we get to this point because we need to
        # request the pet's owner after we get the pet, and we don't count
        # the pet as 'processed' until we've got the owner
        self.getNextPet()

        if toon is None:
            # prevent mem leak
            pet.patchDelete()
            return

        minHp = 15
        maxHp = ToontownGlobals.MaxHpLimit
        normHp = (toon.getMaxHp() - minHp) / float(maxHp - minHp)
        normHp = PythonUtil.clampScalar(normHp, 0., 1.)

        maxMoney = toon.getMaxMoney() + toon.getMaxBankMoney()

        print('%s HP, %s, %s, %s, %s' %
              (toon.getMaxHp(), normHp, toon.getMaxMoney(),
               toon.getMaxBankMoney(), maxMoney))

        szList = MinigameGlobals.SafeZones
        numSz = len(szList)
        for i in range(numSz):
            if normHp < (float(i + 1) / numSz):
                break
            # check that they can even afford a pet from the next sz
            if i < (numSz - 1):
                if maxMoney < PetConstants.ZoneToCostRange[szList[i + 1]][0]:
                    print("toon %s can't afford pet from sz %s" %
                          (pet.getOwnerId(), szList[i + 1]))
                    break
        newSz = szList[i]

        # this will hold the names of modified values for the pet
        fields = []

        if newSz != ToontownGlobals.ToontownCentral:
            print('newSafezone: %s' % newSz)
            # recalculate the pet's traits
            newTraits = PetTraits.PetTraits(pet.getTraitSeed(), newSz)
            pet.setTraits(newTraits.getValueList())
            fields.extend(
                list(map(pet.getSetterName, PetTraits.getTraitNames())))

            pet.setSafeZone(newSz)
            fields.append('setSafeZone')

        if len(fields):
            print('== Fixing pet %s' % pet.doId)
            db = DatabaseObject.DatabaseObject(self.air, pet.doId)
            db.storeObject(pet, fields)

        # prevent mem leak
        pet.patchDelete()
        toon.patchDelete()
 def _FlagDNA__setLayoutYPos(self, val):
     self.layoutData[2] = PythonUtil.clampScalar(
         val, FlagGlobals.YPosLowCount, FlagGlobals.YPosHiCount - 1)
 def _FlagDNA__setLayoutScale(self, val):
     self.layoutData[4] = PythonUtil.clampScalar(
         val, 0, FlagGlobals.LayoutScaleCount - 1)
 def _FlagDNA__setBackgroundStyle(self, val):
     self.bgData[0] = PythonUtil.clampScalar(
         val, 0, FlagGlobals.BackgroundCount - 1)
 def _FlagDNA__setBackgroundColor(self, index, val):
     self.bgData[1 + index] = PythonUtil.clampScalar(
         val, 0, FlagGlobals.ColorCount - 1)
示例#7
0
 def __setEmblemStyle(self, emblemNum, val):
     self.emblems[emblemNum][0] = PythonUtil.clampScalar(
         val, 0, FlagGlobals.EmblemCount - 1)
 def _FlagDNA__setShapeStyle(self, val):
     self.shape = PythonUtil.clampScalar(val, 0, FlagGlobals.ShapeCount)
 def _FlagDNA__setEmblemColor(self, emblemNum, val):
     self.emblems[emblemNum][1] = PythonUtil.clampScalar(val, 0, FlagGlobals.ColorCount - 1)
 def _FlagDNA__setEmblemScale(self, emblemNum, val):
     self.emblems[emblemNum][4] = PythonUtil.clampScalar(
         val, 0, FlagGlobals.EmblemScaleCount - 1)
 def _FlagDNA__setLayoutYPos(self, val):
     self.layoutData[2] = PythonUtil.clampScalar(val, FlagGlobals.YPosLowCount, FlagGlobals.YPosHiCount - 1)
 def _FlagDNA__setLayoutScale(self, val):
     self.layoutData[4] = PythonUtil.clampScalar(val, 0, FlagGlobals.LayoutScaleCount - 1)
 def _FlagDNA__setBackgroundColor(self, index, val):
     self.bgData[1 + index] = PythonUtil.clampScalar(val, 0, FlagGlobals.ColorCount - 1)
 def _FlagDNA__setBackgroundStyle(self, val):
     self.bgData[0] = PythonUtil.clampScalar(val, 0, FlagGlobals.BackgroundCount - 1)
 def _FlagDNA__setShapeStyle(self, val):
     self.shape = PythonUtil.clampScalar(val, 0, FlagGlobals.ShapeCount)
 def _FlagDNA__setEmblemColor(self, emblemNum, val):
     self.emblems[emblemNum][1] = PythonUtil.clampScalar(
         val, 0, FlagGlobals.ColorCount - 1)
示例#17
0
 def __setLayoutStyle(self, val):
     self.layoutData[0] = PythonUtil.clampScalar(
         val, 0, FlagGlobals.LayoutCount - 1)
 def _FlagDNA__setEmblemPos(self, emblemNum, val):
     PosCount = len(FlagGlobals.LayoutOffsets[self.layoutData[0]])
     self.emblems[emblemNum][2] = PythonUtil.clampScalar(
         val, 0, PosCount - 1)
 def _FlagDNA__setEmblemScale(self, emblemNum, val):
     self.emblems[emblemNum][4] = PythonUtil.clampScalar(val, 0, FlagGlobals.EmblemScaleCount - 1)
 def _FlagDNA__setEmblemPos(self, emblemNum, val):
     PosCount = len(FlagGlobals.LayoutOffsets[self.layoutData[0]])
     self.emblems[emblemNum][2] = PythonUtil.clampScalar(val, 0, PosCount - 1)
示例#21
0
 def __setLayoutXPos(self, val):
     self.layoutData[1] = PythonUtil.clampScalar(
         val, FlagGlobals.XPosLowCount, FlagGlobals.XPosHiCount - 1)