def create(self, estateMgr):
        self.estateMgr = estateMgr

        if self.avId not in estateMgr.toons:
            estateMgr.notify.warning(
                'Garden associated to unknown avatar %d, deleting...' %
                self.avId)
            return False

        houseIndex = estateMgr.toons.index(self.avId)

        if self.WANT_FLOWERS:
            boxIndex = 0
            boxes = []
            boxDefs = GardenGlobals.estateBoxes[houseIndex]
            for x, y, h, boxType in boxDefs:
                box = DistributedGardenBoxAI(self)

                box.setTypeIndex(boxType)
                box.setPos(x, y, 0)
                box.setH(h)
                box.setOwnerIndex(houseIndex)
                box.generateWithRequired(estateMgr.zoneId)

                self.objects.add(box)
                boxes.append(box)
                boxIndex += 1

            self._boxes = boxes

        plots = GardenGlobals.estatePlots[houseIndex]
        treeIndex = 0
        flowerIndex = 0
        for plot, (x, y, h, type) in enumerate(plots):
            if type == GardenGlobals.GAG_TREE_TYPE and self.WANT_TREES:
                data = self.data['trees'][treeIndex]

                planted, waterLevel, lastCheck, growthLevel, lastHarvested = data

                if planted != -1:
                    obj = self.plantTree(treeIndex,
                                         planted,
                                         waterLevel=waterLevel,
                                         lastCheck=lastCheck,
                                         growthLevel=growthLevel,
                                         lastHarvested=lastHarvested,
                                         generate=False)

                    self.trees.add(obj)

                else:
                    obj = self.placePlot(treeIndex)

                obj.setPos(x, y, 0)
                obj.setH(h)
                obj.setPlot(plot)
                obj.setOwnerIndex(houseIndex)
                obj.generateWithRequired(estateMgr.zoneId)
                treeIndex += 1

            elif type == GardenGlobals.FLOWER_TYPE and self.WANT_FLOWERS:
                data = self.data['flowers'][flowerIndex]

                planted, waterLevel, lastCheck, growthLevel, variety = data

                if planted != -1:
                    obj = self.plantFlower(flowerIndex,
                                           planted,
                                           variety,
                                           waterLevel=waterLevel,
                                           lastCheck=lastCheck,
                                           growthLevel=growthLevel,
                                           generate=False)

                else:
                    obj = self.placePlot(flowerIndex)
                    obj.flowerIndex = flowerIndex

                obj.setPlot(plot)
                obj.setOwnerIndex(houseIndex)
                obj.generateWithRequired(estateMgr.zoneId)

                index = (0, 1, 2, 2, 2, 3, 3, 3, 4, 4)[flowerIndex]
                idx = (0, 0, 0, 1, 2, 0, 1, 2, 0, 1)[flowerIndex]
                obj.sendUpdate('setBoxDoId', [boxes[index].doId, idx])
                flowerIndex += 1

            elif type == GardenGlobals.STATUARY_TYPE and self.WANT_STATUARY:
                data = self.data['statuary']
                if data == 0:
                    obj = self.placePlot(-1)

                else:
                    obj = self.placeStatuary(data, generate=False)

                obj.setPos(x, y, 0)
                obj.setH(h)
                obj.setPlot(plot)
                obj.setOwnerIndex(houseIndex)
                obj.generateWithRequired(estateMgr.zoneId)

        for tree in self.trees:
            tree.calcDependencies()

        self.reconsiderAvatarOrganicBonus()

        return True
