Beispiel #1
0
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
Beispiel #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
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)
Beispiel #4
0
def admintools():
    if request.method == "POST":
        if request.form["action"] == "HuntStart":
            cube.create_event(app, {
                "eventType": "HuntStart",
            })
        elif request.form["action"] == "FullRelease":
            cube.create_event(app, {
                "eventType": "FullRelease",
                "puzzleId": request.form["puzzleId"],
            })
        elif request.form["action"] == "FullSolve":
            cube.create_event(app, {
                "eventType": "FullSolve",
                "puzzleId": request.form["puzzleId"],
            })
        elif request.form['action'] == 'TrailingTideRelease':
            cube.create_event(
                app, {
                    'eventType': 'TrailingTideWholeIsland',
                    'islandNumber': int(request.form['islandNumber']),
                })
        else:
            abort(400)

    return render_template(
        "admintools.html",
        puzzles=get_puzzles(),
        is_hunt_started=cube.is_hunt_started_async(app).result())
Beispiel #5
0
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())
Beispiel #6
0
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)
Beispiel #10
0
def admintools():
    if request.method == "POST":
        if request.form["action"] == "HuntStart":
            cube.create_event(app, {
                "eventType": "HuntStart",
            })
        elif request.form["action"] == "FullRelease":
            cube.create_event(app, {
                "eventType": "FullRelease",
                "puzzleId": request.form["puzzleId"],
            })
        elif request.form["action"] == "FullSolve":
            cube.create_event(app, {
                "eventType": "FullSolve",
                "puzzleId": request.form["puzzleId"],
            })
        else:
            abort(400)

    return render_template(
        "admintools.html",
        puzzles=get_puzzles(),
        is_hunt_started=cube.is_hunt_started_async(app).result())
Beispiel #11
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
Beispiel #12
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
Beispiel #13
0
def team(team_id):
    if request.method == "POST":
        if request.form["action"] == "ChangeContactInfo":
            if ("email" not in request.form
                    or "primaryPhone" not in request.form
                    or "secondaryPhone" not in request.form):
                abort(400)

            update = {
                "teamId": team_id,
                "teamName": request.form["teamName"],
                "email": request.form["email"],
                "headquarters": request.form["headquarters"],
                "primaryPhone": request.form["primaryPhone"],
                "secondaryPhone": request.form["secondaryPhone"],
            }

            if request.form["password"] and (len(request.form["password"]) >
                                             0):
                update["password"] = request.form["password"]

            cube.update_team(app, team_id, update)
        elif request.form["action"] == "SetPuzzleStatus":
            if request.form["actionType"] == "Unlock":
                status = "UNLOCKED"
            elif request.form["actionType"] == "Solve":
                status = "SOLVED"
            else:
                abort(400)
            cube.update_puzzle_visibility(app, team_id,
                                          request.form["puzzleId"], status)
        elif request.form["action"] == "GrantScore":
            cube.create_event(
                app, {
                    "eventType": "GrantScore",
                    "teamId": team_id,
                    "scoreType": request.form['scoreType'],
                    "scoreAmount": request.form["scoreAmount"],
                })
        elif request.form['action'] == 'TrailingTideRelease':
            cube.create_event(
                app, {
                    'eventType': 'TrailingTideSingleRound',
                    'teamId': team_id,
                    'roundPrefix': request.form['roundPrefix'],
                })
        elif request.form["action"] == "GoContentDelivered":
            cube.create_event(app, {
                "eventType": "GoContentDelivered",
                "teamId": team_id,
            })
        else:
            abort(400)

    team = cube.get_team(app, team_id)
    puzzles = get_puzzle_id_to_puzzle()

    island_properties = cube.get_all_puzzle_properties_for_list(
        app, round_puzzle_map.ISLAND_UNLOCKS)
    brainpower_thresholds = calculate_brainpower_thresholds(island_properties)

    island_visibilities = cube.get_puzzle_visibilities_for_list(
        app, round_puzzle_map.ISLAND_IDS + round_puzzle_map.ISLAND_UNLOCKS,
        team_id)
    open_islands = [
        island for island in round_puzzle_map.ISLAND_IDS
        if island in island_visibilities
        and island_visibilities[island]['status'] in ['UNLOCKED', 'SOLVED']
    ]

    completeable_puzzle_visibilities = cube.get_puzzle_visibilities_for_list(
        app,
        (round_puzzle_map.EMOTION_INTERACTIONS + round_puzzle_map.ISLAND_IDS +
         round_puzzle_map.ISLAND_RECOVERY_INTERACTIONS +
         round_puzzle_map.EVENTS + ['pokemon-unevolved-10'] +
         [round_puzzle_map.EMOTION_RUNAROUND] + round_puzzle_map.FINALES),
        team_id)

    all_visibilities_future = cube.get_puzzle_visibilities_async(
        app, team["teamId"])
    all_visibilities = all_visibilities_future.result().json()["visibilities"]
    visibilities_map = {v["puzzleId"]: v for v in all_visibilities}
    scores = team.get('teamProperties', {}).get('ScoresProperty',
                                                {}).get('scores', {})

    return render_template(
        "team.html",
        team=team,
        puzzles=puzzles,
        completeable_puzzle_visibilities=completeable_puzzle_visibilities,
        all_visibilities=visibilities_map,
        scores=scores,
        brainpower_thresholds=brainpower_thresholds,
        open_islands=open_islands,
        round_puzzle_map=round_puzzle_map,
        is_hunt_started=cube.is_hunt_started_async(app).result())