Whitelist + Recruit + Jpegs

This commit is contained in:
Joseph Ferano 2022-05-12 16:53:21 +07:00
parent c4eb2af1f8
commit f1423c1fbc
6 changed files with 59 additions and 56 deletions

View File

@ -33,6 +33,7 @@ let readItem (reader : RowReader) =
| "Food" -> ItemType.Food | "Food" -> ItemType.Food
| "Accessory" -> ItemType.Accessory | "Accessory" -> ItemType.Accessory
| "Jpeg" -> ItemType.Jpeg | "Jpeg" -> ItemType.Jpeg
| "Whitelist" -> ItemType.Whitelist
| _ -> ItemType.Misc | _ -> ItemType.Misc
Item.Attributes = [ Item.Attributes = [
reader.intOrNone "buy_price" |> Option.map (fun a -> Buyable (a * 1<GBT>)) reader.intOrNone "buy_price" |> Option.map (fun a -> Buyable (a * 1<GBT>))
@ -58,8 +59,8 @@ let getPlayerInventory (did : uint64) =
|> Sql.connect |> Sql.connect
|> Sql.parameters [ "did", Sql.string (string did) ] |> Sql.parameters [ "did", Sql.string (string did) ]
|> Sql.query """ |> Sql.query """
SELECT ii.id,name,description,icon_url,image_url,category,buy_price,sell_price,rate_limit,expiration,drop_chance,can_trade,can_consume, SELECT ii.id,name,description,icon_url,image_url,category,buy_price,sell_price,rate_limit,
attack_power,defense_power,class_name,max_stack,mods expiration,drop_chance,can_trade,can_consume,attack_power,defense_power,class_name,max_stack,mods
FROM inventory_item FROM inventory_item
JOIN item ii on inventory_item.item_id = ii.id JOIN item ii on inventory_item.item_id = ii.id
JOIN "user" usr on inventory_item.user_id = usr.id JOIN "user" usr on inventory_item.user_id = usr.id
@ -104,8 +105,8 @@ let getStoreItems (storeId : string) =
|> Sql.connect |> Sql.connect
|> Sql.parameters [ "sid", Sql.string storeId ] |> Sql.parameters [ "sid", Sql.string storeId ]
|> Sql.query """ |> Sql.query """
SELECT store_id,stock,available,limit_stock,i.id,name,description,icon_url,image_url,category,buy_price,sell_price,rate_limit,expiration,drop_chance,can_trade,can_consume, SELECT store_id,stock,available,limit_stock,i.id,name,description,icon_url,image_url,category,
attack_power,defense_power,class_name,max_stack,mods buy_price,sell_price,rate_limit,expiration,drop_chance,can_trade,can_consume,attack_power,defense_power,class_name,max_stack,mods
FROM store_item FROM store_item
JOIN item i on store_item.item_id = i.id JOIN item i on store_item.item_id = i.id
WHERE store_id = @sid; WHERE store_id = @sid;
@ -124,8 +125,8 @@ let getStoreItemBySymbol (itemSymbol : string) =
|> Sql.connect |> Sql.connect
|> Sql.parameters [ "iid", Sql.string itemSymbol ] |> Sql.parameters [ "iid", Sql.string itemSymbol ]
|> Sql.query """ |> Sql.query """
SELECT store_id,stock,available,limit_stock,i.id,name,description,icon_url,image_url,category,buy_price,sell_price,rate_limit,expiration,drop_chance,can_trade,can_consume, SELECT store_id,stock,available,limit_stock,i.id,name,description,icon_url,image_url,category,
attack_power,defense_power,class_name,max_stack,mods buy_price,sell_price,rate_limit,expiration,drop_chance,can_trade,can_consume,attack_power,defense_power,class_name,max_stack,mods
FROM store_item FROM store_item
JOIN item i on store_item.item_id = i.id JOIN item i on store_item.item_id = i.id
WHERE item_id = @iid; WHERE item_id = @iid;

View File

@ -13,6 +13,7 @@ module Inventory =
| ItemType.Food -> inventory |> List.filter (fun item -> match item.Type with ItemType.Food _ -> true | _ -> false) | ItemType.Food -> inventory |> List.filter (fun item -> match item.Type with ItemType.Food _ -> true | _ -> false)
| ItemType.Accessory -> inventory |> List.filter (fun item -> match item.Type with ItemType.Accessory _ -> true | _ -> false) | ItemType.Accessory -> inventory |> List.filter (fun item -> match item.Type with ItemType.Accessory _ -> true | _ -> false)
| ItemType.Jpeg -> inventory |> List.filter (fun item -> match item.Type with ItemType.Jpeg _ -> true | _ -> false) | ItemType.Jpeg -> inventory |> List.filter (fun item -> match item.Type with ItemType.Jpeg _ -> true | _ -> false)
| ItemType.Whitelist -> inventory |> List.filter (fun item -> match item.Type with ItemType.Whitelist _ -> true | _ -> false)
| ItemType.Misc -> inventory |> List.filter (fun item -> match item.Type with ItemType.Misc _ -> true | _ -> false) | ItemType.Misc -> inventory |> List.filter (fun item -> match item.Type with ItemType.Misc _ -> true | _ -> false)
let findItemById id (inventory : Inventory) = inventory |> List.find (fun item -> item.Id = id) let findItemById id (inventory : Inventory) = inventory |> List.find (fun item -> item.Id = id)

View File

@ -85,6 +85,7 @@ type ItemType =
| Food | Food
| Accessory | Accessory
| Jpeg | Jpeg
| Whitelist
| Misc | Misc
type Effect = type Effect =

View File

@ -57,35 +57,43 @@ let getItemEmbeds owned (items : StoreItem list) =
|> List.map (fun (item,count) -> |> List.map (fun (item,count) ->
let mutable titleText = item.Item.Name let mutable titleText = item.Item.Name
let embed = DiscordEmbedBuilder() let embed = DiscordEmbedBuilder()
use table = new DataTable()
table.SetBorder(Border.None)
table.SetShowTableName(false)
let values : ResizeArray<string * string> = ResizeArray()
if not owned && item.LimitStock then if not owned && item.LimitStock then
values.Add("Stock", $"{item.Stock}") embed.AddField("Stock", $"{item.Stock}", true) |> ignore
item.Item.Attributes item.Item.Attributes
|> List.iter (function |> List.iter (function
| Buyable price -> | Buyable price ->
if not owned then if not owned then
values.Add("Price", (if price = 0<GBT> then "Free" else $"{price} $GBT")) embed.AddField("Price", (if price = 0<GBT> then "Free" else $"{price} $GBT"), true) |> ignore
| Attackable power -> | Attackable power ->
let title = match item.Item.Type with ItemType.Hack -> "Reward" | _ -> "Power" let title = match item.Item.Type with ItemType.Hack -> "Reward" | _ -> "Power"
values.Add($"{title}", string power) embed.AddField($"{title}", string power, true) |> ignore
| Classable className ->
let title =
match item.Item.Type with
| ItemType.Hack -> "Weak Against" | ItemType.Shield -> "Defeats"
| _ -> ""
let goodAgainst =
match item.Item.Type with
| ItemType.Hack -> WeaponClass.getGoodAgainst className |> fst |> string
| ItemType.Shield -> WeaponClass.getGoodAgainst className |> snd |> string
| _ -> ""
let weaponName = Arsenal.weapons |> List.find (fun w -> w.Id = goodAgainst) |> fun i -> i.Name
embed.AddField(title, weaponName, true) |> ignore
| RateLimitable time -> | RateLimitable time ->
match item.Item.Type with let title =
| ItemType.Hack -> () match item.Item.Type with
| ItemType.Shield -> | ItemType.Hack -> "Cooldown" | ItemType.Shield -> "Active For"
let ts = TimeSpan.FromMinutes(int time) | _ -> ""
let timeStr = if ts.Hours = 0 then $"{ts.Minutes} mins" else $"{ts.Hours} hours" let ts = TimeSpan.FromMinutes(int time)
values.Add($"Active", timeStr) let timeStr = if ts.Hours = 0 then $"{ts.Minutes} mins" else $"{ts.Hours} hours"
| _ -> () embed.AddField(title, timeStr, true) |> ignore
| Stackable max -> | Stackable max ->
if owned then if owned
let totalOwned = getTotalOwnedOfItem item.Item (items |> List.map (fun i -> i.Item)) |> Option.defaultValue 1 then embed.AddField($"Owned", $"{count}", true)
titleText <- $"{totalOwned}x " + titleText else embed.AddField($"Max Allowed", $"{max}", true)
// values.Add($"Total Owned", $"{count}") |> ignore
// else values.Add($"Max Allowed", $"{max}") // let totalOwned = getTotalOwnedOfItem item.Item (items |> List.map (fun i -> i.Item)) |> Option.defaultValue 1
() // titleText <- $"{totalOwned}x " + titleText
| Modifiable effects -> | Modifiable effects ->
let fx = let fx =
effects effects
@ -98,31 +106,14 @@ let getItemEmbeds owned (items : StoreItem list) =
$"{f.TargetStat} {str} + {i}" $"{f.TargetStat} {str} + {i}"
| RateMultiplier i -> $"{f.TargetStat} Multiplier - i") | RateMultiplier i -> $"{f.TargetStat} Multiplier - i")
|> String.concat "\n" |> String.concat "\n"
values.Add($"Effect - Amount", $"{fx}") embed.AddField($"Effect - Amount", $"{fx}", true) |> ignore
| _ -> ()) | _ -> ())
for title , _ in values do if item.Item.Type = ItemType.Whitelist then
let column = table.Columns.Add(title) embed.AddField("Mint Allowance", (if item.Item.Id = "WHITEOG" then 3 else 2) |> string, true) |> ignore
column.SetWidth(10) embed.Color <- WeaponClass.getClassEmbedColor item.Item
column.SetDataAlignment(TextAlignment.Center) embed.Title <- titleText
column.SetHeaderBorder(Border.Bottom) embed.Description <- item.Item.Description
column.SetDataBorder(Border.Top) embed.ImageUrl <- "https://stage.degenz.game/blank-row.png"
let arr : obj array = values |> Seq.map snd |> Seq.cast<obj> |> Seq.toArray
table.Rows.Add(arr) |> ignore
// TODO: This isn't working, try using an image
// if not (String.IsNullOrEmpty item.Item.Description) then
// embed.Url <- item.Item.Description
// embed.Footer <- DiscordEmbedBuilder.EmbedFooter()
// embed.Footer.Text <- item.Item.Description
embed
.WithColor(WeaponClass.getClassEmbedColor item.Item)
.WithTitle(titleText)
|> ignore
if table.Columns.Count > 0 then
let split = table.ToPrettyPrintedString().Split("\n")
let text = split |> Array.skip 1 |> Array.take (split.Length - 3) |> String.concat "\n"
embed.WithDescription($"```{text}```") |> ignore
if String.IsNullOrWhiteSpace(item.Item.IconUrl) if String.IsNullOrWhiteSpace(item.Item.IconUrl)
then embed then embed
else embed.WithThumbnail(item.Item.IconUrl)) else embed.WithThumbnail(item.Item.IconUrl))
@ -165,6 +156,14 @@ let purchaseItemEmbed quantity (item : Item) =
embed.ImageUrl <- item.ImageUrl embed.ImageUrl <- item.ImageUrl
embed.Thumbnail <- DiscordEmbedBuilder.EmbedThumbnail() embed.Thumbnail <- DiscordEmbedBuilder.EmbedThumbnail()
embed.Thumbnail.Url <- item.IconUrl embed.Thumbnail.Url <- item.IconUrl
| ItemType.Whitelist ->
embed.ImageUrl <- item.ImageUrl
let og = if item.Id = "WHITEOG" then "OG " else ""
embed.Description <- $"""
🎉 Congratulations, you purchased {og}WHITELIST!
**__Mint Day: 31ST MAY__**
Keep an eye on <#{GuildEnvironment.channelAnnouncements}> for updates!"""
| _ -> embed.Description <- $"Purchased {item.Name}" | _ -> embed.Description <- $"Purchased {item.Name}"
embed embed
@ -253,7 +252,7 @@ let handleBuyItem (ctx : IDiscordContext) itemId =
match item.Attributes , getTotalOwnedOfItem item player.Inventory |> Option.defaultValue 0 with match item.Attributes , getTotalOwnedOfItem item player.Inventory |> Option.defaultValue 0 with
| CanStack max , amount -> | CanStack max , amount ->
embed.AddField("Owned", $"{amount + 1}", true) |> ignore embed.AddField("Owned", $"{amount + 1}", true) |> ignore
embed.AddField("New $GBT Balance", $"`💰` {player.Bank} `💰` {player.Bank - price} `({price} $GBT)`", true) |> ignore embed.AddField("New $GBT Balance", $"`💰` {player.Bank - price} `(-{price} $GBT)`", true) |> ignore
if amount + 1 < max then if amount + 1 < max then
let btn = DiscordButtonComponent(WeaponClass.getClassButtonColor item, $"Buy-{item.Id}-{storeId}", $"Buy Another") let btn = DiscordButtonComponent(WeaponClass.getClassButtonColor item, $"Buy-{item.Id}-{storeId}", $"Buy Another")
builder.AddComponents(btn) |> ignore builder.AddComponents(btn) |> ignore

