def generateCard(self, tileSeed, zoneId):
     rng = RandomNumGen.RandomNumGen(tileSeed)
     rowSize = self.game.getRowSize()
     fishList = FishGlobals.getPondGeneraList(zoneId)
     for i in xrange(len(fishList)):
         fishTuple = fishList.pop(0)
         weight = FishGlobals.getRandomWeight(fishTuple[0], fishTuple[1])
         fish = FishBase.FishBase(fishTuple[0], fishTuple[1], weight)
         fishList.append(fish)
     
     emptyCells = self.game.getCardSize() - 1 - len(fishList)
     rodId = 0
     for i in xrange(emptyCells):
         fishVitals = FishGlobals.getRandomFishVitals(zoneId, rodId, rng)
         while not fishVitals[0]:
             fishVitals = FishGlobals.getRandomFishVitals(zoneId, rodId, rng)
         fish = FishBase.FishBase(fishVitals[1], fishVitals[2], fishVitals[3])
         fishList.append(fish)
         rodId += 1
         if rodId > 4:
             rodId = 0
             continue
     
     for i in xrange(rowSize):
         for j in xrange(self.game.getColSize()):
             color = self.getCellColor(i * rowSize + j)
             if i * rowSize + j == self.game.getCardSize() / 2:
                 tmpFish = 'Free'
             else:
                 choice = rng.randrange(0, len(fishList))
                 tmpFish = fishList.pop(choice)
             xPos = BG.CellImageScale * (j - 2) + BG.GridXOffset
             yPos = BG.CellImageScale * (i - 2) - 0.014999999999999999
             cellGui = BingoCardCell.BingoCardCell(i * rowSize + j, tmpFish, self.model, color, self, image_scale = BG.CellImageScale, pos = (xPos, 0, yPos))
             self.cellGuiList.append(cellGui)
    def generateCard(self, tileSeed, zoneId):
        rng = RandomNumGen.RandomNumGen(tileSeed)
        rowSize = self.game.getRowSize()
        fishList = FishGlobals.getPondGeneraList(zoneId)
        for i in range(len(fishList)):
            fishTuple = fishList.pop(0)
            weight = FishGlobals.getRandomWeight(fishTuple[0], fishTuple[1])
            fish = FishBase.FishBase(fishTuple[0], fishTuple[1], weight)
            fishList.append(fish)

        emptyCells = self.game.getCardSize() - 1 - len(fishList)
        rodId = 0
        for i in range(emptyCells):
            fishVitals = FishGlobals.getRandomFishVitals(zoneId, rodId, rng)
            while not fishVitals[0]:
                fishVitals = FishGlobals.getRandomFishVitals(zoneId, rodId, rng)

            fish = FishBase.FishBase(fishVitals[1], fishVitals[2], fishVitals[3])
            fishList.append(fish)
            rodId += 1
            if rodId > 4:
                rodId = 0

        for i in range(rowSize):
            for j in range(self.game.getColSize()):
                color = self.getCellColor(i * rowSize + j)
                if i * rowSize + j == self.game.getCardSize() / 2:
                    tmpFish = 'Free'
                else:
                    choice = rng.randrange(0, len(fishList))
                    tmpFish = fishList.pop(choice)
                xPos = BG.CellImageScale * (j - 2) + BG.GridXOffset
                yPos = BG.CellImageScale * (i - 2) - 0.015
                cellGui = BingoCardCell.BingoCardCell(i * rowSize + j, tmpFish, self.model, color, self, image_scale=BG.CellImageScale, pos=(xPos, 0, yPos))
                self.cellGuiList.append(cellGui)
Exemple #3
0
    def generateCard(self, tileSeed, zoneId):
        rng = RandomNumGen.RandomNumGen(tileSeed)

        # Retrieve a list of Fish based on the Genus Type. Each Genus
        # found in the pond will be represented on the board.
        fishList = FishGlobals.getPondGeneraList(zoneId)

        # Determine the number of cells left to fill.
        emptyCells = (self.cardSize - 1) - len(fishList)

        rodId = 0
        for i in range(emptyCells):
            fish = FishGlobals.getRandomFishVitals(zoneId, rodId, rng)
            while (not fish[0]):
                fish = FishGlobals.getRandomFishVitals(zoneId, rodId, rng)
            fishList.append((fish[1], fish[2]))
            rodId += 1

            if rodId > 4: rodId = 0

        # Now, fill up the the card by randomly placing the fish in a cell.
        for index in range(self.cardSize):
            if index != self.cardSize // 2:
                choice = rng.randrange(0, len(fishList))
                self.cellList.append(fishList.pop(choice))
            else:
                self.cellList.append((None, None))
Exemple #4
0
    def updatePage(self):
        assert self.notify.debugStateCall(self)

        if hasattr(self, "collectedTotal"):
            # update the total  collection
            self.collectedTotal['text'] = (
                TTLocalizer.FishPageCollectedTotal %
                (len(base.localAvatar.fishCollection),
                 FishGlobals.getTotalNumFish()))

        if hasattr(self, "rod"):
            # update the rod info on the picker
            rod = base.localAvatar.fishingRod
            rodName = TTLocalizer.FishingRodNameDict[rod]
            rodWeightRange = FishGlobals.getRodWeightRange(rod)
            self.rod['text'] = TTLocalizer.FishPageRodInfo % (
                rodName, rodWeightRange[0], rodWeightRange[1])

        if self.mode == FishPage_Tank:
            if hasattr(self, "picker"):
                # the fish list may have changed, update the picker
                newTankFish = base.localAvatar.fishTank.getFish()
                self.picker.update(newTankFish)
        elif self.mode == FishPage_Collection:
            if hasattr(self, "browser"):
                # the fish gallery may have changed, update the browser
                self.browser.update()
        elif self.mode == FishPage_Trophy:
            if hasattr(self, "trophies"):
                # the fishing trophy list may have changed, update the display
                for trophy in self.trophies:
                    trophy.setLevel(-1)
                for trophyId in base.localAvatar.getFishingTrophies():
                    self.trophies[trophyId].setLevel(trophyId)
