コード例 #1
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))
コード例 #2
0
    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)
コード例 #3
0
 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)
コード例 #4
0
ファイル: FishManagerAI.py プロジェクト: perpi06/ttoffline
    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]
コード例 #5
0
ファイル: BingoCardBase.py プロジェクト: colenoreika/rtask
    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))
コード例 #6
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))
コード例 #7
0
 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]
コード例 #8
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)
コード例 #9
0
ファイル: FishManagerAI.py プロジェクト: mpchange/Toontown-2
    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]