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)
Beispiel #2
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)
Beispiel #3
0
 def enterReward(self, code, itemDesc1, itemDesc2, itemDesc3):
     self.__placeAvatar()
     self.bob.reparentTo(self.angleNP)
     self.bob.setZ(self.waterLevel)
     self.__showLineReeling()
     self.castTrack.pause()
     if self.localToonFishing:
         self.__showCastGui()
         if code == FishGlobals.QuestItem:
             self.__showQuestItem(itemDesc1)
         elif code in (FishGlobals.FishItem, FishGlobals.FishItemNewEntry, FishGlobals.FishItemNewRecord):
             genus, species, weight = itemDesc1, itemDesc2, itemDesc3
             fish = FishBase.FishBase(genus, species, weight)
             self.__showFishItem(code, fish)
             if base.wantBingo:
                 self.pond.handleBingoCatch((genus, species))
         elif code == FishGlobals.BootItem:
             self.__showBootItem()
             if base.wantBingo:
                 self.pond.handleBingoCatch(FishGlobals.BingoBoot)
         elif code == FishGlobals.JellybeanItem:
             amount = itemDesc1
             self.__showJellybeanItem(amount)
         elif code == FishGlobals.OverTankLimit:
             self.__hideCastGui()
         else:
             self.__showFailureReason(code)
     self.track = Sequence(Parallel(ActorInterval(self.av, 'reel'), ActorInterval(self.pole, 'cast', startFrame=63, endFrame=127)), ActorInterval(self.av, 'reel-neutral'), Func(self.__hideLine), Func(self.__hideBob), ActorInterval(self.av, 'fish-again'), Func(self.av.loop, 'pole-neutral'))
     self.track.start()
 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)
Beispiel #5
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 makeFromNetLists(self, genusList, speciesList, weightList):
     self.fishList = []
     for genus, species, weight in zip(genusList, speciesList, weightList):
         self.fishList.append(FishBase.FishBase(genus, species, weight))