mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-23 11:42:39 -06:00
Leaderboard fix + ~race finish magic word
This commit is contained in:
parent
25f782d549
commit
071d59f4d0
2 changed files with 11 additions and 7 deletions
|
@ -74,6 +74,7 @@ class DistributedRace(DistributedObject.DistributedObject):
|
|||
self.bananaSound = base.loadSfx('phase_6/audio/sfx/KART_tossBanana.ogg')
|
||||
self.anvilFall = base.loadSfx('phase_6/audio/sfx/KART_Gag_Hit_Anvil.ogg')
|
||||
self.accept('leaveRace', self.leaveRace)
|
||||
self.accept('finishRace', self.finishRace)
|
||||
self.toonsToLink = []
|
||||
self.curveTs = []
|
||||
self.curvePoints = []
|
||||
|
@ -569,11 +570,7 @@ class DistributedRace(DistributedObject.DistributedObject):
|
|||
now = globalClock.getFrameTime()
|
||||
timestamp = globalClockDelta.localToNetworkTime(now)
|
||||
if self.laps == self.lapCount:
|
||||
self.sendUpdate('heresMyT', [localAvatar.doId,
|
||||
self.laps,
|
||||
self.currLapT,
|
||||
timestamp])
|
||||
self.fsm.request('finished')
|
||||
self.finishRace()
|
||||
if self.laps > self.maxLap:
|
||||
self.maxLap = self.laps
|
||||
self.sendUpdate('heresMyT', [localAvatar.doId,
|
||||
|
@ -1088,6 +1085,10 @@ class DistributedRace(DistributedObject.DistributedObject):
|
|||
|
||||
def leaveRace(self):
|
||||
self.fsm.request('leave')
|
||||
|
||||
def finishRace(self):
|
||||
self.sendUpdate('heresMyT', [localAvatar.doId, self.lapCount, self.currLapT, globalClockDelta.localToNetworkTime(globalClock.getFrameTime())])
|
||||
self.fsm.request('finished')
|
||||
|
||||
def racerLeft(self, avId):
|
||||
if avId != localAvatar.doId:
|
||||
|
@ -1243,4 +1244,7 @@ def race(command):
|
|||
if command == 'leave':
|
||||
messenger.send('leaveRace')
|
||||
return 'You left the race!'
|
||||
elif command == 'finish':
|
||||
messenger.send('finishRace')
|
||||
return 'You finished the race!'
|
||||
return 'Invalid command!'
|
||||
|
|
|
@ -31,14 +31,14 @@ class LeaderboardMgrAI:
|
|||
originalRace = self.database[race][1]
|
||||
newRace = list(originalRace)
|
||||
|
||||
newRace.append((name, timestamp))
|
||||
newRace.append([name, timestamp])
|
||||
sortedRace = self.trimList(sorted(newRace, key=operator.itemgetter(1)))
|
||||
|
||||
if originalRace != sortedRace:
|
||||
self.database[race][1] = sortedRace
|
||||
self.saveDatabase()
|
||||
else:
|
||||
self.database[race] = (time.time(), [(name, timestamp)])
|
||||
self.database[race] = [time.time(), [(name, timestamp)]]
|
||||
self.saveDatabase()
|
||||
|
||||
@magicWord(category=CATEGORY_PROGRAMMER, types=[str, int, int, str, int])
|
||||
|
|
Loading…
Reference in a new issue