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()
 def doResultDialog(self):
     self.startInteraction()
     curTrack, curLevel = GardenGlobals.getTreeTrackAndLevel(self.typeIndex)
     species = GardenGlobals.getTreeTypeIndex(curTrack, curLevel)
     treeName = GardenGlobals.PlantAttributes[species]['name']
     stringToShow = TTLocalizer.getResultPlantedSomethingSentence(treeName)
     self.resultDialog = TTDialog.TTDialog(style=TTDialog.Acknowledge, text=stringToShow, command=self.resultsCallback)
    def update(self):
        if base.localAvatar.flowerCollection.hasSpecies(self.species):
            self.flowerPanel.show(showBackground=0)
            self['text'] = TTLocalizer.FlowerSpeciesNames[self.species]
        for variety in range(len(GardenGlobals.getFlowerVarieties(self.species))):
            if base.localAvatar.flowerCollection.hasFlower(self.species, variety):
                name = GardenGlobals.getFlowerVarietyName(self.species, variety)
                self.speciesLabels[variety]['text'] = name
                self.speciesLabels[variety]['state'] = DGG.NORMAL

        self.showRecipe()
    def hasDependentTrees(self):
        myTrack, myLevel = GardenGlobals.getTreeTrackAndLevel(self.typeIndex)
        allGagTrees = base.cr.doFindAll('DistributedGagTree')
        for gagTree in allGagTrees:
            if gagTree.getOwnerId() == localAvatar.doId:
                curTrack, curLevel = GardenGlobals.getTreeTrackAndLevel(gagTree.typeIndex)
                if curTrack == myTrack:
                    if myLevel < curLevel:
                        return True

        return False
    def requestHarvest(self):
        avId = self.air.getAvatarIdFromSender()
        av = self.air.doId2do.get(avId)
        if not av:
            return
        
        if avId != self.ownerDoId:
            self.air.writeServerEvent('suspicious', avId, 'tried to harvest someone else\'s tree!')
            return

        problem = self.isFruiting()
        if problem:
            self.air.writeServerEvent('suspicious', avId, 'tried to harvest a tree that\'s not fruiting!', problem=problem)
            return

        harvested = 0
        track, level = GardenGlobals.getTreeTrackAndLevel(self.typeIndex)
        while av.inventory.addItem(track, level) > 0 and harvested < 10:
            harvested += 1
  
        av.d_setInventory(av.getInventory())
        
        self.lastHarvested = int(time.time())
        self.sendUpdate('setFruiting', [self.getFruiting()])
        self.d_setMovie(GardenGlobals.MOVIE_HARVEST)
        self.update()
    def setSpecies(self, species):
        if self.species == species:
            return
        self.species = species
        if self.species != None:
            if self.flowerPanel:
                self.flowerPanel.destroy()
            varietyToUse = self.flowerCollection.getInitialVariety(self.species)
            self.variety = varietyToUse
            self.flowerPanel = FlowerPhoto.FlowerPhoto(species=self.species, variety=varietyToUse, parent=self)
            zAdj = 0.0131
            xAdj = -0.002
            self.flowerPanel.setPos(-0.229 + xAdj, 1, -0.01 + zAdj)
            self.flowerPanel.setSwimBounds(-0.2461, 0.2367, -0.207 + zAdj, 0.2664 + zAdj)
            self.flowerPanel.setSwimColor(0.75, 0.75, 0.75, 1.0)
            varietyList = GardenGlobals.getFlowerVarieties(self.species)
            self.speciesLabels = []
            offset = 0.075
            startPos = len(varietyList) / 2 * offset
            if not len(varietyList) % 2:
                startPos -= offset / 2
            for variety in range(len(varietyList)):
                label = DirectButton(parent=self, frameSize=(0,
                 0.445,
                 -0.02,
                 0.04), relief=None, state=DGG.DISABLED, pos=(0.06, 0, startPos - variety * offset), text=TTLocalizer.FlowerUnknown, text_fg=(0.2, 0.1, 0.0, 1), text_scale=(0.045, 0.045, 0.45), text_align=TextNode.ALeft, text_font=ToontownGlobals.getInterfaceFont(), command=self.changeVariety, extraArgs=[variety], text1_bg=Vec4(1, 1, 0, 1), text2_bg=Vec4(0.5, 0.9, 1, 1), text3_fg=Vec4(0.4, 0.8, 0.4, 1))
                self.speciesLabels.append(label)

        return
 def generateRandomBasket(self):
     import random
     numFish = random.randint(1, 20)
     self.flowerList = []
     for i in range(numFish):
         species, variety = GardenGlobals.getRandomFlower()
         self.addFlower(species, variety)
 def requestHarvest(self, doId):
     av = simbase.air.doId2do.get(doId)
     harvested = 0
     track, level = GardenGlobals.getTreeTrackAndLevel(self.typeIndex)
     while av.inventory.addItem(track, level) > 0 and harvested < 10:
         harvested += 1
     self.sendUpdate('setMovie', [GardenGlobals.MOVIE_HARVEST, doId])
