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)
Exemple #2
0
def full_objectives():
    core_display_data = get_full_path_core_display_data()
    is_hunt_started = True

    puzzle_properties_async = cube.get_all_puzzle_properties_for_list_async(
        app, ALL_PUZZLES)
    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 []
    }

    statuses = collections.defaultdict(
        lambda: request.args.get('visibility', 'SOLVED'))
    answers = {
        p: ', '.join([
            a['canonicalAnswer']
            for a in puzzle_properties.get(p, {}).get('puzzleProperties', {}).
            get('AnswersProperty', {}).get('answers', [])
        ])
        for p in []
    }

    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 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)
Exemple #4
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
Exemple #5
0
def full_puzzle(puzzle_id):
    puzzle = {
        'puzzleId': puzzle_id,
        'puzzleProperties': {
            'DisplayNameProperty': {
                'displayName': puzzle_id
            }
        },
    }
    puzzle_round_id = 'floaters'
    emotions = []
    feeders = set()
    feeder_properties = {}

    try:
        puzzle = cube.get_puzzle(app, puzzle_id)

        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', [])

        feeders = puzzle.get('puzzleProperties',
                             {}).get('FeedersProperty', {}).get('feeders', [])
        if feeders:
            feeder_properties_async = cube.get_all_puzzle_properties_for_list_async(
                app, feeders)
            feeder_properties = {
                v['puzzleId']: v
                for v in feeder_properties_async.result().json().get(
                    'puzzles', [])
            }
            feeders.sort(key=lambda puzzleId: feeder_properties[puzzleId].get(
                'puzzleProperties', {}).get('SymbolProperty', {}).get(
                    'symbol', ''))

    except HTTPError as e:
        if e.response.status_code != 404:
            raise

    core_display_data = get_full_path_core_display_data()

    pages_without_solutions_async = cube.get_all_puzzle_properties_for_list_async(
        app, ALL_PUZZLES)
    pages_without_solutions = [
        v.get('puzzleProperties', {}).get('DisplayIdProperty',
                                          {}).get('displayId', '')
        for v in pages_without_solutions_async.result().json().get(
            "puzzles", [])
    ]

    return 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,
                           puzzle_visibility={'status': 'UNLOCKED'},
                           feeders_solved=feeders,
                           feeder_count=len(feeders),
                           feeder_properties=feeder_properties,
                           pages_without_solutions=pages_without_solutions)
Exemple #6
0
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
Exemple #7
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