168 lines
7.4 KiB
Forth
168 lines
7.4 KiB
Forth
module Degenz.Embeds
|
|
|
|
open System
|
|
open DSharpPlus
|
|
open DSharpPlus.EventArgs
|
|
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 (actionType: string) (player: PlayerData) (buttonId : string) (items: BattleItem array) =
|
|
items
|
|
|> Array.map (fun item ->
|
|
match player.Actions |> Array.exists (fun i -> i.ActionId = item.Id) with
|
|
| true -> DiscordButtonComponent(Game.getClassButtonColor item.Class, $"{actionType}-{item.Id}", $"{item.Name} (on cooldown)", true)
|
|
| false -> DiscordButtonComponent(Game.getClassButtonColor item.Class, $"{actionType}-{item.Id}-{buttonId}", $"{item.Name}"))
|
|
|
|
let pickDefense actionId player =
|
|
let buttons =
|
|
constructButtons actionId player (string player.DiscordId) (Player.shields player)
|
|
|> Seq.cast<DiscordComponent>
|
|
|
|
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 =
|
|
let buttons =
|
|
let hacks = Player.hacks attacker
|
|
constructButtons actionId attacker $"{defender.DiscordId}-{defender.Name}" hacks
|
|
|> Seq.cast<DiscordComponent>
|
|
|
|
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 (targetName : string) (hack : BattleItem) =
|
|
let embed = DiscordEmbedBuilder()
|
|
embed.ImageUrl <- getHackGif (enum<HackId>(hack.Id))
|
|
|
|
DiscordFollowupMessageBuilder()
|
|
.WithContent($"You successfully hacked {targetName} using {hack.Name}, and stole 💰$GBT {Game.HackPrize} from them!")
|
|
.AddEmbed(embed.Build())
|
|
.AsEphemeral(true)
|
|
|
|
let responseCreatedShield (shield : BattleItem) =
|
|
DiscordFollowupMessageBuilder()
|
|
.AddEmbed(DiscordEmbedBuilder().WithImageUrl(getShieldGif (enum<ShieldId>(shield.Id))))
|
|
.AsEphemeral(true)
|
|
.WithContent($"Mounted {shield.Name} shield for {TimeSpan.FromMinutes(int shield.Cooldown).Hours} hours")
|
|
|
|
let responseCreatedShieldTrainer (shield : BattleItem) =
|
|
DiscordFollowupMessageBuilder()
|
|
.AddEmbed(DiscordEmbedBuilder().WithImageUrl(getShieldGif (enum<ShieldId>(shield.Id))))
|
|
.AsEphemeral(true)
|
|
.WithContent($"Mounted a {shield.Name} defense for {TimeSpan.FromMinutes(int shield.Cooldown).Hours} hours")
|
|
|
|
let eventSuccessfulHack (event : ComponentInteractionCreateEventArgs) target prize =
|
|
DiscordMessageBuilder()
|
|
.WithContent($"{event.User.Username} successfully hacked {target.Name} for a total of {prize} GoodBoyTokenz")
|
|
|
|
let eventFailedHack (event : ComponentInteractionCreateEventArgs) target prize =
|
|
DiscordMessageBuilder()
|
|
.WithContent($"{event.User.Username} successfully hacked {target.Name} for a total of {prize} GoodBoyTokenz")
|
|
|
|
let getGoodAgainst = function
|
|
| BattleClass.Network -> ( ShieldId.Firewall , HackId.Virus )
|
|
| BattleClass.Penetration -> ( ShieldId.Cypher , HackId.RemoteAccess )
|
|
| BattleClass.Exploit -> ( ShieldId.Encryption , HackId.Worm )
|
|
|
|
let getBuyItemsEmbed (player : PlayerData) (itemType : ItemType) (store : BattleItem array) =
|
|
let embeds , buttons =
|
|
store
|
|
|> Array.filter (fun i -> i.Type = itemType)
|
|
|> Array.map (fun item ->
|
|
let embed = DiscordEmbedBuilder()
|
|
match item.Type with
|
|
| Hack ->
|
|
embed
|
|
.AddField($"Weak Against |", getGoodAgainst item.Class |> fst |> string , true)
|
|
.AddField("Cooldown |", $"{TimeSpan.FromMinutes(int item.Cooldown).Minutes} minutes", true)
|
|
.WithThumbnail(getHackIcon (enum<HackId>(item.Id)))
|
|
|> ignore
|
|
| Shield ->
|
|
embed
|
|
.AddField($"Strong Against |", 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("Cost 💰", $"{item.Cost} $GBT", true)
|
|
.WithColor(Game.getClassEmbedColor item.Class)
|
|
.WithTitle($"{item.Name}")
|
|
|> ignore
|
|
let button =
|
|
if player.Arsenal |> 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 getSellItemsEmbed (itemType : ItemType) (player : PlayerData) =
|
|
let embeds , buttons =
|
|
player.Arsenal
|
|
|> Array.filter (fun i -> i.Type = itemType)
|
|
|> Array.map (fun item ->
|
|
let embed = DiscordEmbedBuilder()
|
|
match item.Type with
|
|
| Hack -> embed.WithThumbnail(getHackIcon (enum<HackId>(item.Id))) |> ignore
|
|
| Shield -> embed.WithThumbnail(getShieldIcon (enum<ShieldId>(item.Id))) |> ignore
|
|
embed
|
|
.AddField("Sell For 💰", $"{item.Cost} $GBT", true)
|
|
.WithColor(Game.getClassEmbedColor item.Class)
|
|
.WithTitle($"{item.Name}")
|
|
|> 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)
|