Fix issues where people don't have money and improve hack/shield embeds

This commit is contained in:
Joseph Ferano 2022-02-26 13:27:34 +07:00
parent 658c57f97b
commit ad17e139c6
4 changed files with 29 additions and 10 deletions

View File

@ -36,6 +36,7 @@ let getShieldGif = function
let constructButtons (actionId: string) (buttonInfo : string) (player: PlayerData) itemType ignoreCooldown =
player
|> Player.getItems itemType
|> Array.sortBy (fun i -> i.Power)
|> Array.map (fun item ->
let action =
player.Events
@ -58,13 +59,17 @@ let pickDefense actionId player isTrainer =
let embed =
DiscordEmbedBuilder()
.WithTitle("Shields")
.WithTitle("Shield Defense")
.WithDescription("Pick a shield to protect yourself from hacks")
.WithImageUrl(shieldGif)
for s in Player.getShields player |> Array.sortBy (fun i -> i.Power) do
let hours = TimeSpan.FromMinutes(int s.Cooldown).TotalHours
let against = Game.getGoodAgainst(s.Class) |> snd
embed.AddField(s.Name, $"Active {hours} hours\nDefeats {against}", true) |> ignore
DiscordFollowupMessageBuilder()
.AddComponents(buttons)
.AddEmbed(embed)
.AddEmbeds([ DiscordEmbedBuilder().WithImageUrl(shieldGif).Build() ; embed.Build() ])
.AsEphemeral(true)
let pickHack actionId attacker defender isTrainer =
@ -72,13 +77,16 @@ let pickHack actionId attacker defender isTrainer =
let embed =
DiscordEmbedBuilder()
.WithTitle("Hacks")
.WithDescription($"Pick the hack that you want to use against {defender.Name}")
.WithImageUrl(hackGif)
.WithTitle("Hack Attack")
.WithDescription($"{defender.Name} has **{defender.Bank} $GBT** we can take from them. 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
DiscordFollowupMessageBuilder()
.AddComponents(buttons)
.AddEmbed(embed.Build())
.AddEmbeds([ DiscordEmbedBuilder().WithImageUrl(hackGif).Build() ; embed.Build() ])
.AsEphemeral true
let responseSuccessfulHack earnedMoney (targetId : uint64) amountTaken (hack : Item) =

View File

@ -21,8 +21,8 @@ module Game =
let getGoodAgainst = function
| 0 -> ( ShieldId.Firewall , HackId.Virus )
| 1 -> ( ShieldId.Cypher , HackId.RemoteAccess )
| _ -> ( ShieldId.Encryption , HackId.Worm )
| 1 -> ( ShieldId.Encryption , HackId.RemoteAccess )
| _ -> ( ShieldId.Cypher , HackId.Worm )
let executePlayerAction (ctx : IDiscordContext) (dispatch : PlayerData -> Async<unit>) =
async {

View File

@ -62,6 +62,11 @@ let checkPlayerHasShieldSlotsAvailable (shield : Item) player =
Error $"You are only allowed three shields at a time. Wait {cooldown} to add another shield"
| false -> Ok updatedPlayer
let checkTargetHasFunds target player =
match target.Bank = 0<GBT> with
| true -> Error $"Looks like the poor bastard has no $GBT... pick a different victim."
| false -> Ok player
let calculateDamage (hack : Item) (shield : Item) =
if hack.Class = shield.Class
then Weak

View File

@ -80,6 +80,11 @@ let checkVictimStealingCooldown defender attacker =
Error $"{defender.Name} was robbed recently so they won't be going out for at least another {hours}."
| None -> Ok attacker
let checkTargetHasFunds target player =
match target.Bank = 0<GBT> with
| true -> Error $"Looks like the poor bastard has no $GBT... pick a different victim."
| false -> Ok player
let checkThiefCooldown attacker =
attacker
|> Player.removeExpiredActions
@ -211,7 +216,8 @@ let handleSteal (ctx : IDiscordContext) =
do! attacker
|> Player.removeExpiredActions
// |> checkVictimStealingCooldown defender
|> checkThiefCooldown
|> checkThiefCooldown
>>= checkTargetHasFunds defender
|> handleResultWithResponse ctx (handleYes defender )
})
else