From 9ba075559cfc5359f86431da95621b55e40fe6e7 Mon Sep 17 00:00:00 2001 From: ZaneYork Date: Tue, 10 Sep 2024 11:31:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=A1=E7=A5=A8=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dinner.py | 9 ++++++++- templates/dinner.html | 11 +++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/dinner.py b/dinner.py index 597d978..53d006e 100644 --- a/dinner.py +++ b/dinner.py @@ -101,14 +101,21 @@ def dinner(): else: menu = {} summary = fetch_menu_summary() - result = fetch_roll_result() last_result = fetch_roll_result(-1) + for x in summary: + if x == last_result: + summary[x] = summary[x] * 7 / 10 + total_vote = sum(value for value in summary.values()) + if total_vote == 0: + total_vote = 1 + result = fetch_roll_result() can_roll = (check_roll() == 1) all_choice = list(map(lambda x: {'name': x[0], 'label': x[1]}, fetch_all_menu())) return render_template('dinner.html', all_choice=all_choice, menu=menu, summary=summary, + total_vote=total_vote, result=result, can_roll=can_roll, last_result=last_result) diff --git a/templates/dinner.html b/templates/dinner.html index 27abfea..2ed0781 100644 --- a/templates/dinner.html +++ b/templates/dinner.html @@ -9,7 +9,7 @@

每天8:00-17:30间开放匿名投票更新,17:30以后允许发起抽签,抽签结果确定后不可更改

随机抽签,按得票数决定中签概率

{% if last_result %} -

今日{{ last_result }}中签概率降低30%

+

今日{{ last_result }}最终得票数降低30%

{% endif %}
@@ -33,19 +33,22 @@ onclick="roll()">开始抽签
- +
    {% for key in summary %}
  • - {{ key }} + {{ key }} {{ '{:.2f}'.format(summary[key] | round(2)) }}票 + {{ '{:.2f}'.format(summary[key] / total_vote * 100 | round(2)) }}%
  • {% endfor %}
- +