예제 #9
0
 def __init__(self, parent = aspect2d, **kw):
     self.parent = parent
     gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui')
     optiondefs = (('parent', self.parent, None),
      ('relief', None, None),
      ('incButton_image', (gui.find('**/FndsLst_ScrollUp'),
        gui.find('**/FndsLst_ScrollDN'),
        gui.find('**/FndsLst_ScrollUp_Rllvr'),
        gui.find('**/FndsLst_ScrollUp')), None),
      ('incButton_relief', None, None),
      ('incButton_scale', (1.3, 1.3, -1.3), None),
      ('incButton_pos', (0, 0, -0.525), None),
      ('incButton_image3_color', Vec4(0.8, 0.8, 0.8, 0.5), None),
      ('decButton_image', (gui.find('**/FndsLst_ScrollUp'),
        gui.find('**/FndsLst_ScrollDN'),
        gui.find('**/FndsLst_ScrollUp_Rllvr'),
        gui.find('**/FndsLst_ScrollUp')), None),
      ('decButton_relief', None, None),
      ('decButton_scale', (1.3, 1.3, 1.3), None),
      ('decButton_pos', (0, 0, 0.525), None),
      ('decButton_image3_color', Vec4(0.8, 0.8, 0.8, 0.5), None),
      ('numItemsVisible', 1, None),
      ('items', map(str, GardenGlobals.getFlowerSpecies()), None),
      ('scrollSpeed', 4, None),
      ('itemMakeFunction', FlowerSpeciesPanel.FlowerSpeciesPanel, None),
      ('itemMakeExtraArgs', base.localAvatar.flowerCollection, None))
     gui.removeNode()
     self.defineoptions(kw, optiondefs)
     DirectScrolledList.__init__(self, parent)
     self.initialiseoptions(FlowerBrowser)
     return None
    def canBeHarvested(self):
        myTrack, myLevel = GardenGlobals.getTreeTrackAndLevel(self.typeIndex)
        levelsInTrack = []
        levelTreeDict = {}
        allGagTrees = base.cr.doFindAll('DistributedGagTree')
        for gagTree in allGagTrees:
            if gagTree.getOwnerId() == localAvatar.doId:
                curTrack, curLevel = GardenGlobals.getTreeTrackAndLevel(gagTree.typeIndex)
                if curTrack == myTrack:
                    levelsInTrack.append(curLevel)
                    levelTreeDict[curLevel] = gagTree

        for levelToTest in xrange(myLevel):
            if levelToTest not in levelsInTrack:
                return False
            curTree = levelTreeDict[levelToTest]
            if not curTree.isGTEFullGrown():
                return False

        return True
 def showRecipe(self):
     if base.localAvatar.flowerCollection.hasSpecies(self.species):
         self['text'] = TTLocalizer.FlowerSpeciesNames[self.species]
         if base.localAvatar.flowerCollection.hasFlower(self.species, self.variety):
             name = GardenGlobals.getFlowerVarietyName(self.species, self.variety)
             recipeKey = GardenGlobals.PlantAttributes[self.species]['varieties'][self.variety][0]
             self['text'] = name
             self.createBeanRecipeGui(GardenGlobals.Recipes[recipeKey]['beans'])
         else:
             self.cleanupBeanRecipeGui()
     else:
         self['text'] = TTLocalizer.FlowerUnknown
         self.cleanupBeanRecipeGui()
 def plantSomething(self):
     whatCanBePlanted = GardenGlobals.whatCanBePlanted(self.ownerIndex, self.plot)
     if whatCanBePlanted == GardenGlobals.INVALID_TYPE:
         self.notify.warning('whatCanBePlanted returned INVALID_TYPE for %d %d' % (self.ownerIndex, self.plot))
     elif whatCanBePlanted == GardenGlobals.FLOWER_TYPE:
         self.popupFlowerPlantingGui()
         self.startInteraction()
     elif whatCanBePlanted == GardenGlobals.GAG_TREE_TYPE:
         self.popupTreePlantingGui()
         self.startInteraction()
     elif whatCanBePlanted == GardenGlobals.STATUARY_TYPE:
         self.popupItemPlantingGui()
         self.startInteraction()
 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 getPlantingText(self):
     plantText = 'hardcoding'
     if self.canBePlanted():
         whatCanBePlanted = GardenGlobals.whatCanBePlanted(self.ownerIndex, self.plot)
         plantText = TTLocalizer.GardeningPlant
         if whatCanBePlanted == GardenGlobals.INVALID_TYPE:
             self.notify.warning('whatCanBePlanted returned INVALID_TYPE for %d %d' % (self.ownerIndex, self.plot))
         elif whatCanBePlanted == GardenGlobals.FLOWER_TYPE:
             plantText = TTLocalizer.GardeningPlantFlower
         elif whatCanBePlanted == GardenGlobals.GAG_TREE_TYPE:
             plantText = TTLocalizer.GardeningPlantTree
         elif whatCanBePlanted == GardenGlobals.STATUARY_TYPE:
             plantText = TTLocalizer.GardeningPlantItem
     return plantText
 def plantGagTree(self, track, level, toon):
     #free for now
     #av = simbase.air.doId2do.get(toon)
     #av.inventory.useItem(track, level)
     #av.d_setInventory(av.inventory.makeNetString())
     self.planted = DistributedGagTreeAI(self.air)
     self.planted.setEstate(self.getEstate())
     self.planted.setOwnerPlot(self.doId)
     self.planted.setPlot(self.getPlot())
     self.planted.setHeading(self.getHeading())
     self.planted.setPosition(*self.getPosition())
     self.planted.setOwnerIndex(self.getOwnerIndex())
     self.planted.setTypeIndex(GardenGlobals.getTreeTypeIndex(track, level))
     self.planted.setWaterLevel(0)
     self.planted.setGrowthLevel(0)
     self.sendUpdate('setMovie', [GardenGlobals.MOVIE_PLANT, toon])
