diff --git a/Bot/GuildEnvironment.fs b/Bot/GuildEnvironment.fs index 1be2aa8..a81a5a0 100644 --- a/Bot/GuildEnvironment.fs +++ b/Bot/GuildEnvironment.fs @@ -11,7 +11,8 @@ DotEnv.Load(DotEnvOptions(envFilePaths = [ "../../../../.dev.env" ], overwriteEx let getVar str = Environment.GetEnvironmentVariable(str) let getId str = getVar str |> uint64 -let pgDb = getVar "CONN_STRING_2" +let pgDb = getVar "DATABASE_URL" + let guildId = getId "DISCORD_GUILD" let tokenPlayerInteractions = getVar "TOKEN_PLAYER_INTERACTIONS" let tokenSteal = getVar "TOKEN_STEAL" diff --git a/Bot/Thief.fs b/Bot/Thief.fs index e0bcb93..d523206 100644 --- a/Bot/Thief.fs +++ b/Bot/Thief.fs @@ -151,11 +151,6 @@ let handleSteal (ctx : IDiscordContext) = let num = rand.NextDouble() let dp = { DiscordPlayer.Id = targetId ; DiscordPlayer.Name = targetName } - let stealAction = { - Type = Stealing ( true , dp ) - Cooldown = ThiefCooldown.Minutes * 1 - Timestamp = DateTime.UtcNow - } let getResultEmbed' = getResultEmbed winPercentage prize thief.Bank thief dp // TODO: Send event to the hall of privacy // TODO: We need to check if the player is on cooldown @@ -170,9 +165,8 @@ let handleSteal (ctx : IDiscordContext) = Timestamp = DateTime.UtcNow Cooldown = VictimRecovery.Minutes * 1 } - let actions = t |> Player.removeExpiredActions |> fun p -> Array.append [| mugged |] p.Events - do! DbService.updatePlayer GuildEnvironment.pgDb { t with Bank = max (t.Bank - prize) 0 ; Events = actions } - |> Async.Ignore + do! DbService.updatePlayer GuildEnvironment.pgDb { t with Bank = max (t.Bank - prize) 0 } |> Async.Ignore + do! DbService.addPlayerEvent GuildEnvironment.pgDb victim.DiscordId mugged |> Async.Ignore | None -> () let stole = { @@ -180,13 +174,16 @@ let handleSteal (ctx : IDiscordContext) = Cooldown = ThiefCooldown.Minutes * 1 Timestamp = DateTime.UtcNow } - let actions = thief |> Player.removeExpiredActions |> fun p -> Array.append [| stole |] p.Events - do! DbService.updatePlayer GuildEnvironment.pgDb { thief with Bank = thief.Bank + prize ; Events = actions } - |> Async.Ignore + do! DbService.updatePlayer GuildEnvironment.pgDb { thief with Bank = thief.Bank + prize } |> Async.Ignore + do! DbService.addPlayerEvent GuildEnvironment.pgDb victim.DiscordId stole |> Async.Ignore | false -> let embed = getResultEmbed' WentToPrison - do! DbService.updatePlayer GuildEnvironment.pgDb { thief with Events = Array.append [| stealAction |] thief.Events } - |> Async.Ignore + let imprisoned = { + Type = Imprison + Cooldown = ThiefCooldown.Minutes * 1 + Timestamp = DateTime.UtcNow + } + do! DbService.addPlayerEvent GuildEnvironment.pgDb victim.DiscordId imprisoned |> Async.Ignore do! Messaging.sendFollowUpEmbed ctx (embed.Build()) do! Async.Sleep 2000 let role = ctx.GetGuild().GetRole(GuildEnvironment.rolePrisoner) diff --git a/Shared/Shared.fs b/Shared/Shared.fs index 82fe138..21611f1 100644 --- a/Shared/Shared.fs +++ b/Shared/Shared.fs @@ -100,13 +100,11 @@ module Types = | Stealing of instigator : bool * adversary : DiscordPlayer | Imprison - [] type PlayerEvent = { Type : PlayerEventType Cooldown : int Timestamp : DateTime } - [] type PlayerTraits = { Strength : int Focus : int