def construct(self, gardenData, gType=0):
     self.plotIndex = gardenData[1]
     self.plotType = GardenGlobals.getPlotType(self.ownerIndex,
                                               self.plotIndex)
     self.pos = GardenGlobals.getPlotPos(self.ownerIndex, self.plotIndex)
     self.heading = GardenGlobals.getPlotHeading(self.ownerIndex,
                                                 self.plotIndex)
 def handlePicking(self):
     messenger.send('wakeup')
     fullName = GardenGlobals.getFlowerVarietyName(self.species, self.variety)
     if self.isWilted():
         self.confirmDialog = TTDialog.TTDialog(style=TTDialog.YesNo, text=TTLocalizer.ConfirmWiltedFlower % {'plant': fullName}, command=self.confirmCallback)
     elif not self.isFruiting():
         self.confirmDialog = TTDialog.TTDialog(style=TTDialog.YesNo, text=TTLocalizer.ConfirmUnbloomingFlower % {'plant': fullName}, command=self.confirmCallback)
     elif base.localAvatar.isFlowerBasketFull():
         self.confirmDialog = TTDialog.TTDialog(style=TTDialog.CancelOnly, text=TTLocalizer.ConfirmBasketFull, command=self.confirmCallback)
     else:
         shovel = base.localAvatar.shovel
         skill = base.localAvatar.shovelSkill
         shovelPower = GardenGlobals.getShovelPower(shovel, skill)
         giveSkillUp = True
         beansRequired = GardenGlobals.getNumBeansRequired(self.species, self.variety)
         if not shovelPower == beansRequired:
             giveSkillUp = False
         if giveSkillUp:
             if skill == GardenGlobals.getMaxShovelSkill():
                 text = (TTLocalizer.ConfirmMaxedSkillFlower % {'plant': fullName},)
             else:
                 text = TTLocalizer.ConfirmSkillupFlower % {'plant': fullName}
             self.confirmDialog = TTDialog.TTDialog(style=TTDialog.YesNo, text=text, command=self.confirmCallback)
         else:
             self.confirmDialog = TTDialog.TTDialog(style=TTDialog.YesNo, text=TTLocalizer.ConfirmNoSkillupFlower % {'plant': fullName}, command=self.confirmCallback)
     self.confirmDialog.show()
     base.localAvatar.setInGardenAction(self)
     base.cr.playGame.getPlace().detectedGardenPlotUse()
 def getRequestPurchaseErrorText(self, retcode):
     retval = CatalogItem.CatalogItem.getRequestPurchaseErrorText(self, retcode)
     origText = retval
     if retval == TTLocalizer.CatalogPurchaseItemAvailable or retval == TTLocalizer.CatalogPurchaseItemOnOrder:
         recipeKey = GardenGlobals.getRecipeKeyUsingSpecial(self.gardenIndex)
         if not recipeKey == -1:
             retval += GardenGlobals.getPlantItWithString(self.gardenIndex)
             if self.gardenIndex == GardenGlobals.GardenAcceleratorSpecial:
                 if GardenGlobals.ACCELERATOR_USED_FROM_SHTIKER_BOOK:
                     retval = origText
                     retval += TTLocalizer.UseFromSpecialsTab
                 retval += TTLocalizer.MakeSureWatered
     return retval
    def waterPlant(self):
        avId = self.air.getAvatarIdFromSender()
        av = self.air.doId2do.get(avId)
        if not av:
            return

        if self.waterLevel < GardenGlobals.getMaxWateringCanPower():
            self.waterLevel += GardenGlobals.getWateringCanPower(av.wateringCan, av.wateringCanSkill)
            self.d_setWaterLevel(self.waterLevel)

            self.gardenManager.updateGardenData()

        self.setMovie(GardenGlobals.MOVIE_WATER, self.air.getAvatarIdFromSender())
