Skip to content
This repository has been archived by the owner on Jun 10, 2023. It is now read-only.

Commit

Permalink
gauntlet handler
Browse files Browse the repository at this point in the history
  • Loading branch information
RealistikDash committed Oct 6, 2020
1 parent 7549eab commit 6a43c15
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
20 changes: 19 additions & 1 deletion handlers/levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from helpers.auth import auth
from helpers.timehelper import time_since_midnight, get_timestamp
from objects.levels import SearchQuery, Level
from cron.cachempgauntlets import map_packs
from cron.cachempgauntlets import map_packs, gauntlets
from constants import XorKeys, ResponseCodes, CryptKeys
from config import user_config

Expand Down Expand Up @@ -256,3 +256,21 @@ async def get_map_packs_handler(request : aiohttp.web.Request):
response = f"{response[:-1]}#{len(map_packs)}:{offset}:10#{hashed}"
logging.debug(response)
return aiohttp.web.Response(text=response)

async def get_gauntlets_handler(request : aiohttp.web.Request):
"""Responsible for serving the guantlets to the client."""
# The Soviet Union has changed their diplomatic status on us: Declare War
# No need for postdata here.

gautnlet_resp = ""
hashed = ""
for gauntlet in gauntlets:
gautnlet_resp += joint_string({
1 : gauntlet.ID,
3 : list_comma_string(gauntlet.level_list())
}) + "|"
hashed += str(gauntlet.ID) + list_comma_string(gauntlet.level_list())

response = f"{gautnlet_resp[:-1]}#{level_helper.solo_gen2(hashed)}"
logging.debug(response)
return aiohttp.web.Response(text=response)
3 changes: 2 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from handlers.register import register_handler
from handlers.profiles import profile_comment_handler, profile_handler, user_search_handler, post_account_comment_handler, update_profile_stats_handler, get_account_url_handler, save_user_data_handler, load_save_data_handler, update_acc_settings_handler, leaderboards_handler, mod_check_handler
from handlers.songs import featured_artists_handler, get_songinfo_handler
from handlers.levels import level_search_modular_hanlder, download_level, upload_level_handler, get_daily_handler, get_map_packs_handler
from handlers.levels import level_search_modular_hanlder, download_level, upload_level_handler, get_daily_handler, get_map_packs_handler, get_gauntlets_handler
from handlers.rewards import quests_handler
from handlers.levelextras import level_comments_handler, post_comment_handler, rate_level_handler
from helpers.userhelper import user_helper
Expand Down Expand Up @@ -52,6 +52,7 @@ def config_routes(app: web.Application) -> None:
app.router.add_post("/database/requestUserAccess.php", mod_check_handler)
app.router.add_post("/database/getGJDailyLevel.php", get_daily_handler)
app.router.add_post("/database/getGJMapPacks21.php", get_map_packs_handler)
app.router.add_post("/database/getGJGauntlets21.php", get_gauntlets_handler)
#app.add_subapp("/api/", api)
app.add_subapp("/tools/", tools)

Expand Down
4 changes: 4 additions & 0 deletions objects/levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,7 @@ class Gauntlet():
level3_id : int
level4_id : int
level5_id : int

def level_list(self) -> tuple:
"""Returns a tuple of all levels inside the gauntlet."""
return (self.level1_id, self.level2_id, self.level3_id, self.level4_id, self.level5_id)

0 comments on commit 6a43c15

Please sign in to comment.