Ejemplo n.º 1
0
    def updatePage(self):
        newQuests = toonbase.localToon.quests
        carryLimit = toonbase.localToon.getQuestCarryLimit()
        for i in range(ToontownGlobals.MaxQuestCarryLimit):
            if i < carryLimit:
                self.questFrames[i].show()
            else:
                self.questFrames[i].hide()

        for index, questDesc in self.quests.items():
            if questDesc is not None and list(questDesc) not in newQuests:
                self.clearQuestFrame(index)

        for questDesc in newQuests:
            newQuestDesc = tuple(questDesc)
            if newQuestDesc not in self.quests.values():
                index = self.getLowestUnusedIndex()
                self.fillQuestFrame(newQuestDesc, index)

        for i in self.quests.keys():
            questDesc = self.quests[i]
            if questDesc:
                questId = questDesc[0]
                if Quests.getQuestClass(questId) == Quests.FriendQuest:
                    self.questFrames[i].update(questDesc)

        return
Ejemplo n.º 2
0
 def hasTailorClothingTicket(self, av, npc):
     for questDesc in av.quests:
         questId, fromNpcId, toNpcId, rewardId, toonProgress = questDesc
         questType = Quests.getQuestClass(questId)
         # See if this NPC is the one we are supposed to deliver to
         # You by definition have the item
         if (questType == Quests.DeliverItemQuest):
             if Quests.npcMatches(toNpcId, npc):
                 rewardId = Quests.getAvatarRewardId(av, questId)
                 rewardType = Quests.getRewardClass(rewardId)
                 if (rewardType == Quests.ClothingTicketReward):
                     return 1
                 elif (rewardType == Quests.TIPClothingTicketReward):
                     return 2
                 else:
                     # Reward was not a clothing ticket
                     continue
             else:
                 # NPC does not match
                 continue
         else:
             # Not a deliver item quest
             continue
     # Did not find it, avId does not have clothing ticket on this tailor
     return 0
Ejemplo n.º 3
0
 def updatePage(self):
     newQuests = toonbase.localToon.quests
     carryLimit = toonbase.localToon.getQuestCarryLimit()
     for i in range(ToontownGlobals.MaxQuestCarryLimit):
         if i < carryLimit:
             self.questFrames[i].show()
         else:
             self.questFrames[i].hide()
     
     for (index, questDesc) in self.quests.items():
         if questDesc is not None and list(questDesc) not in newQuests:
             self.clearQuestFrame(index)
         
     
     for questDesc in newQuests:
         newQuestDesc = tuple(questDesc)
         if newQuestDesc not in self.quests.values():
             index = self.getLowestUnusedIndex()
             self.fillQuestFrame(newQuestDesc, index)
         
     
     for i in self.quests.keys():
         questDesc = self.quests[i]
         if questDesc:
             questId = questDesc[0]
             if Quests.getQuestClass(questId) == Quests.FriendQuest:
                 self.questFrames[i].update(questDesc)
Ejemplo n.º 4
0
    def findItemInWater(self, av, zoneId):
        # Similar to recoverItems, but this is called from the
        # DistributedFishingSpot to see if there are any quest items
        # in the water.  No cogs are involved; hence, the only valid
        # questCogType is Quests.AnyFish.

        # Only one item at a time is returned by this function; the
        # function either returns the item found, or None.
        # Note: this does not support two quests with same item
        avQuests = av.quests
        avId = av.getDoId()

        for questDesc in avQuests:
            questClass = Quests.getQuestClass(questDesc[0])
            if (questClass == Quests.RecoverItemQuest):
                quest = Quests.getQuest(questDesc[0])
                if ((quest.getType() == Quests.RecoverItemQuest)
                        and (quest.getHolder() == Quests.AnyFish) and
                    ((random.random() * 100) <= quest.getPercentChance())
                        and (questDesc[4] < quest.getNumItems())
                        and quest.isLocationMatch(zoneId)):
                    # FOUND IT! Increment progress by one item
                    questDesc[4] += 1
                    self.notify.debug("findItemInWater: av %s made progress" %
                                      (avId))
                    av.b_setQuests(avQuests)
                    # Return the item recovered
                    return quest.getItem()
            else:
                # Do not care about this quest here
                continue

        self.notify.debug("findItemInWater: av %s made NO progress" % (avId))
        return None
