コード例 #1
0
    def handleRegularPurchaseManager(self, scoreList):
        """
        regular minigame, handle purchase manager stuff
        """
        # create separate NewbiePurchaseManagerAIs for the noobs
        for id in self.newbieIdList:
            # newbie PM gets a single newbie, and we also give it the
            # list of all players; note that we don't give newbie PMs the
            # 'newbie list' -- that's only for the regular PM.
            pm = NewbiePurchaseManagerAI.NewbiePurchaseManagerAI(
                self.air, id, self.avIdList, scoreList, self.minigameId,
                self.trolleyZone)
            # We have no idea if the newbie PM is going to be around longer
            # than the 'regular' minigame->purchase->minigame... sequence.
            # We have to reference-count the zone. PMs decrement the zone
            # reference count when all participants leave to the playground.
            MinigameCreatorAI.acquireMinigameZone(self.zoneId)
            pm.generateWithRequired(self.zoneId)

        if len(self.avIdList) > len(self.newbieIdList):
            # Create a PurchaseManager
            pm = PurchaseManagerAI.PurchaseManagerAI(self.air, self.avIdList,
                                                     scoreList,
                                                     self.minigameId,
                                                     self.trolleyZone,
                                                     self.newbieIdList)
            pm.generateWithRequired(self.zoneId)
コード例 #2
0
 def handleMetagamePurchaseManager(self, scoreList):
     self.notify.debug('self.newbieIdList = %s' % self.newbieIdList)
     votesToUse = self.startingVotes
     if hasattr(self, 'currentVotes'):
         votesToUse = self.currentVotes
     
     votesArray = []
     for avId in self.avIdList:
         if votesToUse.has_key(avId):
             votesArray.append(votesToUse[avId])
             continue
         self.notify.warning('votesToUse=%s does not have avId=%d' % (votesToUse, avId))
         votesArray.append(0)
     
     if self.metagameRound < TravelGameGlobals.FinalMetagameRoundIndex:
         newRound = self.metagameRound
         if not self.minigameId == ToontownGlobals.TravelGameId:
             for index in range(len(scoreList)):
                 votesArray[index] += scoreList[index]
             
         
         self.notify.debug('votesArray = %s' % votesArray)
         desiredNextGame = None
         if hasattr(self, 'desiredNextGame'):
             desiredNextGame = self.desiredNextGame
         
         numToons = 0
         lastAvId = 0
         for avId in self.avIdList:
             av = simbase.air.doId2do.get(avId)
             if av:
                 numToons += 1
                 lastAvId = avId
                 continue
         
         doNewbie = False
         if numToons == 1 and lastAvId in self.newbieIdList:
             doNewbie = True
         
         if doNewbie:
             pm = NewbiePurchaseManagerAI.NewbiePurchaseManagerAI(self.air, lastAvId, self.avIdList, scoreList, self.minigameId, self.trolleyZone)
             MinigameCreatorAI.acquireMinigameZone(self.zoneId)
             pm.generateWithRequired(self.zoneId)
         else:
             pm = PurchaseManagerAI.PurchaseManagerAI(self.air, self.avIdList, scoreList, self.minigameId, self.trolleyZone, self.newbieIdList, votesArray, newRound, desiredNextGame)
             pm.generateWithRequired(self.zoneId)
     else:
         self.notify.debug('last minigame, handling newbies')
         if ToontownGlobals.JELLYBEAN_TROLLEY_HOLIDAY in simbase.air.holidayManager.currentHolidays or ToontownGlobals.JELLYBEAN_TROLLEY_HOLIDAY_MONTH in simbase.air.holidayManager.currentHolidays:
             votesArray = map(lambda x: MinigameGlobals.JellybeanTrolleyHolidayScoreMultiplier * x, votesArray)
         
         for id in self.newbieIdList:
             pm = NewbiePurchaseManagerAI.NewbiePurchaseManagerAI(self.air, id, self.avIdList, scoreList, self.minigameId, self.trolleyZone)
             MinigameCreatorAI.acquireMinigameZone(self.zoneId)
             pm.generateWithRequired(self.zoneId)
         
         if len(self.avIdList) > len(self.newbieIdList):
             pm = PurchaseManagerAI.PurchaseManagerAI(self.air, self.avIdList, scoreList, self.minigameId, self.trolleyZone, self.newbieIdList, votesArray = votesArray, metagameRound = self.metagameRound)
             pm.generateWithRequired(self.zoneId)
