195 lines
8.4 KiB
Forth
195 lines
8.4 KiB
Forth
module Degenz.Embeds
|
|
|
|
open System
|
|
open DSharpPlus
|
|
open Degenz.Messaging
|
|
open Degenz.Types
|
|
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 getHackIcon = function
|
|
| HackId.Virus -> "https://s10.gifyu.com/images/Virus-icon.jpg"
|
|
| HackId.RemoteAccess -> "https://s10.gifyu.com/images/Mind-Control-Degenz-V2-min.jpg"
|
|
| HackId.Worm -> "https://s10.gifyu.com/images/WormBugAttack_Degenz-min.jpg"
|
|
| _ -> hackGif
|
|
|
|
let getShieldIcon = function
|
|
| ShieldId.Firewall -> "https://s10.gifyu.com/images/Defense-GIF-1-Degenz-1.jpg"
|
|
| ShieldId.Encryption -> "https://s10.gifyu.com/images/Encryption-Degenz-V2-1-min.jpg"
|
|
| ShieldId.Cypher -> "https://s10.gifyu.com/images/Cypher-Smaller.jpg"
|
|
| _ -> shieldGif
|
|
|
|
let getHackGif = function
|
|
| HackId.Virus -> "https://s10.gifyu.com/images/Attack-DegenZ-1.gif"
|
|
| HackId.RemoteAccess -> "https://s10.gifyu.com/images/Mind-Control-Degenz-V2-min.gif"
|
|
| HackId.Worm -> "https://s10.gifyu.com/images/WormBugAttack_Degenz-min.gif"
|
|
| _ -> hackGif
|
|
|
|
let getShieldGif = function
|
|
| ShieldId.Firewall -> "https://s10.gifyu.com/images/Defense-GIF-1-Degenz-min.gif"
|
|
| ShieldId.Encryption -> "https://s10.gifyu.com/images/Encryption-Degenz-V2-1-min.gif"
|
|
| ShieldId.Cypher -> "https://s10.gifyu.com/images/Cypher-Smaller.gif"
|
|
| _ -> shieldGif
|
|
|
|
let constructButtons (actionId: string) (buttonInfo : string) (player: PlayerData) itemType ignoreCooldown =
|
|
player
|
|
|> Player.getItems itemType
|
|
|> Array.map (fun item ->
|
|
let action =
|
|
player.Events
|
|
|> Array.tryFind (fun i ->
|
|
match i.Type with
|
|
| Hacking h -> h.HackId = item.Id && h.IsInstigator
|
|
| Shielding id -> id = item.Id
|
|
| _ -> false)
|
|
let btnColor = Game.getClassButtonColor item.Class
|
|
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<DiscordComponent>
|
|
|
|
let pickDefense actionId player isTrainer =
|
|
let buttons = constructButtons actionId (string player.DiscordId) player ItemType.Shield isTrainer
|
|
|
|
let embed =
|
|
DiscordEmbedBuilder()
|
|
.WithTitle("Shields")
|
|
.WithDescription("Pick a shield to protect yourself from hacks")
|
|
.WithImageUrl(shieldGif)
|
|
|
|
DiscordFollowupMessageBuilder()
|
|
.AddComponents(buttons)
|
|
.AddEmbed(embed)
|
|
.AsEphemeral(true)
|
|
|
|
let pickHack actionId attacker defender isTrainer =
|
|
let buttons = constructButtons actionId $"{defender.DiscordId}-{defender.Name}" attacker ItemType.Hack isTrainer
|
|
|
|
let embed =
|
|
DiscordEmbedBuilder()
|
|
.WithTitle("Hacks")
|
|
.WithDescription($"Pick the hack that you want to use against {defender.Name}")
|
|
.WithImageUrl(hackGif)
|
|
|
|
DiscordFollowupMessageBuilder()
|
|
.AddComponents(buttons)
|
|
.AddEmbed(embed.Build())
|
|
.AsEphemeral true
|
|
|
|
let responseSuccessfulHack earnedMoney (targetId : uint64) amountTaken (hack : Item) =
|
|
let embed =
|
|
DiscordEmbedBuilder()
|
|
.WithImageUrl(getHackGif (enum<HackId>(hack.Id)))
|
|
.WithTitle("Hack Attack")
|
|
.WithDescription($"You successfully hacked <@{targetId}> using {hack.Name}"
|
|
+ (if earnedMoney then $", and took {amountTaken} 💰$GBT from them!" else "!"))
|
|
|
|
DiscordFollowupMessageBuilder()
|
|
.AddEmbed(embed.Build())
|
|
.AsEphemeral(true)
|
|
|
|
let responseCreatedShield (shield : Item) =
|
|
let embed = DiscordEmbedBuilder().WithImageUrl(getShieldGif (enum<ShieldId>(shield.Id)))
|
|
embed.Title <- "Mounted Shield"
|
|
embed.Description <- $"Mounted {shield.Name} shield for {TimeSpan.FromMinutes(int shield.Cooldown).Hours} hours"
|
|
|
|
DiscordFollowupMessageBuilder()
|
|
.AddEmbed(embed)
|
|
.AsEphemeral(true)
|
|
|
|
let eventSuccessfulHack (ctx : IDiscordContext) target prize =
|
|
DiscordMessageBuilder()
|
|
.WithContent($"{ctx.GetDiscordMember().Username} successfully hacked <@{target.DiscordId}> and took {prize} GoodBoyTokenz")
|
|
|
|
let getBuyItemsEmbed (player : PlayerData) (itemType : ItemType) (store : Item array) =
|
|
let embeds , buttons =
|
|
store
|
|
|> Array.filter (fun i -> i.Type = itemType)
|
|
|> Array.map (fun item ->
|
|
let embed = DiscordEmbedBuilder()
|
|
match item.Type with
|
|
| ItemType.Hack ->
|
|
embed
|
|
.AddField($"$GBT Reward |", string item.Power, true)
|
|
.AddField("Cooldown |", $"{TimeSpan.FromMinutes(int item.Cooldown).Minutes} minutes", true)
|
|
.WithThumbnail(getHackIcon (enum<HackId>(item.Id)))
|
|
|> ignore
|
|
| _ ->
|
|
embed
|
|
// .AddField($"Defensive Strength |", string item.Power, true)
|
|
.AddField($"Strong against |", Game.getGoodAgainst item.Class |> snd |> string, true)
|
|
.AddField("Active For |", $"{TimeSpan.FromMinutes(int item.Cooldown).Hours} hours", true)
|
|
.WithThumbnail(getShieldIcon (enum<ShieldId>(item.Id)))
|
|
|> ignore
|
|
embed
|
|
.AddField("Price 💰", (if item.Price = 0<GBT> then "Free" else $"{item.Price} $GBT"), true)
|
|
.WithColor(Game.getClassEmbedColor item.Class)
|
|
.WithTitle($"{item.Name}")
|
|
|> ignore
|
|
let button =
|
|
if player.Inventory |> Array.exists (fun i -> i.Id = item.Id)
|
|
then DiscordButtonComponent(Game.getClassButtonColor item.Class, $"Buy-{item.Id}", $"Own {item.Name}", true)
|
|
else DiscordButtonComponent(Game.getClassButtonColor item.Class, $"Buy-{item.Id}", $"Buy {item.Name}")
|
|
embed.Build() , button :> DiscordComponent)
|
|
|> Array.unzip
|
|
|
|
DiscordFollowupMessageBuilder()
|
|
.AddEmbeds(embeds)
|
|
.AddComponents(buttons)
|
|
.AsEphemeral(true)
|
|
|
|
let getSellEmbed (itemType : ItemType) (player : PlayerData) =
|
|
let embeds , buttons =
|
|
player.Inventory
|
|
|> Array.filter (fun i -> i.Type = itemType)
|
|
|> Array.map (fun item ->
|
|
let embed = DiscordEmbedBuilder()
|
|
match item.Type with
|
|
| ItemType.Hack -> embed.WithThumbnail(getHackIcon (enum<HackId>(item.Id))) |> ignore
|
|
| _ -> embed.WithThumbnail(getShieldIcon (enum<ShieldId>(item.Id))) |> ignore
|
|
embed
|
|
.AddField("Sell For 💰", $"{item.Price} $GBT", true)
|
|
.WithTitle($"{item.Name}")
|
|
.WithColor(Game.getClassEmbedColor item.Class)
|
|
|> ignore
|
|
let button = DiscordButtonComponent(Game.getClassButtonColor item.Class, $"Sell-{item.Id}", $"Sell {item.Name}")
|
|
embed.Build() , button :> DiscordComponent)
|
|
|> Array.unzip
|
|
|
|
DiscordFollowupMessageBuilder()
|
|
.AddEmbeds(embeds)
|
|
.AddComponents(buttons)
|
|
.AsEphemeral(true)
|
|
|
|
let getArsenalEmbed (player : PlayerData) =
|
|
DiscordFollowupMessageBuilder()
|
|
.AsEphemeral(true)
|
|
.AddEmbed(
|
|
DiscordEmbedBuilder()
|
|
.AddField( "Arsenal", Arsenal.statusFormat player ))
|
|
|
|
let getAchievementEmbed rewards description achievement =
|
|
let embed = DiscordEmbedBuilder()
|
|
|
|
GuildEnvironment.botUserHackerBattle
|
|
|> Option.iter (fun bot ->
|
|
embed.Author <- DiscordEmbedBuilder.EmbedAuthor()
|
|
embed.Author.Name <- bot.Username
|
|
embed.Author.IconUrl <- bot.AvatarUrl)
|
|
|
|
DiscordFollowupMessageBuilder()
|
|
.AddEmbed(
|
|
embed.WithTitle("Achievement Unlocked!")
|
|
.WithDescription(description)
|
|
.WithColor(DiscordColor.Gold)
|
|
// .AddField("Achievement", $"🏆 {achievement}")
|
|
.AddField("Achievement", $"{achievement}", true)
|
|
.AddField("Rewards", rewards |> String.concat "\n", true)
|
|
// TODO: Once we add another achievement, fix this
|
|
.WithImageUrl("https://s10.gifyu.com/images/MasterTraining_Degenz.gif"))
|
|
.AsEphemeral(true) |