From b20756b87af9bed360de955a44f799d7c8331ee3 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Mon, 11 Apr 2022 17:53:09 +0700 Subject: [PATCH] Introduce symbol odds --- Bot/Games/SlotMachine.fs | 55 +++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/Bot/Games/SlotMachine.fs b/Bot/Games/SlotMachine.fs index b5c4069..92cdd8b 100644 --- a/Bot/Games/SlotMachine.fs +++ b/Bot/Games/SlotMachine.fs @@ -6,23 +6,37 @@ open System.Threading.Tasks open DSharpPlus open DSharpPlus.Entities open DSharpPlus.EventArgs -open DSharpPlus.SlashCommands open Degenz.Messaging open Degenz.Types -type SlotSymbols = - | Eye - | AnonMask - | CircuitBoard - | Obey - | OldTv - | Pills - | Pizza - | Ramen - | Rat - | Alcohol - | BigBrother - | Sushi +type SlotSymbol = { + index : int + 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 Sushi = { index = 4 ; reel1Count = 7 ; reel2Count = 3 ; reel3Count = 3 } +let Ramen = { index = 5 ; reel1Count = 5 ; reel2Count = 5 ; reel3Count = 4 } +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 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 slots = [| "https://s7.gifyu.com/images/aneye.png" @@ -80,7 +94,7 @@ let payTable = [| |] let PlayPrice = 10 let twoOfAKindPrize = 100 let threeOfAKindPrize = 1000 -let sleepTime = 1000 +let sleepTime = 1500 let spinEmbeds (results : int array) (ctx : IDiscordContext) = async { @@ -157,19 +171,18 @@ let spinFiles (results : int array) (ctx : IDiscordContext) = let spin spinType (ctx : IDiscordContext) = PlayerInteractions.executePlayerAction ctx (fun player -> async { let random = Random(System.Guid.NewGuid().GetHashCode()) - let slotCount = slots.Length - let results = [| random.Next(0, slotCount) ; random.Next(0, slotCount) ; random.Next(0, slotCount) |] + let symbols = [| reel1.[random.Next(0, reel1.Length)] ; reel2.[random.Next(0, reel2.Length)] ; reel3.[random.Next(0, reel3.Length)] |] - let winConditions = (results.[0] = results.[1] && results.[0] = results.[2]) + let winConditions = (symbols.[0] = symbols.[1] && symbols.[0] = symbols.[2]) if winConditions then do! DbService.updatePlayerCurrency twoOfAKindPrize player |> Async.Ignore else do! DbService.updatePlayerCurrency -PlayPrice player |> Async.Ignore match spinType with - | "Embeds" -> do! spinEmbeds results ctx - | "Emojis" -> do! spinEmojis results ctx - | "Files" -> do! spinFiles results ctx + | "Embeds" -> do! spinEmbeds symbols ctx + | "Emojis" -> do! spinEmojis symbols ctx + | "Files" -> do! spinFiles symbols ctx | _ -> () do! Async.Sleep sleepTime