From 0804c1a409dee797144e15dba257a919f406e7af Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Sat, 26 Feb 2022 16:02:26 +0700 Subject: [PATCH] Check if the target has funds and improve the embed for training --- Bot/Embeds.fs | 10 ++++++---- Bot/HackerBattle.fs | 1 + Bot/Thief.fs | 11 +++++++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Bot/Embeds.fs b/Bot/Embeds.fs index 66df061..be37bb7 100644 --- a/Bot/Embeds.fs +++ b/Bot/Embeds.fs @@ -75,14 +75,16 @@ let pickDefense actionId player isTrainer = let pickHack actionId attacker defender isTrainer = let buttons = constructButtons actionId $"{defender.DiscordId}-{defender.Name}" attacker ItemType.Hack isTrainer + let stealMsg = if not isTrainer then $"{defender.Name} has **{defender.Bank} $GBT** we can take from them. " else "" let embed = DiscordEmbedBuilder() .WithTitle("Hack Attack") - .WithDescription($"{defender.Name} has **{defender.Bank} $GBT** we can take from them. Pick the hack you want to use.") + .WithDescription($"{stealMsg}Pick the hack you want to use.") - for h in Player.getHacks attacker |> Array.sortBy (fun i -> i.Power) do - let amount = if h.Power > int defender.Bank then int defender.Bank else h.Power - embed.AddField(h.Name, $"Extract {amount}", true) |> ignore + if not isTrainer then + for h in Player.getHacks attacker |> Array.sortBy (fun i -> i.Power) do + let amount = if h.Power > int defender.Bank then int defender.Bank else h.Power + embed.AddField(h.Name, $"Cooldown {h.Cooldown} mins\nExtract {amount} $GBT", true) |> ignore DiscordFollowupMessageBuilder() .AddComponents(buttons) diff --git a/Bot/HackerBattle.fs b/Bot/HackerBattle.fs index 2d47d45..27b870f 100644 --- a/Bot/HackerBattle.fs +++ b/Bot/HackerBattle.fs @@ -140,6 +140,7 @@ let hack (target : DiscordUser) (ctx : IDiscordContext) = do! attacker |> Player.removeExpiredActions |> checkAlreadyHackedTarget defender + >>= checkTargetHasFunds defender >>= checkHasEmptyHacks >>= checkPlayerIsAttackingThemselves defender |> function diff --git a/Bot/Thief.fs b/Bot/Thief.fs index 128f6ef..12e5975 100644 --- a/Bot/Thief.fs +++ b/Bot/Thief.fs @@ -85,6 +85,11 @@ let checkTargetHasFunds target player = | true -> Error $"Looks like the poor bastard has no $GBT... pick a different victim." | false -> Ok player +let checkPrizeRequestZero request player = + match request <= 0 with + | true -> Error $"You don't want to steal anything? Were you dropped on your head as a kid? Pick a different amount" + | false -> Ok player + let checkThiefCooldown attacker = attacker |> Player.removeExpiredActions @@ -118,6 +123,8 @@ let steal target amount (ctx : IDiscordContext) = thief |> checkPlayerIsAttackingThemselves victim // |> checkVictimStealingCooldown victim + >>= checkTargetHasFunds victim + >>= checkPrizeRequestZero amount |> handleResultWithResponse ctx (fun _ -> async { let cappedPrize , winPercentage , wasCapped = calculateWinPercentage amount (int victim.Bank) thief.Traits.Strength victim.Traits.Strength @@ -244,9 +251,9 @@ type StealGame() = [] member this.Steal (ctx : InteractionContext, - [] amount : double, + [] amount : int64, [] target : DiscordUser) = // enforceChannel (DiscordInteractionContext ctx) (steal target amount) - steal target amount (DiscordInteractionContext ctx) + steal target (int amount) (DiscordInteractionContext ctx)