當前位置: 首頁>>代碼示例>>Python>>正文


Python Quests.avatarHasAllRequiredRewards方法代碼示例

本文整理匯總了Python中Quests.avatarHasAllRequiredRewards方法的典型用法代碼示例。如果您正苦於以下問題:Python Quests.avatarHasAllRequiredRewards方法的具體用法?Python Quests.avatarHasAllRequiredRewards怎麽用?Python Quests.avatarHasAllRequiredRewards使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Quests的用法示例。


在下文中一共展示了Quests.avatarHasAllRequiredRewards方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: requestInteract

# 需要導入模塊: import Quests [as 別名]
# 或者: from Quests import avatarHasAllRequiredRewards [as 別名]
    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
開發者ID:Toonerz,項目名稱:Toontown-World-Online-Leaked-Source,代碼行數:94,代碼來源:QuestManagerAI.py


注:本文中的Quests.avatarHasAllRequiredRewards方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。