예제 #16
0
 def getPlantingText(self):
     plantText = 'hardcoding'
     if self.canBePlanted():
         whatCanBePlanted = GardenGlobals.whatCanBePlanted(
             self.ownerIndex, self.plot)
         plantText = TTLocalizer.GardeningPlant
         if whatCanBePlanted == GardenGlobals.INVALID_TYPE:
             self.notify.warning(
                 'whatCanBePlanted returned INVALID_TYPE for %d %d' %
                 (self.ownerIndex, self.plot))
         elif whatCanBePlanted == GardenGlobals.FLOWER_TYPE:
             plantText = TTLocalizer.GardeningPlantFlower
         elif whatCanBePlanted == GardenGlobals.GAG_TREE_TYPE:
             plantText = TTLocalizer.GardeningPlantTree
         elif whatCanBePlanted == GardenGlobals.STATUARY_TYPE:
             plantText = TTLocalizer.GardeningPlantItem
     return plantText
예제 #17
0
 def showRecipe(self):
     if base.localAvatar.flowerCollection.hasSpecies(self.species):
         self['text'] = TTLocalizer.FlowerSpeciesNames[self.species]
         if base.localAvatar.flowerCollection.hasFlower(
                 self.species, self.variety):
             name = GardenGlobals.getFlowerVarietyName(
                 self.species, self.variety)
             recipeKey = GardenGlobals.PlantAttributes[
                 self.species]['varieties'][self.variety][0]
             self['text'] = name
             self.createBeanRecipeGui(
                 GardenGlobals.Recipes[recipeKey]['beans'])
         else:
             self.cleanupBeanRecipeGui()
     else:
         self['text'] = TTLocalizer.FlowerUnknown
         self.cleanupBeanRecipeGui()
    def setSpecies(self, species):
        if self.species == species:
            return
        self.species = species
        if self.species != None:
            if self.flowerPanel:
                self.flowerPanel.destroy()
            varietyToUse = self.flowerCollection.getInitialVariety(
                self.species)
            self.variety = varietyToUse
            self.flowerPanel = FlowerPhoto.FlowerPhoto(species=self.species,
                                                       variety=varietyToUse,
                                                       parent=self)
            zAdj = 0.0131
            xAdj = -0.002
            self.flowerPanel.setPos(-0.229 + xAdj, 1, -0.01 + zAdj)
            self.flowerPanel.setSwimBounds(-0.2461, 0.2367, -0.207 + zAdj,
                                           0.2664 + zAdj)
            self.flowerPanel.setSwimColor(0.75, 0.75, 0.75, 1.0)
            varietyList = GardenGlobals.getFlowerVarieties(self.species)
            self.speciesLabels = []
            offset = 0.075
            startPos = len(varietyList) / 2 * offset
            if not len(varietyList) % 2:
                startPos -= offset / 2
            for variety in range(len(varietyList)):
                label = DirectButton(
                    parent=self,
                    frameSize=(0, 0.445, -0.02, 0.04),
                    relief=None,
                    state=DGG.DISABLED,
                    pos=(0.06, 0, startPos - variety * offset),
                    text=TTLocalizer.FlowerUnknown,
                    text_fg=(0.2, 0.1, 0.0, 1),
                    text_scale=(0.045, 0.045, 0.45),
                    text_align=TextNode.ALeft,
                    text_font=ToontownGlobals.getInterfaceFont(),
                    command=self.changeVariety,
                    extraArgs=[variety],
                    text1_bg=Vec4(1, 1, 0, 1),
                    text2_bg=Vec4(0.5, 0.9, 1, 1),
                    text3_fg=Vec4(0.4, 0.8, 0.4, 1))
                self.speciesLabels.append(label)

        return
