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)
     if __dev__:
         self.notify.debug('creating entity type registry')
         typeReg = self.getCountryClubEntityTypeReg()
         roomSpec.setEntityTypeReg(typeReg)
     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 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 levelAnnounceGenerate(self):
     self.notify.debug('levelAnnounceGenerate')
     DistributedLevel.DistributedLevel.levelAnnounceGenerate(self)
     specModule = CountryClubRoomSpecs.getCountryClubRoomSpecModule(
         self.roomId)
     roomSpec = LevelSpec.LevelSpec(specModule)
     if __dev__:
         typeReg = self.getCountryClubEntityTypeReg()
         roomSpec.setEntityTypeReg(typeReg)
     DistributedLevel.DistributedLevel.initializeLevel(self, roomSpec)
    def generate(self):
        self.notify.debug('generate %s: room=%s' % (self.doId, self.roomId))

        # create our spec
        self.notify.debug('loading spec')
        specModule = CountryClubRoomSpecs.getCountryClubRoomSpecModule(self.roomId)
        roomSpec = LevelSpec.LevelSpec(specModule)

        if __dev__:
            # create a factory EntityTypeRegistry and hand it to the spec
            self.notify.debug('creating entity type registry')
            typeReg = self.getCountryClubEntityTypeReg()
            roomSpec.setEntityTypeReg(typeReg)
        
        self.notify.debug('creating entities')
        DistributedLevelAI.DistributedLevelAI.generate(self, roomSpec)

        # TODO: convert suits into Entities
        # create the suits
        # Until they are converted to entities, it's important that
        # the suits are created in the levelZone.

        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()
        # alert battle blockers that planner has been created
        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 range(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
Esempio n. 7
0
    def _genFloorLayout(self):
        rng = self.getRng()

        # pick the rooms. Make sure we don't get any repeats.
        startingRoomIDs = CountryClubRoomSpecs.BossbotCountryClubEntranceIDs
        middleRoomIDs = CountryClubRoomSpecs.BossbotCountryClubMiddleRoomIDs
        finalRoomIDs = CountryClubRoomSpecs.BossbotCountryClubFinalRoomIDs

        # how many battles do we want?
        numBattlesLeft = ToontownGlobals.CountryClubNumBattles[
            self.countryClubId]

        # pick the final room first, so we know how many battles we can
        # have in the middle rooms
        finalRoomId = rng.choice(finalRoomIDs)
        numBattlesLeft -= CountryClubRoomSpecs.getNumBattles(finalRoomId)

        middleRoomIds = []
        middleRoomsLeft = self.numRooms - 2

        # we want to hit our target number of battles exactly.
        # pick the battle rooms we will use first, then fill in pure-action
        # rooms

        # get dict of numBattles->list of rooms
        numBattles2middleRoomIds = invertDictLossless(
            CountryClubRoomSpecs.middleRoomId2numBattles)

        # get list of all battle rooms
        allBattleRooms = []
        for num, roomIds in list(numBattles2middleRoomIds.items()):
            if num > 0:
                allBattleRooms.extend(roomIds)

        # Pick out a list of battle rooms that meets our quota exactly.
        while 1:
            # make a copy of the list of battle rooms, and shuffle it
            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:
            # choose action rooms for the rest of the middle rooms
            actionRoomIds = numBattles2middleRoomIds[0]
            for i in range(middleRoomsLeft):
                roomId = rng.choice(actionRoomIds)
                actionRoomIds.remove(roomId)
                middleRoomIds.append(roomId)

        roomIds = []
        # pick a starting room
        roomIds.append(rng.choice(startingRoomIDs))
        # add the chosen middle room IDs in random order
        #rng.shuffle(middleRoomIds)
        # temp only for debugging
        middleRoomIds.sort()
        print(('middleRoomIds=%s' % middleRoomIds))
        roomIds.extend(middleRoomIds)
        # add the chosen final room
        roomIds.append(finalRoomId)
        return roomIds
 def getBattleCellSpec(self, battleCellId):
     cogSpecModule = CountryClubRoomSpecs.getCogSpecModule(self.roomId)
     return cogSpecModule.BattleCells[battleCellId]
 def getReserveCogSpec(self, cogId):
     cogSpecModule = CountryClubRoomSpecs.getCogSpecModule(self.roomId)
     return cogSpecModule.ReserveCogData[cogId]