Ejemplo n.º 5
0
 def toonMadeFriend(self, av, otherAv):
     # This is notifying us that a toon has made a friend.
     # See if this toon has a friend quest.
     # If so, update the progress.
     avQuests = av.quests
     avId = av.getDoId()
     changed = 0
     for questDesc in avQuests:
         questClass = Quests.getQuestClass(questDesc[0])
         if ((questClass == Quests.FriendQuest)
                 or (questClass == Quests.FriendNewbieQuest)):
             quest = Quests.getQuest(questDesc[0])
             if (quest.doesFriendCount(av, otherAv)):
                 # Set progress
                 questDesc[4] += 1
                 changed = 1
         else:
             # Do not care about this quest here
             continue
     # Now send the quests back to the avatar if the status changed
     if changed:
         self.notify.debug("toonMadeFriend: av %s made progress" % (avId))
         av.b_setQuests(avQuests)
     else:
         self.notify.debug("toonMadeFriend: av %s made NO progress" %
                           (avId))
Ejemplo n.º 6
0
    def toonPlayedMinigame(self, av, avList):
        # This is notifying us that a toon has entered a minigame.
        # See if this toon has a minigame quest.  If so, update the progress.
        avQuests = av.quests
        avId = av.getDoId()
        changed = 0

        for questDesc in avQuests:
            questClass = Quests.getQuestClass(questDesc[0])
            if (questClass == Quests.MinigameNewbieQuest):
                quest = Quests.getQuest(questDesc[0])
                num = quest.doesMinigameCount(av, avList)
                if (num > 0):
                    # Set progress
                    questDesc[4] += num
                    changed = 1

        # Now send the quests back to the avatar if the status changed
        if changed:
            self.notify.debug("toonPlayedMinigame: av %s made progress" %
                              (avId))
            av.b_setQuests(avQuests)
        else:
            self.notify.debug("toonPlayedMinigame: av %s made NO progress" %
                              (avId))
        return
Ejemplo n.º 7
0
    def toonRodeTrolleyFirstTime(self, av):
        # This is notifying us that a toon has gotten on the
        # trolley for the first time. See if this toon has a
        # trolley quest. If so, update the progress.
        avQuests = av.quests
        avId = av.getDoId()
        changed = 0

        for questDesc in avQuests:
            questClass = Quests.getQuestClass(questDesc[0])
            if (questClass == Quests.TrolleyQuest):
                # Set progress
                questDesc[4] = 1
                changed = 1
            else:
                # Do not care about this quest here
                pass

        # Now send the quests back to the avatar if the status changed
        if changed:
            self.notify.debug("toonRodeTrolleyFirstTime: av %s made progress" %
                              (avId))
            av.b_setQuests(avQuests)
            # log this event
            self.air.writeServerEvent('firstTrolleyGame', avId, '')
        else:
            self.notify.debug(
                "toonRodeTrolleyFirstTime: av %s made NO progress" % (avId))
        return
Ejemplo n.º 8
0
 def removeClothingTicket(self, av, npc):
     for questDesc in av.quests:
         questId, fromNpcId, toNpcId, rewardId, toonProgress = questDesc
         questClass = Quests.getQuestClass(questId)
         # See if this NPC is the one we are supposed to deliver to
         # You by definition have the item
         if (questClass == Quests.DeliverItemQuest):
             if Quests.npcMatches(toNpcId, npc):
                 rewardId = Quests.getAvatarRewardId(av, questId)
                 rewardClass = Quests.getRewardClass(rewardId)
                 if (rewardClass == Quests.ClothingTicketReward
                         or rewardClass == Quests.TIPClothingTicketReward):
                     # This section is much like completeQuest()
                     av.removeQuest(questId)
                     # Update the toon with the reward. This reward does nothing right
                     # now but it may in the future, so it is the right thing to do
                     reward = Quests.getReward(rewardId)
                     reward.sendRewardAI(av)
                     # Bump the reward
                     self.incrementReward(av)
                     return 1
                 else:
                     # Reward was not a clothing ticket
                     continue
             else:
                 # NPC does not match
                 continue
         else:
             # Not a deliver item quest
             continue
     # Did not find it, avId does not have clothing ticket on this tailor
     return 0
