50 lines
1.5 KiB
Forth
50 lines
1.5 KiB
Forth
module DegenzGame.Functions
|
|
|
|
open System
|
|
open DSharpPlus
|
|
open DSharpPlus.Entities
|
|
open DegenzGame.Shared
|
|
|
|
let hackDescription = ""
|
|
|
|
let statusFormat player =
|
|
$"Hack Inventory: {player.Weapons}
|
|
Shield Inventory: {player.Shields}
|
|
Active Hacks: {player.Attacks |> Array.toList}
|
|
Active Defenses: {player.Defenses |> Array.toList}
|
|
Bank: {player.Bank}"
|
|
|
|
let constructButtons (actionType : string) (playerInfo : string) (weapons : 'a array) =
|
|
weapons
|
|
|> Seq.map (fun hack ->
|
|
DiscordButtonComponent(
|
|
ButtonStyle.Primary,
|
|
$"{actionType}-{hack}-{playerInfo}",
|
|
$"{hack}"))
|
|
|
|
let removeExpiredActions timespan (timestamp : 'a -> DateTime) actions =
|
|
actions
|
|
|> Array.filter (fun act ->
|
|
if DateTime.UtcNow - (timestamp act) < timespan
|
|
then true
|
|
else false)
|
|
|
|
let constructEmbed message =
|
|
let builder = DiscordEmbedBuilder()
|
|
builder.Color <- Optional(DiscordColor.PhthaloGreen)
|
|
builder.Description <- message
|
|
let author = DiscordEmbedBuilder.EmbedAuthor()
|
|
author.Name <- "Degenz Hacker Game"
|
|
author.Url <- "https://twitter.com/degenzgame"
|
|
author.IconUrl <- "https://pbs.twimg.com/profile_images/1473192843359309825/cqjm0VQ4_400x400.jpg"
|
|
builder.Author <- author
|
|
builder.Build()
|
|
|
|
let calculateDamage (hack : int) (shield : int) =
|
|
let hackClass = getClass hack
|
|
let protectionClass = getClass shield
|
|
match hackClass , protectionClass with
|
|
| h , p when h = p -> Weak
|
|
| _ -> Strong
|
|
|