2016-05-18 17:12:46 +00:00
|
|
|
from objects import glob
|
2017-07-31 21:54:50 +00:00
|
|
|
from constants import serverPackets, clientPackets
|
2016-04-19 17:40:59 +00:00
|
|
|
|
|
|
|
def handle(userToken, packetData):
|
|
|
|
# Get usertoken data
|
|
|
|
userID = userToken.userID
|
|
|
|
|
|
|
|
# Get match ID and match object
|
|
|
|
matchID = userToken.matchID
|
|
|
|
|
|
|
|
# Make sure we are in a match
|
|
|
|
if matchID == -1:
|
|
|
|
return
|
|
|
|
|
|
|
|
# Make sure the match exists
|
|
|
|
if matchID not in glob.matches.matches:
|
|
|
|
return
|
|
|
|
|
|
|
|
# The match exists, get object
|
|
|
|
match = glob.matches.matches[matchID]
|
|
|
|
|
|
|
|
# Change slot id in packetData
|
|
|
|
slotID = match.getUserSlotID(userID)
|
|
|
|
|
2017-07-31 21:54:50 +00:00
|
|
|
# Parse the data
|
|
|
|
data = clientPackets.matchFrames(packetData)
|
|
|
|
|
|
|
|
# Update the score
|
|
|
|
match.updateScore(slotID, data["totalScore"])
|
2017-08-10 19:53:18 +00:00
|
|
|
match.updateHP(slotID, data["currentHp"])
|
2017-07-31 21:54:50 +00:00
|
|
|
|
2016-04-19 17:40:59 +00:00
|
|
|
# Enqueue frames to who's playing
|
2016-10-04 21:43:02 +00:00
|
|
|
glob.streams.broadcast(match.playingStreamName, serverPackets.matchFrames(slotID, packetData))
|