Esempio n. 1
0
 def generate(self):
     self.notify.debug('generate %s: room=%s' % (self.doId, self.roomId))
     self.notify.debug('loading spec')
     specModule = CountryClubRoomSpecs.getCountryClubRoomSpecModule(self.roomId)
     roomSpec = LevelSpec.LevelSpec(specModule)
     self.notify.debug('creating entities')
     DistributedLevelAI.DistributedLevelAI.generate(self, roomSpec)
     self.notify.debug('creating cogs')
     cogSpecModule = CountryClubRoomSpecs.getCogSpecModule(self.roomId)
     self.planner = LevelSuitPlannerAI.LevelSuitPlannerAI(self.air, self, DistributedMintSuitAI.DistributedMintSuitAI, DistributedCountryClubBattleAI.DistributedCountryClubBattleAI, cogSpecModule.CogData, cogSpecModule.ReserveCogData, cogSpecModule.BattleCells, battleExpAggreg = self.battleExpAggreg)
     suitHandles = self.planner.genSuits()
     messenger.send('plannerCreated-' + str(self.doId))
     self.suits = suitHandles['activeSuits']
     self.reserveSuits = suitHandles['reserveSuits']
     self.d_setSuits()
     self.notify.debug('finish mint room %s %s creation' % (self.roomId, self.doId))
    def _genFloorLayout(self):
        rng = self.getRng()
        startingRoomIDs = CountryClubRoomSpecs.BossbotCountryClubEntranceIDs
        middleRoomIDs = CountryClubRoomSpecs.BossbotCountryClubMiddleRoomIDs
        finalRoomIDs = CountryClubRoomSpecs.BossbotCountryClubFinalRoomIDs

        numBattlesLeft = ToontownGlobals.CountryClubNumBattles[
            self.countryClubId]

        finalRoomId = rng.choice(finalRoomIDs)
        numBattlesLeft -= CountryClubRoomSpecs.getNumBattles(finalRoomId)

        middleRoomIds = []
        middleRoomsLeft = self.numRooms - 2

        numBattles2middleRoomIds = invertDictLossless(
            CountryClubRoomSpecs.middleRoomId2numBattles)

        allBattleRooms = []
        for num, roomIds in numBattles2middleRoomIds.items():
            if num > 0:
                allBattleRooms.extend(roomIds)
        while 1:
            allBattleRoomIds = list(allBattleRooms)
            rng.shuffle(allBattleRoomIds)
            battleRoomIds = self._chooseBattleRooms(numBattlesLeft,
                                                    allBattleRoomIds)
            if battleRoomIds is not None:
                break

            CountryClubLayout.notify.info(
                'could not find a valid set of battle rooms, trying again')

        middleRoomIds.extend(battleRoomIds)
        middleRoomsLeft -= len(battleRoomIds)

        if middleRoomsLeft > 0:
            actionRoomIds = numBattles2middleRoomIds[0]
            for i in xrange(middleRoomsLeft):
                roomId = rng.choice(actionRoomIds)
                actionRoomIds.remove(roomId)
                middleRoomIds.append(roomId)

        roomIds = []

        roomIds.append(rng.choice(startingRoomIDs))

        middleRoomIds.sort()
        print 'middleRoomIds=%s' % middleRoomIds
        roomIds.extend(middleRoomIds)

        roomIds.append(finalRoomId)

        return roomIds
    def _genFloorLayout(self):
        rng = self.getRng()
        startingRoomIDs = CountryClubRoomSpecs.BossbotCountryClubEntranceIDs
        middleRoomIDs = CountryClubRoomSpecs.BossbotCountryClubMiddleRoomIDs
        finalRoomIDs = CountryClubRoomSpecs.BossbotCountryClubFinalRoomIDs

        numBattlesLeft = ToontownGlobals.CountryClubNumBattles[self.countryClubId]

        finalRoomId = rng.choice(finalRoomIDs)
        numBattlesLeft -= CountryClubRoomSpecs.getNumBattles(finalRoomId)

        middleRoomIds = []
        middleRoomsLeft = self.numRooms - 2

        numBattles2middleRoomIds = invertDictLossless(CountryClubRoomSpecs.middleRoomId2numBattles)

        allBattleRooms = []
        for num, roomIds in numBattles2middleRoomIds.items():
            if num > 0:
                allBattleRooms.extend(roomIds)
        while 1:
            allBattleRoomIds = list(allBattleRooms)
            rng.shuffle(allBattleRoomIds)
            battleRoomIds = self._chooseBattleRooms(numBattlesLeft,
                                                    allBattleRoomIds)
            if battleRoomIds is not None:
                break

            CountryClubLayout.notify.info('could not find a valid set of battle rooms, trying again')

        middleRoomIds.extend(battleRoomIds)
        middleRoomsLeft -= len(battleRoomIds)

        if middleRoomsLeft > 0:
            actionRoomIds = numBattles2middleRoomIds[0]
            for i in xrange(middleRoomsLeft):
                roomId = rng.choice(actionRoomIds)
                actionRoomIds.remove(roomId)
                middleRoomIds.append(roomId)

        roomIds = []

        roomIds.append(rng.choice(startingRoomIDs))

        middleRoomIds.sort()
        print 'middleRoomIds=%s' % middleRoomIds
        roomIds.extend(middleRoomIds)

        roomIds.append(finalRoomId)

        return roomIds