Exemple #5
0
    def updatePage(self):
        if hasattr(self, 'collectedTotal'):
            self.collectedTotal[
                'text'] = TTLocalizer.FishPageCollectedTotal % (
                    len(base.localAvatar.fishCollection),
                    FishGlobals.getTotalNumFish())
        if hasattr(self, 'rod'):
            rod = base.localAvatar.fishingRod
            rodName = TTLocalizer.FishingRodNameDict[rod]
            rodWeightRange = FishGlobals.getRodWeightRange(rod)
            self.rod['text'] = TTLocalizer.FishPageRodInfo % (
                rodName, rodWeightRange[0], rodWeightRange[1])
        if self.mode == FishPage_Tank:
            if hasattr(self, 'picker'):
                newTankFish = base.localAvatar.fishTank.getFish()
                self.picker.update(newTankFish)
        elif self.mode == FishPage_Collection:
            if hasattr(self, 'browser'):
                self.browser.update()
        elif self.mode == FishPage_Trophy:
            if hasattr(self, 'trophies'):
                for trophy in self.trophies:
                    trophy.setLevel(-1)

                for trophyId in base.localAvatar.getFishingTrophies():
                    self.trophies[trophyId].setLevel(trophyId)
Exemple #6
0
    def generateCatch(self, av, zoneId):
        if len(av.fishTank) >= av.getMaxFishTank():
            return [FishGlobals.OverTankLimit, 0, 0, 0]
        else:
            caughtItem = self.air.questManager.toonFished(av, zoneId)
            if caughtItem:
                return [FishGlobals.QuestItem, caughtItem, 0, 0]
            rand = random.random() * 100.0
            for cutoff in FishGlobals.SortedProbabilityCutoffs:
                if rand <= cutoff:
                    itemType = FishGlobals.ProbabilityDict[cutoff]
                    break

            if av.doId in self.requestedFish:
                genus, species = self.requestedFish[av.doId]
                weight = FishGlobals.getRandomWeight(genus, species)
                fish = FishBase(genus, species, weight)
                fishType = av.fishCollection.collectFish(fish)
                if fishType == FishGlobals.COLLECT_NEW_ENTRY:
                    itemType = FishGlobals.FishItemNewEntry
                elif fishType == FishGlobals.COLLECT_NEW_RECORD:
                    itemType = FishGlobals.FishItemNewRecord
                else:
                    itemType = FishGlobals.FishItem
                collectionNetList = av.fishCollection.getNetLists()
                av.d_setFishCollection(collectionNetList[0],
                                       collectionNetList[1],
                                       collectionNetList[2])
                av.fishTank.addFish(fish)
                tankNetList = av.fishTank.getNetLists()
                av.d_setFishTank(tankNetList[0], tankNetList[1],
                                 tankNetList[2])
                del self.requestedFish[av.doId]
                return [itemType, genus, species, weight]
            if itemType == FishGlobals.FishItem:
                success, genus, species, weight = FishGlobals.getRandomFishVitals(
                    zoneId, av.getFishingRod())
                fish = FishBase(genus, species, weight)
                fishType = av.fishCollection.collectFish(fish)
                if fishType == FishGlobals.COLLECT_NEW_ENTRY:
                    itemType = FishGlobals.FishItemNewEntry
                elif fishType == FishGlobals.COLLECT_NEW_RECORD:
                    itemType = FishGlobals.FishItemNewRecord
                else:
                    itemType = FishGlobals.FishItem
                collectionNetList = av.fishCollection.getNetLists()
                av.d_setFishCollection(collectionNetList[0],
                                       collectionNetList[1],
                                       collectionNetList[2])
                av.fishTank.addFish(fish)
                tankNetList = av.fishTank.getNetLists()
                av.d_setFishTank(tankNetList[0], tankNetList[1],
                                 tankNetList[2])
                return [itemType, genus, species, weight]
            if itemType == FishGlobals.BootItem:
                return [itemType, 0, 0, 0]
            money = FishGlobals.Rod2JellybeanDict[av.getFishingRod()]
            av.addMoney(money)
            return [itemType, money, 0, 0]
 def generateRandomTank(self):
     import random
     numFish = random.randint(1, 20)
     self.fishList = []
     for i in xrange(numFish):
         genus, species = FishGlobals.getRandomFish()
         weight = FishGlobals.getRandomWeight(genus, species)
         fish = FishBase.FishBase(genus, species, weight)
         self.addFish(fish)
 def generateCatch(self, av, zoneId):
     if len(av.fishTank) >= av.getMaxFishTank():
         return [FishGlobals.OverTankLimit, 0, 0, 0]
     caughtItem = simbase.air.questManager.toonFished(av, zoneId)
     if caughtItem:
         return [FishGlobals.QuestItem, caughtItem, 0, 0]
     rand = random.random() * 100.0
     for cutoff in FishGlobals.SortedProbabilityCutoffs:
         if rand <= cutoff:
             itemType = FishGlobals.ProbabilityDict[cutoff]
             break
     if av.doId in self.requestedFish:
         genus, species = self.requestedFish[av.doId]
         weight = FishGlobals.getRandomWeight(genus, species)
         fish = FishBase(genus, species, weight)
         fishType = av.fishCollection.collectFish(fish)
         if fishType == FishGlobals.COLLECT_NEW_ENTRY:
             itemType = FishGlobals.FishItemNewEntry
         elif fishType == FishGlobals.COLLECT_NEW_RECORD:
             itemType = FishGlobals.FishItemNewRecord
         else:
             itemType = FishGlobals.FishItem
         netlist = av.fishCollection.getNetLists()
         av.d_setFishCollection(netlist[0], netlist[1], netlist[2])
         av.fishTank.addFish(fish)
         netlist = av.fishTank.getNetLists()
         av.d_setFishTank(netlist[0], netlist[1], netlist[2])
         del self.requestedFish[av.doId]
         return [itemType, genus, species, weight]
     if itemType == FishGlobals.FishItem:
         success, genus, species, weight = FishGlobals.getRandomFishVitals(
             zoneId, av.getFishingRod())
         fish = FishBase(genus, species, weight)
         fishType = av.fishCollection.collectFish(fish)
         if fishType == FishGlobals.COLLECT_NEW_ENTRY:
             itemType = FishGlobals.FishItemNewEntry
         elif fishType == FishGlobals.COLLECT_NEW_RECORD:
             itemType = FishGlobals.FishItemNewRecord
         else:
             itemType = FishGlobals.FishItem
         netlist = av.fishCollection.getNetLists()
         av.d_setFishCollection(netlist[0], netlist[1], netlist[2])
         av.fishTank.addFish(fish)
         netlist = av.fishTank.getNetLists()
         av.d_setFishTank(netlist[0], netlist[1], netlist[2])
         return [itemType, genus, species, weight]
     elif itemType == FishGlobals.BootItem:
         return [itemType, 0, 0, 0]
     else:
         money = FishGlobals.Rod2JellybeanDict[av.getFishingRod()]
         av.addMoney(money)
         return [itemType, money, 0, 0]
 def updatePage(self):
     if hasattr(self, 'collectedTotal'):
         self.collectedTotal['text'] = TTLocalizer.FishPageCollectedTotal % (len(base.localAvatar.fishCollection), FishGlobals.getTotalNumFish())
     
     if hasattr(self, 'rod'):
         rod = base.localAvatar.fishingRod
         rodName = TTLocalizer.FishingRodNameDict[rod]
         rodWeightRange = FishGlobals.getRodWeightRange(rod)
         self.rod['text'] = TTLocalizer.FishPageRodInfo % (rodName, rodWeightRange[0], rodWeightRange[1])
     
     if self.mode == FishPage_Tank:
         if hasattr(self, 'picker'):
             newTankFish = base.localAvatar.fishTank.getFish()
             self.picker.update(newTankFish)
         
     elif self.mode == FishPage_Collection:
         if hasattr(self, 'browser'):
             self.browser.update()
         
     elif self.mode == FishPage_Trophy:
         if hasattr(self, 'trophies'):
             for trophy in self.trophies:
                 trophy.setLevel(-1)
             
             for trophyId in base.localAvatar.getFishingTrophies():
                 self.trophies[trophyId].setLevel(trophyId)
 def enterLocalCasting(self):
     if self.power == 0.0 and len(self.av.fishCollection) == 0:
         self.__showHowTo(TTLocalizer.FishingHowToFailed)
         if self.castTrack:
             self.castTrack.pause()
         self.av.loop("pole-neutral")
         self.track = None
         return
     castCost = FishGlobals.getCastCost(self.av.getFishingRod())
     self.jar["text"] = str(max(self.av.getMoney() - castCost, 0))
     if not self.castTrack:
         self.createCastTrack()
     self.castTrack.pause()
     startT = 0.7 + (1 - self.power) * 0.3
     self.castTrack.start(startT)
     self.track = Sequence(
         Wait(1.2 - startT),
         Func(self.startMoveBobTask),
         Func(self.__showLineCasting),
     )
     self.track.start()
     heading = self.angleNP.getH()
     self.d_doCast(self.power, heading)
     self.timer.countdown(FishGlobals.CastTimeout)
     return
    def doCast(self, power, heading):
        # The client begins a cast.
        avId = self.air.getAvatarIdFromSender()
        self.notify.debug("doCast: avId: %s" % (avId))
        if not self.validate(avId, (self.avId == avId),
                             "doCast: avId is not fishing in this spot"):
            return
        if not self.validate(avId, (0.0 <= power <= 1.0),
                             ("doCast: power: %s is out of range" % power)):
            return
        if not self.validate(avId,
                             (-FishGlobals.FishingAngleMax <= heading <= FishGlobals.FishingAngleMax),
                             ("doCast: heading: %s is out of range" % heading)):
            return

        av = self.air.doId2do.get(self.avId)
        if not self.validate(avId, (av), "doCast: avId not currently logged in to this AI"):
            return
        
        self.__stopTimeout()
        money = av.getMoney()
        # cast cost is based on rod now
        castCost = FishGlobals.getCastCost(av.getFishingRod())
        
        if money < castCost:
            # Not enough money to cast
            self.normalExit()
            return
        
        self.air.writeServerEvent("fished_cast", avId, "%s|%s" %(av.getFishingRod(), castCost))
        av.b_setMoney(money - castCost)
        self.d_setMovie(FishGlobals.CastMovie, power=power, h=heading)
        self.__startTimeout(FishGlobals.CastTimeout)
