Beispiel #1
0
    def loadRecords(self):
        try:
            file = open(self.filename + '.bu', 'rb')
            if os.path.exists(self.filename):
                os.remove(self.filename)
        except IOError:
            try:
                file = open(self.filename, 'rb')
            except IOError:
                return self.getRecordTimes()

        file.seek(0)
        records = self.loadFrom(file)
        file.close()
        for trackId in RaceGlobals.TrackIds:
            if trackId not in records:
                records[trackId] = {}
                for i in RaceGlobals.PeriodIds:
                    records[trackId][i] = []
                    for j in range(0, RaceGlobals.NumRecordsPerPeriod):
                        records[trackId][i].append(
                            RaceGlobals.getDefaultRecord(trackId))

        self.resetLeaderboards()
        return records
Beispiel #2
0
    def resetRecordPeriod(self, period):
        for trackId in RaceGlobals.TrackIds:
            for i in range(0, RaceGlobals.NumRecordsPerPeriod):
                self.trackRecords[trackId][period][
                    i] = RaceGlobals.getDefaultRecord(trackId)

            self.updateLeaderboards(trackId, period)

        self.updateRecordFile()
Beispiel #3
0
    def getRecordTimes(self):
        records = {}
        for trackId in RaceGlobals.TrackIds:
            records[trackId] = {}
            for i in RaceGlobals.PeriodIds:
                records[trackId][i] = []
                for j in range(0, RaceGlobals.NumRecordsPerPeriod):
                    records[trackId][i].append(
                        RaceGlobals.getDefaultRecord(trackId))

        return records