From 86906c1b55b3d207792f45be5a3bd2a91a4a2c61 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Fri, 15 Apr 2022 13:54:19 +0700 Subject: [PATCH] Prize amounts --- Bot/Bot.fs | 4 ++-- Bot/Games/SlotMachine.fs | 48 ++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Bot/Bot.fs b/Bot/Bot.fs index f14f242..a686361 100644 --- a/Bot/Bot.fs +++ b/Bot/Bot.fs @@ -93,8 +93,8 @@ let asdf (_ : DiscordClient) (event : DSharpPlus.EventArgs.InteractionCreateEven :> Task //hackerBattleBot.add_InteractionCreated(AsyncEventHandler(asdf)) -//slotsBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously -//GuildEnvironment.botClientSlots <- Some slotsBot +slotsBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously +GuildEnvironment.botClientSlots <- Some slotsBot hackerBattleBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously GuildEnvironment.botClientHacker <- Some hackerBattleBot diff --git a/Bot/Games/SlotMachine.fs b/Bot/Games/SlotMachine.fs index bb1b746..b4ee021 100644 --- a/Bot/Games/SlotMachine.fs +++ b/Bot/Games/SlotMachine.fs @@ -48,14 +48,14 @@ type Slot = let prizeTable = [ Symbol BigBrother , Symbol BigBrother , Symbol BigBrother , Jackpot - Symbol Eye , Symbol Eye , Symbol Eye , Money 1000 - Symbol Eye , Symbol Eye , Symbol Obey , Money 1000 - Symbol AnonMask , Symbol AnonMask , Symbol AnonMask , Money 250 - Symbol AnonMask , Symbol AnonMask , Symbol Eye , Money 250 - Symbol Ramen , Symbol Ramen , Symbol Ramen , Money 100 - Symbol Ramen , Symbol Ramen , Symbol Eye , Money 100 - Symbol Sushi , Symbol Sushi , Any , Money 10 - Symbol Pizza , Any , Any , Money 5 ] + Symbol Eye , Symbol Eye , Symbol Eye , Money 2000 + Symbol Eye , Symbol Eye , Symbol Obey , Money 2000 + Symbol AnonMask , Symbol AnonMask , Symbol AnonMask , Money 500 + Symbol AnonMask , Symbol AnonMask , Symbol Eye , Money 500 + Symbol Ramen , Symbol Ramen , Symbol Ramen , Money 250 + Symbol Ramen , Symbol Ramen , Symbol Eye , Money 250 + Symbol Sushi , Symbol Sushi , Any , Money 100 + Symbol Pizza , Any , Any , Money 50 ] let slots = @@ -111,7 +111,7 @@ let slotsImages = let payTable = [| |] -let PlayPrice = 10 +let PlayPrice = 5 let twoOfAKindPrize = 100 let threeOfAKindPrize = 1000 let sleepTime = 1500 @@ -174,7 +174,7 @@ let spinFiles (results : int array) (ctx : IDiscordContext) = builder.IsEphemeral <- true let! followUp = itx.CreateFollowupMessageAsync(builder) |> Async.AwaitTask - do! Async.Sleep sleepTime +// do! Async.Sleep sleepTime // let ( name , stream ) = slotsImages.[results.[0]] // let! _ = itx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder() // .AddFile(name + "1.png", stream)) |> Async.AwaitTask @@ -194,34 +194,33 @@ let spin spinType (ctx : IDiscordContext) = 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 winConditions = symbols.[0] = symbols.[1] && symbols.[0] = symbols.[2] let prize = prizeTable - |> List.pick (fun (s1,s2,s3,prize) -> + |> List.tryPick (fun (s1,s2,s3,prize) -> match s1 , s2 , s3 with | Symbol s1' , Symbol s2' , Symbol s3' when s1'.index = symbols.[0] && s2'.index = symbols.[1] && s3'.index = symbols.[2] -> Some prize | Symbol s1' , Symbol s2' , Any when s1'.index = symbols.[0] && s2'.index = symbols.[1] -> Some prize | Symbol s1' , Any , Any when s1'.index = symbols.[0] -> Some prize | _ -> None) - if winConditions - then do! DbService.updatePlayerCurrency twoOfAKindPrize player |> Async.Ignore - else do! DbService.updatePlayerCurrency -PlayPrice player |> Async.Ignore - match spinType with | "Embeds" -> do! spinEmbeds symbols ctx | "Emojis" -> do! spinEmojis symbols ctx | "Files" -> do! spinFiles symbols ctx | _ -> () - do! Async.Sleep sleepTime let builder = DiscordFollowupMessageBuilder() builder.IsEphemeral <- true let embed4 = DiscordEmbedBuilder() embed4.Title <- "Slot Machine" - if winConditions then - embed4.Description <- $"You win {threeOfAKindPrize} GBT!" - else + match prize with + | Some (Money amount) -> + do! DbService.updatePlayerCurrency twoOfAKindPrize player |> Async.Ignore + embed4.Description <- $"You win {amount} GBT!" + | Some (Jackpot) -> + embed4.Description <- $"YOU HIT THE JACKPOT!!!" + | None -> + do! DbService.updatePlayerCurrency -PlayPrice player |> Async.Ignore builder.Content <- "Better luck next time! You paid 1 $GBT" builder.AddEmbed(embed4) |> ignore do! ctx.FollowUp(builder) |> Async.AwaitTask |> Async.Ignore @@ -253,10 +252,11 @@ let sendInitialEmbed (ctx : IDiscordContext) = builder.AddEmbed(embed) |> ignore - let button1 = DiscordButtonComponent(ButtonStyle.Success, $"spin-embeds", $"Spin Embeds 1 $GBT") :> DiscordComponent - let button2 = DiscordButtonComponent(ButtonStyle.Success, $"spin-emojis", $"Spin Emojis 5 $GBT") :> DiscordComponent - let button3 = DiscordButtonComponent(ButtonStyle.Success, $"spin-files", $"Spin Files 10 $GBT") :> DiscordComponent - builder.AddComponents [| button1 ; button2 ; button3 |] |> ignore + let button1 = DiscordButtonComponent(ButtonStyle.Success, $"spin-embeds", $"Spin Embeds {PlayPrice} $GBT") :> DiscordComponent + let button2 = DiscordButtonComponent(ButtonStyle.Success, $"spin-emojis", $"Spin Emojis {PlayPrice} $GBT") :> DiscordComponent +// let button3 = DiscordButtonComponent(ButtonStyle.Success, $"spin-files", $"Spin Files 10 $GBT") :> DiscordComponent +// builder.AddComponents [| button1 ; button2 ; button3 |] |> ignore + builder.AddComponents [| button1 ; button2 |] |> ignore do! GuildEnvironment.botClientSlots.Value.SendMessageAsync(channel, builder) |> Async.AwaitTask |> Async.Ignore