From 36376e24d92094c97794c66e7419b8e5cfffc944 Mon Sep 17 00:00:00 2001 From: Outrun Colors Date: Fri, 16 Sep 2022 13:51:58 -0500 Subject: [PATCH 1/2] Try to blind-fix random dealer error --- files/helpers/twentyone.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/files/helpers/twentyone.py b/files/helpers/twentyone.py index 7aee25487..bb165b082 100644 --- a/files/helpers/twentyone.py +++ b/files/helpers/twentyone.py @@ -251,7 +251,10 @@ def handle_payout(gambler, state, game): def remove_exploitable_information(state): safe_state = state - safe_state['dealer'][1] = '?' + + if len(safe_state['dealer']) >= 2: + safe_state['dealer'][1] = '?' + safe_state['dealer_value'] = '?' return safe_state From 7dbbb27228e03bff31f6b092c22f8b1d31f6d1a2 Mon Sep 17 00:00:00 2001 From: outruncolors <78451621+outruncolors@users.noreply.github.com> Date: Fri, 16 Sep 2022 14:10:45 -0500 Subject: [PATCH 2/2] Remove winnings column from user and replace with a calculated value (#356) * Remove winnings column from user and replace with a calculated value * Handle case for no games played * Idiomatic --- files/classes/user.py | 11 ++++++++++- sql/20220916-remove-winnings-column.sql | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 sql/20220916-remove-winnings-column.sql diff --git a/files/classes/user.py b/files/classes/user.py index a174eff70..1b19ea8cd 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -1,9 +1,11 @@ from sqlalchemy.orm import deferred, aliased +from sqlalchemy.sql import func from secrets import token_hex import pyotp from files.helpers.discord import remove_user from files.helpers.media import * from files.helpers.const import * +from files.classes.casino_game import Casino_Game from files.helpers.twentyone import get_active_twentyone_game_state from files.helpers.sorting_and_time import * from .alts import Alt @@ -58,7 +60,6 @@ class User(Base): marseyawarded = Column(Integer) rehab = Column(Integer) longpost = Column(Integer) - winnings = Column(Integer, default=0) unblockable = Column(Boolean) bird = Column(Integer) email = deferred(Column(String)) @@ -925,3 +926,11 @@ class User(Base): @lazy def active_blackjack_game(self): return json.dumps(get_active_twentyone_game_state(self)) + + @property + @lazy + def winnings(self): + from_casino = g.db.query(func.sum(Casino_Game.winnings)).filter(Casino_Game.user_id == self.id).one()[0] + from_casino_value = from_casino or 0 + + return from_casino_value + self.total_lottery_winnings \ No newline at end of file diff --git a/sql/20220916-remove-winnings-column.sql b/sql/20220916-remove-winnings-column.sql new file mode 100644 index 000000000..cf698ff5f --- /dev/null +++ b/sql/20220916-remove-winnings-column.sql @@ -0,0 +1 @@ +alter table users drop column winnings; \ No newline at end of file