module Degenz.Embeds open System open DSharpPlus open Degenz open Degenz.Messaging open DSharpPlus.Entities let hackGif = "https://s10.gifyu.com/images/Hacker-Degenz-V20ce8eb832734aa62-min.gif" let shieldGif = "https://s10.gifyu.com/images/Defense-Degenz-V2-min.gif" let constructButtons (actionId: string) (buttonInfo : string) (player: PlayerData) (items : Inventory) ignoreCooldown = items |> List.sortBy (fun item -> item.Id) |> List.map (fun item -> let action = player.Events |> List.tryFind (fun event -> match event.Type with | Hacking h -> h.HackId = item.Id && h.IsInstigator | Shielding id -> id = item.Id | _ -> false) let btnColor = WeaponClass.getClassButtonColor item match action , ignoreCooldown with | None , _ | Some _ , true -> DiscordButtonComponent(btnColor, $"{actionId}-{item.Id}-{buttonInfo}-{player.Name}", $"{item.Name}") | Some event , false -> let time = Messaging.getShortTimeText (TimeSpan.FromMinutes(int event.Cooldown)) event.Timestamp DiscordButtonComponent(btnColor, $"{actionId}-{item.Id}", $"{item.Name} ({time} left)", true)) |> Seq.cast let pickDefense actionId player isTrainer = let shieldItems = player.Inventory |> Inventory.getItemsByType ItemType.Shield |> List.sortBy (fun item -> item.Id) let buttons = constructButtons actionId (string player.DiscordId) player shieldItems isTrainer let embed = DiscordEmbedBuilder() .WithTitle("Shield Defense") .WithDescription("Pick a shield to protect yourself from hacks") for shield in Inventory.getShields player.Inventory do let hours = TimeSpan.FromMinutes(int shield.Cooldown).TotalHours |> int let against = WeaponClass.getGoodAgainst shield.Class |> snd let emoji = match shield.Id with | "FIREWALL" -> "<:firewall_shield:971620988649340989>" | "ENCRYPTION" -> "<:encryption_shield:971620979912605727>" | "CYPHER" -> "<:cypher_shield:971620965576503326>" | _ -> "" embed.AddField($"{emoji} {shield.Name}", $"Active {hours} hours\nDefeats {against}", true) |> ignore DiscordFollowupMessageBuilder() .AddComponents(buttons) .AddEmbeds([ DiscordEmbedBuilder().WithImageUrl(shieldGif).Build() ; embed.Build() ]) .AsEphemeral(true) let pickHack actionId attacker defender bonus isTrainer = let hackItems = attacker.Inventory |> Inventory.getItemsByType ItemType.Hack |> List.sortBy (fun item -> item.Id) let buttons = constructButtons actionId $"{defender.DiscordId}-{defender.Name}" attacker hackItems isTrainer let ( outcomeMsg , bonusMsg ) = if attacker.Stats.Strength.Amount > defender.Stats.Strength.Amount then "\nYou're **STRONGER** so you'll **HACK MORE!!!** `💰$GBT`\n" , $"\n**__Potential Bonus:__**\n`{bonus} 💰$GBT`" else "\nYou're **NOT STRONGER** than them, you need to **EAT MORE!**" , "" let stealMsg = if not isTrainer then $""" **{defender.Name}** has `{defender.Bank} 💰$GBT` we can take from them. **__Your Strength:__** `💪 {attacker.Stats.Strength.Amount}` **__Their Strength:__** `💪 {defender.Stats.Strength.Amount}` {outcomeMsg}{bonusMsg}""" else "" let embed = DiscordEmbedBuilder() .WithTitle("Hack Attack") .WithDescription($"{stealMsg}\n\nPick the hack you want to use.") if not isTrainer then let hacks = Inventory.getHacks attacker.Inventory |> List.sortBy (fun h -> h.Id) for hack in hacks do let amount = if hack.Power > int defender.Bank then int defender.Bank else hack.Power let emoji = match hack.Id with | "REMOTE" -> "<:remote_access:971621009981571132>" | "VIRUS" -> "<:virus_hack:971636840580927510>" | "WORM" -> "<:worm_hack:971636842640310312>" | _ -> "" let fieldMsg = $""" Hack Base: `{hack.Power} 💰$GBT` Bonus: `{bonus} 💰$GBT` **Hack Total:** `{amount + bonus} 💰$GBT`""" embed.AddField($"{emoji} __{hack.Name}__", fieldMsg, true) |> ignore DiscordFollowupMessageBuilder() .AddComponents(buttons) .AddEmbeds([ DiscordEmbedBuilder().WithImageUrl(hackGif).Build() ; embed.Build() ]) .AsEphemeral true let responseSuccessfulHack (hacker : PlayerData) (target : PlayerData) totalTaken bonus (hack : HackItem) = let earnedMoney = totalTaken > 0 let msg = $"You successfully hacked <@{target.DiscordId}> using {hack.Name}!\n\n" + (if earnedMoney then $"**__Total Stolen__**: {totalTaken} 💰$GBT\n" else "") let bonusMsg = if bonus > 0 then $"Because your strength is `💪 {hacker.Stats.Strength.Amount}` and your target's strength is `💪 {target.Stats.Strength.Amount}` You stole an extra `{bonus}` 💰$GBT" else "" let embed = DiscordEmbedBuilder() .WithImageUrl(hack.ImageUrl) .WithTitle("✅ Hack Successful!") .WithDescription($"{msg}\n{bonusMsg}") embed.AddField("New $GBT Balance", $"`💰` {hacker.Bank} ⋙ `💰` {hacker.Bank + totalTaken} `(+{totalTaken} $GBT)`") |> ignore DiscordFollowupMessageBuilder() .AddEmbed(embed.Build()) .AsEphemeral(true) let responseCreatedShield (shield : ShieldItem) = let embed = DiscordEmbedBuilder().WithImageUrl(shield.ImageUrl) embed.Title <- "Mounted Shield" embed.Description <- $"Mounted {shield.Name} shield for {TimeSpan.FromMinutes(int shield.Cooldown).TotalHours} hours" DiscordFollowupMessageBuilder() .AddEmbed(embed) .AsEphemeral(true) let eventSuccessfulHack (ctx : IDiscordContext) target prize = DiscordMessageBuilder() .WithAllowedMention(UserMention(target.DiscordId)) .WithContent($"{ctx.GetDiscordMember().Username} successfully hacked {target.Name} and took {prize} GoodBoyTokenz") let getArsenalEmbed (player : PlayerData) = DiscordFollowupMessageBuilder() .AsEphemeral(true) .AddEmbed( DiscordEmbedBuilder() .AddField( "Arsenal", Arsenal.statusFormat player )) let getAchievementEmbed rewards description achievement = let embed = DiscordEmbedBuilder() GuildEnvironment.botClientHacker |> Option.iter (fun bot -> embed.Author <- DiscordEmbedBuilder.EmbedAuthor() embed.Author.Name <- bot.CurrentUser.Username embed.Author.IconUrl <- bot.CurrentUser.AvatarUrl) DiscordFollowupMessageBuilder() .AddEmbed( embed.WithTitle("Achievement Unlocked!") .WithDescription(description) .WithColor(DiscordColor.Gold) // .AddField("Achievement", $"🏆 {achievement}") .AddField("Achievement", $"{achievement}", true) .AddField("Gifts", rewards |> String.concat "\n", true) // TODO: Once we add another achievement, fix this .WithImageUrl("https://s10.gifyu.com/images/MasterTraining_Degenz.gif")) .AsEphemeral(true)