コード例 #1
0
    def addAvBlock(self, avId, block, paid):
        """
        Purpose: The addAvBlock Method updates the starting block of the
        avatar that has requested entry to the block.

        Params: avId - the id of the avatar entering the block.
                block - the Starting Block object that the avatar will enter.
        Return: None
        """

        # Call the Super Class Method
        success = DistributedKartPadAI.addAvBlock(self, avId, block, paid)
        if (success != KartGlobals.ERROR_CODE.success):
            return success

        # Need to store information here....
        timeStamp = globalClockDelta.getRealNetworkTime()
        #self.d_setAvEnterPad( avId, timeStamp )
        self.d_setLastEntered(timeStamp)

        # Start the countdown to kick the avatar out of the spot...
        self.kickAvDict[avId] = self.startCountdown(self.uniqueName(
            'ExitViewPadTask|%s' % (avId)),
                                                    self.__handleKickTimeout,
                                                    KartGlobals.COUNTDOWN_TIME,
                                                    params=[avId])

        return success
コード例 #2
0
    def addAvBlock(self, avId, block, paid):
        """
        Purpose: The addAvBlock Method updates the starting block of the
        avatar that has requested entry to the block.

        Params: avId - the id of the avatar entering the block.
                block - the Starting Block object that the avatar will enter.
        Return: None
        """

        # Grab the avatar and make certain its valid
        av = self.air.doId2do.get(avId, None)
        if (not av):
            self.notify.warning("addAvBlock: Avatar not found with id %s" %
                                (avId))
            return KartGlobals.ERROR_CODE.eGeneric

        # Make sure this track is open
        #if (self.trackId in (RaceGlobals.RT_Urban_1, RaceGlobals.RT_Urban_1_rev) and
        #    not simbase.config.GetBool('test-urban-track', 0)):
        #    return KartGlobals.ERROR_CODE.eTrackClosed

        grandPrixWeekendRunning = self.air.holidayManager.isHolidayRunning(
            ToontownGlobals.CIRCUIT_RACING_EVENT)

        # trialer restriction - only Speedway Practice races
        if not paid and not grandPrixWeekendRunning:
            genre = RaceGlobals.getTrackGenre(self.trackId)
            if not ((genre == RaceGlobals.Speedway) and
                    (self.trackType == RaceGlobals.Practice)):
                return KartGlobals.ERROR_CODE.eUnpaid

        if not (self.state == 'WaitEmpty' or self.state == 'WaitCountdown'):
            #you can only join a racepad in one of these states
            return KartGlobals.ERROR_CODE.eTooLate

        # Only check for non-practice races
        if (av.hasKart() and (not self.trackType == RaceGlobals.Practice)):
            # Check if the toon owns enough tickets for the race
            raceFee = RaceGlobals.getEntryFee(self.trackId, self.trackType)
            avTickets = av.getTickets()

            if (avTickets < raceFee):
                self.notify.debug(
                    "addAvBlock: Avatar %s does not own enough tickets for the race!"
                )
                return KartGlobals.ERROR_CODE.eTickets

        # Call the Super Class Method
        success = DistributedKartPadAI.addAvBlock(self, avId, block, paid)
        if (success != KartGlobals.ERROR_CODE.success):
            return success

        # A valid avatar has entered a starting block, now enter wait
        # countdown state. If already in the WaitCountdown state this
        # will not cause any harm.
        if (self.isOccupied()):
            self.request('WaitCountdown')

        return success