예제 #19
0
 def setTypeIndex(self, typeIndex):
     DistributedPlantBase.DistributedPlantBase.setTypeIndex(self, typeIndex)
     track, level = GardenGlobals.getTreeTrackAndLevel(typeIndex)
     self.gagTrack = track
     self.gagLevel = level
     invModel = loader.loadModel('phase_3.5/models/gui/inventory_icons')
     propName = ToontownBattleGlobals.AvPropsNew[track][level]
     self.prop = invModel.find('**/' + propName)
     self.prop.setScale(7)
     invModel.removeNode()
     invModel2 = loader.loadModel('phase_3.5/models/gui/inventory_icons')
     propName = ToontownBattleGlobals.AvPropsNew[track][level]
     self.prop2 = invModel2.find('**/' + propName)
     self.prop2.setScale(7)
     self.filename = self.attributes['filename']
     self.maxFruit = self.attributes['maxFruit']
     if hasattr(self, 'needToLoad'):
         if self.needToLoad:
             self.loadModel()
예제 #20
0
 def setTypeIndex(self, typeIndex):
     DistributedPlantBase.DistributedPlantBase.setTypeIndex(self, typeIndex)
     track, level = GardenGlobals.getTreeTrackAndLevel(typeIndex)
     self.gagTrack = track
     self.gagLevel = level
     invModel = loader.loadModel('phase_3.5/models/gui/inventory_icons')
     propName = ToontownBattleGlobals.AvPropsNew[track][level]
     self.prop = invModel.find('**/' + propName)
     self.prop.setScale(7)
     invModel.removeNode()
     invModel2 = loader.loadModel('phase_3.5/models/gui/inventory_icons')
     propName = ToontownBattleGlobals.AvPropsNew[track][level]
     self.prop2 = invModel2.find('**/' + propName)
     self.prop2.setScale(7)
     self.filename = self.attributes['filename']
     self.maxFruit = self.attributes['maxFruit']
     if hasattr(self, 'needToLoad'):
         if self.needToLoad:
             self.loadModel()