Exemple #12
0
 def doCast(self, p, h):
     avId = self.air.getAvatarIdFromSender()
     if self.avId != avId:
         self.air.writeServerEvent(
             'suspicious', avId,
             'Toon tried to cast from a pier they\'re not on!')
         return
     av = self.air.doId2do[avId]
     money = av.getMoney()
     cost = FishGlobals.getCastCost(av.getFishingRod())
     if money < cost:
         self.air.writeServerEvent(
             'suspicious', avId,
             'Toon tried to cast without enough jellybeans!')
         return
     if len(av.fishTank) >= av.getMaxFishTank():
         self.air.writeServerEvent(
             'suspicious', avId, 'Toon tried to cast with too many fish!')
         return
     av.takeMoney(cost, False)
     self.d_setMovie(FishGlobals.CastMovie, 0, 0, 0, 0, p, h)
     taskMgr.remove('cancelAnimation%d' % self.doId)
     taskMgr.doMethodLater(2, DistributedFishingSpotAI.cancelAnimation,
                           'cancelAnimation%d' % self.doId, [self])
     taskMgr.remove('timeOut%d' % self.doId)
     taskMgr.doMethodLater(45,
                           DistributedFishingSpotAI.removeFromPierWithAnim,
                           'timeOut%d' % self.doId, [self])
     self.cast = True
