def calculateTrophies(self, avId, won, qualify, time): av = self.air.doId2do[avId] kartingHistory = av.getKartingHistory() avTrophies = av.getKartingTrophies() numTrophies = 0 for i in xrange(30): if avTrophies[i] != 0: numTrophies += 1 oldLaffBoost = int(numTrophies/10) genre = RaceGlobals.getTrackGenre(self.trackId) trophies = [] if won: kartingHistory[genre] += 1 kartingHistory[3] += 1 if kartingHistory[3] > RaceGlobals.TotalWonRaces: avTrophies[RaceGlobals.TotalWins] = 1 trophies.append(RaceGlobals.TotalWins) for i in xrange(3): if kartingHistory[genre] >= RaceGlobals.WonRaces[i] and avTrophies[RaceGlobals.AllWinsList[genre][i]] != 1: avTrophies[RaceGlobals.AllWinsList[genre][i]] = 1 trophies.append(RaceGlobals.AllWinsList[genre][i]) if qualify: kartingHistory[genre + 4] += 1 kartingHistory[7] += 1 if kartingHistory[7] >= RaceGlobals.TotalQualifiedRaces and avTrophies[RaceGlobals.TotalQuals] != 1: avTrophies[RaceGlobals.TotalQuals] = 1 trophies.append(RaceGlobals.TotalQuals) for i in xrange(3): if kartingHistory[genre + 4] >= RaceGlobals.QualifiedRaces[i] and avTrophies[RaceGlobals.AllQualsList[genre][i]] != 1: avTrophies[RaceGlobals.AllQualsList[genre][i]] = 1 trophies.append(RaceGlobals.AllQualsList[genre][i]) for i, history in enumerate(kartingHistory): if history > 255: kartingHistory[i] = 255 av.b_setKartingHistory(kartingHistory) pKartingBest = av.getKartingPersonalBestAll() trackIndex = TTLocalizer.KartRace_TrackNames.keys().index(self.trackId) if pKartingBest[trackIndex] > time or not pKartingBest[trackIndex]: pKartingBest[trackIndex] = time av.b_setKartingPersonalBest(pKartingBest) gTourTrophy = True for bestTime in pKartingBest: if not bestTime: gTourTrophy = False if gTourTrophy: if avTrophies[RaceGlobals.GrandTouring] != 1: avTrophies[RaceGlobals.GrandTouring] = 1 trophies.append(RaceGlobals.GrandTouring) newLaffBoost = int((len(trophies) + numTrophies)/10) if newLaffBoost - oldLaffBoost != 0: for i in xrange(newLaffBoost): if avTrophies[RaceGlobals.TrophyCups[i]] != 1: avTrophies[RaceGlobals.TrophyCups[i]] = 1 trophies.append(RaceGlobals.TrophyCups[i]) av.b_setMaxHp(av.getMaxHp() + newLaffBoost - oldLaffBoost) av.toonUp(av.getMaxHp()) av.b_setKartingTrophies(avTrophies) return trophies
def getTunnelSign(self): cPadId = RaceGlobals.RaceInfo2RacePadId(self.trackId, self.trackType) genreId = RaceGlobals.getTrackGenre(self.trackId) tunnelName = RaceGlobals.getTunnelSignName(genreId, cPadId) self.tunnelSign = self.cr.playGame.hood.loader.geom.find('**/' + tunnelName)
def calculateTrophies(self, avId, won, qualify, time): av = self.air.doId2do[avId] kartingHistory = av.getKartingHistory() avTrophies = av.getKartingTrophies() numTrophies = 0 for i in xrange(30): if avTrophies[i] != 0: numTrophies += 1 oldLaffBoost = int(numTrophies / 10) genre = RaceGlobals.getTrackGenre(self.trackId) trophies = [] if won: kartingHistory[genre] += 1 kartingHistory[3] += 1 if kartingHistory[3] > RaceGlobals.TotalWonRaces: avTrophies[RaceGlobals.TotalWins] = 1 trophies.append(RaceGlobals.TotalWins) for i in xrange(3): if kartingHistory[genre] >= RaceGlobals.WonRaces[ i] and avTrophies[RaceGlobals.AllWinsList[genre] [i]] != 1: avTrophies[RaceGlobals.AllWinsList[genre][i]] = 1 trophies.append(RaceGlobals.AllWinsList[genre][i]) if qualify: kartingHistory[genre + 4] += 1 kartingHistory[7] += 1 if kartingHistory[ 7] >= RaceGlobals.TotalQualifiedRaces and avTrophies[ RaceGlobals.TotalQuals] != 1: avTrophies[RaceGlobals.TotalQuals] = 1 trophies.append(RaceGlobals.TotalQuals) for i in xrange(3): if kartingHistory[ genre + 4] >= RaceGlobals.QualifiedRaces[i] and avTrophies[ RaceGlobals.AllQualsList[genre][i]] != 1: avTrophies[RaceGlobals.AllQualsList[genre][i]] = 1 trophies.append(RaceGlobals.AllQualsList[genre][i]) for i, history in enumerate(kartingHistory): if history > 255: kartingHistory[i] = 255 av.b_setKartingHistory(kartingHistory) pKartingBest = av.getKartingPersonalBestAll() trackIndex = TTLocalizer.KartRace_TrackNames.keys().index(self.trackId) if pKartingBest[trackIndex] > time or not pKartingBest[trackIndex]: pKartingBest[trackIndex] = time av.b_setKartingPersonalBest(pKartingBest) gTourTrophy = True for bestTime in pKartingBest: if not bestTime: gTourTrophy = False if gTourTrophy: if avTrophies[RaceGlobals.GrandTouring] != 1: avTrophies[RaceGlobals.GrandTouring] = 1 trophies.append(RaceGlobals.GrandTouring) newLaffBoost = int((len(trophies) + numTrophies) / 10) if newLaffBoost - oldLaffBoost != 0: for i in xrange(newLaffBoost): if avTrophies[RaceGlobals.TrophyCups[i]] != 1: avTrophies[RaceGlobals.TrophyCups[i]] = 1 trophies.append(RaceGlobals.TrophyCups[i]) av.b_setMaxHp(av.getMaxHp() + newLaffBoost - oldLaffBoost) av.toonUp(av.getMaxHp()) av.b_setKartingTrophies(avTrophies) return trophies