예제 #21
0
 def calcDependencies(self):
     if self.getWilted():
         return
         
     missingPrevIndex = 0
     track, value = GardenGlobals.getTreeTrackAndLevel(self.typeIndex)
     while value:
         value -= 1
         if not self.mgr.hasTree(track, value):
             self.b_setWilted(1)
             continue
             
         tree = self.mgr.getTree(track, value)
         if not tree:
             self.b_setWilted(1)
             continue
         
         self.accept(self.getEventName('going-down', 666), self.ignoreAll)
         self.accept(self.getEventName('remove', track * 7 + value), self.calcDependencies)
예제 #22
0
 def plantSomething(self):
     whatCanBePlanted = GardenGlobals.whatCanBePlanted(
         self.ownerIndex, self.plot)
     if whatCanBePlanted == GardenGlobals.INVALID_TYPE:
         self.notify.warning(
             'whatCanBePlanted returned INVALID_TYPE for %d %d' %
             (self.ownerIndex, self.plot))
     else:
         if whatCanBePlanted == GardenGlobals.FLOWER_TYPE:
             self.popupFlowerPlantingGui()
             self.startInteraction()
         else:
             if whatCanBePlanted == GardenGlobals.GAG_TREE_TYPE:
                 self.popupTreePlantingGui()
                 self.startInteraction()
             else:
                 if whatCanBePlanted == GardenGlobals.STATUARY_TYPE:
                     self.popupItemPlantingGui()
                     self.startInteraction()
 def calcDependencies(self):
     if self.getWilted():
         return
         
     missingPrevIndex = 0
     track, value = GardenGlobals.getTreeTrackAndLevel(self.typeIndex)
     while value:
         value -= 1
         if not self.mgr.hasTree(track, value):
             self.b_setWilted(1)
             continue
             
         tree = self.mgr.getTree(track, value)
         if not tree:
             self.b_setWilted(1)
             continue
         
         self.accept(self.getEventName('going-down', 666), self.ignoreAll)
         self.accept(self.getEventName('remove', track * 7 + value), self.calcDependencies)
예제 #24
0
    def requestHarvest(self):
        avId = self.air.getAvatarIdFromSender()
        av = self.air.doId2do.get(avId)
        if not av:
            return
        if avId != self.ownerDoId:
            self.air.writeServerEvent('suspicious', avId, "tried to harvest someone else's tree!")
            return
        problem = self.isFruiting()
        if problem:
            self.air.writeServerEvent('suspicious', avId, "tried to harvest a tree that's not fruiting!", problem=problem)
            return
        harvested = 0
        track, level = GardenGlobals.getTreeTrackAndLevel(self.typeIndex)
        while av.inventory.addItem(track, level) > 0 and harvested < 10:
            harvested += 1

        av.d_setInventory(av.getInventory())
        self.lastHarvested = int(time.time())
        self.sendUpdate('setFruiting', [self.getFruiting()])
        self.d_setMovie(GardenGlobals.MOVIE_HARVEST)
        self.update()
