Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -47,26 +47,34 @@ def display_bonus_match(bonus_match, bonus_dice_type, bonus_dice_emoji):
|
|
47 |
st.success(f'๐ You rolled a {bonus_dice_type} {bonus_dice_emoji} on the first roll!')
|
48 |
|
49 |
def update_dice_roll_history(dice_type, rolls):
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
-
return bonus_match
|
70 |
|
71 |
def display_dice_roll_results():
|
72 |
download_history = st.checkbox('๐ฅ Download Roll History', value=False)
|
|
|
47 |
st.success(f'๐ You rolled a {bonus_dice_type} {bonus_dice_emoji} on the first roll!')
|
48 |
|
49 |
def update_dice_roll_history(dice_type, rolls):
|
50 |
+
history = st.session_state.dice_roll_history
|
51 |
+
count = st.session_state.count
|
52 |
+
dice_name = dice_type['name']
|
53 |
+
dice_emoji = dice_type['emoji']
|
54 |
+
bonus_match = None
|
55 |
+
|
56 |
+
# Check if the count matches the number of sides of the dice
|
57 |
+
if count > 0 and count % dice_type['sides'] == 0:
|
58 |
+
bonus_match = dice_type['name']
|
59 |
+
bonus_emoji = dice_type['emoji']
|
60 |
+
|
61 |
+
# Update the dice roll history
|
62 |
+
if history is None:
|
63 |
+
history = pd.DataFrame({'Roll': rolls, 'Count': count, 'DiceNumberOfSides': dice_type['sides']})
|
64 |
+
else:
|
65 |
+
new_history = pd.DataFrame({'Roll': rolls, 'Count': count, 'DiceNumberOfSides': dice_type['sides']})
|
66 |
+
history = history.append(new_history, ignore_index=True)
|
67 |
+
|
68 |
+
if bonus_match is not None:
|
69 |
+
history['BonusMatchToDiceName'] = bonus_match
|
70 |
+
history['BonusMatchToDiceEmoji'] = bonus_emoji
|
71 |
+
|
72 |
+
# Add username to history
|
73 |
+
history['Username'] = st.session_state.username
|
74 |
+
|
75 |
+
st.session_state.dice_roll_history = history
|
76 |
+
return history
|
77 |
|
|
|
78 |
|
79 |
def display_dice_roll_results():
|
80 |
download_history = st.checkbox('๐ฅ Download Roll History', value=False)
|