discord-bot-game/Bot/Embeds.fs

149 lines
6.3 KiB
Forth

module Degenz.Embeds
open System
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 getHackGif = 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 getShieldGif = 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 constructButtons (actionType: string) (playerInfo: string) (items: BattleItem array) =
items
|> Array.map (fun item -> DiscordButtonComponent(Game.getClassButtonColor item.Class, $"{actionType}-{item.Id}-{playerInfo}", $"{item.Name}"))
let pickDefense actionId player =
let buttons =
constructButtons actionId (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 $"{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 (targetId : uint64) (hack : BattleItem) =
let embed = DiscordEmbedBuilder()
embed.ImageUrl <- getHackGif (enum<HackId>(hack.Id))
DiscordFollowupMessageBuilder()
.WithContent($"You successfully hacked <@{targetId}> 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) targetId prize =
DiscordMessageBuilder()
.WithContent($"{event.User.Username} successfully hacked <@{targetId}> for a total of {prize} GoodBoyTokenz")
let eventFailedHack (event : ComponentInteractionCreateEventArgs) targetId prize =
DiscordMessageBuilder()
.WithContent($"{event.User.Username} successfully hacked <@{targetId}> 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 (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(getHackGif (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(getShieldGif (enum<ShieldId>(item.Id)))
|> ignore
embed
.AddField("Cost 💰", $"{item.Cost} $GBT", true)
.WithColor(Game.getClassEmbedColor item.Class)
.WithTitle($"{item.Name}")
|> ignore
let button = 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(getHackGif (enum<HackId>(item.Id))) |> ignore
| Shield -> embed.WithThumbnail(getShieldGif (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)