예제 #25
0
    def plantSomething(self):
        whatCanBePlanted = GardenGlobals.whatCanBePlanted(
            self.ownerIndex, self.plot)
        if whatCanBePlanted == GardenGlobals.INVALID_TYPE:
            self.notify.warning(
                'whatCanBePlanted returned INVALID_TYPE for %d %d' %
                (self.ownerIndex, self.plot))
        elif whatCanBePlanted == GardenGlobals.FLOWER_TYPE:
            #self.sendUpdate('plantFlower',[48,1])
            self.popupFlowerPlantingGui()
            #self.cr.playGame.getPlace().detectedGardenPlotUse()
            self.startInteraction()

        elif whatCanBePlanted == GardenGlobals.GAG_TREE_TYPE:
            self.popupTreePlantingGui()
            #self.cr.playGame.getPlace().detectedGardenPlotUse()
            self.startInteraction()
        elif whatCanBePlanted == GardenGlobals.STATUARY_TYPE:
            self.popupItemPlantingGui()
            #self.cr.playGame.getPlace().detectedGardenPlotUse()
            self.startInteraction()
            pass
        pass
 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)
예제 #27
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 stick2Ground(self, *args, **kwargs):
        plotType = GardenGlobals.whatCanBePlanted(self.ownerIndex, self.plot)
        if plotType == GardenGlobals.FLOWER_TYPE:
            return

        return DistributedLawnDecor.DistributedLawnDecor.stick2Ground(self, *args, **kwargs)
예제 #29
0
 def stick2Ground(self, *args, **kwargs):
     plotType = GardenGlobals.whatCanBePlanted(self.ownerIndex, self.plot)
     if plotType == GardenGlobals.FLOWER_TYPE:
         return
     return DistributedLawnDecor.DistributedLawnDecor.stick2Ground(
         self, *args, **kwargs)
예제 #30
0
    def __handleItemPlantingDone(self,
                                 willPlant=0,
                                 recipeStr="",
                                 selectedSpecial=-1):
        assert self.notify.debugStateCall(self)
        self.ignore(self.plantingGuiDoneEvent)
        self.ignore('stoppedAsleep')
        # Ask the AI to complete the sale
        #self.sendUpdate("completeFlowerSale", [sell])
        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:
                    #make sure it is a statuary and not a flower
                    if GardenGlobals.PlantAttributes[species][
                            'plantType'] == GardenGlobals.STATUARY_TYPE:
                        successPlanting = True
                        # Handle ToonStatues separately because another screen has to be added
                        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)

        #    self.resultDialog = TTDialog.TTDialog(
        #        style = TTDialog.Acknowledge,
        #        text = stringToShow,
        #        command = self.resultsCallback
        #        )
        elif willPlant:
            self.resultDialog = TTDialog.TTDialog(
                style=TTDialog.Acknowledge,
                text=TTLocalizer.ResultPlantedNothing,
                command=self.popupItemPlantingGuiAgain)
        else:
            #base.cr.playGame.getPlace().detectedGardenPlotDone()
            self.finishInteraction()

        if successToonStatue:
            self.popupToonStatueSelectionGui(species)
예제 #31
0
 def getFullNameWithRecipe(self):
     name = GardenGlobals.getFlowerVarietyName(self.species, self.variety)
     recipeKey = GardenGlobals.PlantAttributes[self.species]['varieties'][
         self.variety][0]
     name += ' (%s)' % GardenGlobals.Recipes[recipeKey]['beans']
     return name
예제 #32
0
 def getFullName(self):
     return GardenGlobals.getFlowerVarietyName(self.species, self.variety)
