mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-24 12:12:36 -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.bananaSound = base.loadSfx('phase_6/audio/sfx/KART_tossBanana.ogg')
|
||||||
self.anvilFall = base.loadSfx('phase_6/audio/sfx/KART_Gag_Hit_Anvil.ogg')
|
self.anvilFall = base.loadSfx('phase_6/audio/sfx/KART_Gag_Hit_Anvil.ogg')
|
||||||
self.accept('leaveRace', self.leaveRace)
|
self.accept('leaveRace', self.leaveRace)
|
||||||
|
self.accept('finishRace', self.finishRace)
|
||||||
self.toonsToLink = []
|
self.toonsToLink = []
|
||||||
self.curveTs = []
|
self.curveTs = []
|
||||||
self.curvePoints = []
|
self.curvePoints = []
|
||||||
|
@ -569,11 +570,7 @@ class DistributedRace(DistributedObject.DistributedObject):
|
||||||
now = globalClock.getFrameTime()
|
now = globalClock.getFrameTime()
|
||||||
timestamp = globalClockDelta.localToNetworkTime(now)
|
timestamp = globalClockDelta.localToNetworkTime(now)
|
||||||
if self.laps == self.lapCount:
|
if self.laps == self.lapCount:
|
||||||
self.sendUpdate('heresMyT', [localAvatar.doId,
|
self.finishRace()
|
||||||
self.laps,
|
|
||||||
self.currLapT,
|
|
||||||
timestamp])
|
|
||||||
self.fsm.request('finished')
|
|
||||||
if self.laps > self.maxLap:
|
if self.laps > self.maxLap:
|
||||||
self.maxLap = self.laps
|
self.maxLap = self.laps
|
||||||
self.sendUpdate('heresMyT', [localAvatar.doId,
|
self.sendUpdate('heresMyT', [localAvatar.doId,
|
||||||
|
@ -1089,6 +1086,10 @@ class DistributedRace(DistributedObject.DistributedObject):
|
||||||
def leaveRace(self):
|
def leaveRace(self):
|
||||||
self.fsm.request('leave')
|
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):
|
def racerLeft(self, avId):
|
||||||
if avId != localAvatar.doId:
|
if avId != localAvatar.doId:
|
||||||
self.gui.racerLeft(avId, unexpected=False)
|
self.gui.racerLeft(avId, unexpected=False)
|
||||||
|
@ -1243,4 +1244,7 @@ def race(command):
|
||||||
if command == 'leave':
|
if command == 'leave':
|
||||||
messenger.send('leaveRace')
|
messenger.send('leaveRace')
|
||||||
return 'You left the race!'
|
return 'You left the race!'
|
||||||
|
elif command == 'finish':
|
||||||
|
messenger.send('finishRace')
|
||||||
|
return 'You finished the race!'
|
||||||
return 'Invalid command!'
|
return 'Invalid command!'
|
||||||
|
|
|
@ -31,14 +31,14 @@ class LeaderboardMgrAI:
|
||||||
originalRace = self.database[race][1]
|
originalRace = self.database[race][1]
|
||||||
newRace = list(originalRace)
|
newRace = list(originalRace)
|
||||||
|
|
||||||
newRace.append((name, timestamp))
|
newRace.append([name, timestamp])
|
||||||
sortedRace = self.trimList(sorted(newRace, key=operator.itemgetter(1)))
|
sortedRace = self.trimList(sorted(newRace, key=operator.itemgetter(1)))
|
||||||
|
|
||||||
if originalRace != sortedRace:
|
if originalRace != sortedRace:
|
||||||
self.database[race][1] = sortedRace
|
self.database[race][1] = sortedRace
|
||||||
self.saveDatabase()
|
self.saveDatabase()
|
||||||
else:
|
else:
|
||||||
self.database[race] = (time.time(), [(name, timestamp)])
|
self.database[race] = [time.time(), [(name, timestamp)]]
|
||||||
self.saveDatabase()
|
self.saveDatabase()
|
||||||
|
|
||||||
@magicWord(category=CATEGORY_PROGRAMMER, types=[str, int, int, str, int])
|
@magicWord(category=CATEGORY_PROGRAMMER, types=[str, int, int, str, int])
|
||||||
|
|
Loading…
Reference in a new issue