Check if the target has funds and improve the embed for training
This commit is contained in:
parent
ad17e139c6
commit
0804c1a409
@ -75,14 +75,16 @@ let pickDefense actionId player isTrainer =
|
|||||||
let pickHack actionId attacker defender isTrainer =
|
let pickHack actionId attacker defender isTrainer =
|
||||||
let buttons = constructButtons actionId $"{defender.DiscordId}-{defender.Name}" attacker ItemType.Hack 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 =
|
let embed =
|
||||||
DiscordEmbedBuilder()
|
DiscordEmbedBuilder()
|
||||||
.WithTitle("Hack Attack")
|
.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.")
|
||||||
|
|
||||||
|
if not isTrainer then
|
||||||
for h in Player.getHacks attacker |> Array.sortBy (fun i -> i.Power) do
|
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
|
let amount = if h.Power > int defender.Bank then int defender.Bank else h.Power
|
||||||
embed.AddField(h.Name, $"Extract {amount}", true) |> ignore
|
embed.AddField(h.Name, $"Cooldown {h.Cooldown} mins\nExtract {amount} $GBT", true) |> ignore
|
||||||
|
|
||||||
DiscordFollowupMessageBuilder()
|
DiscordFollowupMessageBuilder()
|
||||||
.AddComponents(buttons)
|
.AddComponents(buttons)
|
||||||
|
@ -140,6 +140,7 @@ let hack (target : DiscordUser) (ctx : IDiscordContext) =
|
|||||||
do! attacker
|
do! attacker
|
||||||
|> Player.removeExpiredActions
|
|> Player.removeExpiredActions
|
||||||
|> checkAlreadyHackedTarget defender
|
|> checkAlreadyHackedTarget defender
|
||||||
|
>>= checkTargetHasFunds defender
|
||||||
>>= checkHasEmptyHacks
|
>>= checkHasEmptyHacks
|
||||||
>>= checkPlayerIsAttackingThemselves defender
|
>>= checkPlayerIsAttackingThemselves defender
|
||||||
|> function
|
|> function
|
||||||
|
11
Bot/Thief.fs
11
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."
|
| true -> Error $"Looks like the poor bastard has no $GBT... pick a different victim."
|
||||||
| false -> Ok player
|
| 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 =
|
let checkThiefCooldown attacker =
|
||||||
attacker
|
attacker
|
||||||
|> Player.removeExpiredActions
|
|> Player.removeExpiredActions
|
||||||
@ -118,6 +123,8 @@ let steal target amount (ctx : IDiscordContext) =
|
|||||||
thief
|
thief
|
||||||
|> checkPlayerIsAttackingThemselves victim
|
|> checkPlayerIsAttackingThemselves victim
|
||||||
// |> checkVictimStealingCooldown victim
|
// |> checkVictimStealingCooldown victim
|
||||||
|
>>= checkTargetHasFunds victim
|
||||||
|
>>= checkPrizeRequestZero amount
|
||||||
|> handleResultWithResponse ctx (fun _ -> async {
|
|> handleResultWithResponse ctx (fun _ -> async {
|
||||||
let cappedPrize , winPercentage , wasCapped =
|
let cappedPrize , winPercentage , wasCapped =
|
||||||
calculateWinPercentage amount (int victim.Bank) thief.Traits.Strength victim.Traits.Strength
|
calculateWinPercentage amount (int victim.Bank) thief.Traits.Strength victim.Traits.Strength
|
||||||
@ -244,9 +251,9 @@ type StealGame() =
|
|||||||
|
|
||||||
[<SlashCommand("steal", "Steal some money from another player, but you might go to prison if caught")>]
|
[<SlashCommand("steal", "Steal some money from another player, but you might go to prison if caught")>]
|
||||||
member this.Steal (ctx : InteractionContext,
|
member this.Steal (ctx : InteractionContext,
|
||||||
[<Option("amount", "How much you would like to steal")>] amount : double,
|
[<Option("amount", "How much you would like to steal")>] amount : int64,
|
||||||
[<Option("target", "Who do you want to steal from?")>] target : DiscordUser) =
|
[<Option("target", "Who do you want to steal from?")>] target : DiscordUser) =
|
||||||
// enforceChannel (DiscordInteractionContext ctx) (steal target amount)
|
// enforceChannel (DiscordInteractionContext ctx) (steal target amount)
|
||||||
steal target amount (DiscordInteractionContext ctx)
|
steal target (int amount) (DiscordInteractionContext ctx)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user