示例#5
0
 def __handleItemPlantingDone(self,
                              willPlant=0,
                              recipeStr='',
                              selectedSpecial=-1):
     self.ignore(self.plantingGuiDoneEvent)
     self.ignore('stoppedAsleep')
     self.plantingGui.destroy()
     self.plantingGui = None
     base.localAvatar.showGardeningGui()
     base.localAvatar.removeShovelRelatedDoId(self.doId)
     gardenSpecials = base.localAvatar.getGardenSpecials()
     special = -1
     if selectedSpecial >= 0:
         special = gardenSpecials[selectedSpecial][0]
     successPlanting = False
     successToonStatue = False
     if willPlant:
         recipeKey = GardenGlobals.getRecipeKey(recipeStr, special)
         if recipeKey >= 0:
             species, variety = GardenGlobals.getSpeciesVarietyGivenRecipe(
                 recipeKey)
             if species >= 0 and variety >= 0:
                 if GardenGlobals.PlantAttributes[species][
                         'plantType'] == GardenGlobals.STATUARY_TYPE:
                     successPlanting = True
                     if species >= 205 and species <= 208:
                         successToonStatue = True
                     else:
                         self.sendUpdate('plantStatuary', [species])
         else:
             self.notify.debug('%s %d is not a valid recipe' %
                               (recipeStr, special))
             burntBeans = len(recipeStr)
             self.sendUpdate('plantNothing', [burntBeans])
     if successPlanting:
         itemName = GardenGlobals.PlantAttributes[species]['name']
         stringToShow = TTLocalizer.getResultPlantedSomethingSentence(
             itemName)
     elif willPlant:
         self.resultDialog = TTDialog.TTDialog(
             style=TTDialog.Acknowledge,
             text=TTLocalizer.ResultPlantedNothing,
             command=self.popupItemPlantingGuiAgain)
     else:
         self.finishInteraction()
     if successToonStatue:
         self.popupToonStatueSelectionGui(species)
     return
 def doResultDialog(self):
     self.startInteraction()
     flowerName = GardenGlobals.getFlowerVarietyName(self.species, self.variety)
     stringToShow = TTLocalizer.getResultPlantedSomethingSentence(flowerName)
     self.resultDialog = TTDialog.TTDialog(
         style=TTDialog.Acknowledge, text=stringToShow, command=self.resultsCallback
     )
    def __init__(self, parent, recipe, **kw):
        left = 0
        right = 0.445
        bottom = 0
        top = 0.08
        borderWidth = 0.01
        optiondefs = [('relief', DGG.RIDGE, None),
         ('state', 'normal', None),
         ('pos', (0, 0, 0), None),
         ('frameSize', (left,
           right,
           bottom,
           top), None),
         ('borderWidth', (borderWidth, borderWidth), self.setBorderWidth)]
        self.defineoptions(kw, optiondefs)
        DirectFrame.__init__(self, parent)
        self.initialiseoptions(BeanRecipeGui)
        self.jellyBeanBoxList = []
        xIncrement = 0.052
        for i in range(len(recipe)):
            beanIndex = GardenGlobals.BeanColorLetters.index(recipe[i])
            self.createJellyBeanBox(beanIndex, borderWidth + xIncrement * i, borderWidth)

        for j in range(len(recipe), GardenGlobals.getNumberOfShovelBoxes()):
            self.createEmptyBeanBox(borderWidth + xIncrement * j, borderWidth)

        return
 def __init__(self, doneEvent, specialBoxActive = False):
     if specialBoxActive:
         instructions = TTLocalizer.GardeningChooseBeansItem
         instructionsPos = (0, 0.4)
     else:
         instructions = TTLocalizer.GardeningChooseBeans
         instructionsPos = (0, 0.35)
     DirectFrame.__init__(self, relief=None, state='normal', geom=DGG.getDefaultDialogGeom(), geom_color=ToontownGlobals.GlobalDialogColor, geom_scale=(1.5, 1.0, 1.0), frameSize=(-1, 1, -1, 1), pos=(0, 0, 0), text=instructions, text_wordwrap=20, text_scale=0.08, text_pos=instructionsPos)
     self.initialiseoptions(PlantingGUI)
     self.doneEvent = doneEvent
     buttons = loader.loadModel('phase_3/models/gui/dialog_box_buttons_gui')
     okImageList = (buttons.find('**/ChtBx_OKBtn_UP'), buttons.find('**/ChtBx_OKBtn_DN'), buttons.find('**/ChtBx_OKBtn_Rllvr'))
     cancelImageList = (buttons.find('**/CloseBtn_UP'), buttons.find('**/CloseBtn_DN'), buttons.find('**/CloseBtn_Rllvr'))
     resetImageList = (buttons.find('**/CloseBtn_UP'), buttons.find('**/CloseBtn_DN'), buttons.find('**/CloseBtn_Rllvr'))
     self.cancelButton = DirectButton(parent=self, relief=None, image=cancelImageList, pos=(-0.3, 0, -0.35), text=TTLocalizer.PlantingGuiCancel, text_scale=0.06, text_pos=(0, -0.1), command=self.__cancel)
     self.okButton = DirectButton(parent=self, relief=None, image=okImageList, pos=(0.3, 0, -0.35), text=TTLocalizer.PlantingGuiOk, text_scale=0.06, text_pos=(0, -0.1), command=self.__doPlant)
     self.resetButton = DirectButton(parent=self, relief=None, image=resetImageList, pos=(0.0, 0, -0.35), text=TTLocalizer.PlantingGuiReset, text_scale=0.06, text_pos=(0, -0.1), command=self.__reset)
     buttons.removeNode()
     self.availableBoxes = base.localAvatar.getBoxCapability()
     self.maxBoxes = GardenGlobals.getNumberOfShovelBoxes()
     self.activeBoxesList = []
     self.specialBox = None
     self.specialBoxActive = specialBoxActive
     self.boxList = []
     self.jellyBeanPicker = None
     self.jellyBeanPickerInterval = None
     self.createBoxes()
     guiItems = loader.loadModel('phase_5.5/models/gui/catalog_gui')
     self.beanBank = DirectLabel(self, relief=None, image=guiItems.find('**/bean_bank'), text=str(base.localAvatar.getMoney() + base.localAvatar.getBankMoney()), text_align=TextNode.ARight, text_scale=0.11, text_fg=(0.95, 0.95, 0, 1), text_shadow=(0, 0, 0, 1), text_pos=(0.75, -0.81), text_font=ToontownGlobals.getSignFont(), pos=(-0.85, 0, 0.2), scale=0.5)
     self.matchBoxesToAvailableMoney()
     if PICKER_ALWAYS_UP:
         self.spiffyBeanBoxClicked(0)
     return
