Esempio n. 1
0
    def requestInteract(self, toonId, npc):
        toon = self.air.doId2do.get(toonId)
        if not toon:
            return
        for index, quest in enumerate(self.__toonQuestsList2Quests(toon.quests)):
            questId, fromNpcId, toNpcId, rewardId, toonProgress = toon.quests[index]
            isComplete = quest.getCompletionStatus(toon, toon.quests[index], npc)
            if isComplete != Quests.COMPLETE:
                continue
            if toonId in self.air.tutorialManager.avId2fsm.keys():
                self.air.tutorialManager.avId2fsm[toonId].demand('Tunnel')
            if isinstance(quest, Quests.DeliverGagQuest):
                track, level = quest.getGagType()
                toon.inventory.setItem(track, level, toon.inventory.numItem(track, level) - quest.getNumGags())
                toon.b_setInventory(toon.inventory.makeNetString())
            nextQuest = Quests.getNextQuest(questId, npc, toon)
            if nextQuest == (Quests.NA, Quests.NA):
                if isinstance(quest, Quests.TrackChoiceQuest):
                    npc.presentTrackChoice(toonId, questId, quest.getChoices())
                    return
                rewardId = Quests.getAvatarRewardId(toon, questId)
                npc.completeQuest(toonId, questId, rewardId)
                self.completeQuest(toon, questId)
                self.giveReward(toon, rewardId)
                return
            self.completeQuest(toon, questId)
            nextQuestId = nextQuest[0]
            nextRewardId = Quests.getFinalRewardId(questId, 1)
            nextToNpcId = nextQuest[1]
            self.npcGiveQuest(npc, toon, nextQuestId, nextRewardId, nextToNpcId)
            return

        if len(self.__toonQuestsList2Quests(toon.quests)) >= toon.getQuestCarryLimit():
            self.notify.debug('Rejecting toonId %d because their quest inventory is full.' % toonId)
            npc.rejectAvatar(toonId)
            return
        if toonId in self.air.tutorialManager.avId2fsm.keys():
            if toon.getRewardHistory()[0] == 0:
                self.npcGiveQuest(npc, toon, 101, Quests.findFinalRewardId(101)[0], Quests.getQuestToNpcId(101), storeReward=True)
                self.air.tutorialManager.avId2fsm[toonId].demand('Battle')
                return
        tier = toon.getRewardHistory()[0]
        if Quests.avatarHasAllRequiredRewards(toon, tier):
            if not Quests.avatarWorkingOnRequiredRewards(toon):
                if tier != Quests.LOOPING_FINAL_TIER:
                    tier += 1
                toon.b_setRewardHistory(tier, [])
            else:
                self.notify.debug('Rejecting toonId %d because they are still working on their current tier.' % toonId)
                npc.rejectAvatarTierNotDone(toonId)
                return
        suitableQuests = Quests.chooseBestQuests(tier, npc, toon)
        if not suitableQuests:
            self.notify.debug('Rejecting toonId %d because there are no quests available!' % toonId)
            npc.rejectAvatar(toonId)
            return
        npc.presentQuestChoice(toonId, suitableQuests)
    def requestInteract(self, toonId, npc):
        toon = self.air.doId2do.get(toonId)
        if not toon:
            # TODO: Flag suspicious. They shouldn't have got this far.
            return

        # Check if the toon has any quests to turn in.
        for index, quest in enumerate(self.__toonQuestsList2Quests(toon.quests)):
            questId, fromNpcId, toNpcId, rewardId, toonProgress = toon.quests[index]
            isComplete = quest.getCompletionStatus(toon, toon.quests[index], npc)
            if isComplete != Quests.COMPLETE:
                # This quest isn't complete, skip.
                continue
            # If we're in the Toontorial, move to the next step.
            if toonId in self.air.tutorialManager.avId2fsm.keys():
                self.air.tutorialManager.avId2fsm[toonId].demand('Tunnel')
            # Take away gags if it's a DeliverGagQuest.
            if isinstance(quest, Quests.DeliverGagQuest):
                track, level = quest.getGagType()
                toon.inventory.setItem(track, level, toon.inventory.numItem(track, level) - quest.getNumGags())
                toon.b_setInventory(toon.inventory.makeNetString())
            # Check if the ToonTask has more quests to complete.
            nextQuest = Quests.getNextQuest(questId, npc, toon)
            if nextQuest == (Quests.NA, Quests.NA):
                # No more quests in the current ToonTask!
                if isinstance(quest, Quests.TrackChoiceQuest):
                    # TrackTrainingRewards are a little different, as we now
                    # have to display the gag track selection menu.
                    npc.presentTrackChoice(toonId, questId, quest.getChoices())
                    return
                # This function is pretty weird... not sure why it's even here...
                # But I'll include it just in case... (TMS says: "idk about this
                # one, maybe a single quest can have different rewards?")
                rewardId = Quests.getAvatarRewardId(toon, questId)
                npc.completeQuest(toonId, questId, rewardId)
                self.completeQuest(toon, questId)
                self.giveReward(toon, rewardId)
                return
            else:
                # We have another quest to go, sigh.
                self.completeQuest(toon, questId)
                nextQuestId = nextQuest[0]
                nextRewardId = Quests.getFinalRewardId(questId, 1)
                nextToNpcId = nextQuest[1]
                self.npcGiveQuest(npc, toon, nextQuestId, nextRewardId, nextToNpcId)
                return

        # We had no quests to hand in, maybe they want to take out a new ToonTask?
        if len(self.__toonQuestsList2Quests(toon.quests)) >= toon.getQuestCarryLimit():
            # Nope, they already have the maximum amount of concurring quests they
            # can carry. Reject them.
            self.notify.debug("Rejecting toonId %d because their quest inventory is full." % toonId)
            npc.rejectAvatar(toonId)
            return

        # Are we in the Toontorial?
        if toonId in self.air.tutorialManager.avId2fsm.keys():
            # Are we speaking to Tom?
            if toon.getRewardHistory()[0] == 0:
                self.npcGiveQuest(npc, toon, 101, Quests.findFinalRewardId(101)[0], Quests.getQuestToNpcId(101), storeReward=True) # FIXME please, i have no idea if this is correct
                self.air.tutorialManager.avId2fsm[toonId].demand('Battle')
                return

        # Are they eligible for a tier upgrade?
        tier = toon.getRewardHistory()[0]
        if Quests.avatarHasAllRequiredRewards(toon, tier):
            # They have all the rewards needed for the next tier.
            if not Quests.avatarWorkingOnRequiredRewards(toon):
                # Check to make sure they are not on the LOOPING_FINAL_TIER
                if tier != Quests.LOOPING_FINAL_TIER:
                    tier += 1

                # Set the tier
                toon.b_setRewardHistory(tier, [])
            else:
                # They're eligible for a tier upgrade, but haven't finished all
                # of their required ToonTasks yet.
                self.notify.debug("Rejecting toonId %d because they are still working on their current tier." % toonId)
                npc.rejectAvatarTierNotDone(toonId)
                return

        # Time to give them a list of "suitable" tasks!
        suitableQuests = Quests.chooseBestQuests(tier, npc, toon)
        if not suitableQuests:
            # Uh oh! There's no suitable quests for them at the moment... reject.
            self.notify.debug("Rejecting toonId %d because there are no quests available!" % toonId)
            npc.rejectAvatar(toonId)
            return

        # Tell the NPC to select some quests from the generated list.
        npc.presentQuestChoice(toonId, suitableQuests)
        return
