From 7ebba3f61ac04b9f02c8555d2c77be9bffc832ad Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Thu, 3 Feb 2022 15:26:44 +0700 Subject: [PATCH] Fix some leftover follow up messages and empty arsenal bugs --- Bot/HackerBattle.fs | 10 +++++----- Bot/Store.fs | 2 +- Bot/Trainer.fs | 7 +++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Bot/HackerBattle.fs b/Bot/HackerBattle.fs index 5f1699b..5c906ce 100644 --- a/Bot/HackerBattle.fs +++ b/Bot/HackerBattle.fs @@ -41,8 +41,8 @@ let checkIfHackHasCooldown hackId attacker = let item = Armory.battleItems |> Array.find (fun i -> i.Id = hackId) Error $"{item.Name} is currently on cooldown, wait {cooldown} to use it again." -let checkIfInventoryIsEmpty attacker = - match attacker.Arsenal with +let checkIfHasEmptyHacks attacker = + match Player.hacks attacker with | [||] -> Error $"You currently do not have any Hacks to steal 💰$GBT from others. Please go to the <#{GuildEnvironment.channelArmory}> and purchase one." | _ -> Ok attacker @@ -117,7 +117,7 @@ let attack (ctx : InteractionContext) (target : DiscordUser) = do! attacker |> Player.removeExpiredActions |> checkForExistingTarget defender.DiscordId - >>= checkIfInventoryIsEmpty + >>= checkIfHasEmptyHacks >>= checkIfTargetHasMoney defender >>= checkIfPlayerIsAttackingThemselves defender |> function @@ -134,7 +134,7 @@ let attack (ctx : InteractionContext) (target : DiscordUser) = ctx.FollowUpAsync(builder) |> Async.AwaitTask |> Async.Ignore - | None -> do! sendSimpleResponse ctx "Your target is not connected to the network, they must join first by using the /redpill command" + | None -> do! sendFollowUpMessageFromCtx ctx "Your target is not connected to the network, they must join first by using the /redpill command" }) let handleAttack (event : ComponentInteractionCreateEventArgs) = @@ -168,7 +168,7 @@ let defend (ctx : InteractionContext) = |> Async.AwaitTask |> Async.Ignore else - let msg = $"You currently do not have any Shields to protect you. Please go to the <#{GuildEnvironment.channelArmory}> and purchase one." + let msg = $"You currently do not have any Shields to protect yourself from hacks. Please go to the <#{GuildEnvironment.channelArmory}> and purchase one." do! Messaging.sendFollowUpMessageFromCtx ctx msg }) diff --git a/Bot/Store.fs b/Bot/Store.fs index 3546b09..108e644 100644 --- a/Bot/Store.fs +++ b/Bot/Store.fs @@ -54,7 +54,7 @@ let sell (ctx : InteractionContext) = |> Async.AwaitTask |> Async.Ignore else - do! sendSimpleResponse ctx "You currently have no inventory to sell" + do! sendFollowUpMessageFromCtx ctx "You currently have no inventory to sell" }) let handleBuyItem (ctx : InteractionContext) itemId = diff --git a/Bot/Trainer.fs b/Bot/Trainer.fs index 0135ac8..2e4ed52 100644 --- a/Bot/Trainer.fs +++ b/Bot/Trainer.fs @@ -30,7 +30,6 @@ let sendInitialEmbed (client : DiscordClient) = let handleTrainerStep1 (event : ComponentInteractionCreateEventArgs) = Game.executePlayerEvent event (fun player -> async { - let shieldMessage , weaponName = if Player.shields player |> Array.isEmpty then $"You do not have any Shields in your arsenal, take this {defaultShield.Name}, you can use it for now.\n\n" , defaultShield.Name @@ -40,7 +39,7 @@ let handleTrainerStep1 (event : ComponentInteractionCreateEventArgs) = do! sendFollowUpMessage event ("Beautopia© is a dangerous place...\n" - + "Quick, put up a SHIELD 🛡 before another Degen hacks you, and steals your 💰$GBT.\n" + + "Quick, put up a SHIELD 🛡 before another Degen hacks you, and steals your 💰$GBT.\n\n" + shieldMessage + "To enable it, you need to run the `/shield` slash command.\n\n" + $"Type the `/shield` command now, then select - `{weaponName}`\n") @@ -49,7 +48,7 @@ let handleTrainerStep1 (event : ComponentInteractionCreateEventArgs) = let defend (ctx : InteractionContext) = Game.executePlayerInteraction ctx (fun player -> async { let playerWithShields = - match player.Arsenal with + match Player.shields player with | [||] -> { player with Arsenal = [| defaultShield |] } | _ -> player @@ -86,7 +85,7 @@ let handleDefense (event : ComponentInteractionCreateEventArgs) = let handleTrainerStep3 (event : ComponentInteractionCreateEventArgs) = Game.executePlayerEvent event (fun player -> async { let hackMessage , weaponName = - if Player.shields player |> Array.isEmpty + if Player.hacks player |> Array.isEmpty then $"You do not have any Hacks in your arsenal, take this `{defaultHack.Name}`, you can use it for now.\n\n" , defaultHack.Name else let name = Player.hacks player |> Array.tryHead |> Option.defaultValue defaultHack |> fun w -> w.Name