示例#9
0
 def announceGenerate(self):
     self.plotType = GardenGlobals.whatCanBePlanted(self.ownerIndex,
                                                    self.plot)
     self.stickUp = 0.0
     if self.getOwnerId() != localAvatar.doId:
         self.defaultModel = None
     elif self.plotType == GardenGlobals.FLOWER_TYPE:
         self.collSphereRadius = 2.0
         self.collSphereOffset = 0.0
         self.plotScale = 0.7
         self.stickUp = 1.1
     elif self.plotType == GardenGlobals.GAG_TREE_TYPE:
         self.collSphereRadius = 3.0
         self.plotScale = 1.5
         self.colorScaler = Vec4(1.0, 1.0, 1.0, 1)
     elif self.plotType == GardenGlobals.STATUARY_TYPE:
         self.collSphereRadius = 3.0
         self.plotScale = 0.075
         self.stickUp = -0.0
         self.defaultModel = 'phase_5.5/models/estate/garden_slab'
     else:
         self.collSphereOffset = 0.0
     self.notify.debug('announceGenerate')
     DistributedLawnDecor.DistributedLawnDecor.announceGenerate(self)
     return
    def construct(self, gardenData):
        DistributedPlantBaseAI.construct(self, gardenData)

        self.wilted = gardenData.getUint8()
        if self.waterLevel == -1:
            self.wilted = True

        self.gagTrack, self.gagLevel = GardenGlobals.getTreeTrackAndLevel(self.typeIndex)
示例#11
0
    def construct(self, gardenData):
        DistributedPlantBaseAI.construct(self, gardenData)

        self.wilted = gardenData.getUint8()
        if self.waterLevel == -1:
            self.wilted = True

        self.gagTrack, self.gagLevel = GardenGlobals.getTreeTrackAndLevel(
            self.typeIndex)
    def waterPlantDone(self):
        avId = self.air.getAvatarIdFromSender()
        av = self.air.doId2do.get(avId)
        if not av:
            return

        currSkill = av.getWateringCanSkill()
        if self.waterLevel < GardenGlobals.getMaxWateringCanPower():
            av.b_setWateringCanSkill(currSkill + 1 + self.getGrowthState())

        self.setMovie(GardenGlobals.MOVIE_CLEAR, self.air.getAvatarIdFromSender())
 def constructTree(self, plotIndex, gagTrack, gagLevel):
     gardenData = [
         0, plotIndex,
         GardenGlobals.getTreeTypeIndex(gagTrack, gagLevel), 0, 0,
         self.getTimestamp(), 0
     ]
     plot = occupier2Class[GardenGlobals.TreePlot](self.air, self,
                                                   self.house.housePos)
     plot.construct(gardenData)
     self.plots[plotIndex] = plot
     self.updateGardenData()
