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 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 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
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 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
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 for index in xrange(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)) return None
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])
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 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.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
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 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 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 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
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] 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] 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]) return [itemType, genus, species, weight] else: money = FishGlobals.Rod2JellybeanDict[av.getFishingRod()] av.addMoney(money) return [itemType, money, 0, 0]
def __showSellFishConfirmDialog(self, numFishCaught): self.__makeGui() msg = TTLocalizer.STOREOWNER_TROPHY % (numFishCaught, FishGlobals.getTotalNumFish()) self.sellFishConfirmDialog.setMessage(msg) self.sellFishConfirmDialog.show()
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] 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] 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]) 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])