示例#1
0
 def recoverMerits(self,
                   av,
                   cogList,
                   zoneId,
                   multiplier=1,
                   extraMerits=None):
     avId = av.getDoId()
     meritsRecovered = [0, 0, 0, 0, 0]
     if extraMerits is None:
         extraMerits = [0, 0, 0, 0, 0]
     if self.air.suitInvasionManager.getInvading():
         multiplier *= getInvasionMultiplier()
     for i in xrange(len(extraMerits)):
         if CogDisguiseGlobals.isSuitComplete(av.getCogParts(), i):
             meritsRecovered[i] += extraMerits[i]
             self.notify.debug('recoverMerits: extra merits = %s' %
                               extraMerits[i])
     self.notify.debug('recoverMerits: multiplier = %s' % multiplier)
     for cogDict in cogList:
         dept = SuitDNA.suitDepts.index(cogDict['track'])
         if avId in cogDict['activeToons']:
             if CogDisguiseGlobals.isSuitComplete(
                     av.getCogParts(),
                     SuitDNA.suitDepts.index(cogDict['track'])):
                 self.notify.debug(
                     'recoverMerits: checking against cogDict: %s' %
                     cogDict)
                 rand = random.random() * 100
                 if rand <= self.getPercentChance(
                 ) and not cogDict['isVirtual']:
                     merits = cogDict['level'] * MeritMultiplier
                     merits = int(round(merits))
                     if cogDict['hasRevives']:
                         merits *= 2
                     merits = merits * multiplier
                     merits = int(round(merits))
                     meritsRecovered[dept] += merits
                     self.notify.debug('recoverMerits: merits = %s' %
                                       merits)
                 else:
                     self.notify.debug('recoverMerits: virtual cog!')
     if meritsRecovered != [0, 0, 0, 0, 0]:
         actualCounted = [0, 0, 0, 0, 0]
         merits = av.getCogMerits()
         for i in xrange(len(meritsRecovered)):
             max = CogDisguiseGlobals.getTotalMerits(av, i)
             if max:
                 if merits[i] + meritsRecovered[i] <= max:
                     actualCounted[i] = meritsRecovered[i]
                     merits[i] += meritsRecovered[i]
                 else:
                     actualCounted[i] = max - merits[i]
                     merits[i] = max
                 av.b_setCogMerits(merits)
         if reduce(lambda x, y: x + y, actualCounted):
             self.air.writeServerEvent(
                 'merits', avId, '%s|%s|%s|%s|%s' % tuple(actualCounted))
             self.notify.debug('recoverMerits: av %s recovered merits %s' %
                               (avId, actualCounted))
     return meritsRecovered
    def recoverMerits(self, av, cogList, zoneId, multiplier=1, extraMerits=None):
        avId = av.getDoId()
        meritsRecovered = [0, 0, 0, 0]
        if extraMerits is None:
            extraMerits = [0, 0, 0, 0]
        if self.air.suitInvasionManager.getInvading():
            multiplier *= getInvasionMultiplier()
        for i in range(len(extraMerits)):
            if CogDisguiseGlobals.isSuitComplete(av.getCogParts(), i):
                meritsRecovered[i] += extraMerits[i]
                self.notify.debug("recoverMerits: extra merits = %s" % extraMerits[i])

        self.notify.debug("recoverMerits: multiplier = %s" % multiplier)
        for cogDict in cogList:
            dept = SuitDNA.suitDepts.index(cogDict["track"])
            if avId in cogDict["activeToons"]:
                if CogDisguiseGlobals.isSuitComplete(av.getCogParts(), SuitDNA.suitDepts.index(cogDict["track"])):
                    self.notify.debug("recoverMerits: checking against cogDict: %s" % cogDict)
                    rand = random.random() * 100
                    if rand <= self.getPercentChance() and not cogDict["isVirtual"]:
                        merits = cogDict["level"] * MeritMultiplier
                        merits = int(round(merits))
                        if cogDict["hasRevives"]:
                            merits *= 2
                        merits = merits * multiplier
                        merits = int(round(merits))
                        meritsRecovered[dept] += merits
                        self.notify.debug("recoverMerits: merits = %s" % merits)
                    else:
                        self.notify.debug("recoverMerits: virtual cog!")

        if meritsRecovered != [0, 0, 0, 0]:
            actualCounted = [0, 0, 0, 0]
            merits = av.getCogMerits()
            for i in range(len(meritsRecovered)):
                max = CogDisguiseGlobals.getTotalMerits(av, i)
                if max:
                    if merits[i] + meritsRecovered[i] <= max:
                        actualCounted[i] = meritsRecovered[i]
                        merits[i] += meritsRecovered[i]
                    else:
                        actualCounted[i] = max - merits[i]
                        merits[i] = max
                    av.b_setCogMerits(merits)

            if reduce(lambda x, y: x + y, actualCounted):
                self.air.writeServerEvent(
                    "merits",
                    avId=avId,
                    bossbot=actualCounted[0],
                    lawbot=actualCounted[1],
                    cashbot=actualCounted[2],
                    sellbot=actualCounted[3],
                )
                self.notify.debug("recoverMerits: av %s recovered merits %s" % (avId, actualCounted))
        return meritsRecovered
