Introduce symbol odds

This commit is contained in:
Joseph Ferano 2022-04-11 17:53:09 +07:00
parent 6db2a23fc3
commit b20756b87a

View File

@ -6,23 +6,37 @@ open System.Threading.Tasks
open DSharpPlus open DSharpPlus
open DSharpPlus.Entities open DSharpPlus.Entities
open DSharpPlus.EventArgs open DSharpPlus.EventArgs
open DSharpPlus.SlashCommands
open Degenz.Messaging open Degenz.Messaging
open Degenz.Types open Degenz.Types
type SlotSymbols = type SlotSymbol = {
| Eye index : int
| AnonMask reel1Count : int
| CircuitBoard reel2Count : int
| Obey reel3Count : int
| OldTv }
| Pills
| Pizza let BigBrother = { index = 0 ; reel1Count = 1 ; reel2Count = 1 ; reel3Count = 1 }
| Ramen let Eye = { index = 1 ; reel1Count = 3 ; reel2Count = 2 ; reel3Count = 1 }
| Rat let Obey = { index = 2 ; reel1Count = 2 ; reel2Count = 2 ; reel3Count = 2 }
| Alcohol let AnonMask = { index = 3 ; reel1Count = 1 ; reel2Count = 5 ; reel3Count = 8 }
| BigBrother let Sushi = { index = 4 ; reel1Count = 7 ; reel2Count = 3 ; reel3Count = 3 }
| Sushi 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 = let slots =
[| "https://s7.gifyu.com/images/aneye.png" [| "https://s7.gifyu.com/images/aneye.png"
@ -80,7 +94,7 @@ let payTable = [| |]
let PlayPrice = 10<GBT> let PlayPrice = 10<GBT>
let twoOfAKindPrize = 100<GBT> let twoOfAKindPrize = 100<GBT>
let threeOfAKindPrize = 1000<GBT> let threeOfAKindPrize = 1000<GBT>
let sleepTime = 1000 let sleepTime = 1500
let spinEmbeds (results : int array) (ctx : IDiscordContext) = let spinEmbeds (results : int array) (ctx : IDiscordContext) =
async { async {
@ -157,19 +171,18 @@ let spinFiles (results : int array) (ctx : IDiscordContext) =
let spin spinType (ctx : IDiscordContext) = let spin spinType (ctx : IDiscordContext) =
PlayerInteractions.executePlayerAction ctx (fun player -> async { PlayerInteractions.executePlayerAction ctx (fun player -> async {
let random = Random(System.Guid.NewGuid().GetHashCode()) let random = Random(System.Guid.NewGuid().GetHashCode())
let slotCount = slots.Length let symbols = [| reel1.[random.Next(0, reel1.Length)] ; reel2.[random.Next(0, reel2.Length)] ; reel3.[random.Next(0, reel3.Length)] |]
let results = [| random.Next(0, slotCount) ; random.Next(0, slotCount) ; random.Next(0, slotCount) |]
let winConditions = (results.[0] = results.[1] && results.[0] = results.[2]) let winConditions = (symbols.[0] = symbols.[1] && symbols.[0] = symbols.[2])
if winConditions if winConditions
then do! DbService.updatePlayerCurrency twoOfAKindPrize player |> Async.Ignore then do! DbService.updatePlayerCurrency twoOfAKindPrize player |> Async.Ignore
else do! DbService.updatePlayerCurrency -PlayPrice player |> Async.Ignore else do! DbService.updatePlayerCurrency -PlayPrice player |> Async.Ignore
match spinType with match spinType with
| "Embeds" -> do! spinEmbeds results ctx | "Embeds" -> do! spinEmbeds symbols ctx
| "Emojis" -> do! spinEmojis results ctx | "Emojis" -> do! spinEmojis symbols ctx
| "Files" -> do! spinFiles results ctx | "Files" -> do! spinFiles symbols ctx
| _ -> () | _ -> ()
do! Async.Sleep sleepTime do! Async.Sleep sleepTime