def _genFloorLayout(self): rng = self.getRng() startingRoomIDs = MintRoomSpecs.CashbotMintEntranceIDs middleRoomIDs = MintRoomSpecs.CashbotMintMiddleRoomIDs finalRoomIDs = MintRoomSpecs.CashbotMintFinalRoomIDs numBattlesLeft = ToontownGlobals.MintNumBattles[self.mintId] finalRoomId = rng.choice(finalRoomIDs) numBattlesLeft -= MintRoomSpecs.getNumBattles(finalRoomId) middleRoomIds = [] middleRoomsLeft = self.numRooms - 2 numBattles2middleRoomIds = invertDictLossless( MintRoomSpecs.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 MintLayout.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)) rng.shuffle(middleRoomIds) roomIds.extend(middleRoomIds) roomIds.append(finalRoomId) return roomIds
def _genFloorLayout(self): rng = self.getRng() startingRoomIDs = MintRoomSpecs.CashbotMintEntranceIDs middleRoomIDs = MintRoomSpecs.CashbotMintMiddleRoomIDs finalRoomIDs = MintRoomSpecs.CashbotMintFinalRoomIDs numBattlesLeft = ToontownGlobals.MintNumBattles[self.mintId] finalRoomId = rng.choice(finalRoomIDs) numBattlesLeft -= MintRoomSpecs.getNumBattles(finalRoomId) middleRoomIds = [] middleRoomsLeft = self.numRooms - 2 numBattles2middleRoomIds = invertDictLossless(MintRoomSpecs.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 MintLayout.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)) rng.shuffle(middleRoomIds) roomIds.extend(middleRoomIds) roomIds.append(finalRoomId) return roomIds
def _genFloorLayout(self): rng = self.getRng() # pick the rooms. Make sure we don't get any repeats. startingRoomIDs = MintRoomSpecs.CashbotMintEntranceIDs middleRoomIDs = MintRoomSpecs.CashbotMintMiddleRoomIDs finalRoomIDs = MintRoomSpecs.CashbotMintFinalRoomIDs # how many battles do we want? numBattlesLeft = ToontownGlobals.MintNumBattles[self.mintId] # pick the final room first, so we know how many battles we can # have in the middle rooms finalRoomId = rng.choice(finalRoomIDs) numBattlesLeft -= MintRoomSpecs.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( MintRoomSpecs.middleRoomId2numBattles) # get list of all battle rooms allBattleRooms = [] for num, roomIds in 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 MintLayout.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 xrange(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) roomIds.extend(middleRoomIds) # add the chosen final room roomIds.append(finalRoomId) return roomIds