Esempio n. 3
0
    def requestInteract(self, toonId, npc):
        toon = self.air.doId2do.get(toonId)
        if not toon:
            # TODO: Flag suspicious. They shouldn't have got this far.
            return

        # Check if the toon has any quests to turn in.
        for index, quest in enumerate(self.__toonQuestsList2Quests(toon.quests)):
            questId, fromNpcId, toNpcId, rewardId, toonProgress = toon.quests[index]
            isComplete = quest.getCompletionStatus(toon, toon.quests[index], npc)
            if isComplete != Quests.COMPLETE:
                # This quest isn't complete, skip.
                continue
            # If we're in the Toontorial, move to the next step.
            if toonId in self.air.tutorialManager.avId2fsm.keys():
                self.air.tutorialManager.avId2fsm[toonId].demand('Tunnel')
            # Take away gags if it's a DeliverGagQuest.
            if isinstance(quest, Quests.DeliverGagQuest):
                track, level = quest.getGagType()
                toon.inventory.setItem(track, level, toon.inventory.numItem(track, level) - quest.getNumGags())
                toon.b_setInventory(toon.inventory.makeNetString())
            # Check if the ToonTask has more quests to complete.
            nextQuest = Quests.getNextQuest(questId, npc, toon)
            if nextQuest == (Quests.NA, Quests.NA):
                # No more quests in the current ToonTask!
                if isinstance(quest, Quests.TrackChoiceQuest):
                    # TrackTrainingRewards are a little different, as we now
                    # have to display the gag track selection menu.
                    npc.presentTrackChoice(toonId, questId, quest.getChoices())
                    return
                # This function is pretty weird... not sure why it's even here...
                # But I'll include it just in case... (TMS says: "idk about this
                # one, maybe a single quest can have different rewards?")
                rewardId = Quests.getAvatarRewardId(toon, questId)
                npc.completeQuest(toonId, questId, rewardId)
                self.completeQuest(toon, questId)
                self.giveReward(toon, rewardId)
                return
            else:
                # We have another quest to go, sigh.
                self.completeQuest(toon, questId)
                nextQuestId = nextQuest[0]
                nextRewardId = Quests.getFinalRewardId(questId, 1)
                nextToNpcId = nextQuest[1]
                self.npcGiveQuest(npc, toon, nextQuestId, nextRewardId, nextToNpcId)
                return

        # We had no quests to hand in, maybe they want to take out a new ToonTask?
        if len(self.__toonQuestsList2Quests(toon.quests)) >= toon.getQuestCarryLimit():
            # Nope, they already have the maximum amount of concurring quests they
            # can carry. Reject them.
            self.notify.debug("Rejecting toonId %d because their quest inventory is full." % toonId)
            npc.rejectAvatar(toonId)
            return

        # Are we in the Toontorial?
        if toonId in self.air.tutorialManager.avId2fsm.keys():
            # Are we speaking to Tom?
            if toon.getRewardHistory()[0] == 0:
                self.npcGiveQuest(npc, toon, 101, Quests.findFinalRewardId(101)[0], Quests.getQuestToNpcId(101), storeReward=True) # FIXME please, i have no idea if this is correct
                self.air.tutorialManager.avId2fsm[toonId].demand('Battle')
                return

        # Are they eligible for a tier upgrade?
        tier = toon.getRewardHistory()[0]
        if Quests.avatarHasAllRequiredRewards(toon, tier):
            # They have all the rewards needed for the next tier.
            if not Quests.avatarWorkingOnRequiredRewards(toon):
                # Check to make sure they are not on the LOOPING_FINAL_TIER
                if tier != Quests.LOOPING_FINAL_TIER:
                    tier += 1

                # Set the tier
                toon.b_setRewardHistory(tier, [])
            else:
                # They're eligible for a tier upgrade, but haven't finished all
                # of their required ToonTasks yet.
                self.notify.debug("Rejecting toonId %d because they are still working on their current tier." % toonId)
                npc.rejectAvatarTierNotDone(toonId)
                return

        # Time to give them a list of "suitable" tasks!
        suitableQuests = Quests.chooseBestQuests(tier, npc, toon)
        if not suitableQuests:
            # Uh oh! There's no suitable quests for them at the moment... reject.
            self.notify.debug("Rejecting toonId %d because there are no quests available!" % toonId)
            npc.rejectAvatar(toonId)
            return

        # Tell the NPC to select some quests from the generated list.
        npc.presentQuestChoice(toonId, suitableQuests)
        return