示例#14
0
    def createBlankGarden(self):
        gardenData = PyDatagram()

        plots = GardenGlobals.getGardenPlots(self.house.housePos)
        gardenData.addUint8(len(plots))

        for i, plotData in enumerate(plots):
            gardenData.addUint8(GardenGlobals.EmptyPlot)
            gardenData.addUint8(i)

        self.house.b_setGardenData(gardenData.getMessage())
        self.loadGarden()
示例#15
0
    def createBlankGarden(self):
        gardenData = PyDatagram()

        plots = GardenGlobals.getGardenPlots(self.house.housePos)
        gardenData.addUint8(len(plots))

        for i, plotData in enumerate(plots):
            gardenData.addUint8(GardenGlobals.EmptyPlot)
            gardenData.addUint8(i)

        self.house.b_setGardenData(gardenData.getMessage())
        self.loadGarden()
    def updatePage(self):
        if hasattr(self, "collectedTotal"):
            self.collectedTotal["text"] = TTLocalizer.GardenPageCollectedTotal % (
                len(base.localAvatar.flowerCollection),
                GardenGlobals.getNumberOfFlowerVarieties(),
            )
        if hasattr(self, "shovelBar"):
            shovel = base.localAvatar.shovel
            shovelName = TTLocalizer.ShovelNameDict[shovel]
            curShovelSkill = base.localAvatar.shovelSkill
            maxShovelSkill = GardenGlobals.ShovelAttributes[shovel]["skillPts"]
            if shovel == GardenGlobals.MAX_SHOVELS - 1:
                maxShovelSkill -= 1
            wateringCan = base.localAvatar.wateringCan
            wateringCanName = TTLocalizer.WateringCanNameDict[wateringCan]
            curWateringCanSkill = base.localAvatar.wateringCanSkill
            maxWateringCanSkill = GardenGlobals.WateringCanAttributes[wateringCan]["skillPts"]
            if wateringCan == GardenGlobals.MAX_WATERING_CANS - 1:
                maxWateringCanSkill -= 1
            textToUse = TTLocalizer.GardenPageShovelInfo % (shovelName, curShovelSkill, maxShovelSkill)
            self.shovelBar["text"] = textToUse
            self.shovelBar["value"] = float(curShovelSkill) / float(maxShovelSkill) * self.barLength + self.FUDGE_FACTOR
            textToUse = TTLocalizer.GardenPageWateringCanInfo % (
                wateringCanName,
                curWateringCanSkill,
                maxWateringCanSkill,
            )
            self.wateringCanBar["text"] = textToUse
            self.wateringCanBar["value"] = (
                float(curWateringCanSkill) / float(maxWateringCanSkill) * self.barLength + self.FUDGE_FACTOR
            )
        else:
            print "no shovel bar"
        if self.mode == GardenPage_Collection:
            if hasattr(self, "browser"):
                self.browser.update()
        elif self.mode == GardenPage_Basket:
            if hasattr(self, "picker"):
                newBasketFlower = base.localAvatar.flowerBasket.getFlower()
                self.picker.update(newBasketFlower)
        elif self.mode == GardenPage_Trophy:
            if hasattr(self, "trophies"):
                for trophy in self.trophies:
                    trophy.setLevel(-1)

                for trophyId in base.localAvatar.getGardenTrophies():
                    self.trophies[trophyId].setLevel(trophyId)

        elif self.mode == GardenPage_Specials:
            self.createGardenSpecialsList()
            if not base.cr.playGame.getPlace().getState() == "stickerBook":
                self.specialsPhoto.hide()
示例#17
0
    def constructTree(self, plotIndex, gagTrack, gagLevel):
        dg = PyDatagram()
        dg.addUint8(plotIndex)
        dg.addUint8(GardenGlobals.getTreeTypeIndex(gagTrack, gagLevel))  # Type Index
        dg.addInt8(0)  # Water Level
        dg.addInt8(0)  # Growth Level
        dg.addUint32(self.getTimestamp())
        dg.addUint8(0)  # Wilted State (False)
        gardenData = PyDatagramIterator(dg)

        plot = occupier2Class[GardenGlobals.TreePlot](self.air, self, self.house.housePos)
        plot.construct(gardenData)
        self.plots[plotIndex] = plot

        self.updateGardenData()
示例#18
0
    def createBlankGarden(self):
        gardenData = PyDatagram()

        # NF
        plots = GardenGlobals.getGardenPlots(self.house.housePos)
        boxes = GardenGlobals.getBoxPlots(self.house.housePos)

        tester = plots + boxes

        length_p_b = len(plots) + len(boxes)

        gardenData.addUint8(length_p_b)

        for i, plotData in enumerate(tester):

            if i != 6:
                gardenData.addUint8(GardenGlobals.EmptyPlot)
            else:
                gardenData.addUint8(GardenGlobals.PlanterBox)

            gardenData.addUint8(i)

        self.house.b_setGardenData(gardenData.getMessage())
        self.loadGarden()
