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