Fix embeds, take money upfront, GTE

This commit is contained in:
Joseph Ferano 2022-04-20 13:13:40 +07:00
parent 310699ea50
commit c0282083a2

View File

@ -232,6 +232,7 @@ let spin multiplier (ctx : IDiscordContext) =
| 2 -> PlayPricex2 | 2 -> PlayPricex2
| _ -> PlayPricex3 | _ -> PlayPricex3
let execute player = async { let execute player = async {
do! DbService.updatePlayerCurrency -playAmount player |> Async.Ignore
let random = Random(Guid.NewGuid().GetHashCode()) let random = Random(Guid.NewGuid().GetHashCode())
let symbols = [| reel1.[random.Next(0, reel1.Length)] ; reel2.[random.Next(0, reel2.Length)] ; reel3.[random.Next(0, reel3.Length)] |] let symbols = [| reel1.[random.Next(0, reel1.Length)] ; reel2.[random.Next(0, reel2.Length)] ; reel3.[random.Next(0, reel3.Length)] |]
@ -265,27 +266,30 @@ let spin multiplier (ctx : IDiscordContext) =
let prizeWithMultiplier = amount * multiplier let prizeWithMultiplier = amount * multiplier
do! DbService.updatePlayerCurrency prizeWithMultiplier player |> Async.Ignore do! DbService.updatePlayerCurrency prizeWithMultiplier player |> Async.Ignore
embed.Color <- DiscordColor.Green embed.Color <- DiscordColor.Green
embed.Description <- $"You win **{prizeWithMultiplier}** GBT!" embed.Description <- $"You win! You got **{prizeWithMultiplier}** GBT 🎉"
embed.AddField("Result", $"{slotsContent}", true) |> ignore // embed.AddField("Result", $"{slotsContent}", true) |> ignore
embed.AddField("Bet", $"{playAmount}", true) |> ignore
embed.AddField("Prize", $"{prizeWithMultiplier}") |> ignore
addGBTField embed prizeWithMultiplier addGBTField embed prizeWithMultiplier
return "WON" , prizeWithMultiplier return "WON" , prizeWithMultiplier
| Some (Jackpot) -> | Some (Jackpot) ->
let! jackpot = getJackpotAmount () let! jackpot = getJackpotAmount ()
embed.Color <- DiscordColor.Purple embed.Color <- DiscordColor.Purple
embed.Description <- $"YOU HIT THE JACKPOT!!!" embed.Description <- $"YOU HIT THE JACKPOT!!!"
embed.AddField("Result", $"{slotsContent}", true) |> ignore // embed.AddField("Result", $"{slotsContent}", true) |> ignore
embed.AddField("Bet", $"{playAmount}", true) |> ignore
embed.AddField("Prize", $"{jackpot}") |> ignore
addGBTField embed jackpot addGBTField embed jackpot
do! DbService.updatePlayerCurrency jackpot player |> Async.Ignore do! DbService.updatePlayerCurrency jackpot player |> Async.Ignore
do! resetJackpot BaseJackpotAmount |> Async.Ignore do! resetJackpot BaseJackpotAmount |> Async.Ignore
return "JACKPOT" , jackpot return "JACKPOT" , jackpot
| None -> | None ->
do! DbService.updatePlayerCurrency -playAmount player |> Async.Ignore
do! incrementJackpot playAmount |> Async.Ignore do! incrementJackpot playAmount |> Async.Ignore
let! jackpot = getJackpotAmount ()
embed.Description <- $"Better luck next time! You paid {playAmount} $GBT" embed.Description <- $"Better luck next time! You paid {playAmount} $GBT"
embed.Color <- DiscordColor.Red embed.Color <- DiscordColor.Red
embed.AddField("New JACKPOT", $"`💰` {jackpot} `$GBT`", true) |> ignore embed.AddField("Bet", $"{playAmount}", true) |> ignore
embed.AddField("Result", $"{slotsContent}", true) |> ignore // embed.AddField("New JACKPOT", $"`💰` {jackpot} `$GBT`", true) |> ignore
// embed.AddField("Result", $"{slotsContent}", true) |> ignore
addGBTField embed -playAmount addGBTField embed -playAmount
return "LOST" , 0<GBT> return "LOST" , 0<GBT>
} }
@ -295,7 +299,7 @@ let spin multiplier (ctx : IDiscordContext) =
do! Analytics.slotPlayed (ctx.GetDiscordMember()) playAmount result prizeAmount do! Analytics.slotPlayed (ctx.GetDiscordMember()) playAmount result prizeAmount
} }
PlayerInteractions.executePlayerAction ctx (fun player -> PlayerInteractions.executePlayerAction ctx (fun player ->
if player.Bank > playAmount then if player.Bank >= playAmount then
execute player execute player
else else
Messaging.sendFollowUpMessage ctx "You do not have sufficient funds to play") Messaging.sendFollowUpMessage ctx "You do not have sufficient funds to play")