예제 #33
0
    def movieDone(self):
        self.clearInteractingToon()
        if self.lastMovie == GardenGlobals.MOVIE_PLANT:
            type = GardenGlobals.whatCanBePlanted(self.ownerIndex, self.plot)
            if type == GardenGlobals.GAG_TREE_TYPE:
                self.lastMovie = None
                avId = self.lastMovieAvId
                gagTrack, gagLevel = self.lastMovieArgs
                zoneId = self.zoneId
                estateOwnerDoId = simbase.air.estateMgr.zone2owner.get(zoneId)
                estate = simbase.air.estateMgr.estate.get(estateOwnerDoId)
                if estate:
                    toon = simbase.air.doId2do.get(avId)
                    toon.inventory.useItem(gagTrack, gagLevel)
                    toon.d_setInventory(toon.inventory.makeNetString())
                    estate.removeGardenPlot(self.ownerIndex, self.plot)
                    typeIndex = GardenGlobals.getTreeTypeIndex(
                        gagTrack, gagLevel)
                    itemId = estate.plantTree(avId=avId,
                                              type=typeIndex,
                                              plot=self.plot,
                                              water=0,
                                              growth=0,
                                              optional=0)

                    # tell the new tree to tell the avatar to finish up the planting movie
                    tree = simbase.air.doId2do.get(itemId)
                    tree.setMovie(GardenGlobals.MOVIE_FINISHPLANTING, avId)

                    #log we are planting a tree
                    self.air.writeServerEvent("garden_plant_tree", avId,
                                              '%d|%d' % (gagTrack, gagLevel))
            else:
                self.lastMovie = None
                avId = self.lastMovieAvId
                species, variety = self.lastMovieArgs
                zoneId = self.zoneId
                estateOwnerDoId = simbase.air.estateMgr.zone2owner.get(zoneId)
                estate = simbase.air.estateMgr.estate.get(estateOwnerDoId)

                if estate:
                    estate.removeGardenPlot(self.ownerIndex, self.plot)
                    itemId = estate.plantFlower(avId=avId,
                                                type=species,
                                                plot=self.plot,
                                                water=0,
                                                growth=0,
                                                optional=variety)

                    # tell the new tree to tell the avatar to finish up the planting movie
                    flower = simbase.air.doId2do.get(itemId)
                    flower.setMovie(GardenGlobals.MOVIE_FINISHPLANTING, avId)

                    #since plant statuary calls plant flower, lets differentiate between the two
                    if type == GardenGlobals.FLOWER_TYPE:
                        #log we are planting a flower
                        self.air.writeServerEvent("garden_plant_flower", avId,
                                                  '%d|%d' % (species, variety))
                    elif type == GardenGlobals.STATUARY_TYPE:
                        #log we are planting a statue
                        self.air.writeServerEvent("garden_plant_statue", avId,
                                                  '%d' % (species))
                    else:
                        self.notify.warning('unhandled case %s' % type)

        elif self.lastMovie == GardenGlobals.MOVIE_FINISHREMOVING:
            self.lastMovie = None
            zoneId = self.zoneId
            avId = self.lastMovieAvId
            estateOwnerDoId = simbase.air.estateMgr.zone2owner.get(zoneId)
            estate = simbase.air.estateMgr.estate.get(estateOwnerDoId)
            if estate:
                itemId = self.doId
                # tell the gardenplot to tell the toon to clear the movie
                item = simbase.air.doId2do.get(itemId)
                item.setMovie(GardenGlobals.MOVIE_CLEAR, avId)