コード例 #3
0
 def handleMetagamePurchaseManager(self, scoreList):
     self.notify.debug('self.newbieIdList = %s' % self.newbieIdList)
     votesToUse = self.startingVotes
     if hasattr(self, 'currentVotes'):
         votesToUse = self.currentVotes
     
     votesArray = []
     for avId in self.avIdList:
         if votesToUse.has_key(avId):
             votesArray.append(votesToUse[avId])
             continue
         self.notify.warning('votesToUse=%s does not have avId=%d' % (votesToUse, avId))
         votesArray.append(0)
     
     if self.metagameRound < TravelGameGlobals.FinalMetagameRoundIndex:
         newRound = self.metagameRound
         if not self.minigameId == ToontownGlobals.TravelGameId:
             for index in range(len(scoreList)):
                 votesArray[index] += scoreList[index]
             
         
         self.notify.debug('votesArray = %s' % votesArray)
         desiredNextGame = None
         if hasattr(self, 'desiredNextGame'):
             desiredNextGame = self.desiredNextGame
         
         numToons = 0
         lastAvId = 0
         for avId in self.avIdList:
             av = simbase.air.doId2do.get(avId)
             if av:
                 numToons += 1
                 lastAvId = avId
                 continue
         
         doNewbie = False
         if numToons == 1 and lastAvId in self.newbieIdList:
             doNewbie = True
         
         if doNewbie:
             pm = NewbiePurchaseManagerAI.NewbiePurchaseManagerAI(self.air, lastAvId, self.avIdList, scoreList, self.minigameId, self.trolleyZone)
             MinigameCreatorAI.acquireMinigameZone(self.zoneId)
             pm.generateWithRequired(self.zoneId)
         else:
             pm = PurchaseManagerAI.PurchaseManagerAI(self.air, self.avIdList, scoreList, self.minigameId, self.trolleyZone, self.newbieIdList, votesArray, newRound, desiredNextGame)
             pm.generateWithRequired(self.zoneId)
     else:
         self.notify.debug('last minigame, handling newbies')
         if ToontownGlobals.JELLYBEAN_TROLLEY_HOLIDAY in simbase.air.holidayManager.currentHolidays or ToontownGlobals.JELLYBEAN_TROLLEY_HOLIDAY_MONTH in simbase.air.holidayManager.currentHolidays:
             votesArray = map(lambda x: MinigameGlobals.JellybeanTrolleyHolidayScoreMultiplier * x, votesArray)
         
         for id in self.newbieIdList:
             pm = NewbiePurchaseManagerAI.NewbiePurchaseManagerAI(self.air, id, self.avIdList, scoreList, self.minigameId, self.trolleyZone)
             MinigameCreatorAI.acquireMinigameZone(self.zoneId)
             pm.generateWithRequired(self.zoneId)
         
         if len(self.avIdList) > len(self.newbieIdList):
             pm = PurchaseManagerAI.PurchaseManagerAI(self.air, self.avIdList, scoreList, self.minigameId, self.trolleyZone, self.newbieIdList, votesArray = votesArray, metagameRound = self.metagameRound)
             pm.generateWithRequired(self.zoneId)
コード例 #4
0
 def handleRegularPurchaseManager(self, scoreList):
     for id in self.newbieIdList:
         pm = NewbiePurchaseManagerAI.NewbiePurchaseManagerAI(self.air, id, self.avIdList, scoreList, self.minigameId, self.trolleyZone)
         MinigameCreatorAI.acquireMinigameZone(self.zoneId)
         pm.generateWithRequired(self.zoneId)
     
     if len(self.avIdList) > len(self.newbieIdList):
         pm = PurchaseManagerAI.PurchaseManagerAI(self.air, self.avIdList, scoreList, self.minigameId, self.trolleyZone, self.newbieIdList)
         pm.generateWithRequired(self.zoneId)
コード例 #5
0
ファイル: DistributedMinigameAI.py プロジェクト: z010155/c0d3
    def handleRegularPurchaseManager(self, scoreList):
        for id in self.newbieIdList:
            pm = NewbiePurchaseManagerAI.NewbiePurchaseManagerAI(self.air, id, self.avIdList, scoreList, self.minigameId, self.trolleyZone)
            MinigameCreatorAI.acquireMinigameZone(self.zoneId)
            pm.generateWithRequired(self.zoneId)

        if len(self.avIdList) > len(self.newbieIdList):
            pm = PurchaseManagerAI.PurchaseManagerAI(self.air, self.avIdList, scoreList, self.minigameId, self.trolleyZone, self.newbieIdList)
            pm.generateWithRequired(self.zoneId)