Ejemplo n.º 9
0
 def toonUsedPhone(self, av):
     # This is notifying us that a toon used his phone
     # See if this toon has a phone quest.  If so, update the progress.
     avQuests = av.quests
     avId = av.getDoId()
     changed = 0
     for questDesc in avQuests:
         questClass = Quests.getQuestClass(questDesc[0])
         if (questClass == Quests.PhoneQuest):
             # Set progress
             questDesc[4] = 1
             changed = 1
     # Now send the quests back to the avatar if the status changed
     if changed:
         self.notify.debug("toonUsedPhone: av %s made progress" % (avId))
         av.b_setQuests(avQuests)
     else:
         self.notify.debug("toonUsedPhone: av %s made NO progress" % (avId))
     return
Ejemplo n.º 10
0
    def toonKilledCogdo(self, av, difficulty, numFloors, zoneId, avList):
        # This is the battle notifying us that a toon has defeated a
        # cogdo.  See if this toon has a quest on this cogdo.
        # If so, update the progress.
        avQuests = av.quests
        avId = av.getDoId()
        changed = 0

        #self.notify.debug("toonKilledBuilding: avId: %s, track: %s, diff: %s, numFloors: %s, zoneId: %s" %
        #                  (avId, track, difficulty, numFloors, zoneId))
        for questDesc in avQuests:
            questClass = Quests.getQuestClass(questDesc[0])
            """ TODO
            if ((questClass == Quests.BuildingQuest) or
                (questClass == Quests.BuildingNewbieQuest)):
                quest = Quests.getQuest(questDesc[0])
                matchedTrack = ((quest.getBuildingTrack() == Quests.Any) or (quest.getBuildingTrack() == track))
                matchedNumFloors = (quest.getNumFloors() <= numFloors)
                matchedLocation = quest.isLocationMatch(zoneId)
                if matchedTrack and matchedNumFloors and matchedLocation:
                    num = quest.doesBuildingCount(avId, avList)
                    if (num > 0):
                        questDesc[4] += num
                        changed = 1
            else:
                # Do not care about this quest here
                continue
                """

        # Now send the quests back to the avatar if the status changed
        if changed:
            self.notify.debug("toonKilledCogdo: av made progress")
            av.b_setQuests(avQuests)
        else:
            self.notify.debug("toonKilledCogdo: av made NO progress")
        return
Ejemplo n.º 11
0
    def recoverItems(self, av, cogList, zoneId):
        avQuests = av.quests
        avId = av.getDoId()
        itemsRecovered = []
        itemsNotRecovered = []
        changed = 0

        for questDesc in avQuests:
            questClass = Quests.getQuestClass(questDesc[0])
            if (questClass == Quests.RecoverItemQuest):
                quest = Quests.getQuest(questDesc[0])
                # See if the cog that stole the item is in the cogList
                questCogType = quest.getHolder()
                qualifier = quest.getHolderType()
                for cogDict in cogList:
                    # If the cogType is Quests.Any, that means any cog
                    # Ok, now check to see if we recovered the item based
                    # on the percent chance of finding it stored in the quest
                    # Only find items if we still need them
                    self.notify.debug(
                        "recoverItems: checking against cogDict: %s" %
                        (cogDict))
                    if ((questCogType == Quests.Any)
                            or (questCogType == cogDict[qualifier]) or
                            # If it is level based, count those higher too
                        ((qualifier == 'level') and
                         (questCogType <= cogDict[qualifier]))):
                        if avId in cogDict['activeToons']:
                            if not quest.testDone(
                                    questDesc[4]
                            ):  #if questDesc[4] < quest.getNumItems():
                                if quest.isLocationMatch(zoneId):
                                    #rand = random.random() * 100
                                    #if rand <= quest.getPercentChance():
                                    check, count = quest.testRecover(
                                        questDesc[4])
                                    if check:
                                        # FOUND IT! Increment progress by one item
                                        #questDesc[4] += 1
                                        # Keep track of all the items recovered
                                        itemsRecovered.append(quest.getItem())
                                        #changed = 1
                                        self.notify.debug(
                                            "recoverItems: av %s made progress: %s"
                                            % (avId, questDesc[4]))
                                    else:
                                        self.notify.debug(
                                            "recoverItems: av %s made NO progress (item not found) [%s > %s])"
                                            % (avId, check,
                                               quest.getPercentChance()))
                                        itemsNotRecovered.append(
                                            quest.getItem())
                                    #keeping track of missed items
                                    changed = 1
                                    questDesc[4] = count
                                else:
                                    self.notify.debug(
                                        "recoverItems: av %s made NO progress (wrong location)"
                                        % (avId))
                            else:
                                self.notify.debug(
                                    "recoverItems: av %s made NO progress (have enough already)"
                                    % (avId))
                        else:
                            self.notify.debug(
                                "recoverItems: av %s made NO progress (av not active)"
                                % (avId))
                    else:
                        self.notify.debug(
                            "recoverItems: av %s made NO progress (wrong cog type)"
                            % (avId))
            else:
                # Do not care about this quest here
                continue

        # Now send the quests back to the avatar if the status changed

        # Note: this means that an avatar will immediately get credit
        # for finding an item, even if the item is found in the middle
        # floor of a building and the avatar later is killed on a
        # later floor, thus failing the building.
        if changed:
            av.b_setQuests(avQuests)

        return (itemsRecovered, itemsNotRecovered)
