Setup steal bot, more tweaks
This commit is contained in:
parent
b03d712479
commit
8652828892
4
.gitignore
vendored
4
.gitignore
vendored
@ -10,9 +10,7 @@
|
|||||||
*.userosscache
|
*.userosscache
|
||||||
*.sln.docstates
|
*.sln.docstates
|
||||||
|
|
||||||
env.prod
|
*.env
|
||||||
env.stag
|
|
||||||
env.dev
|
|
||||||
|
|
||||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
*.userprefs
|
*.userprefs
|
||||||
|
18
Bot/Bot.fs
18
Bot/Bot.fs
@ -5,7 +5,6 @@ open DSharpPlus
|
|||||||
open DSharpPlus.SlashCommands
|
open DSharpPlus.SlashCommands
|
||||||
open Degenz
|
open Degenz
|
||||||
open Degenz.HackerBattle
|
open Degenz.HackerBattle
|
||||||
open Degenz.RockPaperScissors
|
|
||||||
open Degenz.Store
|
open Degenz.Store
|
||||||
open Degenz.Thief
|
open Degenz.Thief
|
||||||
open Emzi0767.Utilities
|
open Emzi0767.Utilities
|
||||||
@ -17,11 +16,12 @@ let guild = GuildEnvironment.guildId
|
|||||||
|
|
||||||
let hackerBattleConfig = DiscordConfiguration()
|
let hackerBattleConfig = DiscordConfiguration()
|
||||||
let storeConfig = DiscordConfiguration()
|
let storeConfig = DiscordConfiguration()
|
||||||
|
let stealConfig = DiscordConfiguration()
|
||||||
//let slotMachineConfig = DiscordConfiguration()
|
//let slotMachineConfig = DiscordConfiguration()
|
||||||
//hackerBattleConfig.MinimumLogLevel <- Microsoft.Extensions.Logging.LogLevel.Trace
|
//hackerBattleConfig.MinimumLogLevel <- Microsoft.Extensions.Logging.LogLevel.Trace
|
||||||
|
|
||||||
//let configs = [| hackerBattleConfig ; storeConfig ; slotMachineConfig ; |]
|
//let configs = [| hackerBattleConfig ; storeConfig ; slotMachineConfig ; |]
|
||||||
let configs = [ hackerBattleConfig ; storeConfig ]
|
let configs = [ hackerBattleConfig ; storeConfig ; stealConfig ]
|
||||||
|
|
||||||
hackerBattleConfig.TokenType <- TokenType.Bot
|
hackerBattleConfig.TokenType <- TokenType.Bot
|
||||||
hackerBattleConfig.Intents <- DiscordIntents.All
|
hackerBattleConfig.Intents <- DiscordIntents.All
|
||||||
@ -29,27 +29,34 @@ hackerBattleConfig.Intents <- DiscordIntents.All
|
|||||||
storeConfig.TokenType <- TokenType.Bot
|
storeConfig.TokenType <- TokenType.Bot
|
||||||
storeConfig.Intents <- DiscordIntents.All
|
storeConfig.Intents <- DiscordIntents.All
|
||||||
|
|
||||||
|
stealConfig.TokenType <- TokenType.Bot
|
||||||
|
stealConfig.Intents <- DiscordIntents.All
|
||||||
|
|
||||||
hackerBattleConfig.Token <- GuildEnvironment.tokenHackerBattle
|
hackerBattleConfig.Token <- GuildEnvironment.tokenHackerBattle
|
||||||
storeConfig.Token <- GuildEnvironment.tokenStore
|
storeConfig.Token <- GuildEnvironment.tokenStore
|
||||||
|
stealConfig.Token <- GuildEnvironment.tokenSteal
|
||||||
//slotMachineConfig.Token <- Environment.GetEnvironmentVariable("BOT_SLOT_MACHINE")
|
//slotMachineConfig.Token <- Environment.GetEnvironmentVariable("BOT_SLOT_MACHINE")
|
||||||
|
|
||||||
let hackerBattleBot = new DiscordClient(hackerBattleConfig)
|
let hackerBattleBot = new DiscordClient(hackerBattleConfig)
|
||||||
let storeBot = new DiscordClient(storeConfig)
|
let storeBot = new DiscordClient(storeConfig)
|
||||||
|
let stealBot = new DiscordClient(stealConfig)
|
||||||
//let slotMachineBot = new DiscordClient(slotMachineConfig)
|
//let slotMachineBot = new DiscordClient(slotMachineConfig)
|
||||||
|
|
||||||
//let clients = [| hackerBattleBot ; storeBot ; slotMachineBot |]
|
//let clients = [| hackerBattleBot ; storeBot ; slotMachineBot |]
|
||||||
let hackerCommands = hackerBattleBot.UseSlashCommands()
|
let hackerCommands = hackerBattleBot.UseSlashCommands()
|
||||||
let storeCommands = storeBot.UseSlashCommands()
|
let storeCommands = storeBot.UseSlashCommands()
|
||||||
|
let stealCommands = stealBot.UseSlashCommands()
|
||||||
//let sc3 = slotMachineBot.UseSlashCommands()
|
//let sc3 = slotMachineBot.UseSlashCommands()
|
||||||
|
|
||||||
hackerCommands.RegisterCommands<HackerGame>(guild);
|
hackerCommands.RegisterCommands<HackerGame>(guild);
|
||||||
hackerCommands.RegisterCommands<StealGame>(guild);
|
|
||||||
//hackerCommands.RegisterCommands<RPSGame>(guild);
|
|
||||||
storeCommands.RegisterCommands<Store>(guild);
|
storeCommands.RegisterCommands<Store>(guild);
|
||||||
|
stealCommands.RegisterCommands<StealGame>(guild);
|
||||||
|
//hackerCommands.RegisterCommands<RPSGame>(guild);
|
||||||
//sc3.RegisterCommands<SlotMachine>(guild);
|
//sc3.RegisterCommands<SlotMachine>(guild);
|
||||||
|
|
||||||
hackerBattleBot.add_ComponentInteractionCreated(AsyncEventHandler(HackerBattle.handleButtonEvent))
|
hackerBattleBot.add_ComponentInteractionCreated(AsyncEventHandler(HackerBattle.handleButtonEvent))
|
||||||
storeBot.add_ComponentInteractionCreated(AsyncEventHandler(Store.handleStoreEvents))
|
storeBot.add_ComponentInteractionCreated(AsyncEventHandler(Store.handleStoreEvents))
|
||||||
|
stealBot.add_ComponentInteractionCreated(AsyncEventHandler(Thief.handleStealButton))
|
||||||
|
|
||||||
let asdf (_ : DiscordClient) (event : DSharpPlus.EventArgs.InteractionCreateEventArgs) =
|
let asdf (_ : DiscordClient) (event : DSharpPlus.EventArgs.InteractionCreateEventArgs) =
|
||||||
async {
|
async {
|
||||||
@ -72,9 +79,12 @@ if guild <> 922419263275425832uL then
|
|||||||
|
|
||||||
hackerBattleBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
hackerBattleBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
GuildEnvironment.botUserHackerBattle <- Some hackerBattleBot.CurrentUser
|
GuildEnvironment.botUserHackerBattle <- Some hackerBattleBot.CurrentUser
|
||||||
|
|
||||||
storeBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
storeBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
GuildEnvironment.botUserArmory <- Some storeBot.CurrentUser
|
GuildEnvironment.botUserArmory <- Some storeBot.CurrentUser
|
||||||
|
|
||||||
|
stealBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
|
|
||||||
//async {
|
//async {
|
||||||
// let! user = hackerBattleBot.GetUserAsync(GuildEnvironment.botIdHackerBattle) |> Async.AwaitTask
|
// let! user = hackerBattleBot.GetUserAsync(GuildEnvironment.botIdHackerBattle) |> Async.AwaitTask
|
||||||
// if user <> null then
|
// if user <> null then
|
||||||
|
@ -4,18 +4,16 @@ module Degenz.GuildEnvironment
|
|||||||
open System
|
open System
|
||||||
open DSharpPlus.Entities
|
open DSharpPlus.Entities
|
||||||
open dotenv.net
|
open dotenv.net
|
||||||
let g = Environment.GetEnvironmentVariable("DISCORD_GUILD")
|
DotEnv.Load(DotEnvOptions(envFilePaths = [ "../../../../.dev.env" ], overwriteExistingVars = false))
|
||||||
printfn $"{g}"
|
//DotEnv.Load(DotEnvOptions(envFilePaths = [ "../../../../.sta.env" ], overwriteExistingVars = false))
|
||||||
DotEnv.Load(DotEnvOptions(envFilePaths = [ "../../../../env.dev" ], overwriteExistingVars = false))
|
//DotEnv.Load(DotEnvOptions(envFilePaths = [ "../../../../.prod.env" ], overwriteExistingVars = false))
|
||||||
//DotEnv.Load(DotEnvOptions(envFilePaths = [ "../../../../env.stag" ], overwriteExistingVars = false))
|
|
||||||
//DotEnv.Load(DotEnvOptions(envFilePaths = [ "../../../../env.prod" ], overwriteExistingVars = false))
|
|
||||||
|
|
||||||
let getVar str = Environment.GetEnvironmentVariable(str)
|
let getVar str = Environment.GetEnvironmentVariable(str)
|
||||||
let getId str = getVar str |> uint64
|
let getId str = getVar str |> uint64
|
||||||
|
|
||||||
let guildId = getId "DISCORD_GUILD"
|
let guildId = getId "DISCORD_GUILD"
|
||||||
printfn $"{guildId}"
|
|
||||||
let tokenPlayerInteractions = getVar "TOKEN_PLAYER_INTERACTIONS"
|
let tokenPlayerInteractions = getVar "TOKEN_PLAYER_INTERACTIONS"
|
||||||
|
let tokenSteal = getVar "TOKEN_STEAL"
|
||||||
let tokenHackerBattle = getVar "TOKEN_HACKER_BATTLE"
|
let tokenHackerBattle = getVar "TOKEN_HACKER_BATTLE"
|
||||||
let tokenStore = getVar "TOKEN_STORE"
|
let tokenStore = getVar "TOKEN_STORE"
|
||||||
let channelEventsHackerBattle = getId "CHANNEL_EVENTS_HACKER_BATTLE"
|
let channelEventsHackerBattle = getId "CHANNEL_EVENTS_HACKER_BATTLE"
|
||||||
|
18
Bot/Thief.fs
18
Bot/Thief.fs
@ -4,11 +4,12 @@ open System
|
|||||||
open System.Threading.Tasks
|
open System.Threading.Tasks
|
||||||
open DSharpPlus
|
open DSharpPlus
|
||||||
open DSharpPlus.Entities
|
open DSharpPlus.Entities
|
||||||
|
open DSharpPlus.EventArgs
|
||||||
open DSharpPlus.SlashCommands
|
open DSharpPlus.SlashCommands
|
||||||
open Degenz.Messaging
|
open Degenz.Messaging
|
||||||
|
|
||||||
let ThiefCooldown = TimeSpan.FromMinutes(1)
|
let ThiefCooldown = TimeSpan.FromMinutes(1)
|
||||||
let VictimRecovery = TimeSpan.FromHours(6)
|
let VictimRecovery = TimeSpan.FromHours(4)
|
||||||
|
|
||||||
type StealResult =
|
type StealResult =
|
||||||
| Success
|
| Success
|
||||||
@ -116,7 +117,8 @@ let checkThiefCooldown attacker =
|
|||||||
|
|
||||||
let calculateWinPercentage amountRequested bank attackerStrength defenderStrength =
|
let calculateWinPercentage amountRequested bank attackerStrength defenderStrength =
|
||||||
let powerPercentage = float (attackerStrength - defenderStrength) * 0.005 + 0.1
|
let powerPercentage = float (attackerStrength - defenderStrength) * 0.005 + 0.1
|
||||||
let cappedAmount = float bank * 0.5
|
// let cappedAmount = float bank * 0.5
|
||||||
|
let cappedAmount = float bank
|
||||||
let cappedRequest , wasCapped = if amountRequested > cappedAmount then ( cappedAmount , true ) else ( amountRequested , false )
|
let cappedRequest , wasCapped = if amountRequested > cappedAmount then ( cappedAmount , true ) else ( amountRequested , false )
|
||||||
let wagerPercentage = 1.0 - (cappedRequest / cappedAmount)
|
let wagerPercentage = 1.0 - (cappedRequest / cappedAmount)
|
||||||
// Max chance of success is 90.0%
|
// Max chance of success is 90.0%
|
||||||
@ -246,6 +248,18 @@ let handleSteal (ctx : IDiscordContext) =
|
|||||||
do! ctx.Respond InteractionResponseType.UpdateMessage builder |> Async.AwaitTask
|
do! ctx.Respond InteractionResponseType.UpdateMessage builder |> Async.AwaitTask
|
||||||
} |> Async.StartAsTask :> Task
|
} |> Async.StartAsTask :> Task
|
||||||
|
|
||||||
|
let handleStealButton (_ : DiscordClient) (event : ComponentInteractionCreateEventArgs) =
|
||||||
|
let eventCtx = DiscordEventContext event :> IDiscordContext
|
||||||
|
match event.Id with
|
||||||
|
| id when id.StartsWith("Steal") -> handleSteal eventCtx
|
||||||
|
| _ ->
|
||||||
|
task {
|
||||||
|
let builder = DiscordInteractionResponseBuilder()
|
||||||
|
builder.IsEphemeral <- true
|
||||||
|
builder.Content <- $"Incorrect Action identifier {eventCtx.GetInteractionId()}"
|
||||||
|
do! eventCtx.Respond InteractionResponseType.ChannelMessageWithSource builder |> Async.AwaitTask
|
||||||
|
}
|
||||||
|
|
||||||
type StealGame() =
|
type StealGame() =
|
||||||
inherit ApplicationCommandModule ()
|
inherit ApplicationCommandModule ()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user