Exemple #13
0
 def __init__(self, parent = aspect2d, **kw):
     self.parent = parent
     gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui')
     optiondefs = (('parent', 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, FishGlobals.getGenera()), None),
      ('scrollSpeed', 4, None),
      ('itemMakeFunction', GenusPanel.GenusPanel, None),
      ('itemMakeExtraArgs', None, None))
     gui.removeNode()
     self.defineoptions(kw, optiondefs)
     DirectScrolledList.__init__(self, parent)
     self.initialiseoptions(FishBrowser)
 def completeSale(self, sell):
     avId = self.air.getAvatarIdFromSender()
     if self.busy != avId:
         self.air.writeServerEvent(
             'suspicious', avId,
             'DistributedNPCFishermanAI.completeSale busy with %s' %
             self.busy)
         self.notify.warning(
             'somebody called setMovieDone that I was not busy with! avId: %s'
             % avId)
         return
     if sell:
         av = simbase.air.doId2do.get(avId)
         if av:
             trophyResult = self.air.fishManager.creditFishTank(av)
             if trophyResult:
                 movieType = NPCToons.SELL_MOVIE_TROPHY
                 extraArgs = [
                     len(av.fishCollection),
                     FishGlobals.getTotalNumFish()
                 ]
             else:
                 movieType = NPCToons.SELL_MOVIE_COMPLETE
                 extraArgs = []
             self.d_setMovie(avId, movieType, extraArgs)
     else:
         av = simbase.air.doId2do.get(avId)
         if av:
             self.d_setMovie(avId, NPCToons.SELL_MOVIE_NOFISH)
     self.sendClearMovie(None)
     return
Exemple #15
0
 def setGenus(self, genus):
     if self.genus == genus:
         return
     self.genus = genus
     if self.genus != None:
         if self.fishPanel:
             self.fishPanel.destroy()
         f = FishBase.FishBase(self.genus, 0, 0)
         self.fishPanel = FishPhoto.FishPhoto(fish=f, parent=self)
         self.fishPanel.setPos(-0.23, 1, -0.01)
         self.fishPanel.setSwimBounds(-0.2461, 0.2367, -0.207, 0.2664)
         self.fishPanel.setSwimColor(0.47, 1.0, 0.99, 1.0)
         speciesList = FishGlobals.getSpecies(self.genus)
         self.speciesLabels = []
         offset = 0.075
         startPos = len(speciesList) / 2 * offset
         if not len(speciesList) % 2:
             startPos -= offset / 2
         for species in xrange(len(speciesList)):
             label = DirectLabel(
                 parent=self,
                 relief=None,
                 state=DGG.NORMAL,
                 pos=(0.06, 0, startPos - species * offset),
                 text=TTLocalizer.UnknownFish,
                 text_fg=(0.2, 0.1, 0.0, 1),
                 text_scale=TTLocalizer.GPgenus,
                 text_align=TextNode.ALeft,
                 text_font=ToontownGlobals.getInterfaceFont())
             self.speciesLabels.append(label)
    def completeSale(self, sell):
        avId = self.air.getAvatarIdFromSender()
        if self.busy != avId:
            self.air.writeServerEvent('suspicious', avId=avId, issue='DistributedNPCFishermanAI.completeSale busy with %s' % self.busy)
            self.notify.warning('somebody called setMovieDone that I was not busy with! avId: %s' % avId)
            return
        if sell:
            av = simbase.air.doId2do.get(avId)
            if av:

                #maybe: recreate Disney-style fishManager that does the above code?
                trophyResult = self.air.fishManager.creditFishTank(av)
                if trophyResult:
                    movieType = NPCToons.SELL_MOVIE_TROPHY
                    extraArgs = [len(av.fishCollection), FishGlobals.getTotalNumFish()]
                else:
                    movieType = NPCToons.SELL_MOVIE_COMPLETE
                    extraArgs = []
                self.d_setMovie(avId, movieType, extraArgs)
        else:
            av = simbase.air.doId2do.get(avId)
            if av:
                self.d_setMovie(avId, NPCToons.SELL_MOVIE_NOFISH)
        self.sendClearMovie(None)
        return