Ejemplo n.º 12
0
    def completeQuest(self, av, npc, questId):
        self.notify.info("completeQuest: avId: %s, npcId: %s, questId: %s" %
                         (av.getDoId(), npc.getNpcId(), questId))

        # If this is a track choice, we do not actually complete the quest,
        # We present the track choice gui. This can be cancelled which will
        # not complete the quest.
        questClass = Quests.getQuestClass(questId)
        if questClass == Quests.TrackChoiceQuest:
            self.notify.debug(
                "completeQuest: presentTrackChoice avId: %s, npcId: %s, questId: %s"
                % (av.getDoId(), npc.getNpcId(), questId))
            quest = Quests.getQuest(questId)
            tracks = quest.getChoices()
            npc.presentTrackChoice(av.getDoId(), questId, tracks)
            # Do not increment reward until avatar has chosen track
            # This happens in avatarChoseTrack
            return

        # If this is a deliver gag quest, we need to actually remove the
        # gags delivered from the player's inventory
        if questClass == Quests.DeliverGagQuest:
            self.notify.debug(
                "completeQuest: presentTrackChoice avId: %s, npcId: %s, questId: %s"
                % (av.getDoId(), npc.getNpcId(), questId))
            # Use the items from the inventory now
            quest = Quests.getQuest(questId)
            track, level = quest.getGagType()
            for i in range(0, quest.getNumGags()):
                av.inventory.useItem(track, level)
            av.d_setInventory(av.inventory.makeNetString())

        # See if this quest is part of a multiquest. If it is, we assign
        # the next part of the multiquest.
        nextQuestId, nextToNpcId = Quests.getNextQuest(questId, npc, av)
        eventLogMessage = "%s|%s|%s|%s" % (questId, npc.getNpcId(),
                                           questClass.__name__, nextQuestId)

        if nextQuestId == Quests.NA:
            rewardId = Quests.getAvatarRewardId(av, questId)
            # Update the toon with the reward
            reward = Quests.getReward(rewardId)

            # Clothing quests should have been handled by the Tailor.
            # Just to make sure
            if (reward.getType() == Quests.ClothingTicketReward):
                self.notify.warning(
                    "completeQuest: rogue ClothingTicketReward avId: %s, npcId: %s, questId: %s"
                    % (av.getDoId(), npc.getNpcId(), questId))
                npc.freeAvatar(av.getDoId())
                return

            # Nope, this is the end, dish out the reward
            av.removeQuest(questId)
            # TODO: put this in the movie
            reward.sendRewardAI(av)
            # Full heal for completing a quest
            av.toonUp(av.maxHp)
            # Tell the npc to deliver the movie which will
            # complete the quest, display the reward, and do nothing else
            npc.completeQuest(av.getDoId(), questId, rewardId)
            # Bump the reward
            self.incrementReward(av)

            eventLogMessage += "|%s|%s" % (reward.__class__.__name__,
                                           reward.getAmount())

        else:
            # Full heal for completing part of a multistage quest
            av.toonUp(av.maxHp)
            # The user is not presented with a choice here
            av.removeQuest(questId)
            nextRewardId = Quests.getQuestReward(nextQuestId, av)
            if npc.getHq():
                fromNpcId = Quests.ToonHQ
            else:
                fromNpcId = npc.getNpcId()
            self.assignQuest(av.getDoId(),
                             fromNpcId,
                             nextQuestId,
                             nextRewardId,
                             nextToNpcId,
                             startingQuest=0)
            npc.assignQuest(av.getDoId(), nextQuestId, nextRewardId,
                            nextToNpcId)
            eventLogMessage += "|next %s" % (nextQuestId)

        self.air.writeServerEvent('questComplete', av.getDoId(),
                                  eventLogMessage)