2016-10-02 20:48:14 +00:00
|
|
|
from common.constants import mods
|
2016-05-18 17:12:46 +00:00
|
|
|
from constants import clientPackets
|
|
|
|
from constants import matchModModes
|
2016-10-02 20:48:14 +00:00
|
|
|
from objects import glob
|
|
|
|
|
2016-04-19 17:40:59 +00:00
|
|
|
|
|
|
|
def handle(userToken, packetData):
|
|
|
|
# Get token data
|
|
|
|
userID = userToken.userID
|
|
|
|
|
|
|
|
# Get packet data
|
|
|
|
packetData = clientPackets.changeMods(packetData)
|
|
|
|
|
|
|
|
# Make sure the match exists
|
|
|
|
matchID = userToken.matchID
|
|
|
|
if matchID not in glob.matches.matches:
|
|
|
|
return
|
|
|
|
match = glob.matches.matches[matchID]
|
|
|
|
|
|
|
|
# Set slot or match mods according to modType
|
2016-11-17 18:13:06 +00:00
|
|
|
if match.matchModMode == matchModModes.FREE_MOD:
|
2016-04-19 17:40:59 +00:00
|
|
|
# Freemod
|
|
|
|
# Host can set global DT/HT
|
|
|
|
if userID == match.hostUserID:
|
|
|
|
# If host has selected DT/HT and Freemod is enabled, set DT/HT as match mod
|
2016-10-02 20:48:14 +00:00
|
|
|
if (packetData["mods"] & mods.DOUBLETIME) > 0:
|
2016-10-08 18:45:53 +00:00
|
|
|
match.changeMods(mods.DOUBLETIME)
|
2016-09-02 10:41:19 +00:00
|
|
|
# Nightcore
|
2016-10-02 20:48:14 +00:00
|
|
|
if (packetData["mods"] & mods.NIGHTCORE) > 0:
|
2016-10-08 18:45:53 +00:00
|
|
|
match.changeMods(match.mods + mods.NIGHTCORE)
|
2016-10-02 20:48:14 +00:00
|
|
|
elif (packetData["mods"] & mods.HALFTIME) > 0:
|
2016-10-08 18:45:53 +00:00
|
|
|
match.changeMods(mods.HALFTIME)
|
2016-04-19 17:40:59 +00:00
|
|
|
else:
|
|
|
|
# No DT/HT, set global mods to 0 (we are in freemod mode)
|
2016-10-08 18:45:53 +00:00
|
|
|
match.changeMods(0)
|
2016-04-19 17:40:59 +00:00
|
|
|
|
|
|
|
# Set slot mods
|
|
|
|
slotID = match.getUserSlotID(userID)
|
2016-09-02 15:45:10 +00:00
|
|
|
if slotID is not None:
|
2016-04-19 17:40:59 +00:00
|
|
|
match.setSlotMods(slotID, packetData["mods"])
|
|
|
|
else:
|
|
|
|
# Not freemod, set match mods
|
2016-10-08 18:45:53 +00:00
|
|
|
match.changeMods(packetData["mods"])
|