Exemple #17
0
 def fishSold(self):
     avId = self.air.getAvatarIdFromSender()
     if self.busy != avId:
         self.air.writeServerEvent(
             'suspicious', avId,
             'DistributedNPCPetshopAI.fishSold busy with %s' % self.busy)
         self.notify.warning(
             'somebody called fishSold that I was not busy with! avId: %s' %
             avId)
         return
     av = simbase.air.doId2do.get(avId)
     if av:
         trophyResult = self.air.fishManager.creditFishTank(av)
         if trophyResult:
             movieType = NPCToons.SELL_MOVIE_TROPHY
             extraArgs = [
                 len(av.fishCollection),
                 FishGlobals.getTotalNumFish()
             ]
         else:
             movieType = NPCToons.SELL_MOVIE_COMPLETE
             extraArgs = []
         self.d_setMovie(avId, movieType, extraArgs)
         self.transactionType = 'fish'
     self.sendClearMovie(None)
     return
    def completeSale(self, sell):
        avId = self.air.getAvatarIdFromSender()
        if self.busy != avId:
            self.air.writeServerEvent('suspicious', avId, 'DistributedNPCFishermanAI.completeSale busy with %s' % self.busy)
            self.notify.warning('somebody called setMovieDone that I was not busy with! avId: %s' % avId)
            return

        for spot in self.air.hoodId2Hood[ZoneUtil.getCanonicalBranchZone(self.zoneId)].fishingSpots:
            if spot.avId == avId:
                self.sendClearMovie(None)
                return

        if sell:
            av = simbase.air.doId2do.get(avId)
            if av:

                #maybe: recreate Disney-style fishManager that does the above code?
                trophyResult = self.air.fishManager.creditFishTank(av)
                if trophyResult:
                    movieType = NPCToons.SELL_MOVIE_TROPHY
                    extraArgs = [len(av.fishCollection), FishGlobals.getTotalNumFish()]
                else:
                    movieType = NPCToons.SELL_MOVIE_COMPLETE
                    extraArgs = []
                self.d_setMovie(avId, movieType, extraArgs)
        else:
            av = simbase.air.doId2do.get(avId)
            if av:
                self.d_setMovie(avId, NPCToons.SELL_MOVIE_NOFISH)
        self.sendClearMovie(None)
        return
Exemple #19
0
    def fishSold(self):
        assert self.notify.debug('fishSold()')
        avId = self.air.getAvatarIdFromSender()

        if self.busy != avId:
            self.air.writeServerEvent('suspicious', avId, 'DistributedNPCPetshopAI.fishSold busy with %s' % (self.busy))
            self.notify.warning("somebody called fishSold that I was not busy with! avId: %s" % avId)
            return
            
        av = simbase.air.doId2do.get(avId)
        if av:
            # this function sells the fish, clears the tank, and
            # updates the collection, trophies, and maxhp. One stop shopping!
            trophyResult = self.air.fishManager.creditFishTank(av)

            if trophyResult:
                movieType = NPCToons.SELL_MOVIE_TROPHY
                extraArgs = [len(av.fishCollection), FishGlobals.getTotalNumFish()]
            else:
                movieType = NPCToons.SELL_MOVIE_COMPLETE
                extraArgs = []
            
            # Send a movie to reward the avatar
            self.d_setMovie(avId, movieType, extraArgs)
            self.transactionType = "fish"
        else:
            # perhaps the avatar got disconnected, just leave the fish
            # in his tank and let him resell them next time
            pass
        self.sendClearMovie(None)
 def __showSellFishConfirmDialog(self, numFishCaught):
     self.__makeGui()
     msg = TTLocalizer.STOREOWNER_TROPHY % (
         numFishCaught,
         FishGlobals.getTotalNumFish(),
     )
     self.sellFishConfirmDialog.setMessage(msg)
     self.sellFishConfirmDialog.show()
Exemple #21
0
 def update(self):
     if base.localAvatar.fishCollection.hasGenus(
             self.genus) and self.fishPanel is not None:
         self.fishPanel.show(showBackground=1)
         self['text'] = TTLocalizer.FishGenusNames[self.genus]
     for species in xrange(len(FishGlobals.getSpecies(self.genus))):
         if base.localAvatar.fishCollection.hasFish(self.genus, species):
             self.speciesLabels[species][
                 'text'] = TTLocalizer.FishSpeciesNames[self.genus][species]
 def generateCard(self, tileSeed, zoneId):
     rng = RandomNumGen.RandomNumGen(tileSeed)
     fishList = FishGlobals.getPondGeneraList(zoneId)
     emptyCells = self.cardSize - 1 - len(fishList)
     rodId = 0
     for i in xrange(emptyCells):
         fish = FishGlobals.getRandomFishVitals(zoneId, rodId, rng)
         while not fish[0]:
             fish = FishGlobals.getRandomFishVitals(zoneId, rodId, rng)
         fishList.append((fish[1], fish[2]))
         rodId += 1
         if rodId > 4:
             rodId = 0
             continue
     
     for index in xrange(self.cardSize):
         if index != self.cardSize / 2:
             choice = rng.randrange(0, len(fishList))
             self.cellList.append(fishList.pop(choice))
             continue
         self.cellList.append((None, None))