示例#19
0
    def constructTree(self, plotIndex, gagTrack, gagLevel):
        dg = PyDatagram()
        dg.addUint8(plotIndex)
        dg.addUint8(GardenGlobals.getTreeTypeIndex(gagTrack, gagLevel))  # Type Index
        dg.addInt8(0)  # Water Level
        dg.addInt8(0)  # Growth Level
        dg.addUint32(self.getTimestamp())
        dg.addUint8(0)  # Wilted State (False)
        gardenData = PyDatagramIterator(dg)

        plot = occupier2Class[GardenGlobals.TreePlot](self.air, self, self.house.housePos)
        plot.construct(gardenData)
        self.plots[plotIndex] = plot

        self.updateGardenData()
示例#20
0
 def __handleFlowerPlantingDone(self,
                                willPlant=0,
                                recipeStr='',
                                special=-1):
     self.ignore(self.plantingGuiDoneEvent)
     self.ignore('stoppedAsleep')
     self.plantingGui.destroy()
     self.plantingGui = None
     base.localAvatar.showGardeningGui()
     base.localAvatar.removeShovelRelatedDoId(self.doId)
     successPlanting = False
     if willPlant:
         recipeKey = GardenGlobals.getRecipeKey(recipeStr, special)
         if recipeKey >= 0:
             species, variety = GardenGlobals.getSpeciesVarietyGivenRecipe(
                 recipeKey)
             if species >= 0 and variety >= 0:
                 self.sendUpdate('plantFlower', [species, variety])
                 successPlanting = True
         else:
             self.notify.debug('%s %d is not a valid recipe' %
                               (recipeStr, special))
             burntBeans = len(recipeStr)
             self.sendUpdate('plantNothing', [burntBeans])
     if successPlanting:
         flowerName = GardenGlobals.getFlowerVarietyName(species, variety)
         stringToShow = TTLocalizer.getResultPlantedSomethingSentence(
             flowerName)
     elif willPlant:
         self.resultDialog = TTDialog.TTDialog(
             style=TTDialog.Acknowledge,
             text=TTLocalizer.ResultPlantedNothing,
             command=self.popupFlowerPlantingGuiAgain)
     else:
         self.finishInteraction()
     return
示例#21
0
 def isSkillTooLow(self, avatar):
     recipeKey = GardenGlobals.getRecipeKeyUsingSpecial(self.gardenIndex)
     recipe = GardenGlobals.Recipes[recipeKey]
     numBeansRequired = len(recipe['beans'])
     canPlant = avatar.getBoxCapability()
     result = False
     if canPlant < numBeansRequired:
         result = True
     if not result and GardenGlobals.Specials.has_key(self.gardenIndex) and GardenGlobals.Specials[self.gardenIndex].has_key('minSkill'):
         minSkill = GardenGlobals.Specials[self.gardenIndex]['minSkill']
         if avatar.shovelSkill < minSkill:
             result = True
         else:
             result = False
     return result
    def createBlankGarden(self):
        data = []

        plots = GardenGlobals.getGardenPlots(self.house.housePos)

        for i, plotData in enumerate(plots):
            holdingList = []
            holdingList.append(GardenGlobals.EmptyPlot)
            holdingList.append(i)
            data.append(holdingList)

        myPickledGarden = pickle.dumps(data)

        # Sends gatden data to clients
        self.house.b_setGardenData(myPickledGarden)
        self.loadGarden()
 def awardedTrophy(self, avId):
     if base.localAvatar.doId == avId:
         base.cr.playGame.getPlace().detectedGardenPlotUse()
         msg = TTLocalizer.GardenTrophyAwarded % (len(base.localAvatar.getFlowerCollection()), GardenGlobals.getNumberOfFlowerVarieties())
         self.awardDialog = TTDialog.TTDialog(style=TTDialog.Acknowledge, text=msg, command=self.closedAwardDialog)
示例#24
0
    def construct(self, gardenData):
        self.plotIndex = gardenData.getUint8()

        self.plotType = GardenGlobals.getPlotType(self.ownerIndex, self.plotIndex)
        self.pos = GardenGlobals.getPlotPos(self.ownerIndex, self.plotIndex)
        self.heading = GardenGlobals.getPlotHeading(self.ownerIndex, self.plotIndex)