コード例 #6
0
    def handleMetagamePurchaseManager(self, scoreList):
        """
        metagame being played, handle play again and consider newbies
        """
        self.notify.debug('self.newbieIdList = %s' % self.newbieIdList)
        votesToUse = self.startingVotes

        if hasattr(self, 'currentVotes'):
            votesToUse = self.currentVotes

        votesArray = []
        for avId in self.avIdList:
            if votesToUse.has_key(avId):
                votesArray.append(votesToUse[avId])
            else:
                self.notify.warning('votesToUse=%s does not have avId=%d' %
                                    (votesToUse, avId))
                votesArray.append(0)

        if self.metagameRound < TravelGameGlobals.FinalMetagameRoundIndex:
            newRound = self.metagameRound  # let purchaseManager handle incrementing it

            # if this is not the travel game, add the beans we earned to the votes list
            # also make sure it's not the last game
            if not self.minigameId == ToontownGlobals.TravelGameId:
                for index in range(len(scoreList)):
                    votesArray[index] += scoreList[index]

            self.notify.debug('votesArray = %s' % votesArray)

            desiredNextGame = None
            if hasattr(self, 'desiredNextGame'):
                desiredNextGame = self.desiredNextGame

            numToons = 0
            lastAvId = 0
            for avId in self.avIdList:
                av = simbase.air.doId2do.get(avId)
                if av:
                    numToons += 1
                    lastAvId = avId
            doNewbie = False
            if numToons == 1 and lastAvId in self.newbieIdList:
                doNewbie = True

            if doNewbie:
                # newbie PM gets a single newbie, and we also give it the
                # list of all players; note that we don't give newbie PMs the
                # 'newbie list' -- that's only for the regular PM.
                pm = NewbiePurchaseManagerAI.NewbiePurchaseManagerAI(
                    self.air, lastAvId, self.avIdList, scoreList,
                    self.minigameId, self.trolleyZone)
                # We have no idea if the newbie PM is going to be around longer
                # than the 'regular' minigame->purchase->minigame... sequence.
                # We have to reference-count the zone. PMs decrement the zone
                # reference count when all participants leave to the playground.
                MinigameCreatorAI.acquireMinigameZone(self.zoneId)
                pm.generateWithRequired(self.zoneId)
            else:
                pm = PurchaseManagerAI.PurchaseManagerAI(
                    self.air, self.avIdList, scoreList, self.minigameId,
                    self.trolleyZone, self.newbieIdList, votesArray, newRound,
                    desiredNextGame)
                pm.generateWithRequired(self.zoneId)
        else:
            # this is the last minigame, handle newbies. and playAgain
            # also for now weare doing a regular minigame if only 1 person
            # presses play again,
            self.notify.debug('last minigame, handling newbies')

            # create separate NewbiePurchaseManagerAIs for the noobs
            for id in self.newbieIdList:
                # newbie PM gets a single newbie, and we also give it the
                # list of all players; note that we don't give newbie PMs the
                # 'newbie list' -- that's only for the regular PM.
                pm = NewbiePurchaseManagerAI.NewbiePurchaseManagerAI(
                    self.air, id, self.avIdList, scoreList, self.minigameId,
                    self.trolleyZone)
                # We have no idea if the newbie PM is going to be around longer
                # than the 'regular' minigame->purchase->minigame... sequence.
                # We have to reference-count the zone. PMs decrement the zone
                # reference count when all participants leave to the playground.
                MinigameCreatorAI.acquireMinigameZone(self.zoneId)
                pm.generateWithRequired(self.zoneId)

            if len(self.avIdList) > len(self.newbieIdList):
                # Create a PurchaseManager
                pm = PurchaseManagerAI.PurchaseManagerAI(
                    self.air,
                    self.avIdList,
                    scoreList,
                    self.minigameId,
                    self.trolleyZone,
                    self.newbieIdList,
                    votesArray=votesArray,
                    metagameRound=self.metagameRound)
                pm.generateWithRequired(self.zoneId)