Exemple #23
0
    def generateCard(self, tileSeed, zoneId):
        rng = RandomNumGen.RandomNumGen(tileSeed)
        fishList = FishGlobals.getPondGeneraList(zoneId)
        emptyCells = self.cardSize - 1 - len(fishList)
        rodId = 0
        for i in xrange(emptyCells):
            fish = FishGlobals.getRandomFishVitals(zoneId, rodId, rng)
            while not fish[0]:
                fish = FishGlobals.getRandomFishVitals(zoneId, rodId, rng)
            fishList.append((fish[1], fish[2]))
            rodId += 1
            if rodId > 4:
                rodId = 0
                continue

        for index in xrange(self.cardSize):
            if index != self.cardSize / 2:
                choice = rng.randrange(0, len(fishList))
                self.cellList.append(fishList.pop(choice))
                continue
            self.cellList.append((None, None))
 def fishSold(self):
     avId = self.air.getAvatarIdFromSender()
     if self.busy != avId:
         self.air.writeServerEvent('suspicious', avId=avId, issue='DistributedNPCPetshopAI.fishSold busy with %s' % self.busy)
         self.notify.warning('somebody called fishSold that I was not busy with! avId: %s' % avId)
         return
     av = simbase.air.doId2do.get(avId)
     if av:
         trophyResult = self.air.fishManager.creditFishTank(av)
         if trophyResult:
             movieType = NPCToons.SELL_MOVIE_TROPHY
             extraArgs = [len(av.fishCollection), FishGlobals.getTotalNumFish()]
         else:
             movieType = NPCToons.SELL_MOVIE_COMPLETE
             extraArgs = []
         self.d_setMovie(avId, movieType, extraArgs)
         self.transactionType = 'fish'
     self.sendClearMovie(None)
 def enterLocalAdjusting(self, guiEvent = None):
     if self.track:
         self.track.pause()
     
     if self.castTrack:
         self.castTrack.pause()
     
     self.power = 0.0
     self.firstCast = 0
     self.castButton['image0_color'] = Vec4(0, 1, 0, 1)
     self.castButton['text'] = ''
     self.av.stopLookAround()
     self._DistributedFishingSpot__hideLine()
     self._DistributedFishingSpot__hideBob()
     self.howToDialog.hide()
     castCost = FishGlobals.getCastCost(self.av.getFishingRod())
     if self.av.getMoney() < castCost:
         self._DistributedFishingSpot__hideCastGui()
         self._DistributedFishingSpot__showBroke()
         self.av.loop('pole-neutral')
         return None
     
     if self.av.isFishTankFull():
         self._DistributedFishingSpot__hideCastGui()
         self._DistributedFishingSpot__showFishTankFull()
         self.av.loop('pole-neutral')
         return None
     
     self.arrow.show()
     self.arrow.setColorScale(1, 1, 0, 0.69999999999999996)
     self.startAngleNP = self.angleNP.getH()
     self.getMouse()
     self.initMouseX = self.mouseX
     self.initMouseY = self.mouseY
     self._DistributedFishingSpot__hideBob()
     if config.GetBool('fishing-independent-axes', 0):
         taskMgr.add(self.localAdjustingCastTaskIndAxes, self.taskName('adjustCastTask'))
     else:
         taskMgr.add(self.localAdjustingCastTask, self.taskName('adjustCastTask'))
     if base.wantBingo:
         bingoMgr = self.pond.getPondBingoManager()
         if bingoMgr:
             bingoMgr.castingStarted()
    def doCast(self, p, h):
        avId = self.air.getAvatarIdFromSender()
        if not avId:
            return

        if self.avId != avId:
            self.air.writeServerEvent(
                'suspicious', avId,
                'Toon tried to cast from a fishing spot they\'re not on!')
            return

        av = self.air.doId2do.get(avId)
        if not av:
            self.air.writeServerEvent(
                'suspicious', avId,
                'Toon tried to cast, but they don\'t exist on this shard!')
            return

        money = av.getMoney()
        cost = FishGlobals.getCastCost(av.getFishingRod())
        if money < cost:
            self.air.writeServerEvent(
                'suspicious', avId,
                'Toon tried to cast without enough jellybeans!')
            return

        if len(av.fishTank) >= av.getMaxFishTank():
            self.air.writeServerEvent(
                'suspicious', avId, 'Toon tried to cast with too many fish!')
            return

        av.takeMoney(cost, False)
        self.d_setMovie(FishGlobals.CastMovie, 0, 0, 0, 0, p, h)
        taskMgr.remove('cancel-animation-%d' % self.doId)
        taskMgr.doMethodLater(2, self.d_setMovie,
                              'cancel-animation-%d' % self.doId,
                              [FishGlobals.NoMovie, 0, 0, 0, 0, 0, 0])
        taskMgr.remove('time-out-%d' % self.doId)
        taskMgr.doMethodLater(FishGlobals.CastTimeout,
                              self.removeFromFishingSpotWithAnim,
                              'time-out-%d' % self.doId)
        self.cast = True
 def enterLocalCasting(self):
     if self.power == 0.0 and len(self.av.fishCollection) == 0:
         self.__showHowTo(TTLocalizer.FishingHowToFailed)
         if self.castTrack:
             self.castTrack.pause()
         self.av.loop('pole-neutral')
         self.track = None
         return
     castCost = FishGlobals.getCastCost(self.av.getFishingRod())
     self.jar['text'] = str(max(self.av.getMoney() - castCost, 0))
     if not self.castTrack:
         self.createCastTrack()
     self.castTrack.pause()
     startT = 0.7 + (1 - self.power) * 0.3
     self.castTrack.start(startT)
     self.track = Sequence(Wait(1.2 - startT), Func(self.startMoveBobTask), Func(self.__showLineCasting))
     self.track.start()
     heading = self.angleNP.getH()
     self.d_doCast(self.power, heading)
     self.timer.countdown(FishGlobals.CastTimeout)