示例#3
0
    def recoverMerits(self,
                      toon,
                      suitsKilled,
                      zoneId,
                      multiplier=1,
                      extraMerits=None):
        if 1:  #extraMerits is None:
            extraMerits = [0, 0, 0, 0]

        #else:
        # extraMerits = [0, extraMerits, 0, 0]

        # to do: figure out which track we should add extra merits to (check zoneId?)

        amounts = {x: y for x, y in zip(SuitDNA.suitDepts, extraMerits)}
        parts = toon.getCogParts()

        # calc
        for suit in suitsKilled:
            if suit['isVirtual']:
                continue

            track, level = suit['track'], suit['level']
            deptIdx = SuitDNA.suitDepts.index(track)
            if not CogDisguiseGlobals.isSuitComplete(parts, deptIdx):
                continue

            mult = multiplier * (
                getInvasionMultiplier(self.air.suitInvasionManager.isMega())
                if self.air.suitInvasionManager.hasInvading() else 1)
            mult *= int(suit['hasRevives']) + 1

            amount = int((level + 1) / 2 * mult)
            amounts[track] += amount

        merits = toon.getCogMerits()
        am2 = [0, 0, 0, 0]

        for dept, value in amounts.items():
            dept = SuitDNA.suitDepts.index(dept)
            needed = max(
                0,
                CogDisguiseGlobals.getTotalMerits(toon, dept) - merits[dept])
            am2[dept] = min(needed, value)

        # apply
        toon.b_setCogMerits([x + y for x, y in zip(merits, am2)])

        return am2
 def recoverMerits(self, av, cogList, zoneId, multiplier = 1, extraMerits = None, addInvasion = True):
     avId = av.getDoId()
     meritsRecovered = [0, 0, 0, 0]
     if extraMerits is None:
         extraMerits = [0, 0, 0, 0]
     if addInvasion and self.air.suitInvasionManager.getInvading():
         multiplier *= getInvasionMultiplier()
     for i in xrange(len(extraMerits)):
         if CogDisguiseGlobals.isSuitComplete(av.getCogParts(), i):
             meritsRecovered[i] += extraMerits[i]
             self.notify.debug('recoverMerits: extra merits = %s' % extraMerits[i])
     self.notify.debug('recoverMerits: multiplier = %s' % multiplier)
     for cogDict in cogList:
         dept = SuitDNA.suitDepts.index(cogDict['track'])
         if avId in cogDict['activeToons']:
             if CogDisguiseGlobals.isSuitComplete(av.getCogParts(), SuitDNA.suitDepts.index(cogDict['track'])):
                 self.notify.debug('recoverMerits: checking against cogDict: %s' % cogDict)
                 rand = random.random() * 100
                 if rand <= self.getPercentChance() and not cogDict['isVirtual']:
                     merits = cogDict['level'] * MeritMultiplier
                     merits = int(round(merits))
                     if cogDict['hasRevives']:
                         merits *= 2
                     merits = merits * multiplier
                     merits = int(round(merits))
                     meritsRecovered[dept] += merits
                     self.notify.debug('recoverMerits: merits = %s' % merits)
                 else:
                     self.notify.debug('recoverMerits: virtual cog!')
     if meritsRecovered != [0, 0, 0, 0]:
         actualCounted = [0, 0, 0, 0]
         merits = av.getCogMerits()
         for i in xrange(len(meritsRecovered)):
             max = CogDisguiseGlobals.getTotalMerits(av, i)
             if max:
                 if merits[i] + meritsRecovered[i] <= max:
                     actualCounted[i] = meritsRecovered[i]
                     merits[i] += meritsRecovered[i]
                 else:
                     actualCounted[i] = max - merits[i]
                     merits[i] = max
                 av.b_setCogMerits(merits)
         if reduce(lambda x, y: x + y, actualCounted):
             self.air.writeServerEvent('merits', avId, '%s|%s|%s|%s' % tuple(actualCounted))
             self.notify.debug('recoverMerits: av %s recovered merits %s' % (avId, actualCounted))
     return meritsRecovered
 def recoverMerits(self, toon, suitsKilled, zoneId, multiplier = 1, extraMerits = None):
     if 1: #extraMerits is None:
         extraMerits = [0, 0, 0, 0]
         
     #else:
         # extraMerits = [0, extraMerits, 0, 0]
     
     # to do: figure out which track we should add extra merits to (check zoneId?)
         
     amounts = {x: y for x, y in zip(SuitDNA.suitDepts, extraMerits)}
     parts = toon.getCogParts()
     
     # calc
     for suit in suitsKilled:
         if suit['isVirtual']:
             continue
             
         track, level = suit['track'], suit['level']
         deptIdx = SuitDNA.suitDepts.index(track)
         if not CogDisguiseGlobals.isSuitComplete(parts, deptIdx):
             continue
         
         mult = multiplier * (getInvasionMultiplier(self.air.suitInvasionManager.isMega()) if self.air.suitInvasionManager.hasInvading() else 1)
         mult *= int(suit['hasRevives']) + 1
             
         amount = int((level + 1) / 2 * mult)
         amounts[track] += amount
         
     merits = toon.getCogMerits()
     am2 = [0, 0, 0, 0]
     
     for dept, value in amounts.items():
         dept = SuitDNA.suitDepts.index(dept)
         needed = max(0, CogDisguiseGlobals.getTotalMerits(toon, dept) - merits[dept])
         am2[dept] = min(needed, value)
         
     # apply
     toon.b_setCogMerits([x + y for x, y in zip(merits, am2)])
     
     return am2
     
