properly calculate user's winnings

This commit is contained in:
2025-04-01 22:57:19 -04:00
parent 348d6f96a8
commit 251c2d4c19

View File

@@ -253,7 +253,7 @@ pub async fn blackjack(ctx: Context<'_>, amount: String) -> Result<(), Error>
Ordering::Less => {
if players_count == 21 {
let amount = amount * 3 / 2;
balance += amount * 3 / 2;
balance += amount;
format!("You've won with a Blackjack! You've gained **{amount}** tokens.")
} else {
balance += amount;
@@ -261,9 +261,15 @@ pub async fn blackjack(ctx: Context<'_>, amount: String) -> Result<(), Error>
}
}
Ordering::Greater if dealers_count > 21 => {
if players_count == 21 {
let amount = amount * 3 / 2;
balance += amount;
format!("You've won with a Blackjack! You've gained **{amount}** tokens.")
} else {
balance += amount;
format!("You've won! **{amount}** tokens have been added to your account.")
}
}
Ordering::Equal => {
format!("A draw!")
}