Exemple #28
0
 def enterLocalAdjusting(self, guiEvent=None):
     if self.track:
         self.track.pause()
     if self.castTrack:
         self.castTrack.pause()
     self.power = 0.0
     self.firstCast = 0
     self.castButton['image0_color'] = Vec4(0, 1, 0, 1)
     self.castButton['text'] = ''
     self.av.stopLookAround()
     self.__hideLine()
     self.__hideBob()
     self.howToDialog.hide()
     castCost = FishGlobals.getCastCost(self.av.getFishingRod())
     if self.av.getMoney() < castCost:
         self.__hideCastGui()
         self.__showBroke()
         self.av.loop('pole-neutral')
         return
     if self.av.isFishTankFull():
         self.__hideCastGui()
         self.__showFishTankFull()
         self.av.loop('pole-neutral')
         return
     self.arrow.show()
     self.arrow.setColorScale(1, 1, 0, 0.7)
     self.startAngleNP = self.angleNP.getH()
     self.getMouse()
     self.initMouseX = self.mouseX
     self.initMouseY = self.mouseY
     self.__hideBob()
     if config.GetBool('fishing-independent-axes', 0):
         taskMgr.add(self.localAdjustingCastTaskIndAxes,
                     self.taskName('adjustCastTask'))
     else:
         taskMgr.add(self.localAdjustingCastTask,
                     self.taskName('adjustCastTask'))
     if base.wantBingo:
         bingoMgr = self.pond.getPondBingoManager()
         if bingoMgr:
             bingoMgr.castingStarted()
 def doCast(self, p, h):
     avId = self.air.getAvatarIdFromSender()
     if self.avId != avId:
         self.air.writeServerEventMessage('suspicious', avId, 'Toon tried to cast from a pier they\'re not on!')
         return
     av = self.air.doId2do[avId]
     money = av.getMoney()
     cost = FishGlobals.getCastCost(av.getFishingRod())
     if money < cost:
         self.air.writeServerEventMessage('suspicious', avId, 'Toon tried to cast without enough jellybeans!')
         return
     if len(av.fishTank) >= av.getMaxFishTank():
         self.air.writeServerEventMessage('suspicious', avId, 'Toon tried to cast with too many fish!')
         return
     av.takeMoney(cost, False)
     self.d_setMovie(FishGlobals.CastMovie, 0, 0, 0, 0, p, h)
     taskMgr.remove('cancelAnimation%d' % self.doId)
     taskMgr.doMethodLater(2, DistributedFishingSpotAI.cancelAnimation, 'cancelAnimation%d' % self.doId, [self])
     taskMgr.remove('timeOut%d' % self.doId)
     taskMgr.doMethodLater(45, DistributedFishingSpotAI.removeFromPierWithAnim, 'timeOut%d' % self.doId, [self])
     self.cast = True
Exemple #30
0
 def getValue(self):
     return FishGlobals.getValue(self.genus, self.species, self.weight)
Exemple #31
0
 def getRarity(self):
     return FishGlobals.getRarity(self.genus, self.species)
 def __showSellFishConfirmDialog(self, numFishCaught):
     self.__makeGui()
     msg = TTLocalizer.STOREOWNER_TROPHY % (numFishCaught, FishGlobals.getTotalNumFish())
     self.sellFishConfirmDialog.setMessage(msg)
     self.sellFishConfirmDialog.show()
