Odds calculations, show prize tables
This commit is contained in:
parent
721b409e07
commit
c713245f05
19
Bot/Bot.fs
19
Bot/Bot.fs
@ -15,7 +15,7 @@ let guild = GuildEnvironment.guildId
|
||||
|
||||
let hackerBattleConfig = DiscordConfiguration()
|
||||
let storeConfig = DiscordConfiguration()
|
||||
let stealConfig = DiscordConfiguration()
|
||||
//let stealConfig = DiscordConfiguration()
|
||||
let inviterConfig = DiscordConfiguration()
|
||||
let slotsConfig = DiscordConfiguration()
|
||||
let adminConfig = DiscordConfiguration()
|
||||
@ -28,8 +28,8 @@ hackerBattleConfig.Intents <- DiscordIntents.All
|
||||
storeConfig.TokenType <- TokenType.Bot
|
||||
storeConfig.Intents <- DiscordIntents.All
|
||||
|
||||
stealConfig.TokenType <- TokenType.Bot
|
||||
stealConfig.Intents <- DiscordIntents.All
|
||||
//stealConfig.TokenType <- TokenType.Bot
|
||||
//stealConfig.Intents <- DiscordIntents.All
|
||||
|
||||
inviterConfig.TokenType <- TokenType.Bot
|
||||
inviterConfig.Intents <- DiscordIntents.All
|
||||
@ -42,28 +42,28 @@ adminConfig.Intents <- DiscordIntents.All
|
||||
|
||||
hackerBattleConfig.Token <- GuildEnvironment.tokenHackerBattle
|
||||
storeConfig.Token <- GuildEnvironment.tokenStore
|
||||
stealConfig.Token <- GuildEnvironment.tokenSteal
|
||||
//stealConfig.Token <- GuildEnvironment.tokenSteal
|
||||
inviterConfig.Token <- GuildEnvironment.tokenInviter
|
||||
slotsConfig.Token <- GuildEnvironment.tokenSlots
|
||||
adminConfig.Token <- GuildEnvironment.tokenAdmin
|
||||
|
||||
let hackerBattleBot = new DiscordClient(hackerBattleConfig)
|
||||
let storeBot = new DiscordClient(storeConfig)
|
||||
let stealBot = new DiscordClient(stealConfig)
|
||||
//let stealBot = new DiscordClient(stealConfig)
|
||||
let inviterBot = new DiscordClient(inviterConfig)
|
||||
let slotsBot = new DiscordClient(slotsConfig)
|
||||
let adminBot = new DiscordClient(adminConfig)
|
||||
|
||||
let hackerCommands = hackerBattleBot.UseSlashCommands()
|
||||
let storeCommands = storeBot.UseSlashCommands()
|
||||
let stealCommands = stealBot.UseSlashCommands()
|
||||
//let stealCommands = stealBot.UseSlashCommands()
|
||||
let inviterCommands = inviterBot.UseSlashCommands()
|
||||
let slotsCommands = slotsBot.UseSlashCommands()
|
||||
let adminCommands = adminBot.UseSlashCommands()
|
||||
|
||||
hackerCommands.RegisterCommands<HackerBattle.HackerGame>(guild);
|
||||
storeCommands.RegisterCommands<Store.Store>(guild);
|
||||
stealCommands.RegisterCommands<Thief.StealGame>(guild);
|
||||
//stealCommands.RegisterCommands<Thief.StealGame>(guild);
|
||||
inviterCommands.RegisterCommands<InviteTracker.Inviter>(guild);
|
||||
//slotsCommands.RegisterCommands<SlotMachine.SlotMachine>(guild);
|
||||
adminCommands.RegisterCommands<Admin.AdminBot>(guild)
|
||||
@ -71,10 +71,11 @@ adminCommands.RegisterCommands<Admin.AdminBot>(guild)
|
||||
hackerBattleBot.add_ComponentInteractionCreated(AsyncEventHandler(HackerBattle.handleButtonEvent))
|
||||
hackerBattleBot.add_MessageCreated(AsyncEventHandler(HackerBattle.handleMessageCreated))
|
||||
storeBot.add_ComponentInteractionCreated(AsyncEventHandler(Store.handleStoreEvents))
|
||||
stealBot.add_ComponentInteractionCreated(AsyncEventHandler(Thief.handleStealButton))
|
||||
//stealBot.add_ComponentInteractionCreated(AsyncEventHandler(Thief.handleStealButton))
|
||||
inviterBot.add_GuildMemberAdded(AsyncEventHandler(InviteTracker.handleGuildMemberAdded))
|
||||
inviterBot.add_ComponentInteractionCreated(AsyncEventHandler(InviteTracker.handleButtonEvent))
|
||||
slotsBot.add_ComponentInteractionCreated(AsyncEventHandler(SlotMachine.handleSpin))
|
||||
slotsBot.add_ComponentInteractionCreated(AsyncEventHandler(SlotMachine.handleButton))
|
||||
slotsBot.add_GuildDownloadCompleted(AsyncEventHandler(SlotMachine.handleGuildDownloadCompleted))
|
||||
adminBot.add_GuildDownloadCompleted(AsyncEventHandler(Admin.handleGuildDownloadReady))
|
||||
|
||||
let asdf (_ : DiscordClient) (event : DSharpPlus.EventArgs.InteractionCreateEventArgs) =
|
||||
|
@ -1,42 +1,39 @@
|
||||
module Degenz.SlotMachine
|
||||
|
||||
open System
|
||||
open System.IO
|
||||
open System.Threading.Tasks
|
||||
open DSharpPlus
|
||||
open DSharpPlus.Entities
|
||||
open DSharpPlus.EventArgs
|
||||
open Degenz.Messaging
|
||||
open Degenz.Types
|
||||
open Npgsql.FSharp
|
||||
|
||||
type SlotSymbol = {
|
||||
index : int
|
||||
emojiName : string
|
||||
reel1Count : int
|
||||
reel2Count : int
|
||||
reel3Count : int
|
||||
}
|
||||
|
||||
let BigBrother = { index = 0 ; reel1Count = 1 ; reel2Count = 1 ; reel3Count = 1 }
|
||||
let Eye = { index = 1 ; reel1Count = 3 ; reel2Count = 2 ; reel3Count = 1 }
|
||||
let Obey = { index = 2 ; reel1Count = 2 ; reel2Count = 2 ; reel3Count = 2 }
|
||||
let AnonMask = { index = 3 ; reel1Count = 1 ; reel2Count = 5 ; reel3Count = 8 }
|
||||
let Ramen = { index = 5 ; reel1Count = 5 ; reel2Count = 5 ; reel3Count = 4 }
|
||||
let Sushi = { index = 4 ; reel1Count = 7 ; reel2Count = 3 ; reel3Count = 3 }
|
||||
let Pizza = { index = 6 ; reel1Count = 2 ; reel2Count = 6 ; reel3Count = 0 }
|
||||
let Alcohol = { index = 7 ; reel1Count = 1 ; reel2Count = 1 ; reel3Count = 1 }
|
||||
//let Circuit = { index = 0 ; reel1Count = 0 ; reel2Count = 0 ; reel3Count = 4 }
|
||||
//let OldTv = { index = 9 ; reel1Count = 1 ; reel2Count = 1 ; reel3Count = 1 }
|
||||
//let Pills = { index = 10 ; reel1Count = 1 ; reel2Count = 1 ; reel3Count = 1 }
|
||||
//let Rat = { index = 11 ; reel1Count = 1 ; reel2Count = 1 ; reel3Count = 1 }
|
||||
let BigBrother = { index = 0 ; reel1Count = 1 ; reel2Count = 1 ; reel3Count = 1 ; emojiName = "bigbrother" }
|
||||
let Eye = { index = 1 ; reel1Count = 3 ; reel2Count = 2 ; reel3Count = 1 ; emojiName = "aneye" }
|
||||
let Obey = { index = 2 ; reel1Count = 2 ; reel2Count = 2 ; reel3Count = 2 ; emojiName = "obey" }
|
||||
let AnonMask = { index = 3 ; reel1Count = 1 ; reel2Count = 2 ; reel3Count = 4 ; emojiName = "anonmask" }
|
||||
let Ramen = { index = 5 ; reel1Count = 3 ; reel2Count = 3 ; reel3Count = 1 ; emojiName = "ramen" }
|
||||
let Sushi = { index = 4 ; reel1Count = 3 ; reel2Count = 2 ; reel3Count = 2 ; emojiName = "sushi" }
|
||||
let Pizza = { index = 6 ; reel1Count = 2 ; reel2Count = 4 ; reel3Count = 0 ; emojiName = "pizza" }
|
||||
let Alcohol = { index = 7 ; reel1Count = 1 ; reel2Count = 1 ; reel3Count = 1 ; emojiName = "alcohol" }
|
||||
let Circuit = { index = 0 ; reel1Count = 0 ; reel2Count = 0 ; reel3Count = 2 ; emojiName = "circuitboard" }
|
||||
let OldTv = { index = 9 ; reel1Count = 1 ; reel2Count = 2 ; reel3Count = 2 ; emojiName = "oldtv" }
|
||||
let Pills = { index = 10 ; reel1Count = 2 ; reel2Count = 1 ; reel3Count = 2 ; emojiName = "pills" }
|
||||
let Rat = { index = 11 ; reel1Count = 2 ; reel2Count = 1 ; reel3Count = 1 ; emojiName = "rat" }
|
||||
|
||||
//let symbols = [ BigBrother ; Eye ; Obey ; AnonMask ; Sushi ; Ramen ; Pizza ; Alcohol ; Circuit ; OldTv ; Pills ; Rat ]
|
||||
let symbols = [ BigBrother ; Eye ; Obey ; AnonMask ; Sushi ; Ramen ; Pizza ; Alcohol ]
|
||||
let symbols = [ BigBrother ; Eye ; Obey ; AnonMask ; Sushi ; Ramen ; Pizza ; Alcohol ; Circuit ; OldTv ; Pills ; Rat ]
|
||||
//let symbols = [ BigBrother ; Eye ; Obey ; AnonMask ; Sushi ; Ramen ; Pizza ; Alcohol ]
|
||||
|
||||
let getReel fn = List.fold (fun acc elem -> List.replicate (fn elem) elem.index @ acc) [] symbols |> List.toArray
|
||||
|
||||
let reel1 = getReel (fun s -> s.reel1Count)
|
||||
let reel2 = getReel (fun s -> s.reel2Count)
|
||||
let reel3 = getReel (fun s -> s.reel3Count)
|
||||
let getReel fn = List.fold (fun acc elem -> (List.replicate (fn elem) elem) @ acc) [] symbols |> List.toArray
|
||||
|
||||
type Prize =
|
||||
| Money of int<GBT>
|
||||
@ -47,16 +44,51 @@ type Slot =
|
||||
| Any
|
||||
|
||||
let prizeTable =
|
||||
[ Symbol BigBrother , Symbol BigBrother , Symbol BigBrother , Jackpot
|
||||
Symbol Eye , Symbol Eye , Symbol Eye , Money 2000<GBT>
|
||||
Symbol Eye , Symbol Eye , Symbol Obey , Money 2000<GBT>
|
||||
Symbol AnonMask , Symbol AnonMask , Symbol AnonMask , Money 500<GBT>
|
||||
Symbol AnonMask , Symbol AnonMask , Symbol Eye , Money 500<GBT>
|
||||
Symbol Ramen , Symbol Ramen , Symbol Ramen , Money 250<GBT>
|
||||
Symbol Ramen , Symbol Ramen , Symbol Eye , Money 250<GBT>
|
||||
Symbol Sushi , Symbol Sushi , Any , Money 100<GBT>
|
||||
Symbol Pizza , Any , Any , Money 50<GBT> ]
|
||||
[| Symbol BigBrother , Symbol BigBrother , Symbol BigBrother , Jackpot
|
||||
Symbol Eye , Symbol Eye , Symbol Eye , Money 500<GBT>
|
||||
Symbol Eye , Symbol Eye , Symbol Obey , Money 500<GBT>
|
||||
Symbol AnonMask , Symbol AnonMask , Symbol AnonMask , Money 250<GBT>
|
||||
Symbol AnonMask , Symbol AnonMask , Symbol Eye , Money 250<GBT>
|
||||
Symbol Ramen , Symbol Ramen , Symbol Ramen , Money 100<GBT>
|
||||
Symbol Ramen , Symbol Ramen , Symbol Eye , Money 100<GBT>
|
||||
Symbol Sushi , Symbol Sushi , Any , Money 50<GBT>
|
||||
Symbol Pizza , Any , Any , Money 20<GBT> |]
|
||||
|
||||
let totalPerReel (reel : SlotSymbol -> int) = List.sumBy reel symbols
|
||||
|
||||
let calculateOdds prizeIndex =
|
||||
match prizeTable.[prizeIndex] with
|
||||
| Symbol s1 , Symbol s2 , Symbol s3 , _ -> s1.reel1Count * s2.reel2Count * s3.reel3Count
|
||||
| Symbol s1 , Symbol s2 , Any , _ -> s1.reel1Count * s2.reel2Count * totalPerReel (fun s -> s.reel3Count)
|
||||
| Symbol s1 , Any , Any , _ -> s1.reel1Count * totalPerReel (fun s -> s.reel2Count) * totalPerReel (fun s -> s.reel3Count)
|
||||
| _ -> 0
|
||||
|
||||
let getTotalCombinations () =
|
||||
(List.sumBy (fun s -> s.reel1Count) symbols)
|
||||
* (List.sumBy (fun s -> s.reel2Count) symbols)
|
||||
* (List.sumBy (fun s -> s.reel3Count) symbols)
|
||||
|
||||
let getOddsForPrize prizeIndex =
|
||||
let odds = calculateOdds prizeIndex
|
||||
let total = getTotalCombinations ()
|
||||
$"{odds} in {total }"
|
||||
|
||||
//getOddsForPrize 0
|
||||
//getOddsForPrize 1
|
||||
//getOddsForPrize 5
|
||||
//getOddsForPrize 8
|
||||
|
||||
let getTotalWaysOfWinning () =
|
||||
[0..prizeTable.Length - 1]
|
||||
|> List.sumBy calculateOdds
|
||||
|
||||
//totalPerReel (fun s -> s.reel1Count)
|
||||
//totalPerReel (fun s -> s.reel2Count)
|
||||
//totalPerReel (fun s -> s.reel3Count)
|
||||
|
||||
let reel1 = getReel (fun s -> s.reel1Count)
|
||||
let reel2 = getReel (fun s -> s.reel2Count)
|
||||
let reel3 = getReel (fun s -> s.reel3Count)
|
||||
|
||||
let slots =
|
||||
[| "https://s7.gifyu.com/images/aneye.png"
|
||||
@ -82,111 +114,63 @@ let slots =
|
||||
// "https://s7.gifyu.com/images/ramen08336d448018c98f.png"
|
||||
// "https://s7.gifyu.com/images/rat14f65f54f0d75036.png" |]
|
||||
|
||||
let slotEmojis =
|
||||
[| "<:sushi:>"
|
||||
"<:pizza:>"
|
||||
"<:ramen:>"
|
||||
"<:circuitboard:>"
|
||||
"<:obey:>"
|
||||
"<:pills:>"
|
||||
"<:oldtv:>"
|
||||
"<:rat:>"
|
||||
"<:aneye:>"
|
||||
"<:anon:>" |]
|
||||
|
||||
let slotsImages =
|
||||
[| "./images/anonmask.png"
|
||||
"./images/circuitboard.png"
|
||||
"./images/aneye.png"
|
||||
"./images/obey.png"
|
||||
"./images/oldtv.png"
|
||||
"./images/pills.png"
|
||||
"./images/pizza.png"
|
||||
"./images/ramen.png"
|
||||
"./images/rat.png"
|
||||
"./images/bigbrother.png"
|
||||
"./images/alcohol.png"
|
||||
"./images/sushi.png" |]
|
||||
// |> Array.map (fun path -> ( Path.GetFileNameWithoutExtension(path) , File.OpenRead(path) ))
|
||||
|
||||
let payTable = [| |]
|
||||
let slotEmojiNames =
|
||||
[| "sushi"
|
||||
"bigbrother"
|
||||
"pizza"
|
||||
"ramen"
|
||||
"circuitboard"
|
||||
"obey"
|
||||
"pills"
|
||||
"oldtv"
|
||||
"rat"
|
||||
"aneye"
|
||||
"alcohol"
|
||||
"anonmask" |]
|
||||
|
||||
let PlayPrice = 5<GBT>
|
||||
let twoOfAKindPrize = 100<GBT>
|
||||
let threeOfAKindPrize = 1000<GBT>
|
||||
let sleepTime = 1500
|
||||
let mutable guildEmojis : Map<string, DiscordEmoji> option = None
|
||||
let mutable anyEmoji : DiscordEmoji option = None
|
||||
|
||||
let spinEmbeds (results : int array) (ctx : IDiscordContext) =
|
||||
async {
|
||||
let itx = ctx.GetInteraction()
|
||||
let getJackpotAmount () =
|
||||
GuildEnvironment.connectionString
|
||||
|> Sql.connect
|
||||
|> Sql.query "SELECT stock FROM item WHERE symbol = 'JACKPOT'"
|
||||
|> Sql.executeRowAsync (fun read -> (read.int "price") * 1<GBT>)
|
||||
|
||||
let builder = DiscordFollowupMessageBuilder()
|
||||
let incrementJackpot amount =
|
||||
GuildEnvironment.connectionString
|
||||
|> Sql.connect
|
||||
|> Sql.parameters [ ( "amount" , Sql.int (int amount) ) ]
|
||||
|> Sql.query "UPDATE item SET stock = stock + @amount WHERE symbol = 'JACKPOT'"
|
||||
|> Sql.executeNonQueryAsync
|
||||
|
||||
builder.Content <- "Spinning!"
|
||||
builder.IsEphemeral <- true
|
||||
|
||||
let e1 = DiscordEmbedBuilder().WithImageUrl(slots.[results[0]])
|
||||
let e2 = DiscordEmbedBuilder().WithImageUrl(slots.[results[1]])
|
||||
let e3 = DiscordEmbedBuilder().WithImageUrl(slots.[results[2]])
|
||||
|
||||
let! followUp = itx.CreateFollowupMessageAsync(builder) |> Async.AwaitTask
|
||||
do! Async.Sleep sleepTime
|
||||
let! _ = itx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().AddEmbeds([ e1.Build() ])) |> Async.AwaitTask
|
||||
do! Async.Sleep sleepTime
|
||||
let! _ = itx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().AddEmbeds([ e1.Build() ; e2.Build() ])) |> Async.AwaitTask
|
||||
do! Async.Sleep sleepTime
|
||||
let! _ = itx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().AddEmbeds([ e1.Build() ; e2.Build() ; e3.Build() ])) |> Async.AwaitTask
|
||||
do! Async.Sleep sleepTime
|
||||
let! _ = itx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().AddEmbeds([ e1.Build() ; e2.Build() ; e3.Build() ])) |> Async.AwaitTask
|
||||
|
||||
return ()
|
||||
}
|
||||
|
||||
let spinEmojis (results : int array) (ctx : IDiscordContext) =
|
||||
let spinEmojis (results : SlotSymbol array) (ctx : IDiscordContext) =
|
||||
async {
|
||||
let itx = ctx.GetInteraction()
|
||||
let emojis = ctx.GetGuild().Emojis |> Seq.map (fun kvp -> kvp.Value) |> Seq.toArray
|
||||
let builder = DiscordFollowupMessageBuilder()
|
||||
|
||||
builder.Content <- "Spinning!"
|
||||
builder.IsEphemeral <- true
|
||||
let! followUp = itx.CreateFollowupMessageAsync(builder) |> Async.AwaitTask
|
||||
|
||||
do! Async.Sleep sleepTime
|
||||
let content = $"{Formatter.Emoji(emojis.[results.[0]])}"
|
||||
let! _ = itx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().WithContent(content)) |> Async.AwaitTask
|
||||
do! Async.Sleep sleepTime
|
||||
let content = $"{Formatter.Emoji(emojis.[results.[0]])}{Formatter.Emoji(emojis.[results.[1]])}"
|
||||
let! _ = itx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().WithContent(content)) |> Async.AwaitTask
|
||||
do! Async.Sleep sleepTime
|
||||
let content = $"{Formatter.Emoji(emojis.[results.[0]])}{Formatter.Emoji(emojis.[results.[1]])}{Formatter.Emoji(emojis.[results.[2]])}"
|
||||
let! _ = itx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().WithContent(content)) |> Async.AwaitTask
|
||||
|
||||
return ()
|
||||
}
|
||||
|
||||
let spinFiles (results : int array) (ctx : IDiscordContext) =
|
||||
async {
|
||||
let itx = ctx.GetInteraction()
|
||||
let builder = DiscordFollowupMessageBuilder()
|
||||
|
||||
builder.Content <- "Spinning!"
|
||||
builder.IsEphemeral <- true
|
||||
let! followUp = itx.CreateFollowupMessageAsync(builder) |> Async.AwaitTask
|
||||
|
||||
// do! Async.Sleep sleepTime
|
||||
// let ( name , stream ) = slotsImages.[results.[0]]
|
||||
// let! _ = itx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder()
|
||||
// .AddFile(name + "1.png", stream)) |> Async.AwaitTask
|
||||
// do! Async.Sleep sleepTime
|
||||
// let ( name , stream ) = slotsImages.[results.[1]]
|
||||
// let! _ = itx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder()
|
||||
// .AddFile(name + "2.png", stream)) |> Async.AwaitTask
|
||||
// do! Async.Sleep sleepTime
|
||||
// let ( name , stream ) = slotsImages.[results.[2]]
|
||||
// let! _ = itx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder()
|
||||
// .AddFile(name + "3.png", stream)) |> Async.AwaitTask
|
||||
return ()
|
||||
match guildEmojis with
|
||||
| Some emojis ->
|
||||
let e1 = Formatter.Emoji(emojis.[results.[0].emojiName])
|
||||
let e2 = Formatter.Emoji(emojis.[results.[1].emojiName])
|
||||
let e3 = Formatter.Emoji(emojis.[results.[2].emojiName])
|
||||
do! Async.Sleep sleepTime
|
||||
let content = $"{e1}"
|
||||
let! _ = itx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().WithContent(content)) |> Async.AwaitTask
|
||||
do! Async.Sleep sleepTime
|
||||
let content = $"{e1}{e2}"
|
||||
let! _ = itx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().WithContent(content)) |> Async.AwaitTask
|
||||
do! Async.Sleep sleepTime
|
||||
let content = $"{e1}{e2}{e3}"
|
||||
let! _ = itx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().WithContent(content)) |> Async.AwaitTask
|
||||
return ()
|
||||
| None -> return ()
|
||||
}
|
||||
|
||||
let spin spinType (ctx : IDiscordContext) =
|
||||
@ -196,50 +180,103 @@ let spin spinType (ctx : IDiscordContext) =
|
||||
|
||||
let prize =
|
||||
prizeTable
|
||||
|> List.tryPick (fun (s1,s2,s3,prize) ->
|
||||
|> Array.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
|
||||
| Symbol s1' , Symbol s2' , Symbol s3' when s1'.index = symbols.[0].index && s2'.index = symbols.[1].index && s3'.index = symbols.[2].index -> Some prize
|
||||
| Symbol s1' , Symbol s2' , Any when s1'.index = symbols.[0].index && s2'.index = symbols.[1].index -> Some prize
|
||||
| Symbol s1' , Any , Any when s1'.index = symbols.[0].index -> Some prize
|
||||
| _ -> None)
|
||||
|
||||
match spinType with
|
||||
| "Embeds" -> do! spinEmbeds symbols ctx
|
||||
| "Emojis" -> do! spinEmojis symbols ctx
|
||||
| "Files" -> do! spinFiles symbols ctx
|
||||
// | "Files" -> do! spinFiles symbols ctx
|
||||
| _ -> ()
|
||||
|
||||
do! Async.Sleep 2000
|
||||
let builder = DiscordFollowupMessageBuilder()
|
||||
builder.IsEphemeral <- true
|
||||
let embed4 = DiscordEmbedBuilder()
|
||||
embed4.Title <- "Slot Machine"
|
||||
embed4.Title <- "Results"
|
||||
match prize with
|
||||
| Some (Money amount) ->
|
||||
do! DbService.updatePlayerCurrency twoOfAKindPrize player |> Async.Ignore
|
||||
embed4.Description <- $"You win {amount} GBT!"
|
||||
do! DbService.updatePlayerCurrency amount player |> Async.Ignore
|
||||
embed4.ImageUrl <- "https://s7.gifyu.com/images/youwin.png"
|
||||
embed4.Description <- $"You win **{amount}** GBT!"
|
||||
| Some (Jackpot) ->
|
||||
embed4.ImageUrl <- "https://s7.gifyu.com/images/jackpot2ac30c9823f6a91c.png"
|
||||
embed4.Description <- $"YOU HIT THE JACKPOT!!!"
|
||||
| None ->
|
||||
do! DbService.updatePlayerCurrency -PlayPrice player |> Async.Ignore
|
||||
builder.Content <- "Better luck next time! You paid 1 $GBT"
|
||||
do! incrementJackpot PlayPrice |> Async.AwaitTask |> Async.Ignore
|
||||
embed4.Description <- $"Better luck next time! You paid {PlayPrice} $GBT"
|
||||
let button1 = DiscordButtonComponent(ButtonStyle.Success, $"spin", $"Spin Again {PlayPrice} $GBT") :> DiscordComponent
|
||||
let button2 = DiscordButtonComponent(ButtonStyle.Success, $"prizes", $"Show Prizes") :> DiscordComponent
|
||||
builder.AddComponents [| button1 ; button2 |] |> ignore
|
||||
builder.AddEmbed(embed4) |> ignore
|
||||
do! ctx.FollowUp(builder) |> Async.AwaitTask |> Async.Ignore
|
||||
|
||||
return ()
|
||||
})
|
||||
|
||||
let handleSpin (_ : DiscordClient) (event : ComponentInteractionCreateEventArgs) =
|
||||
let handlePrizeTable (ctx : IDiscordContext) =
|
||||
task {
|
||||
do! Messaging.defer ctx
|
||||
let embed = DiscordEmbedBuilder()
|
||||
match guildEmojis , anyEmoji with
|
||||
| Some emojis , Some any ->
|
||||
let folder acc elem =
|
||||
let s1,s2,s3,prize = elem
|
||||
let prizeTxt =
|
||||
match prize with
|
||||
| Money m -> $"**{m}** $GBT"
|
||||
| Jackpot -> $"**🎉JACKPOT🎉**"
|
||||
let line =
|
||||
match s1 , s2 , s3 with
|
||||
| Symbol s1' , Symbol s2' , Symbol s3' ->
|
||||
$"{Formatter.Emoji(emojis.[s1'.emojiName])}{Formatter.Emoji(emojis.[s2'.emojiName])}{Formatter.Emoji(emojis.[s3'.emojiName])}"
|
||||
| Symbol s1' , Symbol s2' , Any ->
|
||||
$"{Formatter.Emoji(emojis.[s1'.emojiName])}{Formatter.Emoji(emojis.[s2'.emojiName])}{Formatter.Emoji(any)}"
|
||||
| Symbol s1' , Any , Any ->
|
||||
$"{Formatter.Emoji(emojis.[s1'.emojiName])}{Formatter.Emoji(any)}{Formatter.Emoji(any)}"
|
||||
| _ -> ""
|
||||
$"{acc}\n{line} ⠀⠀|⠀⠀ {prizeTxt}"
|
||||
let! jackpot = getJackpotAmount ()
|
||||
let rows = Array.fold folder "" prizeTable
|
||||
embed.Color <- DiscordColor.Green
|
||||
embed.Title <- "Degenz Slots Prize Table"
|
||||
embed.Description <- $"Current Jackpot At: **{jackpot}** $GBT\n\n**Combo** ⠀⠀⠀⠀⠀⠀⠀ **Prize**\n{rows}"
|
||||
let builder = DiscordFollowupMessageBuilder()
|
||||
builder.IsEphemeral <- true
|
||||
do! ctx.FollowUp(builder.AddEmbed(embed))
|
||||
| _ , _ -> return ()
|
||||
} :> Task
|
||||
|
||||
let handleButton (_ : DiscordClient) (event : ComponentInteractionCreateEventArgs) =
|
||||
let ctx = DiscordEventContext event
|
||||
task {
|
||||
match event.Id with
|
||||
| "spin-embeds" -> do! spin "Embeds" ctx
|
||||
| "spin-emojis" -> do! spin "Emojis" ctx
|
||||
| "spin-files" -> do! spin "Files" ctx
|
||||
| "spin" -> do! spin "Emojis" ctx
|
||||
| "prizes" -> do! handlePrizeTable ctx
|
||||
| _ ->
|
||||
printfn "Wrong Spin ID"
|
||||
return ()
|
||||
} :> Task
|
||||
|
||||
let handleGuildDownloadCompleted (_ : DiscordClient) (event : GuildDownloadCompletedEventArgs) =
|
||||
task {
|
||||
let ( result , guild ) = event.Guilds.TryGetValue(GuildEnvironment.guildId)
|
||||
guildEmojis <-
|
||||
guild.Emojis
|
||||
|> Seq.map (fun kvp -> kvp.Value) |> Seq.toArray
|
||||
|> Seq.filter (fun de -> Array.contains de.Name slotEmojiNames)
|
||||
|> Seq.distinctBy (fun de -> de.Name)
|
||||
|> Seq.map (fun de -> ( de.Name , de ))
|
||||
|> Map.ofSeq
|
||||
|> Some
|
||||
anyEmoji <- guild.Emojis |> Seq.tryPick (fun kvp -> if kvp.Value.Name = "any" then Some kvp.Value else None)
|
||||
return ()
|
||||
} :> Task
|
||||
|
||||
let sendInitialEmbed (ctx : IDiscordContext) =
|
||||
async {
|
||||
try
|
||||
@ -252,10 +289,8 @@ let sendInitialEmbed (ctx : IDiscordContext) =
|
||||
|
||||
builder.AddEmbed(embed) |> 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
|
||||
let button1 = DiscordButtonComponent(ButtonStyle.Success, $"spin", $"Spin {PlayPrice} $GBT") :> DiscordComponent
|
||||
let button2 = DiscordButtonComponent(ButtonStyle.Success, $"prizes", $"Show Prizes") :> DiscordComponent
|
||||
builder.AddComponents [| button1 ; button2 |] |> ignore
|
||||
do! GuildEnvironment.botClientSlots.Value.SendMessageAsync(channel, builder)
|
||||
|> Async.AwaitTask
|
||||
|
Loading…
x
Reference in New Issue
Block a user