def replaceFish(self, fish):
     depth = fish.myData["depth"]
     index = fish.index
     self.fishHistogram[fish.myData["id"]][0] -= 1
     self.uncaughtFish.remove(fish)
     fish.destroy()
     fishData = FishingGlobals.giveMeAFish(self.location, depth, self.fishHistogram)
     f = Fish(self, fishData, index)
     f.fsm.request("Offscreen")
     self.fishHistogram[f.myData["id"]][0] += 1
     f.pickPositionAndSwim()
     self.uncaughtFish.append(f)
Exemple #2
0
 def replaceFish(self, fish):
     depth = fish.myData['depth']
     index = fish.index
     self.fishHistogram[fish.myData['id']][0] -= 1
     self.uncaughtFish.remove(fish)
     fish.destroy()
     fishData = FishingGlobals.giveMeAFish(self.location, depth,
                                           self.fishHistogram)
     f = Fish(self, fishData, index)
     f.fsm.request('Offscreen')
     self.fishHistogram[f.myData['id']][0] += 1
     f.pickPositionAndSwim()
     self.uncaughtFish.append(f)
    def loadFish(self):
        rodSize = self.gameObject.getAvatarsBestRod()
        for depth in range(len(FishingGlobals.fishCountRangePerRodPerLevel[rodSize])):
            numberOfFishForThisLevel = random.randint(
                FishingGlobals.fishCountRangePerRodPerLevel[rodSize][depth][0],
                FishingGlobals.fishCountRangePerRodPerLevel[rodSize][depth][1],
            )
            for fishIndex in range(numberOfFishForThisLevel):
                fishData = FishingGlobals.giveMeAFish(self.location, depth, self.fishHistogram)
                f = Fish(self, fishData, len(self.uncaughtFish))
                self.fishHistogram[f.myData["id"]][0] += 1
                f.fsm.request("Offscreen")
                self.uncaughtFish.append(f)

            self.legendaryFish = None
Exemple #4
0
    def loadFish(self):
        rodSize = self.gameObject.getAvatarsBestRod()
        for depth in range(
                len(FishingGlobals.fishCountRangePerRodPerLevel[rodSize])):
            numberOfFishForThisLevel = random.randint(
                FishingGlobals.fishCountRangePerRodPerLevel[rodSize][depth][0],
                FishingGlobals.fishCountRangePerRodPerLevel[rodSize][depth][1])
            for fishIndex in range(numberOfFishForThisLevel):
                fishData = FishingGlobals.giveMeAFish(self.location, depth,
                                                      self.fishHistogram)
                f = Fish(self, fishData, len(self.uncaughtFish))
                self.fishHistogram[f.myData['id']][0] += 1
                f.fsm.request('Offscreen')
                self.uncaughtFish.append(f)

            self.legendaryFish = None
Exemple #5
0
    def caughtFish(self, fishId, weight):
        avatar = self.air.doId2do.get(self.air.getAvatarIdFromSender())

        if not avatar:
            return

        fishData = FishingGlobals.getFishData(fishId)
        if not fishData:
            self.air.logPotentialHacker(
                message='Received caughtFish update for an invalid fish!',
                accountId=self.air.getAccountIdFromSender(),
                fishId=fishId,
                weight=weight)
            return

        minWeight, maxWeight = fishData['weightRange']

        if weight < minWeight or weight > maxWeight:
            self.air.logPotentialHacker(
                message='Received caughtFish update for invalid weight.',
                accountId=self.air.getAccountIdFromSender(),
                fishId=fishId,
                weight=weight)
            return

        reward = fishData['gold'] * weight
        bonusReward = 0
        if self.air.holidayMgr.isHolidayActive(
                HolidayGlobals.DOUBLEGOLDHOLIDAY
        ) or self.air.holidayMgr.isHolidayActive(
                HolidayGlobals.DOUBLEGOLDHOLIDAYPAID):
            bonusReward = reward * 2

        if bonusReward:
            reward += bonusReward
            self.sendUpdateToAvatarId(avatar.doId, 'setGoldBonus',
                                      [bonusReward])

        experience = fishData['experience']
        bonusExperience = 0
        if self.air.holidayMgr.isHolidayActive(HolidayGlobals.DOUBLEXPHOLIDAY):
            bonusExperience = experience * 2

        if bonusExperience:
            experience += bonusExperience
            self.sendUpdateToAvatarId(avatar.doId, 'setXpBonus',
                                      [bonusExperience])

        inventory = self.air.inventoryManager.getInventory(avatar.doId)

        if not inventory:
            self.notify.warning('Failed to get inventory for avatar %d!' %
                                avatar.doId)
            return

        currentLevel = ReputationGlobals.getLevelFromTotalReputation(
            InventoryType.FishingRep, inventory.getFishingRep())[0]
        expectedLevel = ReputationGlobals.getLevelFromTotalReputation(
            InventoryType.FishingRep,
            inventory.getFishingRep() + experience)[0]

        if expectedLevel > currentLevel:
            if expectedLevel in FishingGlobals.unlockLevelToSkillId:
                unlockedSkill = FishingGlobals.unlockLevelToSkillId[
                    expectedLevel]

                inventory.b_setStack(unlockedSkill, 1)

        inventory.setGoldInPocket(inventory.getGoldInPocket() + reward)
        inventory.setFishingRep(inventory.getFishingRep() + experience)

        # Clear Tutorial flags
        if not inventory.getStack(InventoryType.FishingTutorial):
            inventory.b_setStack(InventoryType.FishingTutorial, 1)
 def startLegendaryFish(self, whichFish=None):
     self.notify.debug("start LegendaryFish %s" % str(whichFish))
     fishData = FishingGlobals.getALegendaryFish(whichFish)
     self.legendaryFish = LegendaryFish(self, fishData, 0)
     self.activeFish = self.legendaryFish
     self.legendaryFish.fsm.request("AboutToBiteLure")
Exemple #7
0
 def startLegendaryFish(self, whichFish=None):
     self.notify.debug('start LegendaryFish %s' % str(whichFish))
     fishData = FishingGlobals.getALegendaryFish(whichFish)
     self.legendaryFish = LegendaryFish(self, fishData, 0)
     self.activeFish = self.legendaryFish
     self.legendaryFish.fsm.request('AboutToBiteLure')