Exemple #33
0
    def generateCatch(self, av, zoneId):
        if len(av.fishTank) >= av.getMaxFishTank():
            return [FishGlobals.OverTankLimit, 0, 0, 0]
        rand = random.random() * 100.0
        for cutoff in FishGlobals.SortedProbabilityCutoffs:
            if rand <= cutoff:
                itemType = FishGlobals.ProbabilityDict[cutoff]
                break
        if av.doId in self.requestedFish:
            genus, species = self.requestedFish[av.doId]
            weight = FishGlobals.getRandomWeight(genus, species)
            fish = FishBase(genus, species, weight)
            fishType = av.fishCollection.collectFish(fish)
            if fishType == FishGlobals.COLLECT_NEW_ENTRY:
                itemType = FishGlobals.FishItemNewEntry
            elif fishType == FishGlobals.COLLECT_NEW_RECORD:
                itemType = FishGlobals.FishItemNewRecord
            else:
                itemType = FishGlobals.FishItem
            netlist = av.fishCollection.getNetLists()
            av.d_setFishCollection(netlist[0], netlist[1], netlist[2])
            av.fishTank.addFish(fish)
            netlist = av.fishTank.getNetLists()
            av.d_setFishTank(netlist[0], netlist[1], netlist[2])
            del self.requestedFish[av.doId]
            av.addStat(ToontownGlobals.STAT_FISH)
            return [itemType, genus, species, weight]
        if itemType == FishGlobals.FishItem:
            success, genus, species, weight = FishGlobals.getRandomFishVitals(
                zoneId, av.getFishingRod())
            fish = FishBase(genus, species, weight)
            fishType = av.fishCollection.collectFish(fish)
            if fishType == FishGlobals.COLLECT_NEW_ENTRY:
                itemType = FishGlobals.FishItemNewEntry
            elif fishType == FishGlobals.COLLECT_NEW_RECORD:
                itemType = FishGlobals.FishItemNewRecord
            else:
                itemType = FishGlobals.FishItem
            netlist = av.fishCollection.getNetLists()
            av.d_setFishCollection(netlist[0], netlist[1], netlist[2])
            av.fishTank.addFish(fish)
            netlist = av.fishTank.getNetLists()
            av.d_setFishTank(netlist[0], netlist[1], netlist[2])
            messenger.send('topToonsManager-event',
                           [av.doId, TopToonsGlobals.CAT_FISH, 1])
            av.addStat(ToontownGlobals.STAT_FISH)
            return [itemType, genus, species, weight]
        elif itemType == FishGlobals.BootItem:
            return [itemType, 0, 0, 0]
        elif itemType == FishGlobals.QuestItem:
            itemId = simbase.air.questManager.toonCaughtFishingItem(av)

            if itemId != -1:
                return [itemType, itemId, 0, 0]
            else:
                success, genus, species, weight = FishGlobals.getRandomFishVitals(
                    zoneId, av.getFishingRod())
                fish = FishBase(genus, species, weight)
                fishType = av.fishCollection.collectFish(fish)
                if fishType == FishGlobals.COLLECT_NEW_ENTRY:
                    itemType = FishGlobals.FishItemNewEntry
                elif fishType == FishGlobals.COLLECT_NEW_RECORD:
                    itemType = FishGlobals.FishItemNewRecord
                else:
                    itemType = FishGlobals.FishItem
                netlist = av.fishCollection.getNetLists()
                av.d_setFishCollection(netlist[0], netlist[1], netlist[2])
                av.fishTank.addFish(fish)
                netlist = av.fishTank.getNetLists()
                av.d_setFishTank(netlist[0], netlist[1], netlist[2])
                messenger.send('topToonsManager-event',
                               [av.doId, TopToonsGlobals.CAT_FISH, 1])
                av.addStat(ToontownGlobals.STAT_FISH)
                return [itemType, genus, species, weight]
        else:
            money = FishGlobals.Rod2JellybeanDict[av.getFishingRod()]
            av.addMoney(money)
            return [itemType, money, 0, 0]
    def completeFishSale(self):
        avId = self.air.getAvatarIdFromSender()
        av = self.air.doId2do.get(avId)
        
        if not av:
            return

        if self.air.fishManager.creditFishTank(av):
            self.sendUpdateToAvatarId(avId, 'thankSeller', [ToontownGlobals.FISHSALE_TROPHY, len(av.fishCollection), FishGlobals.getTotalNumFish()])
        else:
            self.sendUpdateToAvatarId(avId, 'thankSeller', [ToontownGlobals.FISHSALE_COMPLETE, 0, 0])
Exemple #35
0
    def generateCard(self, tileSeed, zoneId):
        assert (self.game != None)

        rng = RandomNumGen.RandomNumGen(tileSeed)
        rowSize = self.game.getRowSize()

        # Retrieve a list of Fish based on the Genus Type. Each Genus
        # found in the pond will be represented on the board.
        fishList = FishGlobals.getPondGeneraList(zoneId)

        # Go through the fish list and generate actual fish.
        # NOTE: This should likely be removed when the fish logos come into play.
        # There is no need to generate a Fish object. Tuples (genus, species)
        # can effectively be used to identify the type of fish for a specific
        # BingoCardCell.
        for i in xrange(len(fishList)):
            fishTuple = fishList.pop(0)
            weight = FishGlobals.getRandomWeight(fishTuple[0], fishTuple[1])
            fish = FishBase.FishBase(fishTuple[0], fishTuple[1], weight)
            fishList.append(fish)

        # Determine the number of cells left to fill.
        emptyCells = (self.game.getCardSize() - 1) - len(fishList)

        # Fill up the empty cells with randomly generated fish. In order to
        # maintain fairness, iterate through the rods as well.
        rodId = 0
        for i in xrange(emptyCells):
            fishVitals = FishGlobals.getRandomFishVitals(zoneId, rodId, rng)
            while (not fishVitals[0]):
                fishVitals = FishGlobals.getRandomFishVitals(
                    zoneId, rodId, rng)

            fish = FishBase.FishBase(fishVitals[1], fishVitals[2],
                                     fishVitals[3])
            fishList.append(fish)
            rodId += 1
            if rodId > 4: rodId = 0

        # Now that we have generated all of the fish that will make up the card,
        # it is time to actually generate a BingoCardCell for every fish. This
        # cell will be parented to the GUI instance and its position and scale
        # are based on the CardImageScale. (See base positions above)
        for i in xrange(rowSize):
            for j in xrange(self.game.getColSize()):
                color = self.getCellColor(i * rowSize + j)
                if i * rowSize + j == self.game.getCardSize() / 2:
                    tmpFish = 'Free'
                else:
                    choice = rng.randrange(0, len(fishList))
                    tmpFish = fishList.pop(choice)

                xPos = BG.CellImageScale * (j - 2) + BG.GridXOffset
                yPos = BG.CellImageScale * (i - 2) - 0.015
                cellGui = BingoCardCell.BingoCardCell(
                    i * rowSize + j,
                    tmpFish,
                    self.model,
                    color,
                    self,
                    image_scale=BG.CellImageScale,
                    pos=(xPos, 0, yPos),
                )
                self.cellGuiList.append(cellGui)
    def completeFishSale(self):
        avId = self.air.getAvatarIdFromSender()
        av = self.air.doId2do.get(avId)
        
        if not av:
            return

        if self.air.fishManager.creditFishTank(av):
            self.sendUpdateToAvatarId(avId, 'thankSeller', [ToontownGlobals.FISHSALE_TROPHY, len(av.fishCollection), FishGlobals.getTotalNumFish()])
        else:
            self.sendUpdateToAvatarId(avId, 'thankSeller', [ToontownGlobals.FISHSALE_COMPLETE, 0, 0])