View File

@ -41,6 +41,7 @@ let channelBackAlley = getId "CHANNEL_BACKALLEY"
let channelMarket = getId "CHANNEL_MARKET" let channelMarket = getId "CHANNEL_MARKET"
let channelAccessoryShop = getId "CHANNEL_ACCESSORIES" let channelAccessoryShop = getId "CHANNEL_ACCESSORIES"
let channelGiveaway = getId "CHANNEL_GIVEAWAY" let channelGiveaway = getId "CHANNEL_GIVEAWAY"
let channelAnnouncements = getId "CHANNEL_ANNOUNCEMENTS"
//let channelThievery = getId "CHANNEL_THIEVERY" //let channelThievery = getId "CHANNEL_THIEVERY"
let botIdHackerBattle = getId "BOT_HACKER_BATTLE" let botIdHackerBattle = getId "BOT_HACKER_BATTLE"

View File

@ -284,21 +284,21 @@ let sendInitialEmbed (ctx : IDiscordContext) =
let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelRecruitment) let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelRecruitment)
let rewardMsg = $""" let rewardMsg = $"""
**__Win $2,000:__** **__Win $2,000:__**
- 🙋 1 invite = 1 entry per day 🙋 1 invite = 1 entry everyday*
- 🎟 $100 daily raffles till mint* 🎟 $100 daily raffles till mint
- 💰 Earn an additional 100 $GBT for every Degen you invite! 💰 Earn an additional 100 $GBT for every Degen you invite!
**__How To Invite:__** **__How To Invite:__**
- CLICK THE BUTTON below - CLICK THE BUTTON below
- Share your LINK with anyone you want to invite. - Share your LINK with anyone you want to invite.
**must have invited at least 1 Degen to be eligible for that days $100 raffle* **Every invite increases your chances of winning the daily $100 raffles*
""" """
let embed = let embed =
DiscordEmbedBuilder() DiscordEmbedBuilder()
.WithColor(DiscordColor.CornflowerBlue) .WithColor(DiscordColor.CornflowerBlue)
.WithDescription(rewardMsg) .WithDescription(rewardMsg)
.WithImageUrl("https://cdn.discordapp.com/attachments/922422890991849542/973939752321564753/invite_banner7.png") .WithImageUrl("https://s8.gifyu.com/images/invite-banner-usdc.png")
.WithTitle("Invite Degenz") .WithTitle("Invite Degenz")
let builder = DiscordMessageBuilder().AddEmbed(embed) let builder = DiscordMessageBuilder().AddEmbed(embed)