Exemplo n.º 1
0
    def getExpTrack(self, toon, origExp, earnedExp, deathList, origQuestsList, itemList, missedItemList, origMeritList, meritList, partList, toonList, uberEntry, helpfulToonsList, noSkip = False):
        track = Sequence(Func(self.initGagFrame, toon, origExp, origMeritList, noSkip=noSkip), Wait(1.0))
        endTracks = [0,
         0,
         0,
         0,
         0,
         0,
         0]
        trackEnded = 0
        for trackIndex in xrange(len(earnedExp)):
            if earnedExp[trackIndex] > 0 or origExp[trackIndex] >= ToontownBattleGlobals.MaxSkill:
                track += self.getTrackIntervalList(toon, trackIndex, origExp[trackIndex], earnedExp[trackIndex], ToontownBattleGlobals.getUberFlagSafe(uberEntry, trackIndex))
                maxExp = ToontownBattleGlobals.MaxSkill - ToontownBattleGlobals.UberSkill
                if origExp[trackIndex] < maxExp and earnedExp[trackIndex] + origExp[trackIndex] >= maxExp:
                    endTracks[trackIndex] = 1
                    trackEnded = 1

        for dept in xrange(len(SuitDNA.suitDepts)):
            if meritList[dept]:
                track += self.getMeritIntervalList(toon, dept, origMeritList[dept], meritList[dept])

        track.append(Wait(0.75))
        itemInterval = self.getItemIntervalList(toon, itemList)
        if itemInterval:
            track.append(Func(self.initItemFrame, toon))
            track.append(Wait(0.25))
            track += itemInterval
            track.append(Wait(0.5))
        missedItemInterval = self.getMissedItemIntervalList(toon, missedItemList)
        if missedItemInterval:
            track.append(Func(self.initMissedItemFrame, toon))
            track.append(Wait(0.25))
            track += missedItemInterval
            track.append(Wait(0.5))
        self.notify.debug('partList = %s' % partList)
        newPart = 0
        for part in partList:
            if part != 0:
                newPart = 1
                break

        if newPart:
            partList = self.getCogPartIntervalList(toon, partList)
            if partList:
                track.append(Func(self.initCogPartFrame, toon))
                track.append(Wait(0.25))
                track += partList
                track.append(Wait(0.5))
        questList = self.getQuestIntervalList(toon, deathList, toonList, origQuestsList, itemList, helpfulToonsList)
        if questList:
            avQuests = []
            for i in xrange(0, len(origQuestsList), 5):
                avQuests.append(origQuestsList[i:i + 5])

            track.append(Func(self.initQuestFrame, toon, copy.deepcopy(avQuests)))
            track.append(Wait(0.25))
            track += questList
            track.append(Wait(0.5))
        track.append(Wait(0.25))
        if trackEnded:
            track.append(Func(self.vanishFrames))
            track.append(Fanfare.makeFanfare(0, toon)[0])
            for i in xrange(len(endTracks)):
                if endTracks[i] is 1:
                    track += self.getEndTrackIntervalList(toon, toonList, i)

            track.append(Func(self.cleanupEndTrack))
        return track
Exemplo n.º 2
0
    def getExpTrack(self,
                    toon,
                    origExp,
                    earnedExp,
                    deathList,
                    origQuestsList,
                    itemList,
                    missedItemList,
                    origMeritList,
                    meritList,
                    partList,
                    toonList,
                    uberEntry,
                    helpfulToonsList,
                    noSkip=False):
        track = Sequence(
            Func(self.initGagFrame,
                 toon,
                 origExp,
                 origMeritList,
                 noSkip=noSkip), Wait(1.0))
        endTracks = [0, 0, 0, 0, 0, 0, 0]
        trackEnded = 0
        for trackIndex in xrange(len(earnedExp)):
            if earnedExp[trackIndex] > 0 or origExp[
                    trackIndex] >= ToontownBattleGlobals.MaxSkill:
                track += self.getTrackIntervalList(
                    toon, trackIndex, origExp[trackIndex],
                    earnedExp[trackIndex],
                    ToontownBattleGlobals.getUberFlagSafe(
                        uberEntry, trackIndex))
                maxExp = ToontownBattleGlobals.MaxSkill - ToontownBattleGlobals.UberSkill
                if origExp[trackIndex] < maxExp and earnedExp[
                        trackIndex] + origExp[trackIndex] >= maxExp:
                    endTracks[trackIndex] = 1
                    trackEnded = 1

        for dept in xrange(len(SuitDNA.suitDepts)):
            if meritList[dept]:
                track += self.getMeritIntervalList(toon, dept,
                                                   origMeritList[dept],
                                                   meritList[dept])

        track.append(Wait(0.75))
        itemInterval = self.getItemIntervalList(toon, itemList)
        if itemInterval:
            track.append(Func(self.initItemFrame, toon))
            track.append(Wait(0.25))
            track += itemInterval
            track.append(Wait(0.5))
        missedItemInterval = self.getMissedItemIntervalList(
            toon, missedItemList)
        if missedItemInterval:
            track.append(Func(self.initMissedItemFrame, toon))
            track.append(Wait(0.25))
            track += missedItemInterval
            track.append(Wait(0.5))
        self.notify.debug('partList = %s' % partList)
        newPart = 0
        for part in partList:
            if part != 0:
                newPart = 1
                break

        if newPart:
            partList = self.getCogPartIntervalList(toon, partList)
            if partList:
                track.append(Func(self.initCogPartFrame, toon))
                track.append(Wait(0.25))
                track += partList
                track.append(Wait(0.5))
        questList = self.getQuestIntervalList(toon, deathList, toonList,
                                              origQuestsList, itemList,
                                              helpfulToonsList)
        if questList:
            avQuests = []
            for i in xrange(0, len(origQuestsList), 5):
                avQuests.append(origQuestsList[i:i + 5])

            track.append(
                Func(self.initQuestFrame, toon, copy.deepcopy(avQuests)))
            track.append(Wait(0.25))
            track += questList
            track.append(Wait(0.5))
        track.append(Wait(0.25))
        if trackEnded:
            track.append(Func(self.vanishFrames))
            track.append(Fanfare.makeFanfare(0, toon)[0])
            for i in xrange(len(endTracks)):
                if endTracks[i] is 1:
                    track += self.getEndTrackIntervalList(toon, toonList, i)

            track.append(Func(self.cleanupEndTrack))
        return track
