def mp_make(): if len(message) < 2: raise exceptions.invalidArgumentsException( "Wrong syntax: !mp make <name>") matchName = " ".join(message[1:]).strip() if not matchName: raise exceptions.invalidArgumentsException( "Match name must not be empty!") userID = userUtils.getID(fro) for (_, __match) in glob.matches.matches.items(): if __match.hostUserID == userID: return "You have opened match {}, please close it before use this command!".format( __match.matchID) matchID = glob.matches.createMatch(matchName, generalUtils.stringMd5( generalUtils.randomString(32)), 0, "Tournament", "", 0, userID, isTourney=True) glob.matches.matches[matchID].sendUpdates() return "Tourney match #{} created!".format(matchID)
def make(response, token, sender, channel, message): if len(message) < 1: raise exceptions.invalidArgumentsException( "Wrong syntax: !mp make <name>") matchName = " ".join(message[0:]).strip() if not matchName: raise exceptions.invalidArgumentsException( "Match name must not be empty!") userID = userUtils.getID(sender) matchID = glob.matches.createMatch(matchName, generalUtils.stringMd5( generalUtils.randomString(32)), 0, "Tournament", "", 0, -1, creatorUserID=userID, isTourney=True) glob.matches.matches[matchID].sendUpdates() if token.irc: newChan = "{}_{}".format(chatChannels.MULTIPLAYER_PREFIX, matchID) glob.ircServer.banchoJoinChannel(token.username, newChan) for c in glob.ircServer.clients.values(): if c.banchoUsername == token.username: c.joinHandler(None, [newChan]) else: token.joinMatch(matchID) if not token.tournament: glob.matches.matches[matchID].setHost(userID) response.target = sender response.setContent( token, "Created the tournament match #{} {}".format(matchID, matchName))
def mp_random_password(): userID = userUtils.getID(fro) if not can_user_touch_lobby(get_match_id_from_channel(chan), userID): return False password = generalUtils.stringMd5(generalUtils.randomString(32)) _match = glob.matches.matches[get_match_id_from_channel(chan)] _match.changePassword(password) return "Match password has been changed to a random one"
def mpMake(): if len(message) < 2: raise exceptions.invalidArgumentsException("Wrong syntax: !mp make <name>") matchName = " ".join(message[1:]).strip() if not matchName: raise exceptions.invalidArgumentsException("Match name must not be empty!") matchID = glob.matches.createMatch(matchName, generalUtils.stringMd5(generalUtils.randomString(32)), 0, "Tournament", "", 0, -1, isTourney=True) glob.matches.matches[matchID].sendUpdates() return "Tourney match #{} created!".format(matchID)
def asyncGet(self): statusCode = 400 response = {'message': "invalid parameters"} try: # Check args if not requestsManager.checkArguments( self.request.arguments, ['k', 'matchName', 'gameMode', 'isTourney']): raise exceptions.invalidArgumentsException() # Check ci key key = self.get_argument('k') if key is None or key != glob.conf.config["server"]["cikey"]: response[ 'message'] = 'Bad secret key. You are not allowed to access to this api.' raise exceptions.invalidArgumentsException() matchName = self.get_argument('matchName') gameMode = getGameModeForMatchAPI(self.get_argument('gameMode')) isTourney = self.get_argument('isTourney') if isTourney == 'True': isTourney = True elif isTourney == 'False': isTourney = False else: response[ 'message'] = 'isTourney is requirement not optional. Only accepts True or False' raise exceptions.invalidArgumentsException() if gameMode is None: response[ 'message'] = 'Oh my we only accepts gameMode std, taiko, ctb and mania' raise exceptions.invalidArgumentsException() matchID = glob.matches.createMatch( matchName, generalUtils.stringMd5(generalUtils.randomString(32)), 0, "Tournament", "", gameMode, -1, isTourney=isTourney) glob.matches.matches[matchID].sendUpdates() response = {"matchID": matchID} statusCode = 200 except exceptions.invalidArgumentsException: statusCode = 400 self.write(json.dumps(response)) self.set_status(statusCode)
def asyncGet(self): try: # Get request ip ip = self.getRequestIP() # Check arguments if not requestsManager.checkArguments(self.request.arguments, ["c", "k"]): raise exceptions.invalidArgumentsException(MODULE_NAME) # Get arguments key = self.get_argument("k") targetID = self.get_argument("c") if key is None or key != generalUtils.stringMd5( glob.conf.config["server"]["apikey"]): raise exceptions.invalidArgumentsException(MODULE_NAME) targetUsername = userUtils.getUsername(targetID) if (targetUsername is None): raise exceptions.invalidArgumentsException(MODULE_NAME) # Serve replay log.info("Serving {}.txt".format(targetUsername)) fileName = ".data/pl/{}.txt".format(targetUsername) if os.path.isfile(fileName): with open(fileName, "rb") as f: fileContent = f.read() self.write(fileContent) self.set_header("Content-length", len(fileContent)) self.set_header("Content-Description", "File Transfer") self.set_header( "Content-Disposition", "attachment; filename=\"{}_trace.txt\"".format( targetUsername)) else: log.warning("Trace {} doesn't exist".format(targetUsername)) self.write("") except exceptions.invalidArgumentsException: pass except exceptions.loginFailedException: pass
def handle(userToken, packetData): # Read new settings packetData = clientPackets.changeMatchSettings(packetData) # Get match ID matchID = userToken.matchID # Make sure the match exists if matchID not in glob.matches.matches: return # Host check with glob.matches.matches[matchID] as match: if userToken.userID != match.hostUserID: return # Some dank memes easter egg memeTitles = [ "RWC 2020", "Ripple is a duck", "Dank memes", "1337ms Ping", "Iscriviti a Xenotoze", "...e i marĂ²?", "Superman dies", "The brace is on fire", "print_foot()", "#FREEZEBARKEZ", "Ripple devs are actually cats", "Thank Mr Shaural", "NEVER GIVE UP", "T I E D W I T H U N I T E D", "HIGHEST HDHR LOBBY OF ALL TIME", "This is gasoline and I set myself on fire", "Everyone is cheating apparently", "Kurwa mac", "TATOE", "This is not your drama landfill.", "I like cheese", "NYO IS NOT A CAT HE IS A DO(N)G", "Datingu startuato" ] # Set match name match.matchName = packetData["matchName"] if packetData["matchName"] != "meme" else random.choice(memeTitles) # Update match settings match.inProgress = packetData["inProgress"] if packetData["matchPassword"] != "": match.matchPassword = generalUtils.stringMd5(packetData["matchPassword"]) else: match.matchPassword = "" match.beatmapName = packetData["beatmapName"] match.beatmapID = packetData["beatmapID"] match.hostUserID = packetData["hostUserID"] match.gameMode = packetData["gameMode"] oldBeatmapMD5 = match.beatmapMD5 oldMods = match.mods oldMatchTeamType = match.matchTeamType match.mods = packetData["mods"] match.beatmapMD5 = packetData["beatmapMD5"] match.matchScoringType = packetData["scoringType"] match.matchTeamType = packetData["teamType"] match.matchModMode = packetData["freeMods"] # Reset ready if needed if oldMods != match.mods or oldBeatmapMD5 != match.beatmapMD5: match.resetReady() # Reset mods if needed if match.matchModMode == matchModModes.NORMAL: # Reset slot mods if not freeMods match.resetMods() else: # Reset match mods if freemod match.mods = 0 # Initialize teams if team type changed if match.matchTeamType != oldMatchTeamType: match.initializeTeams() # Force no freemods if tag coop if match.matchTeamType == matchTeamTypes.TAG_COOP or match.matchTeamType == matchTeamTypes.TAG_TEAM_VS: match.matchModMode = matchModModes.NORMAL # Send updated settings match.sendUpdates() # Console output log.info("MPROOM{}: Updated room settings".format(match.matchID))
def buildFullReplay(scoreID=None, scoreData=None, rawReplay=None): if all(v is None for v in (scoreID, scoreData)) or all( v is not None for v in (scoreID, scoreData)): raise AttributeError( "Either scoreID or scoreData must be provided, not neither or both" ) if scoreData is None: scoreData = glob.db.fetch( "SELECT scores.*, users.username FROM scores LEFT JOIN users ON scores.userid = users.id " "WHERE scores.id = %s", [scoreID]) else: scoreID = scoreData["id"] if scoreData is None or scoreID is None: raise exceptions.scoreNotFoundError() if rawReplay is None: # Make sure raw replay exists fileName = getFirstReplayFileName(scoreID) if fileName is None: raise FileNotFoundError() # Read raw replay with open(fileName, "rb") as f: rawReplay = f.read() # Calculate missing replay data rank = generalUtils.getRank(int(scoreData["play_mode"]), int(scoreData["mods"]), int(scoreData["accuracy"]), int(scoreData["300_count"]), int(scoreData["100_count"]), int(scoreData["50_count"]), int(scoreData["misses_count"])) magicHash = generalUtils.stringMd5( "{}p{}o{}o{}t{}a{}r{}e{}y{}o{}u{}{}{}".format( int(scoreData["100_count"]) + int(scoreData["300_count"]), scoreData["50_count"], scoreData["gekis_count"], scoreData["katus_count"], scoreData["misses_count"], scoreData["beatmap_md5"], scoreData["max_combo"], "True" if int(scoreData["full_combo"]) == 1 else "False", scoreData["username"], scoreData["score"], rank, scoreData["mods"], "True")) # Add headers (convert to full replay) fullReplay = binaryHelper.binaryWrite([ [scoreData["play_mode"], dataTypes.byte], [20150414, dataTypes.uInt32], [scoreData["beatmap_md5"], dataTypes.string], [scoreData["username"], dataTypes.string], [magicHash, dataTypes.string], [scoreData["300_count"], dataTypes.uInt16], [scoreData["100_count"], dataTypes.uInt16], [scoreData["50_count"], dataTypes.uInt16], [scoreData["gekis_count"], dataTypes.uInt16], [scoreData["katus_count"], dataTypes.uInt16], [scoreData["misses_count"], dataTypes.uInt16], [scoreData["score"], dataTypes.uInt32], [scoreData["max_combo"], dataTypes.uInt16], [scoreData["full_combo"], dataTypes.byte], [scoreData["mods"], dataTypes.uInt32], [0, dataTypes.byte], [toDotTicks(int(scoreData["time"])), dataTypes.uInt64], [rawReplay, dataTypes.rawReplay], [0, dataTypes.uInt32], [0, dataTypes.uInt32], ]) # Return full replay return fullReplay
def mpRandomPassword(): password = generalUtils.stringMd5(generalUtils.randomString(32)) _match = glob.matches.matches[getMatchIDFromChannel(chan)] _match.changePassword(password) return "Match password has been changed to a random one"
def buildFullReplay(scoreID=None, scoreData=None, rawReplay=None, relax=0): if all(v is None for v in (scoreID, scoreData)) or all( v is not None for v in (scoreID, scoreData)): raise AttributeError( "Either scoreID or scoreData must be provided, not neither or both" ) if scoreData is None: if features.MASTER_SCORE_TABLE: scoreData = glob.db.fetch( "SELECT s.*, users.username FROM scores_master as s LEFT JOIN users ON s.userid = users.id " "WHERE s.id = %s AND special_mode = %s", [scoreID, int(relax)]) else: scoreData = glob.db.fetch( f"SELECT s.*, users.username FROM {modeSwitches.score[relax]} as s LEFT JOIN users ON s.userid = users.id " "WHERE s.id = %s", [scoreID]) else: scoreID = scoreData["id"] if scoreData is None or scoreID is None: raise exceptions.scoreNotFoundError() if rawReplay is None: # Make sure raw replay exists fileName = "{}{}/replay_{}.osr".format( glob.conf.config["server"]["replayspath"], modeSwitches.rp_folder[relax], scoreID) if not os.path.isfile(fileName): log.error('[SM{}] Trying to open {}...'.format(relax, fileName)) raise FileNotFoundError() # Read raw replay with open(fileName, "rb") as f: rawReplay = f.read() # Calculate missing replay data rank = generalUtils.getRank(int(scoreData["play_mode"]), int(scoreData["mods"]), int(scoreData["accuracy"]), int(scoreData["300_count"]), int(scoreData["100_count"]), int(scoreData["50_count"]), int(scoreData["misses_count"])) magicHash = generalUtils.stringMd5( "{}p{}o{}o{}t{}a{}r{}e{}y{}o{}u{}{}{}".format( int(scoreData["100_count"]) + int(scoreData["300_count"]), scoreData["50_count"], scoreData["gekis_count"], scoreData["katus_count"], scoreData["misses_count"], scoreData["beatmap_md5"], scoreData["max_combo"], "True" if int(scoreData["full_combo"]) == 1 else "False", scoreData["username"], scoreData["score"], rank, scoreData["mods"], "True")) # Add headers (convert to full replay) fullReplay = binaryHelper.binaryWrite([ [scoreData["play_mode"], dataTypes.byte], [20150414, dataTypes.uInt32], [scoreData["beatmap_md5"], dataTypes.string], [scoreData["username"], dataTypes.string], [magicHash, dataTypes.string], [scoreData["300_count"], dataTypes.uInt16], [scoreData["100_count"], dataTypes.uInt16], [scoreData["50_count"], dataTypes.uInt16], [scoreData["gekis_count"], dataTypes.uInt16], [scoreData["katus_count"], dataTypes.uInt16], [scoreData["misses_count"], dataTypes.uInt16], [scoreData["score"], dataTypes.uInt32], [scoreData["max_combo"], dataTypes.uInt16], [scoreData["full_combo"], dataTypes.byte], [scoreData["mods"], dataTypes.uInt32], [0, dataTypes.byte], [generalHelper.toDotTicks(int(scoreData["time"])), dataTypes.uInt64], [rawReplay, dataTypes.rawReplay], [0, dataTypes.uInt32], [scoreData['id'], dataTypes.uInt64], ]) # Return full replay return fullReplay
def asyncGet(self, replayID): try: # Make sure the score exists scoreData = glob.db.fetch( "SELECT scores.*, users.username FROM scores LEFT JOIN users ON scores.userid = users.id WHERE scores.id = %s", [replayID]) if scoreData is None: raise exceptions.fileNotFoundException(MODULE_NAME, replayID) # Make sure raw replay exists fileName = ".data/replays/replay_{}.osr".format(replayID) if not os.path.isfile(fileName): raise exceptions.fileNotFoundException(MODULE_NAME, fileName) # Read raw replay with open(fileName, "rb") as f: rawReplay = f.read() # Calculate missing replay data rank = generalUtils.getRank(int(scoreData["play_mode"]), int(scoreData["mods"]), int(scoreData["accuracy"]), int(scoreData["300_count"]), int(scoreData["100_count"]), int(scoreData["50_count"]), int(scoreData["misses_count"])) magicHash = generalUtils.stringMd5( "{}p{}o{}o{}t{}a{}r{}e{}y{}o{}u{}{}{}".format( int(scoreData["100_count"]) + int(scoreData["300_count"]), scoreData["50_count"], scoreData["gekis_count"], scoreData["katus_count"], scoreData["misses_count"], scoreData["beatmap_md5"], scoreData["max_combo"], "True" if int(scoreData["full_combo"]) == 1 else "False", scoreData["username"], scoreData["score"], rank, scoreData["mods"], "True")) # Add headers (convert to full replay) fullReplay = binaryHelper.binaryWrite([ [scoreData["play_mode"], dataTypes.byte], [20150414, dataTypes.uInt32], [scoreData["beatmap_md5"], dataTypes.string], [scoreData["username"], dataTypes.string], [magicHash, dataTypes.string], [scoreData["300_count"], dataTypes.uInt16], [scoreData["100_count"], dataTypes.uInt16], [scoreData["50_count"], dataTypes.uInt16], [scoreData["gekis_count"], dataTypes.uInt16], [scoreData["katus_count"], dataTypes.uInt16], [scoreData["misses_count"], dataTypes.uInt16], [scoreData["score"], dataTypes.uInt32], [scoreData["max_combo"], dataTypes.uInt16], [scoreData["full_combo"], dataTypes.byte], [scoreData["mods"], dataTypes.uInt32], [0, dataTypes.byte], [ int((scoreData["time"] * 10000000) + 621355968000000000), dataTypes.uInt64 ], [rawReplay, dataTypes.rawReplay], [0, dataTypes.uInt32], [0, dataTypes.uInt32], ]) # Serve full replay self.write(fullReplay) self.add_header("Content-type", "application/octet-stream") self.set_header("Content-length", len(fullReplay)) self.set_header("Content-Description", "File Transfer") self.set_header( "Content-Disposition", "attachment; filename=\"{}.osr\"".format(scoreData["id"])) except exceptions.fileNotFoundException: self.write("Replay not found")
def buildFullReplay(scoreID=None, scoreData=None, rawReplay=None): if all(v is None for v in (scoreID, scoreData)) or all( v is not None for v in (scoreID, scoreData)): raise AttributeError( "Either scoreID or scoreData must be provided, not neither or both" ) mode = 0 # TODO: Implement better way to handle this if scoreData is None: scoreData = glob.db.fetch( "SELECT osu_scores_high.*, phpbb_users.username FROM osu_scores_high LEFT JOIN phpbb_users ON osu_scores_high.user_id = phpbb_users.user_id " "WHERE osu_scores_high.score_id = %s", [scoreID]) if scoreData is None: mode = 1 scoreData = glob.db.fetch( "SELECT osu_scores_taiko_high.*, phpbb_users.username FROM osu_scores_taiko_high LEFT JOIN phpbb_users ON osu_scores_taiko_high.user_id = phpbb_users.user_id " "WHERE osu_scores_taiko_high.score_id = %s", [scoreID]) if scoreData is None: mode = 2 scoreData = glob.db.fetch( "SELECT osu_scores_fruits_high.*, phpbb_users.username FROM osu_scores_fruits_high LEFT JOIN phpbb_users ON osu_scores_fruits_high.user_id = phpbb_users.user_id " "WHERE osu_scores_fruits_high.score_id = %s", [scoreID]) if scoreData is None: mode = 3 scoreData = glob.db.fetch( "SELECT osu_scores_mania_high.*, phpbb_users.username FROM osu_scores_mania_high LEFT JOIN phpbb_users ON osu_scores_mania_high.user_id = phpbb_users.user_id " "WHERE osu_scores_mania_high.score_id = %s", [scoreID]) else: scoreID = scoreData["id"] if scoreData is None or scoreID is None: raise exceptions.scoreNotFoundError() scoreID = int(scoreID) if rawReplay is None: rawReplay = getRawReplayS3(scoreID) # Calculate missing replay data rank = generalUtils.getRank(int(mode), int(scoreData["mods"]), int(scoreData["accuracy"]), int(scoreData["count300"]), int(scoreData["count100"]), int(scoreData["count50"]), int(scoreData["countmiss"])) checksum = glob.db.fetch( "SELECT checksum FROM osu_beatmaps WHERE beatmap_id = %s LIMIT 1", (scoreData["beatmap_id"])) magicHash = generalUtils.stringMd5( "{}p{}o{}o{}t{}a{}r{}e{}y{}o{}u{}{}{}".format( int(scoreData["count100"]) + int(scoreData["count300"]), scoreData["count50"], scoreData["countgeki"], scoreData["countkatu"], scoreData["countmiss"], checksum, scoreData["maxcombo"], "True" if int(scoreData["perfect"]) == 1 else "False", # TODO: check whether full combo or not (or "perfect" means "full combo"?) scoreData["username"], scoreData["score"], rank, scoreData["enabled_mods"], "True")) # Add headers (convert to full replay) fullReplay = binaryHelper.binaryWrite([ [mode, dataTypes.byte], [20150414, dataTypes.uInt32], [scoreData["checksum"], dataTypes.string], [scoreData["username"], dataTypes.string], [magicHash, dataTypes.string], [scoreData["count300"], dataTypes.uInt16], [scoreData["count100"], dataTypes.uInt16], [scoreData["count50"], dataTypes.uInt16], [scoreData["countgeki"], dataTypes.uInt16], [scoreData["countkatu"], dataTypes.uInt16], [scoreData["countmiss"], dataTypes.uInt16], [scoreData["score"], dataTypes.uInt32], [scoreData["maxcombo"], dataTypes.uInt16], [scoreData["perfect"], dataTypes.byte], [scoreData["enabled_mods"], dataTypes.uInt32], [0, dataTypes.byte], [toDotTicks(int(scoreData["date"])), dataTypes.uInt64], [rawReplay, dataTypes.rawReplay], [0, dataTypes.uInt32], [0, dataTypes.uInt32], ]) # Return full replay return fullReplay
def randomPassword(response, token, sender, channel, message): password = generalUtils.stringMd5(generalUtils.randomString(32)) _match = getCurrentMatch(channel) _match.changePassword(password) response.setContent(token, "Match password has been changed to a random one")
def handle(userToken, packetData): # Read new settings packetData = clientPackets.changeMatchSettings(packetData) # Get match ID matchID = userToken.matchID # Make sure the match exists if matchID not in glob.matches.matches: return # Host check with glob.matches.matches[matchID] as match: if userToken.userID != match.hostUserID: return # Some dank memes easter egg memeTitles = [ "OWC 2020", "AC is a duck", "Dank memes", "1337ms Ping", "Iscriviti a Xenotoze", "...e i marĂ²?", "Superman dies", "The brace is on fire", "print_foot()", "#FREEZEBARKEZ", "osu!thailand devs are actually cats", "Thank Mr Shaural", "NEVER GIVE UP", "T I E D W I T H U N I T E D", "HIGHEST HDHR LOBBY OF ALL TIME", "This is gasoline and I set myself on fire", "Everyone is cheating apparently", "Kurwa mac", "TATOE", "This is not your drama landfill.", "I like cheese", "AOBA IS NOT A CAT HE IS A DO(N)G", "YAMI NI NOMARE YO" ] # Set match name match.matchName = packetData["matchName"] if packetData["matchName"] != "meme" else random.choice(memeTitles) # Update match settings # NOBODY SHOULD INTRUDE A SINGLE PLAYER MATCH AFTER ALL (tempfix) inProgress = bool(packetData["inProgress"]) slotTaken = [slot for slot in match.slots if slot.status & slotStatuses.OCCUPIED] slotPlay = [slot for slot in slotTaken if slot.status & slotStatuses.PLAYING] # log.info("MPROOM{}: ProgPkt({}) SlotPlay({} left)".format(match.matchID,inProgress,len(slotPlay))) if len(slotTaken) <= 1: match.inProgress = False else: match.inProgress = len(slotPlay) > 0 and inProgress if packetData["matchPassword"] != "": match.matchPassword = generalUtils.stringMd5(packetData["matchPassword"]) else: match.matchPassword = "" match.beatmapName = packetData["beatmapName"] match.beatmapID = packetData["beatmapID"] match.hostUserID = packetData["hostUserID"] match.gameMode = packetData["gameMode"] oldBeatmapMD5 = match.beatmapMD5 oldMods = match.mods oldMatchTeamType = match.matchTeamType match.mods = packetData["mods"] match.beatmapMD5 = packetData["beatmapMD5"] match.matchScoringType = packetData["scoringType"] match.matchTeamType = packetData["teamType"] match.matchModMode = packetData["multiSpecial"] # Reset ready if needed if oldMods != match.mods or oldBeatmapMD5 != match.beatmapMD5: match.resetReady() # Reset mods if needed if match.matchModMode & matchModModes.FREE_MOD: # TODO: Implement a FREEMOD barrier configuration # which works as follows: # - turn off all FM mods on main mods # - turn only FM mods on personal/player's free mods # match.mods = 0 if match.freeModHandler == matchFreeModTypes.datenshi: for i, slot in zip(range(len(match.slots)), match.slots): slot.mods = packetData['slot{}Mods'.format(i)] else: match.mods = match.mods & ~mods.FM for i, slot in zip(range(len(match.slots)), match.slots): #if match.hostUserID == 3: # log.info("MPROOM{} - Slot {} Mods {}".format(match.matchID, i + 1, slot.mods)) slot.mods = packetData['slot{}Mods'.format(i)] & mods.FM else: # Synchronize mods if it's no FM for i, slot in zip(range(len(match.slots)), match.slots): slot.mods = match.mods match.seed = packetData['seed'] # Initialize teams if team type changed if match.matchTeamType != oldMatchTeamType: match.initializeTeams() # Force no freemods if tag coop # if match.matchTeamType == matchTeamTypes.TAG_COOP or match.matchTeamType == matchTeamTypes.TAG_TEAM_VS: # match.matchModMode = matchModModes.NORMAL # Send updated settings match.sendUpdates() # Console output log.info("MPROOM{}: Updated room settings".format(match.matchID))
def handle(userToken, packetData): # Read new settings packetData = clientPackets.changeMatchSettings(packetData) # Get match ID matchID = userToken.matchID # Make sure the match exists if matchID not in glob.matches.matches: return # Host check with glob.matches.matches[matchID] as match: if userToken.userID != match.hostUserID: return # Realistik was her memeTitles = [ "I hate boxes", "this text is funny", "Hit kids not juul", "dark is the best osu! player", "I'm spiderman", "DING DONG", "matt from wii sports", "Intel is an expensive space heater brand", "she so shiny", "im a freaking ferrari", "Welp shouldnt have bought that switch then", "RealistikBot hot" ] # Set match name match.matchName = packetData["matchName"] if packetData[ "matchName"] != "meme" else random.choice(memeTitles) # Update match settings match.inProgress = packetData["inProgress"] if packetData["matchPassword"] != "": match.matchPassword = generalUtils.stringMd5( packetData["matchPassword"]) else: match.matchPassword = "" match.beatmapName = packetData["beatmapName"] match.beatmapID = packetData["beatmapID"] match.hostUserID = packetData["hostUserID"] match.gameMode = packetData["gameMode"] oldBeatmapMD5 = match.beatmapMD5 oldMods = match.mods oldMatchTeamType = match.matchTeamType match.mods = packetData["mods"] match.beatmapMD5 = packetData["beatmapMD5"] match.matchScoringType = packetData["scoringType"] match.matchTeamType = packetData["teamType"] match.matchModMode = packetData["freeMods"] # Reset ready if needed if oldMods != match.mods or oldBeatmapMD5 != match.beatmapMD5: match.resetReady() # Reset mods if needed if match.matchModMode == matchModModes.NORMAL: # Reset slot mods if not freeMods match.resetMods() else: # Reset match mods if freemod match.mods = 0 # Initialize teams if team type changed if match.matchTeamType != oldMatchTeamType: match.initializeTeams() # Force no freemods if tag coop if match.matchTeamType == matchTeamTypes.TAG_COOP or match.matchTeamType == matchTeamTypes.TAG_TEAM_VS: match.matchModMode = matchModModes.NORMAL # Send updated settings match.sendUpdates() # Console output log.info("MPROOM{}: Updated room settings".format(match.matchID))
def handle(userToken, packetData): # Read new settings packetData = clientPackets.changeMatchSettings(packetData) # Get match ID matchID = userToken.matchID # Make sure the match exists if matchID not in glob.matches.matches: return # Host check with glob.matches.matches[matchID] as match: if userToken.userID != match.hostUserID or userToken.userID != match.tourneyHost: return # Some dank memes easter egg memeTitles = [ "KWC 2020", "Crystal is a duck", "Dank memes", "1337ms Ping", "Superman dies", "The brace is on fire", "70 points", "print_foot()", "Ripple devs are actually suckers", "NEVER GIVE UP AND GIVE UP", "HIGHEST HDHR LOBBY OF ALL TIME", "Everyone is cheating apparently", "When hqosu player join Kurikku, he automaticly leaves :fact:" "Kurwa mac", "TATOE", "This is not your drama landfill.", "Cmyui likes 70000 code lines" ] # Set match name match.matchName = packetData["matchName"] if packetData[ "matchName"] != "meme" else random.choice(memeTitles) # Update match settings match.inProgress = packetData["inProgress"] if packetData["matchPassword"] != "": match.matchPassword = generalUtils.stringMd5( packetData["matchPassword"]) else: match.matchPassword = "" match.beatmapName = packetData["beatmapName"] match.beatmapID = packetData["beatmapID"] match.hostUserID = packetData["hostUserID"] match.gameMode = packetData["gameMode"] oldBeatmapMD5 = match.beatmapMD5 oldMods = match.mods oldMatchTeamType = match.matchTeamType match.mods = packetData["mods"] match.beatmapMD5 = packetData["beatmapMD5"] match.matchScoringType = packetData["scoringType"] match.matchTeamType = packetData["teamType"] match.matchModMode = packetData["freeMods"] # Reset ready if needed if oldMods != match.mods or oldBeatmapMD5 != match.beatmapMD5: match.resetReady() # Reset mods if needed if match.matchModMode == matchModModes.NORMAL: # Reset slot mods if not freeMods match.resetMods() else: # Reset match mods if freemod match.mods = 0 # Initialize teams if team type changed if match.matchTeamType != oldMatchTeamType: match.initializeTeams() # Force no freemods if tag coop if match.matchTeamType == matchTeamTypes.TAG_COOP or match.matchTeamType == matchTeamTypes.TAG_TEAM_VS: match.matchModMode = matchModModes.NORMAL # Send updated settings match.sendUpdates() # Console output log.info("MPROOM{}: Updated room settings".format(match.matchID))
def handle(userToken, packetData): # Read new settings packetData = clientPackets.changeMatchSettings(packetData) # Get match ID matchID = userToken.matchID # Make sure the match exists if matchID not in glob.matches.matches: return # Host check with glob.matches.matches[matchID] as match: if userToken.userID != match.hostUserID: return # Some dank memes easter egg memeTitles = [ "Ain't rape if you enjoy it." ] # Set match name match.matchName = packetData["matchName"] if packetData["matchName"] != "meme" else random.choice(memeTitles) # Update match settings match.inProgress = packetData["inProgress"] if packetData["matchPassword"] != "": match.matchPassword = generalUtils.stringMd5(packetData["matchPassword"]) else: match.matchPassword = "" match.beatmapName = packetData["beatmapName"] match.beatmapID = packetData["beatmapID"] match.hostUserID = packetData["hostUserID"] match.gameMode = packetData["gameMode"] oldBeatmapMD5 = match.beatmapMD5 oldMods = match.mods oldMatchTeamType = match.matchTeamType match.mods = packetData["mods"] match.beatmapMD5 = packetData["beatmapMD5"] match.matchScoringType = packetData["scoringType"] match.matchTeamType = packetData["teamType"] match.matchModMode = packetData["freeMods"] # Reset ready if needed if oldMods != match.mods or oldBeatmapMD5 != match.beatmapMD5: match.resetReady() # Reset mods if needed if match.matchModMode == matchModModes.NORMAL: # Reset slot mods if not freeMods match.resetMods() else: # Reset match mods if freemod match.mods = 0 # Initialize teams if team type changed if match.matchTeamType != oldMatchTeamType: match.initializeTeams() # Force no freemods if tag coop if match.matchTeamType == matchTeamTypes.TAG_COOP or match.matchTeamType == matchTeamTypes.TAG_TEAM_VS: match.matchModMode = matchModModes.NORMAL # Send updated settings match.sendUpdates() # Console output log.info("MPROOM{}: Updated room settings".format(match.matchID))
with open(fileName, "rb") as f: rawReplay = f.read() # Calculate missing replay data rank = generalUtils.getRank(int(scoreData["play_mode"]), int(scoreData["mods"]), int(scoreData["accuracy"]), int(scoreData["300_count"]), int(scoreData["100_count"]), int(scoreData["50_count"]), int(scoreData["misses_count"])) magicHash = generalUtils.stringMd5( "{}p{}o{}o{}t{}a{}r{}e{}y{}o{}u{}{}{}".format( int(scoreData["100_count"]) + int(scoreData["300_count"]), scoreData["50_count"], scoreData["gekis_count"], scoreData["katus_count"], scoreData["misses_count"], scoreData["beatmap_md5"], scoreData["max_combo"], "True" if int(scoreData["full_combo"]) == 1 else "False", scoreData["username"], scoreData["score"], rank, scoreData["mods"], "True")) # Add headers (convert to full replay) fullReplay = binaryHelper.binaryWrite([ [scoreData["play_mode"], dataTypes.byte], [20150414, dataTypes.uInt32], [scoreData["beatmap_md5"], dataTypes.string], [scoreData["username"], dataTypes.string], [magicHash, dataTypes.string], [scoreData["300_count"], dataTypes.uInt16], [scoreData["100_count"], dataTypes.uInt16], [scoreData["50_count"], dataTypes.uInt16], [scoreData["gekis_count"], dataTypes.uInt16],