def puzzle_solution(puzzle_id): if app.config["SITE_MODE"] != 'solution': abort(403) puzzle_visibility_async = cube.get_puzzle_visibility_async(app, puzzle_id) core_team_properties_async = cube.get_team_properties_async(app) puzzle_async = cube.get_puzzle_async(app, puzzle_id) puzzle_visibility = puzzle_visibility_async.result().json() if puzzle_visibility['status'] not in ['UNLOCKED', 'SOLVED']: abort(403) core_display_data = make_core_display_data(core_team_properties_async) puzzle = puzzle_async.result().json() canonical_puzzle_id = puzzle.get('puzzleId') puzzle_round_id = [ r_id for r_id, round_puzzle_ids in ROUND_PUZZLE_MAP.iteritems() if canonical_puzzle_id in round_puzzle_ids ] puzzle_round_id = puzzle_round_id[0] if len(puzzle_round_id) > 0 else None emotions = puzzle.get('puzzleProperties', {}).get('EmotionsProperty', {}).get('emotions', []) with metrics.timer("present.puzzle_render"): return render_template("solutions/%s.html" % puzzle_id, core_display_data=core_display_data, is_hunt_started=True, puzzle_id=puzzle_id, puzzle_round_id=puzzle_round_id, emotions=emotions, puzzle=puzzle, puzzle_visibility=puzzle_visibility, solution=True)
def activity_log(): is_hunt_started_async = cube.is_hunt_started_async(app) core_team_properties_async = cube.get_team_properties_async(app) team_visibility_changes_async = cube.get_team_visibility_changes_async(app) team_submissions_async = cube.get_team_submissions_async(app) all_puzzles_async = cube.get_all_puzzle_properties_async(app) is_hunt_started = is_hunt_started_async.result() core_display_data = make_core_display_data(core_team_properties_async) visibility_changes = [ vc for vc in team_visibility_changes_async.result() if vc["status"] in ['UNLOCKED', 'SOLVED'] ] activity_entries = visibility_changes + team_submissions_async.result() activity_entries.sort(key=lambda entry: entry["timestamp"], reverse=True) all_puzzles = { v["puzzleId"]: v for v in all_puzzles_async.result().json()["puzzles"] } interactions_and_finales = [v["puzzleId"] for v in []] r = make_response( render_template("activity_log.html", core_display_data=core_display_data, is_hunt_started=is_hunt_started, activity_entries=activity_entries, all_puzzles=all_puzzles, interactions_and_finales=interactions_and_finales)) r.headers.set('Cache-Control', 'private, max-age=0, no-cache, no-store') return r
def puzzle_list(): if not cube.is_hunt_started_async(app).result(): abort(403) core_team_properties_async = cube.get_team_properties_async(app) all_visibilities_async = cube.get_puzzle_visibilities_async(app) all_puzzles_async = cube.get_all_puzzle_properties_async(app) core_display_data = make_core_display_data(core_team_properties_async) all_visibilities = { v["puzzleId"]: v for v in all_visibilities_async.result().json()["visibilities"] } all_puzzles = { v["puzzleId"]: v for v in all_puzzles_async.result().json()["puzzles"] } with metrics.timer("present.puzzle_list_render"): r = make_response( render_template( "puzzle_list.html", core_display_data=core_display_data, is_hunt_started=True, all_visibilities=all_visibilities, all_puzzles=all_puzzles, round_puzzle_map=ROUND_PUZZLE_MAP, )) r.headers.set('Cache-Control', 'private, max-age=0, no-cache, no-store') return r
def puzzle_list(): if not cube.is_hunt_started_async(app).result(): abort(403) core_visibilities_async = cube.get_puzzle_visibilities_for_list_async( app, CHARACTER_IDS + QUEST_IDS + ['merchants', 'battle']) core_team_properties_async = cube.get_team_properties_async(app) all_visibilities_async = cube.get_puzzle_visibilities_async(app) all_puzzles_async = cube.get_all_puzzle_properties_async(app) core_display_data = make_core_display_data(core_visibilities_async, core_team_properties_async) all_visibilities = { v["puzzleId"]: v for v in all_visibilities_async.result().json()["visibilities"] } all_puzzles = { v["puzzleId"]: v for v in all_puzzles_async.result().json()["puzzles"] } with metrics.timer("present.puzzle_list_render"): return render_template("puzzle_list.html", core_display_data=core_display_data, all_visibilities=all_visibilities, all_puzzles=all_puzzles, round_puzzle_map=ROUND_PUZZLE_MAP)
def activity_log(): core_visibilities_async = cube.get_puzzle_visibilities_for_list_async( app, CHARACTER_IDS + QUEST_IDS + ['merchants', 'battle']) core_team_properties_async = cube.get_team_properties_async(app) team_visibility_changes_async = cube.get_team_visibility_changes_async(app) team_submissions_async = cube.get_team_submissions_async(app) all_puzzles_async = cube.get_all_puzzle_properties_async(app) core_display_data = make_core_display_data(core_visibilities_async, core_team_properties_async) visibility_changes = [ vc for vc in team_visibility_changes_async.result() if vc["status"] in ['UNLOCKED', 'SOLVED'] and not vc["puzzleId"].startswith("event") ] activity_entries = visibility_changes + team_submissions_async.result() activity_entries.sort(key=lambda entry: entry["timestamp"], reverse=True) all_puzzles = { v["puzzleId"]: v for v in all_puzzles_async.result().json()["puzzles"] } return render_template("activity_log.html", core_display_data=core_display_data, activity_entries=activity_entries, all_puzzles=all_puzzles)
def puzzle_solution(puzzle_id): if app.config["SITE_MODE"] != 'solution': abort(403) puzzle_visibility_async = cube.get_puzzle_visibility_async(app, puzzle_id) core_visibilities_async = cube.get_puzzle_visibilities_for_list_async( app, CHARACTER_IDS + QUEST_IDS + ['merchants', 'battle']) core_team_properties_async = cube.get_team_properties_async(app) puzzle_async = cube.get_puzzle_async(app, puzzle_id) puzzle_visibility = puzzle_visibility_async.result().json() if puzzle_visibility['status'] not in ['UNLOCKED', 'SOLVED']: abort(403) core_display_data = make_core_display_data(core_visibilities_async, core_team_properties_async) puzzle = puzzle_async.result().json() canonical_puzzle_id = puzzle.get('puzzleId') puzzle_round_id = [ r_id for r_id, round_puzzle_ids in ROUND_PUZZLE_MAP.iteritems() if canonical_puzzle_id in round_puzzle_ids ] puzzle_round_id = puzzle_round_id[0] if len(puzzle_round_id) > 0 else None with metrics.timer("present.puzzle_render"): return render_template("solutions/%s.html" % puzzle_id, core_display_data=core_display_data, puzzle_id=puzzle_id, puzzle_round_id=puzzle_round_id, puzzle=puzzle, puzzle_visibility=puzzle_visibility)
def round(round_id): round_puzzle_ids = ROUND_PUZZLE_MAP.get(round_id, []) + [round_id] round_visibility_async = cube.get_puzzle_visibility_async(app, round_id) core_visibilities_async = cube.get_puzzle_visibilities_for_list_async( app, CHARACTER_IDS + QUEST_IDS + ['merchants', 'battle']) core_team_properties_async = cube.get_team_properties_async(app) puzzle_visibilities_async = cube.get_puzzle_visibilities_for_list_async( app, round_puzzle_ids) puzzle_properties_async = cube.get_all_puzzle_properties_for_list_async( app, round_puzzle_ids) round_visibility = round_visibility_async.result().json() if round_visibility['status'] not in ['UNLOCKED', 'SOLVED']: abort(403) core_display_data = make_core_display_data(core_visibilities_async, core_team_properties_async) puzzle_visibilities = { v["puzzleId"]: v for v in puzzle_visibilities_async.result().json().get( "visibilities", []) } puzzle_properties = { puzzle.get('puzzleId'): puzzle for puzzle in puzzle_properties_async.result().json().get( 'puzzles', []) } with metrics.timer("present.round_render"): return render_template("rounds/%s.html" % round_id, core_display_data=core_display_data, round_id=round_id, puzzle_properties=puzzle_properties, puzzle_visibilities=puzzle_visibilities)
def sponsors(): is_hunt_started_async = cube.is_hunt_started_async(app) core_team_properties_async = cube.get_team_properties_async(app) core_display_data = make_core_display_data(core_team_properties_async) return render_template("sponsors.html", core_display_data=core_display_data, is_hunt_started=is_hunt_started_async.result())
def credits(): if app.config["SITE_MODE"] != 'solution': abort(403) core_team_properties_async = cube.get_team_properties_async(app) is_hunt_started_async = cube.is_hunt_started_async(app) core_display_data = make_core_display_data(core_team_properties_async) return render_template("credits.html", core_display_data=core_display_data, is_hunt_started=is_hunt_started_async.result())
def inventory(): if not cube.is_hunt_started_async(app).result(): abort(403) core_visibilities_async = cube.get_puzzle_visibilities_for_list_async( app, CHARACTER_IDS + QUEST_IDS + ['merchants', 'battle']) core_team_properties_async = cube.get_team_properties_async(app) core_display_data = make_core_display_data(core_visibilities_async, core_team_properties_async) return render_template("inventory.html", core_display_data=core_display_data)
def safety(): is_hunt_started_async = cube.is_hunt_started_async(app) core_visibilities_async = cube.get_puzzle_visibilities_for_list_async( app, CHARACTER_IDS + QUEST_IDS + ['merchants', 'battle']) core_team_properties_async = cube.get_team_properties_async(app) if is_hunt_started_async.result(): core_display_data = make_core_display_data(core_visibilities_async, core_team_properties_async) return render_template("safety.html", core_display_data=core_display_data) else: return render_template("safety.html")
def index(): if not cube.is_hunt_started_async(app).result(): return prehunt_index() round_puzzle_ids = ROUND_PUZZLE_MAP.get('index') core_visibilities_async = cube.get_puzzle_visibilities_for_list_async( app, CHARACTER_IDS + QUEST_IDS + ['merchants', 'battle']) core_team_properties_async = cube.get_team_properties_async(app) puzzle_visibilities_async = cube.get_puzzle_visibilities_for_list_async( app, round_puzzle_ids) puzzle_properties_async = cube.get_all_puzzle_properties_for_list_async( app, round_puzzle_ids) core_display_data = make_core_display_data(core_visibilities_async, core_team_properties_async) puzzle_visibilities = { v["puzzleId"]: v for v in puzzle_visibilities_async.result().json().get( "visibilities", []) } puzzle_properties = { puzzle.get('puzzleId'): puzzle for puzzle in puzzle_properties_async.result().json().get( 'puzzles', []) } visible_puzzle_ids = set([ key for key in puzzle_visibilities if puzzle_visibilities.get(key, {}).get('status', '') != 'INVISIBLE' ]) fog_number = len([map_item for map_item in \ ['dynast','dungeon','thespians','bridge','criminal','minstrels','cube','warlord','rescue_the_linguist','rescue_the_chemist','rescue_the_economist','merchants','fortress']\ if map_item in visible_puzzle_ids]) with metrics.timer("present.index_render"): return render_template("index.html", core_display_data=core_display_data, visible_puzzle_ids=visible_puzzle_ids, fog_number=fog_number, puzzle_visibilities=puzzle_visibilities)
def index(): core_team_properties_async = cube.get_team_properties_async(app) is_hunt_started_async = cube.is_hunt_started_async(app) core_display_data = make_core_display_data(core_team_properties_async) if not is_hunt_started_async.result(): return prehunt_index(core_display_data=core_display_data) round_puzzle_ids = ROUND_PUZZLE_MAP.get('round1') puzzle_visibilities_async = cube.get_puzzle_visibilities_for_list_async( app, round_puzzle_ids) puzzle_properties_async = cube.get_all_puzzle_properties_for_list_async( app, round_puzzle_ids) puzzle_visibilities = { v["puzzleId"]: v for v in puzzle_visibilities_async.result().json().get( "visibilities", []) } puzzle_properties = { puzzle.get('puzzleId'): puzzle for puzzle in puzzle_properties_async.result().json().get( 'puzzles', []) } with metrics.timer("present.index_render"): r = make_response( render_template("index.html", core_display_data=core_display_data, is_hunt_started=True, puzzle_properties=puzzle_properties, puzzle_visibilities=puzzle_visibilities)) r.headers.set('Cache-Control', 'private, max-age=0, no-cache, no-store') return r
def objectives(): is_hunt_started_async = cube.is_hunt_started_async(app) objective_visibilities_async = cube.get_puzzle_visibilities_for_list_async( app, []) puzzle_properties_async = cube.get_all_puzzle_properties_for_list_async( app, ALL_PUZZLES) core_team_properties_async = cube.get_team_properties_async(app) core_display_data = make_core_display_data(core_team_properties_async) if is_hunt_started_async.result(): is_hunt_started = True objective_visibilities = { r['puzzleId']: r for r in objective_visibilities_async.result().json() ['visibilities'] } puzzle_properties = { puzzle.get('puzzleId'): puzzle for puzzle in puzzle_properties_async.result().json().get( 'puzzles', []) } else: is_hunt_started = False objective_visibilities = {} puzzle_properties = {} objective_visibilities = collections.defaultdict( lambda: {'status': 'INVISIBLE'}, objective_visibilities) statuses = {p: objective_visibilities[p]['status'] for p in []} answers = { p: ', '.join(objective_visibilities[p].get('solvedAnswers', [])) for p in [] } puzzle_properties = { puzzle.get('puzzleId'): puzzle for puzzle in puzzle_properties_async.result().json().get( 'puzzles', []) } names = { p: puzzle_properties.get(p, {}).get('puzzleProperties', {}).get('DisplayNameProperty', {}).get('displayName', '') for p in [] } display_ids = { p: puzzle_properties.get(p, {}).get('puzzleProperties', {}).get('DisplayIdProperty', {}).get('displayId', '') for p in [] } def count_solved(puzzles): return sum(1 for p in puzzles if statuses[p] == 'SOLVED') # Much less messy to calculate these here than inside templates counts = {} r = make_response( render_template("mission_objectives.html", core_display_data=core_display_data, names=names, display_ids=display_ids, is_hunt_started=is_hunt_started, counts=counts, statuses=statuses, answers=answers)) r.headers.set('Cache-Control', 'private, max-age=0, no-cache, no-store') return r
def puzzle(puzzle_id): puzzle_visibility_async = cube.get_puzzle_visibility_async(app, puzzle_id) core_team_properties_async = cube.get_team_properties_async(app) puzzle_async = cube.get_puzzle_async(app, puzzle_id) puzzle_visibility = puzzle_visibility_async.result().json() if puzzle_visibility['status'] not in [ 'UNLOCKED', 'SOLVED' ] and app.config["SITE_MODE"] != 'solution': abort(403) interactions_and_finales_async = cube.get_all_puzzle_properties_for_list_async( app, []) interactions_finales = interactions_and_finales_async.result().json().get( "puzzles") interactions_finales = {v["puzzleId"]: v for v in interactions_finales} interactions_finales = [ interactions_finales[interaction_finale].get( 'puzzleProperties', {}).get('DisplayIdProperty', {}).get('displayId', interaction_finale) for interaction_finale in interactions_finales ] if puzzle_id in interactions_finales and app.config[ "SITE_MODE"] != 'solution': abort(403) core_display_data = make_core_display_data(core_team_properties_async) puzzle = puzzle_async.result().json() # This pretends to be generic, but is actually just used for the Pokemon submetas feeders_solved = [] feeder_properties = {} feeders = puzzle.get('puzzleProperties', {}).get('FeedersProperty', {}).get('feeders', []) if feeders: feeder_properties_async = cube.get_all_puzzle_properties_for_list_async( app, feeders) feeder_visibility_async = cube.get_puzzle_visibilities_for_list_async( app, feeders) feeder_properties = { v['puzzleId']: v for v in feeder_properties_async.result().json().get( 'puzzles', []) } feeders_solved = [ v['puzzleId'] for v in feeder_visibility_async.result().json().get( 'visibilities', []) if v['status'] == 'SOLVED' ] feeders_solved.sort(key=lambda puzzleId: feeder_properties[puzzleId]. get('SymbolProperty', {}).get('symbol', '')) canonical_puzzle_id = puzzle.get('puzzleId') puzzle_round_id = [ r_id for r_id, round_puzzle_ids in ROUND_PUZZLE_MAP.iteritems() if canonical_puzzle_id in round_puzzle_ids ] puzzle_round_id = puzzle_round_id[0] if len(puzzle_round_id) > 0 else None emotions = puzzle.get('puzzleProperties', {}).get('EmotionsProperty', {}).get('emotions', []) pages_without_solutions_async = cube.get_all_puzzle_properties_for_list_async( app, []) pages_without_solutions = [ v.get('puzzleProperties', {}).get('DisplayIdProperty', {}).get('displayId', '') for v in pages_without_solutions_async.result().json().get( "puzzles", []) ] with metrics.timer("present.puzzle_render"): r = make_response( render_template("puzzles/%s.html" % puzzle_id, core_display_data=core_display_data, is_hunt_started=True, puzzle_id=puzzle_id, puzzle_round_id=puzzle_round_id, emotions=emotions, puzzle=puzzle, interactions_finales=interactions_finales, puzzle_visibility=puzzle_visibility, pages_without_solutions=pages_without_solutions, feeders_solved=feeders_solved, feeder_count=len(feeders), feeder_properties=feeder_properties)) r.headers.set('Cache-Control', 'private, max-age=0, no-cache, no-store') return r