예제 #34
0
    def plantFlower(self, species, variety):
        print "planting flower species=%d variety=%d" % (species, variety)
        senderId = self.air.getAvatarIdFromSender()

        zoneId = self.zoneId
        estateOwnerDoId = simbase.air.estateMgr.zone2owner.get(zoneId)

        if not senderId == estateOwnerDoId:
            self.notify.warning(
                "how did this happen, planting a flower you don't own")
            return

        if not species in GardenGlobals.PlantAttributes:
            self.air.writeServerEvent(
                'suspicious', senderId,
                'Planting a species %s that does not exist.' % (species))
            return

        if estateOwnerDoId:
            estate = simbase.air.estateMgr.estate.get(estateOwnerDoId)
            if estate:
                #we should have a valid DistributedEstateAI at this point
                #first get the recipe back
                plantType = GardenGlobals.PlantAttributes[species]['plantType']
                if plantType == GardenGlobals.STATUARY_TYPE:
                    # Statues have only one type. Added this so that I could use the variety to contain the optional field for the ToonStatuary
                    recipeKey = GardenGlobals.PlantAttributes[species][
                        'varieties'][0][0]
                else:
                    recipeKey = GardenGlobals.PlantAttributes[species][
                        'varieties'][variety][0]
                recipe = GardenGlobals.Recipes[recipeKey]
                #find out how many beans the toon can plant
                toon = simbase.air.doId2do.get(senderId)
                shovelIndex = toon.getShovel()
                shovelPower = GardenGlobals.getShovelPower(
                    shovelIndex, toon.getShovelSkill())
                allOk = 1
                if shovelPower >= len(recipe['beans']):
                    skillUpOnPlanting = 0
                    if skillUpOnPlanting:
                        if shovelPower == len(recipe['beans']):
                            #time to add skill points
                            currentShovelSkill = toon.getShovelSkill()
                            newShovelSkill = currentShovelSkill + shovelPower
                            toon.b_setShovelSkill(newShovelSkill)
                else:
                    self.notify.warning(
                        "ILLEGAL recipe used!! shovel is not powerful enough!!! fool!"
                    )
                    allOk = 0
                if toon.takeMoney(len(recipe['beans'])):
                    pass
                else:
                    self.notify.warning("Not enough beans for recipe!!! fool!")
                    allOk = 0

                #if all goes well plant the flower
                if allOk:
                    self.setMovie(GardenGlobals.MOVIE_PLANT, senderId,
                                  (species, variety))
예제 #35
0
 def announceGenerate(self):
     DistributedLawnDecorAI.announceGenerate(self)
     self.plotType = GardenGlobals.whatCanBePlanted(self.ownerIndex, self.plot)
     self.__plantingAvId = 0
예제 #36
0
 def __init__(self, parent = aspect2d, **kw):
     self.parent = parent
     gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui')
     optiondefs = (('parent', self.parent, None), ('relief', None, None), ('incButton_image', (gui.find('**/FndsLst_ScrollUp'), gui.find('**/FndsLst_ScrollDN'), gui.find('**/FndsLst_ScrollUp_Rllvr'), gui.find('**/FndsLst_ScrollUp')), None), ('incButton_relief', None, None), ('incButton_scale', (1.3, 1.3, -1.3), None), ('incButton_pos', (0, 0, -0.52500000000000002), None), ('incButton_image3_color', Vec4(0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 0.5), None), ('decButton_image', (gui.find('**/FndsLst_ScrollUp'), gui.find('**/FndsLst_ScrollDN'), gui.find('**/FndsLst_ScrollUp_Rllvr'), gui.find('**/FndsLst_ScrollUp')), None), ('decButton_relief', None, None), ('decButton_scale', (1.3, 1.3, 1.3), None), ('decButton_pos', (0, 0, 0.52500000000000002), None), ('decButton_image3_color', Vec4(0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 0.5), None), ('numItemsVisible', 1, None), ('items', map(str, GardenGlobals.getFlowerSpecies()), None), ('scrollSpeed', 4, None), ('itemMakeFunction', FlowerSpeciesPanel.FlowerSpeciesPanel, None), ('itemMakeExtraArgs', base.localAvatar.flowerCollection, None))
     gui.removeNode()
     self.defineoptions(kw, optiondefs)
     DirectScrolledList.__init__(self, parent)
     self.initialiseoptions(FlowerBrowser)
예제 #37
0
 def getFullName(self):
     return GardenGlobals.getFlowerVarietyName(self.species, self.variety)
 def announceGenerate(self):
     DistributedLawnDecorAI.announceGenerate(self)
     self.plotType = GardenGlobals.whatCanBePlanted(self.ownerIndex, self.plot)
     self.__plantingAvId = 0
예제 #39
0
 def getFullNameWithRecipe(self):
     name = GardenGlobals.getFlowerVarietyName(self.species, self.variety)
     recipeKey = GardenGlobals.PlantAttributes[self.species]['varieties'][self.variety][0]
     name += ' (%s)' % GardenGlobals.Recipes[recipeKey]['beans']
     return name