コード例 #1
0
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)
コード例 #2
0
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
コード例 #3
0
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)
コード例 #4
0
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)
コード例 #5
0
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)
コード例 #6
0
def puzzletoken(puzzle_id):
    puzzle_visibility_async = cube.get_puzzle_visibility_async(app, puzzle_id)
    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)

    puzzle = puzzle_async.result().json()

    with metrics.timer("present.puzzletoken_render"):
        return generate_puzzle_token_json(puzzle)
コード例 #7
0
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)
コード例 #8
0
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
コード例 #9
0
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