|
|
|
@ -255,6 +255,24 @@ def objective_qrcode(objective_hash):
@@ -255,6 +255,24 @@ def objective_qrcode(objective_hash):
|
|
|
|
|
@login_required |
|
|
|
|
def objective(objective_hash): |
|
|
|
|
objective = Objective.query.filter_by(hash=objective_hash).first_or_404() |
|
|
|
|
if current_user.role_in_game(objective.game) == Role.bunny: |
|
|
|
|
player = current_user.player_in(objective.game) |
|
|
|
|
if not objective in player.found_objectives: |
|
|
|
|
player.found_objectives.append(objective) |
|
|
|
|
db.session.commit() |
|
|
|
|
if objective.name: |
|
|
|
|
flash(f'You found objective: {objective.name}!') |
|
|
|
|
else: |
|
|
|
|
flash('You found an objective!') |
|
|
|
|
elif objective.name: |
|
|
|
|
flash(f"You have already found objective '{objective.name}'") |
|
|
|
|
else: |
|
|
|
|
flash('You have already found this objective') |
|
|
|
|
return redirect(url_for('main.game_dashboard', game_name=objective.game.name)) |
|
|
|
|
elif not objective.owned_by(current_user): |
|
|
|
|
flash("Only bunnies in an objective's game can find objectives!") |
|
|
|
|
abort(403) |
|
|
|
|
|
|
|
|
|
owner = objective.owned_by(current_user) |
|
|
|
|
qrcode = generate_qr_code(objective) if owner else None |
|
|
|
|
form = ObjectiveForm() |
|
|
|
|