Example #2
0
    def create(self, estateMgr):
        if self.avId not in estateMgr.toons:
            estateMgr.notify.warning(
                "Garden associated to unknown avatar %d, deleting..." %
                self.avId)
            print estateMgr.toons
            return False

        houseIndex = estateMgr.toons.index(self.avId)

        if self.WANT_FLOWERS:
            boxDefs = GardenGlobals.estateBoxes[houseIndex]
            for x, y, h, boxType in boxDefs:
                box = DistributedGardenBoxAI(estateMgr.air)

                box.setTypeIndex(boxType)
                box.setPos(x, y, 0)
                box.setH(h)
                box.setOwnerIndex(houseIndex)
                box.generateWithRequired(estateMgr.zoneId)

                self.objects.append(box)

        plots = GardenGlobals.estatePlots[houseIndex]
        treeIndex = 0
        for x, y, h, type in plots:
            if type == GardenGlobals.GAG_TREE_TYPE and self.WANT_TREES:
                planted, waterLevel, nextLevelDecrease, growthLevel, nextGrowth = self.treesData[
                    treeIndex]
                if planted:
                    treeIndex += 1
                    tree = DistributedGagTreeAI(estateMgr.air)
                    tree.setPos(x, y, 0)
                    tree.setH(h)
                    tree.setOwnerIndex(houseIndex)
                    tree.setWaterLevel(waterLevel)
                    tree.setGrowthLevel(growthLevel)
                    tree.calculate(nextGrowth, nextLevelDecrease)
                    tree.generateWithRequired(estateMgr.zoneId)

                    self.trees.append(tree)
    def create(self, estateMgr):
        self.estateMgr = estateMgr
        
        if self.avId not in estateMgr.toons:
            estateMgr.notify.warning('Garden associated to unknown avatar %d, deleting...' % self.avId)
            return False
        
        houseIndex = estateMgr.toons.index(self.avId)

        if self.WANT_FLOWERS:
            boxIndex = 0
            boxes = []
            boxDefs = GardenGlobals.estateBoxes[houseIndex]
            for x, y, h, boxType in boxDefs:
                box = DistributedGardenBoxAI(self)
            
                box.setTypeIndex(boxType)
                box.setPos(x, y, 0)
                box.setH(h)
                box.setOwnerIndex(houseIndex)
                box.generateWithRequired(estateMgr.zoneId)
            
                self.objects.add(box)
                boxes.append(box)
                boxIndex += 1
                
            self._boxes = boxes
                
        plots = GardenGlobals.estatePlots[houseIndex]
        treeIndex = 0
        flowerIndex = 0
        for plot, (x, y, h, type) in enumerate(plots):
            if type == GardenGlobals.GAG_TREE_TYPE and self.WANT_TREES:
                data = self.data['trees'][treeIndex]
                
                planted, waterLevel, lastCheck, growthLevel, lastHarvested = data
                
                if planted != -1:
                    obj = self.plantTree(treeIndex, planted, waterLevel=waterLevel,
                                         lastCheck=lastCheck, growthLevel=growthLevel,
                                         lastHarvested=lastHarvested, generate=False)
                    
                    self.trees.add(obj)
                    
                else:
                    obj = self.placePlot(treeIndex)
                    
                obj.setPos(x, y, 0)
                obj.setH(h)
                obj.setPlot(plot)
                obj.setOwnerIndex(houseIndex)
                obj.generateWithRequired(estateMgr.zoneId)
                treeIndex += 1
                
            elif type == GardenGlobals.FLOWER_TYPE and self.WANT_FLOWERS:
                data = self.data['flowers'][flowerIndex]
                
                planted, waterLevel, lastCheck, growthLevel, variety = data
                
                if planted != -1:
                    obj = self.plantFlower(flowerIndex, planted, variety, waterLevel=waterLevel,
                                           lastCheck=lastCheck, growthLevel=growthLevel,
                                           generate=False)
                   
                else:
                    obj = self.placePlot(flowerIndex)
                    obj.flowerIndex = flowerIndex
           
                obj.setPlot(plot)
                obj.setOwnerIndex(houseIndex)
                obj.generateWithRequired(estateMgr.zoneId)
                
                index = (0, 1, 2, 2, 2, 3, 3, 3, 4, 4)[flowerIndex]
                idx = (0, 0, 0, 1, 2, 0, 1, 2, 0, 1)[flowerIndex]
                obj.sendUpdate('setBoxDoId', [boxes[index].doId, idx])
                flowerIndex += 1
                
            elif type == GardenGlobals.STATUARY_TYPE and self.WANT_STATUARY:
                data = self.data['statuary']
                if data == 0:
                    obj = self.placePlot(-1)
                    
                else:
                    obj = self.placeStatuary(data, generate=False)
                 
                obj.setPos(x, y, 0)
                obj.setH(h)
                obj.setPlot(plot)
                obj.setOwnerIndex(houseIndex)
                obj.generateWithRequired(estateMgr.zoneId)

        for tree in self.trees:
            tree.calcDependencies()
            
        self.reconsiderAvatarOrganicBonus()
                
        return True
    def create(self, estateMgr):
        if self.avId not in estateMgr.toons:
            estateMgr.notify.warning("Garden associated to unknown avatar %d, deleting..." % self.avId)
            print estateMgr.toons
            return False
        
        houseIndex = estateMgr.toons.index(self.avId)

        if self.WANT_FLOWERS:
            boxDefs = GardenGlobals.estateBoxes[houseIndex]
            for x, y, h, boxType in boxDefs:
                box = DistributedGardenBoxAI(estateMgr.air)
            
                box.setTypeIndex(boxType)
                box.setPos(x, y, 0)
                box.setH(h)
                box.setOwnerIndex(houseIndex)
                box.generateWithRequired(estateMgr.zoneId)
            
                self.objects.append(box)
                
        plots = GardenGlobals.estatePlots[houseIndex]
        treeIndex = 0
        for x, y, h, type in plots:
            if type == GardenGlobals.GAG_TREE_TYPE and self.WANT_TREES:
                planted, waterLevel, nextLevelDecrease, growthLevel, nextGrowth = self.treesData[treeIndex]
                if planted:
                    treeIndex += 1
                    tree = DistributedGagTreeAI(estateMgr.air)
                    tree.setPos(x, y, 0)
                    tree.setH(h)
                    tree.setOwnerIndex(houseIndex)
                    tree.setWaterLevel(waterLevel)
                    tree.setGrowthLevel(growthLevel)
                    tree.calculate(nextGrowth, nextLevelDecrease)
                    tree.generateWithRequired(estateMgr.zoneId)
                
                    self.trees.append(tree)