def createLawOffice(self, StageId, entranceId, players):
     for avId in players:
         if bboard.has('StageId-%s' % avId):
             StageId = bboard.get('StageId-%s' % avId)
             break
     floor = 0
     layoutIndex = None
     for avId in players:
         if bboard.has('stageRoom-%s' % avId):
             roomId = bboard.get('stageRoom-%s' % avId)
             for lt in StageId2Layouts[StageId]:
                 for i in xrange(StageLayout.getNumFloors(lt)):
                     layout = StageLayout.StageLayout(StageId, i, stageLayout = lt)
                     if roomId in layout.getRoomIds():
                         layoutIndex = lt
                         floor = i
             else:
                 StageRoomSpecs = StageRoomSpecs
                 roomName = StageRoomSpecs.CashbotStageRoomId2RoomName[roomId]
                 LawOfficeManagerAI.notify.warning('room %s (%s) not found in any floor of Stage %s' % (roomId, roomName, StageId))
     StageZone = self.air.allocateZone()
     if layoutIndex is None:
         layoutIndex = random.choice(StageId2Layouts[StageId])
     Stage = DistributedStageAI.DistributedStageAI(self.air, StageId, StageZone, floor, players, layoutIndex)
     Stage.generateWithRequired(StageZone)
     return StageZone
Ejemplo n.º 2
0
    def createStage(self, stageId, players):
        for avId in players:
            if bboard.has('stageId-%s' % avId):
                stageId = bboard.get('stageId-%s' % avId)
                break

        numFloors = StageLayout.getNumFloors(stageId)
        floor = random.randrange(numFloors)
        for avId in players:
            if bboard.has('stageFloor-%s' % avId):
                floor = bboard.get('stageFloor-%s' % avId)
                floor = max(0, floor)
                floor = min(floor, numFloors - 1)
                break

        for avId in players:
            if bboard.has('stageRoom-%s' % avId):
                roomId = bboard.get('stageRoom-%s' % avId)
                for i in xrange(numFloors):
                    layout = StageLayout.StageLayout(stageId, i)
                    if roomId in layout.getRoomIds():
                        floor = i
                else:
                    from toontown.coghq import StageRoomSpecs
                    roomName = StageRoomSpecs.CashbotStageRoomId2RoomName[roomId]
                    StageManagerAI.notify.warning('room %s (%s) not found in any floor of stage %s' % (roomId, roomName, stageId))

        stageZone = self.air.allocateZone()
        stage = DistributedStageAI.DistributedStageAI(self.air, stageId, stageZone, floor, players)
        stage.generateWithRequired(stageZone)
        return stageZone
Ejemplo n.º 3
0
    def generate(self):
        DistributedObjectAI.DistributedObjectAI.generate(self)
        self.notify.info('generate %s, id=%s, floor=%s' %
                         (self.doId, self.stageId, self.floorNum))
        self.layout = StageLayout.StageLayout(self.stageId, self.floorNum,
                                              self.layoutIndex)
        self.rooms = []
        if self.battleExpAggreg is None:
            self.battleExpAggreg = BattleExperienceAggregatorAI.BattleExperienceAggregatorAI(
            )
        for i in xrange(self.layout.getNumRooms()):
            room = DistributedStageRoomAI.DistributedStageRoomAI(
                self.air, self.stageId, self.doId, self.zoneId,
                self.layout.getRoomId(i), i * 2, self.avIds,
                self.battleExpAggreg)
            room.generateWithRequired(self.zoneId)
            self.rooms.append(room)

        roomDoIds = []
        for room in self.rooms:
            roomDoIds.append(room.doId)

        self.sendUpdate('setRoomDoIds', [roomDoIds])
        self.placeElevatorsOnMarkers()
        if __dev__:
            simbase.stage = self
        description = '%s|%s|%s' % (self.stageId, self.floorNum, self.avIds)
        for avId in self.avIds:
            self.air.writeServerEvent('stageEntered', avId, description)

        return
Ejemplo n.º 4
0
 def createLawOffice(self, StageId, entranceId, players):
     for avId in players:
         if bboard.has('StageId-%s' % avId):
             StageId = bboard.get('StageId-%s' % avId)
             break
     floor = 0
     layoutIndex = None
     for avId in players:
         if bboard.has('stageRoom-%s' % avId):
             roomId = bboard.get('stageRoom-%s' % avId)
             for lt in StageId2Layouts[StageId]:
                 for i in xrange(StageLayout.getNumFloors(lt)):
                     layout = StageLayout.StageLayout(StageId, i, stageLayout = lt)
                     if roomId in layout.getRoomIds():
                         layoutIndex = lt
                         floor = i
             else:
                 StageRoomSpecs = StageRoomSpecs
                 roomName = StageRoomSpecs.CashbotStageRoomId2RoomName[roomId]
                 LawOfficeManagerAI.notify.warning('room %s (%s) not found in any floor of Stage %s' % (roomId, roomName, StageId))
     StageZone = self.air.allocateZone()
     if layoutIndex is None:
         layoutIndex = random.choice(StageId2Layouts[StageId])
     Stage = DistributedStageAI.DistributedStageAI(self.air, StageId, StageZone, floor, players, layoutIndex)
     Stage.generateWithRequired(StageZone)
     return StageZone
Ejemplo n.º 5
0
 def setFloorNum(self, num):
     DistributedStage.notify.debug('floorNum: %s' % num)
     self.floorNum = num
     bboard.post(DistributedStage.FloorNum, num)
     self.layout = StageLayout.StageLayout(self.stageId, self.floorNum,
                                           self.layoutIndex)
     self.smallTitleText.setText(TTLocalizer.LawOfficeFloorTitle %
                                 (self.floorNum + 1))
Ejemplo n.º 6
0
    def generate(self):
        DistributedObjectAI.DistributedObjectAI.generate(self)
        self.notify.info('generate %s, id=%s, floor=%s' %
                         (self.doId, self.stageId, self.floorNum))

        self.layout = StageLayout.StageLayout(self.stageId, self.floorNum,
                                              self.layoutIndex)
        self.rooms = []

        if self.battleExpAggreg is None:
            # create a battle experience aggregator for the stage rooms to share
            self.battleExpAggreg = BattleExperienceAggregatorAI.\
                                   BattleExperienceAggregatorAI()

        # create a StageRoom level obj for each room in the layout
        for i in range(self.layout.getNumRooms()):
            # i*2 for roomNum leaves numbers for hallways
            room = DistributedStageRoomAI.DistributedStageRoomAI(
                self.air, self.stageId, self.doId, self.zoneId,
                self.layout.getRoomId(i), i * 2, self.avIds,
                self.battleExpAggreg)
            room.generateWithRequired(self.zoneId)
            self.rooms.append(room)

        roomDoIds = []
        for room in self.rooms:
            roomDoIds.append(room.doId)
        self.sendUpdate('setRoomDoIds', [roomDoIds])

        self.placeElevatorsOnMarkers()

        if __dev__:
            simbase.stage = self

        # log that toons entered the stage
        description = '%s|%s|%s' % (self.stageId, self.floorNum, self.avIds)
        for avId in self.avIds:
            self.air.writeServerEvent('stageEntered', avId, description)
 def setFloorNum(self, num):
     DistributedStage.notify.debug('floorNum: %s' % num)
     self.floorNum = num
     bboard.post(DistributedStage.FloorNum, num)
     self.layout = StageLayout.StageLayout(self.stageId, self.floorNum,
                                           self.layoutIndex)