Send the api fail info and teams too when a mp match finishes.

This commit is contained in:
goeo_ 2017-08-10 15:53:18 -04:00
parent aa1887e2c4
commit 5f279da6cf
2 changed files with 21 additions and 1 deletions

View File

@ -27,6 +27,7 @@ def handle(userToken, packetData):
# Update the score
match.updateScore(slotID, data["totalScore"])
match.updateHP(slotID, data["currentHp"])
# Enqueue frames to who's playing
glob.streams.broadcast(match.playingStreamName, serverPackets.matchFrames(slotID, packetData))

View File

@ -23,6 +23,8 @@ class slot:
self.skip = False
self.complete = False
self.score = 0
self.failed = False
self.passed = True
class match:
def __init__(self, matchID, matchName, matchPassword, beatmapID, beatmapName, beatmapMD5, gameMode, hostUserID, isTourney=False):
@ -339,6 +341,16 @@ class match:
"""
self.slots[slotID].score = score
def updateHP(self, slotID, hp):
"""
Update HP for a slot
:param slotID: the slot that the user that is updating their hp is in
:param hp: the new hp to update
:return:
"""
self.slots[slotID].failed = True if hp == 254 else False
def playerCompleted(self, userID):
"""
Set userID's slot completed to True
@ -386,7 +398,10 @@ class match:
if self.slots[i].user is not None and self.slots[i].status == slotStatuses.PLAYING:
infoToSend["scores"][glob.tokens.tokens[self.slots[i].user].userID] = {
"score": self.slots[i].score,
"mods": self.slots[i].mods
"mods": self.slots[i].mods,
"failed": self.slots[i].failed,
"pass": self.slots[i].passed,
"team": self.slots[i].team
}
# Send the info to the api
@ -419,6 +434,8 @@ class match:
self.slots[i].skip = False
self.slots[i].complete = False
self.slots[i].score = 0
self.slots[i].failed = False
self.slots[i].passed = True
def getUserSlotID(self, userID):
"""
@ -612,6 +629,8 @@ class match:
if slotID is None:
return
self.slots[slotID].passed = False
# Send packet to everyone
glob.streams.broadcast(self.playingStreamName, serverPackets.playerFailed(slotID))