示例#6
0
    def recoverMerits(self, av, cogList, zoneId, multiplier=1, extraMerits=None):
        avId = av.getDoId()
        meritsRecovered = [0,0,0,0]
        if extraMerits is None:
            extraMerits = [0,0,0,0]

        # multiply merit bonus during invasions too
        if self.air.suitInvasionManager.getInvading():
            multiplier *= getInvasionMultiplier()
          
        # start with any extra merits
        for i in range(len(extraMerits)):
            if CogDisguiseGlobals.isSuitComplete(av.getCogParts(), i):
                meritsRecovered[i] += extraMerits[i]
                self.notify.debug("recoverMerits: extra merits = %s" % (extraMerits[i]))

        self.notify.debug("recoverMerits: multiplier = %s" % (multiplier))
                                        
        # add merits for every cog defeated
        for cogDict in cogList:
            dept = SuitDNA.suitDepts.index(cogDict['track'])
            if avId in cogDict['activeToons']:
                # only let them recover merits if suit is complete
                if CogDisguiseGlobals.isSuitComplete(av.getCogParts(),
                                                     SuitDNA.suitDepts.index(cogDict['track'])):
                    self.notify.debug("recoverMerits: checking against cogDict: %s" % (cogDict))
                    # determine if we 'won' any merits
                    rand = random.random() * 100

                    # don't reward merits for 'virtual' cogs
                    if rand <= self.getPercentChance() and not cogDict['isVirtual']:
                        # add in recovered merits
                        merits = cogDict['level'] * MeritMultiplier
                        # round up
                        merits = int(round(merits))
                        # if this cog had revives, reward 2x merits
                        if cogDict['hasRevives']:
                            merits *= 2                      
                        # add floor/stage bonus
                        merits = merits * multiplier
                        # round up again
                        merits = int(round(merits))
                        # sum it up
                        meritsRecovered[dept] += merits
                        self.notify.debug("recoverMerits: merits = %s" % (merits))
                    else:
                        self.notify.debug("recoverMerits: virtual cog!")


        # Now set the merits on the avatar if the status changed
        if meritsRecovered != [0,0,0,0]:
            actualCounted = [0,0,0,0]
            merits = av.getCogMerits()
            for i in range(len(meritsRecovered)):
                max = CogDisguiseGlobals.getTotalMerits(av, i)
                if max:
                    # if we are under level max, inc merits
                    if merits[i] + meritsRecovered[i] <= max:
                        actualCounted[i] = meritsRecovered[i]
                        merits[i] += meritsRecovered[i]
                    else:
                        actualCounted[i] = max - merits[i]
                        # otherwise set to max
                        merits[i] = max
                    # update the toons merits
                    av.b_setCogMerits(merits)

            # Only log if they actually got some merits
            if reduce(lambda x,y: x+y, actualCounted):
                self.air.writeServerEvent('merits', avId, ("%s|%s|%s|%s" % tuple(actualCounted)))
                self.notify.debug("recoverMerits: av %s recovered merits %s" % (avId, actualCounted))
            
        return meritsRecovered