Exemplo n.º 3
0
    def getExpTrack(self, toon, origExp, earnedExp, deathList, origQuestsList, itemList,
                    missedItemList, origMeritList, meritList, partList,
                    toonList, uberEntry, helpfulToonsList):
        """
        Assumes for input:
        origExp: a list of 7 values, corresponding to current experience
        levels in each track.
        earnedExp: a list of 7 values, corresponding to amount of experience
        earned in the battle for each track.
        deathList: a list of the suits that were killed in battle the
        list will be flattened triplets of (suitIndex, level, involvedToonBits)
        suitIndex is the index of the suit in SuitDNA.suitHeadTypes.
        For example, Flunky is suitIndex 0, Yes Man is suitIndex 2.

        toonList is a list of toons that positionally corresponds to the
        bitmasks embedded in the deathlist; toons that are no longer
        present are represented as 'None'. Note that this might be
        different from a battle's current activeToons list if any toons
        have just recently dropped.
        """

        track = Sequence(Func(self.initGagFrame, toon, origExp, origMeritList),
                         Wait(1.0))

        endTracks = [0,0,0,0,0,0,0]
        trackEnded = 0

        #uberField = ToontownBattleGlobals.decodeUber(uberEntry)

        for trackIndex in range(len(earnedExp)):
            # Create a track for each gag track in which we gained experience
            if earnedExp[trackIndex] > 0 or origExp[trackIndex] >= ToontownBattleGlobals.MaxSkill:
                track += self.getTrackIntervalList(toon, trackIndex,
                                                            origExp[trackIndex],
                                                            earnedExp[trackIndex],
                                                            ToontownBattleGlobals.getUberFlagSafe(uberEntry, trackIndex))
                # if we weren't at the end of the track yet, but we will be there
                # after experience is divvied up, make a note of it
                maxExp = ToontownBattleGlobals.MaxSkill - ToontownBattleGlobals.UberSkill
                if (origExp[trackIndex] < maxExp) and (earnedExp[trackIndex] + origExp[trackIndex] >= maxExp):
                    endTracks[trackIndex] = 1
                    trackEnded = 1

        for dept in range(len(SuitDNA.suitDepts)):
            # Create a track for each cog dept in which we gained merits
            if meritList[dept]:
                track += self.getMeritIntervalList(toon,
                                                   dept,
                                                   origMeritList[dept],
                                                   meritList[dept])

        track.append(Wait(1.0))

        itemInterval = self.getItemIntervalList(toon, itemList)
        if itemInterval:
            track.append(Func(self.initItemFrame, toon))
            track.append(Wait(1.0))
            track += itemInterval
            track.append(Wait(1.0))

        missedItemInterval = self.getMissedItemIntervalList(toon, missedItemList)
        if missedItemInterval:
            track.append(Func(self.initMissedItemFrame, toon))
            track.append(Wait(1.0))
            track += missedItemInterval
            track.append(Wait(1.0))

        # debug
        self.notify.debug("partList = %s" % partList)

        newPart = 0
        for part in partList:
            if part != 0:
                newPart = 1
                break
        if newPart:
            partList = self.getCogPartIntervalList(toon, partList)
            if partList:
                track.append(Func(self.initCogPartFrame, toon))
                track.append(Wait(1.0))
                track += partList
                track.append(Wait(1.0))

        # Add on any quest progress intervals
        questList = self.getQuestIntervalList(toon, deathList, toonList, origQuestsList, itemList, helpfulToonsList)
        if questList:
            # We have to make a copy of the toon's quest data now,
            # when we build up the tracks, rather than later, while
            # we're playing them back.  This is because the AI will
            # send our quest progress update any moment.
            track.append(Func(self.initQuestFrame, toon, copy.deepcopy(toon.quests)))
            track.append(Wait(1.0))
            track += questList
            track.append(Wait(2.0))

        # if the player has reached the end of a track, queue up the frames vanishing
        # and a fanfare occurring
        if trackEnded:
            track.append(Func(self.vanishFrames))
            track.append(Fanfare.makeFanfare(0,toon)[0])

            # for each track we've reached the end up, create an end track interval
            for i in range(len(endTracks)):
                if endTracks[i] == 1:
                        track += self.getEndTrackIntervalList(toon,toonList,i)

            # at the end, cleanup and cause all the endtrack frames to vanish
            track.append(Func(self.cleanupEndTrack))

        return track