Read store items from json file
This commit is contained in:
parent
f92e253dac
commit
5ef3243c41
4
GameConfig/HackerGame.json
Normal file
4
GameConfig/HackerGame.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"AttackerPrize" : 1.337,
|
||||||
|
"AttackerPenalty" : 0.345
|
||||||
|
}
|
62
GameConfig/Items.json
Normal file
62
GameConfig/Items.json
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"Name" : "Virus",
|
||||||
|
"ItemType" : { "Case" : "Weapon" },
|
||||||
|
"Cost" : 5.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name" : "Ransom",
|
||||||
|
"ItemType" : { "Case" : "Weapon" },
|
||||||
|
"Cost" : 10.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name" : "Worm",
|
||||||
|
"ItemType" : { "Case" : "Weapon" },
|
||||||
|
"Cost" : 5.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name" : "DDos",
|
||||||
|
"ItemType" : { "Case" : "Weapon" },
|
||||||
|
"Cost" : 10.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name" : "Crack",
|
||||||
|
"ItemType" : { "Case" : "Weapon" },
|
||||||
|
"Cost" : 5.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name" : "Injection",
|
||||||
|
"ItemType" : { "Case" : "Weapon" },
|
||||||
|
"Cost" : 10.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name" : "Firewall",
|
||||||
|
"ItemType" : { "Case" : "Shield" },
|
||||||
|
"Cost" : 5.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name" : "PortScan",
|
||||||
|
"ItemType" : { "Case" : "Shield" },
|
||||||
|
"Cost" : 10.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name" : "Encryption",
|
||||||
|
"ItemType" : { "Case" : "Shield" },
|
||||||
|
"Cost" : 5.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name" : "Hardening",
|
||||||
|
"ItemType" : { "Case" : "Shield" },
|
||||||
|
"Cost" : 10.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name" : "Cypher",
|
||||||
|
"ItemType" : { "Case" : "Shield" },
|
||||||
|
"Cost" : 5.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name" : "Sanitation",
|
||||||
|
"ItemType" : { "Case" : "Shield" },
|
||||||
|
"Cost" : 10.0
|
||||||
|
}
|
||||||
|
]
|
@ -131,7 +131,7 @@ let handleAttack (event : ComponentInteractionCreateEventArgs) =
|
|||||||
|> Async.Ignore
|
|> Async.Ignore
|
||||||
| true ->
|
| true ->
|
||||||
let builder = DiscordInteractionResponseBuilder()
|
let builder = DiscordInteractionResponseBuilder()
|
||||||
let prize = 0.0623f
|
let prize = 0.223f
|
||||||
builder.IsEphemeral <- true
|
builder.IsEphemeral <- true
|
||||||
builder.Content <- $"Hack failed! {split.[3]} was able to mount a successful defense! You lost {prize} GoodBoyTokenz!"
|
builder.Content <- $"Hack failed! {split.[3]} was able to mount a successful defense! You lost {prize} GoodBoyTokenz!"
|
||||||
do! event.Interaction.CreateResponseAsync(InteractionResponseType.UpdateMessage, builder)
|
do! event.Interaction.CreateResponseAsync(InteractionResponseType.UpdateMessage, builder)
|
||||||
|
@ -27,7 +27,7 @@ module Commands =
|
|||||||
Shields = shields
|
Shields = shields
|
||||||
Attacks = [||]
|
Attacks = [||]
|
||||||
Defenses = [||]
|
Defenses = [||]
|
||||||
Bank = 0f }
|
Bank = 15f }
|
||||||
|
|
||||||
let addHackerRole (ctx : InteractionContext) =
|
let addHackerRole (ctx : InteractionContext) =
|
||||||
async {
|
async {
|
||||||
@ -49,6 +49,7 @@ module Commands =
|
|||||||
}
|
}
|
||||||
|
|
||||||
if newPlayer then
|
if newPlayer then
|
||||||
|
// TODO: Add a better registration message that shows which weapon and how much currency they start with
|
||||||
do! ctx.CreateResponseAsync("You are now an elite haxxor", true)
|
do! ctx.CreateResponseAsync("You are now an elite haxxor", true)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
else
|
else
|
||||||
|
@ -30,6 +30,17 @@ type Shield =
|
|||||||
| Sanitation = 5
|
| Sanitation = 5
|
||||||
| Cypher = 3
|
| Cypher = 3
|
||||||
|
|
||||||
|
[<CLIMutable>]
|
||||||
|
type Item = {
|
||||||
|
Name : string
|
||||||
|
ItemType : ItemType
|
||||||
|
Cost : single
|
||||||
|
}
|
||||||
|
|
||||||
|
let weaponInventory = [| Weapon.Virus ; Weapon.Ransom ; Weapon.DDos ; Weapon.Worm ; Weapon.Crack ; Weapon.Injection |]
|
||||||
|
let shieldInventory = [| Shield.Firewall ; Shield.PortScan ; Shield.Encryption ; Shield.Cypher ; Shield.Hardening ; Shield.Sanitation |]
|
||||||
|
|
||||||
|
|
||||||
let getClass =
|
let getClass =
|
||||||
function
|
function
|
||||||
| 0
|
| 0
|
||||||
@ -68,9 +79,6 @@ type Player =
|
|||||||
Bank: single }
|
Bank: single }
|
||||||
|
|
||||||
|
|
||||||
let weaponInventory = [| Weapon.Virus ; Weapon.Ransom ; Weapon.DDos ; Weapon.Worm ; Weapon.Crack ; Weapon.Injection |]
|
|
||||||
let shieldInventory = [| Shield.Firewall ; Shield.PortScan ; Shield.Encryption ; Shield.Cypher ; Shield.Hardening ; Shield.Sanitation |]
|
|
||||||
|
|
||||||
let createSimpleResponseAsync msg (ctx: InteractionContext) =
|
let createSimpleResponseAsync msg (ctx: InteractionContext) =
|
||||||
async {
|
async {
|
||||||
let builder = DiscordInteractionResponseBuilder()
|
let builder = DiscordInteractionResponseBuilder()
|
||||||
|
@ -4,9 +4,9 @@ open DSharpPlus.Entities
|
|||||||
open DSharpPlus
|
open DSharpPlus
|
||||||
open DSharpPlus.EventArgs
|
open DSharpPlus.EventArgs
|
||||||
open DSharpPlus.SlashCommands
|
open DSharpPlus.SlashCommands
|
||||||
open DegenzGame
|
|
||||||
open DegenzGame.Shared
|
open DegenzGame.Shared
|
||||||
open Emzi0767.Utilities
|
open Emzi0767.Utilities
|
||||||
|
open Newtonsoft.Json
|
||||||
|
|
||||||
module Commands =
|
module Commands =
|
||||||
let constructItemButtons playerInfo (items : 'a array) =
|
let constructItemButtons playerInfo (items : 'a array) =
|
||||||
@ -16,10 +16,15 @@ module Commands =
|
|||||||
let viewStore (ctx : InteractionContext) =
|
let viewStore (ctx : InteractionContext) =
|
||||||
async {
|
async {
|
||||||
let builder = DiscordInteractionResponseBuilder()
|
let builder = DiscordInteractionResponseBuilder()
|
||||||
let hacks = weaponInventory |> Array.map (fun w -> $"{w} - 5 GBT") |> String.concat "\n"
|
|
||||||
builder.AddEmbed (constructEmbed $"Hacks:\n{hacks}") |> ignore
|
try
|
||||||
let shields = shieldInventory |> Array.map (fun w -> $"{w} - 5 GBT") |> String.concat "\n"
|
let file = System.IO.File.ReadAllText("Items.json")
|
||||||
builder.AddEmbed (constructEmbed $"Shields:\n{shields}") |> ignore
|
JsonConvert.DeserializeObject<Item array>(file)
|
||||||
|
|> Array.groupBy (fun (i : Item) -> i.ItemType)
|
||||||
|
|> Array.iter (fun ( itemType , items ) ->
|
||||||
|
let itemList = items |> Array.map (fun i -> $"{i.Name} - {i.Cost} GBT") |> String.concat "\n"
|
||||||
|
builder.AddEmbed (constructEmbed $"{itemType}:\n{itemList}") |> ignore)
|
||||||
|
with _ -> builder.Content <- "System error preparing inventory for viewing"
|
||||||
|
|
||||||
builder.AsEphemeral true |> ignore
|
builder.AsEphemeral true |> ignore
|
||||||
|
|
||||||
|
@ -12,6 +12,10 @@
|
|||||||
<Content Include=".dockerignore" />
|
<Content Include=".dockerignore" />
|
||||||
<Content Include="Dockerfile" />
|
<Content Include="Dockerfile" />
|
||||||
<Content Include="paket.references" />
|
<Content Include="paket.references" />
|
||||||
|
<Content Include="..\GameConfig\Items.json">
|
||||||
|
<Link>Items.json</Link>
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\DbService\DbService.fsproj" />
|
<ProjectReference Include="..\DbService\DbService.fsproj" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user