From 8861756bf9db69f6de66c20a66209480dfdcaef1 Mon Sep 17 00:00:00 2001 From: Sadra Sabouri <43045767+sadrasabouri@users.noreply.github.com> Date: Thu, 2 May 2024 11:17:43 -0700 Subject: [PATCH] Implement role-specific night actions [Copilot Workspace] --- mafia.py | 31 ++++++++++++++++++++++++++++++- templates/Player.html | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/mafia.py b/mafia.py index 47f7803..012e617 100644 --- a/mafia.py +++ b/mafia.py @@ -14,6 +14,7 @@ ip2role_index_name = {} nComments = 0 comments_ordered = [] +night_actions = {} # Store night actions @auth.verify_password def verify_password(username, password): @@ -103,7 +104,35 @@ def GOD_PAGE(): prompt_message=msg, roles={role:roles.count(role) for role in set(roles)}, comments=comments_ordered, role2team=role2team) - +@app.route('/night_action', methods=['POST']) +def night_action(): + global night_actions + if request.method == 'POST': + action_type = None + target = None + player_ip = request.remote_addr + if 'nightKill' in request.form: + action_type = 'kill' + target = request.form['nightKill'] + elif 'detect' in request.form: + action_type = 'detect' + target = request.form['detect'] + elif 'save' in request.form: + action_type = 'save' + target = request.form['save'] + if action_type and target: + night_actions[player_ip] = {'action': action_type, 'target': target} + return render_template('Player.html', player=ip2role_index_name[player_ip]) + +@app.route('/process_night_actions') +def process_night_actions(): + global night_actions, ip2role_index_name + # Process night actions here + # This is a placeholder for the logic to process night actions based on the collected data in night_actions + # Reset night actions for the next night + night_actions = {} + return "Night actions processed." + @app.errorhandler(404) def invalid_route(e): return render_template("404.html", is_farsi=True) diff --git a/templates/Player.html b/templates/Player.html index 82c2d2a..f563466 100644 --- a/templates/Player.html +++ b/templates/Player.html @@ -20,6 +20,44 @@