def __handleSetRaceCountdownTimeout(self, params=[]): """ Comment: """ # set the timer task to off, because raceExit calls removeAvBlock and # shouldn't call. SHOULD BREAK UP THOSE CALLS. self.timerTask = None players = self.avId2BlockDict.keys() circuitLoop = [] if self.trackType == RaceGlobals.Circuit: circuitLoop = RaceGlobals.getCircuitLoop(self.trackId) raceZone = self.raceMgr.createRace(self.trackId, self.trackType, self.numLaps, players, circuitLoop[1:], {}, {}, [], {}, circuitTotalBonusTickets={}) for avId in self.avId2BlockDict.keys(): if (avId): self.notify.debug( "Handling Race Launch Countdown for avatar %s" % (avId)) # Tell each player that they should enter # the mint, and which zone it is in. self.sendUpdateToAvatarId(avId, "setRaceZone", [raceZone]) self.avId2BlockDict[avId].raceExit() # Let's now restart for a new race. self.request('WaitEmpty') return Task.done
def createRace(self): self.raceZone = self.air.allocateZone() avatars = [] for block in self.startingBlocks: if block.avId != 0: avatars.append(block.avId) self.sendUpdateToAvatarId(block.avId, 'setRaceZone', [self.raceZone]) race = DistributedRaceAI(self.air) race.setZoneId(self.raceZone) race.setTrackId(self.trackId) race.setRaceType(self.trackType) race.setAvatars(avatars) if self.trackType == RaceGlobals.Circuit: race.setCircuitLoop(RaceGlobals.getCircuitLoop(self.trackId)) else: race.setCircuitLoop([]) race.setStartingPlaces(range(len(avatars))) race.setLapCount(3) race.generateWithRequired(self.raceZone) for avId in avatars: if avId in self.air.doId2do: av = self.air.doId2do[avId] entryFee = RaceGlobals.getEntryFee(self.trackId, self.trackType) if av.getTickets() < entryFee: self.air.writeServerEvent( 'suspicious', avId, 'Toon somehow lost tickets between entering a race and it leaving!' ) av.b_setTickets(0) else: av.b_setTickets(av.getTickets() - entryFee) self.b_setState('WaitEmpty', globalClockDelta.getRealNetworkTime())
def createRace(self): self.raceZone = self.air.allocateZone() avatars = [] for block in self.startingBlocks: if block.avId != 0: avatars.append(block.avId) self.sendUpdateToAvatarId(block.avId, 'setRaceZone', [self.raceZone]) race = DistributedRaceAI(self.air) race.setZoneId(self.raceZone) race.setTrackId(self.trackId) race.setRaceType(self.trackType) race.setAvatars(avatars) if self.trackType == RaceGlobals.Circuit: race.setCircuitLoop(RaceGlobals.getCircuitLoop(self.trackId)) else: race.setCircuitLoop([]) race.setStartingPlaces(range(len(avatars))) race.setLapCount(3) race.generateWithRequired(self.raceZone) for avId in avatars: if avId in self.air.doId2do: av = self.air.doId2do[avId] entryFee = RaceGlobals.getEntryFee(self.trackId, self.trackType) if av.getTickets() < entryFee: self.air.writeServerEvent('suspicious', avId, 'Toon somehow lost tickets between entering a race and it leaving!') av.b_setTickets(0) else: av.b_setTickets(av.getTickets() - entryFee) self.b_setState('WaitEmpty', globalClockDelta.getRealNetworkTime())
def enterRace(self, task): trackId, raceType = self.trackInfo circuitLoop = [] if raceType == RaceGlobals.Circuit: circuitLoop = RaceGlobals.getCircuitLoop(trackId) raceZone = self.air.raceMgr.createRace(trackId, raceType, self.laps, self.avIds, circuitLoop=circuitLoop[1:], circuitPoints={}, circuitTimes={}) for block in self.startingBlocks: self.sendUpdateToAvatarId(block.avId, 'setRaceZone', [raceZone]) block.raceExit() return task.done