Reorder things, and remove explicit modules, remove unused opens
This commit is contained in:
parent
c45f1c6ca6
commit
9659656e4a
@ -13,11 +13,11 @@
|
||||
<Content Include="paket.references" />
|
||||
<Compile Include="Prelude.fs" />
|
||||
<Compile Include="GuildEnvironment.fs" />
|
||||
<Compile Include="GameTypes.fs" />
|
||||
<Compile Include="Messaging.fs" />
|
||||
<Compile Include="GameTypes.fs" />
|
||||
<Compile Include="GameHelpers.fs" />
|
||||
<Compile Include="DbService.fs" />
|
||||
<Compile Include="PlayerInteractions.fs" />
|
||||
<Compile Include="GameHelpers.fs" />
|
||||
<Compile Include="XP.fs" />
|
||||
<Compile Include="Embeds.fs" />
|
||||
<Compile Include="Games\SlotMachine.fs" />
|
||||
|
@ -1,8 +1,6 @@
|
||||
module Degenz.DbService
|
||||
|
||||
open System.Security.Cryptography.X509Certificates
|
||||
open Degenz.Types
|
||||
|
||||
open Degenz
|
||||
open System
|
||||
open Npgsql.FSharp
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
module Degenz.Embeds
|
||||
|
||||
open System
|
||||
open DSharpPlus
|
||||
open Degenz.Messaging
|
||||
open Degenz.Types
|
||||
open DSharpPlus.Entities
|
||||
@ -45,7 +44,7 @@ let constructButtons (actionId: string) (buttonInfo : string) (player: PlayerDat
|
||||
| Hacking h -> h.HackId = item.Id && h.IsInstigator
|
||||
| Shielding id -> id = item.Id
|
||||
| _ -> false)
|
||||
let btnColor = Game.getClassButtonColor item.Class
|
||||
let btnColor = WeaponClass.getClassButtonColor item.Class
|
||||
match action , ignoreCooldown with
|
||||
| None , _ | Some _ , true ->
|
||||
DiscordButtonComponent(btnColor, $"{actionId}-{item.Id}-{buttonInfo}-{player.Name}", $"{item.Name}")
|
||||
@ -64,7 +63,7 @@ let pickDefense actionId player isTrainer =
|
||||
|
||||
for s in Player.getShields player |> Array.sortBy (fun i -> i.Power) do
|
||||
let hours = TimeSpan.FromMinutes(int s.Cooldown).TotalHours
|
||||
let against = Game.getGoodAgainst(s.Class) |> snd
|
||||
let against = WeaponClass.getGoodAgainst(s.Class) |> snd
|
||||
embed.AddField(s.Name, $"Active {hours} hours\nDefeats {against}", true) |> ignore
|
||||
|
||||
DiscordFollowupMessageBuilder()
|
||||
@ -132,19 +131,19 @@ let getBuyItemsEmbed (player : PlayerData) (itemType : ItemType) (store : Item a
|
||||
| _ ->
|
||||
embed
|
||||
// .AddField($"Defensive Strength |", string item.Power, true)
|
||||
.AddField($"Strong against |", Game.getGoodAgainst item.Class |> snd |> string, true)
|
||||
.AddField($"Strong against |", WeaponClass.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("Price 💰", (if item.Price = 0<GBT> then "Free" else $"{item.Price} $GBT"), true)
|
||||
.WithColor(Game.getClassEmbedColor item.Class)
|
||||
.WithColor(WeaponClass.getClassEmbedColor item.Class)
|
||||
.WithTitle($"{item.Name}")
|
||||
|> ignore
|
||||
let button =
|
||||
if player.Inventory |> 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}")
|
||||
then DiscordButtonComponent(WeaponClass.getClassButtonColor item.Class, $"Buy-{item.Id}", $"Own {item.Name}", true)
|
||||
else DiscordButtonComponent(WeaponClass.getClassButtonColor item.Class, $"Buy-{item.Id}", $"Buy {item.Name}")
|
||||
embed.Build() , button :> DiscordComponent)
|
||||
|> Array.unzip
|
||||
|
||||
@ -165,9 +164,9 @@ let getSellEmbed (itemType : ItemType) (player : PlayerData) =
|
||||
embed
|
||||
.AddField("Sell For 💰", $"{item.Price} $GBT", true)
|
||||
.WithTitle($"{item.Name}")
|
||||
.WithColor(Game.getClassEmbedColor item.Class)
|
||||
.WithColor(WeaponClass.getClassEmbedColor item.Class)
|
||||
|> ignore
|
||||
let button = DiscordButtonComponent(Game.getClassButtonColor item.Class, $"Sell-{item.Id}", $"Sell {item.Name}")
|
||||
let button = DiscordButtonComponent(WeaponClass.getClassButtonColor item.Class, $"Sell-{item.Id}", $"Sell {item.Name}")
|
||||
embed.Build() , button :> DiscordComponent)
|
||||
|> Array.unzip
|
||||
|
||||
|
@ -16,6 +16,7 @@ module Armory =
|
||||
let getItem itemId = battleItems |> Array.find (fun w -> w.Id = itemId)
|
||||
|
||||
module WeaponClass =
|
||||
// TODO: Find a different place to put this
|
||||
let SameTargetAttackCooldown = System.TimeSpan.FromHours(1)
|
||||
|
||||
let getClassButtonColor = function
|
||||
|
@ -1,12 +1,6 @@
|
||||
namespace Degenz
|
||||
|
||||
open System
|
||||
open System.Threading.Tasks
|
||||
open DSharpPlus
|
||||
open DSharpPlus.Entities
|
||||
open DSharpPlus.EventArgs
|
||||
open DSharpPlus.SlashCommands
|
||||
open Newtonsoft.Json
|
||||
|
||||
[<Microsoft.FSharp.Core.AutoOpen>]
|
||||
module Types =
|
||||
|
@ -8,6 +8,7 @@ open DSharpPlus.EventArgs
|
||||
open DSharpPlus.SlashCommands
|
||||
open Degenz
|
||||
open Degenz.Messaging
|
||||
open Degenz.PlayerInteractions
|
||||
|
||||
let checkPlayerIsAttackingThemselves defender attacker =
|
||||
match attacker.DiscordId = defender.DiscordId with
|
||||
@ -95,7 +96,7 @@ let updateCombatants successfulHack (attacker : PlayerData) (defender : PlayerDa
|
||||
}
|
||||
{ Type = Hacking hackEvent
|
||||
Timestamp = DateTime.UtcNow
|
||||
Cooldown = if isDefenderEvent then int Game.SameTargetAttackCooldown.TotalMinutes * 1<mins> else hack.Cooldown }
|
||||
Cooldown = if isDefenderEvent then int WeaponClass.SameTargetAttackCooldown.TotalMinutes * 1<mins> else hack.Cooldown }
|
||||
|
||||
[ DbService.updatePlayer GuildEnvironment.pgDb <| updatePlayer prize (event false) attacker
|
||||
DbService.updatePlayer GuildEnvironment.pgDb <| updatePlayer -prize (event true) defender
|
||||
@ -136,7 +137,7 @@ let failedHack (ctx : IDiscordContext) attacker defender hack =
|
||||
}
|
||||
|
||||
let hack (target : DiscordUser) (ctx : IDiscordContext) =
|
||||
PlayerInteractions.executePlayerActionWithTarget target ctx (fun attacker defender -> async {
|
||||
executePlayerActionWithTarget target ctx (fun attacker defender -> async {
|
||||
do! attacker
|
||||
|> Player.removeExpiredActions
|
||||
|> checkAlreadyHackedTarget defender
|
||||
@ -151,7 +152,7 @@ let hack (target : DiscordUser) (ctx : IDiscordContext) =
|
||||
})
|
||||
|
||||
let handleAttack (ctx : IDiscordContext) =
|
||||
PlayerInteractions.executePlayerAction ctx (fun attacker -> async {
|
||||
executePlayerAction ctx (fun attacker -> async {
|
||||
let tokens = ctx.GetInteractionId().Split("-")
|
||||
let hackId = int tokens.[1]
|
||||
let hack = Armory.getItem hackId
|
||||
@ -176,7 +177,7 @@ let handleAttack (ctx : IDiscordContext) =
|
||||
})
|
||||
|
||||
let defend (ctx : IDiscordContext) =
|
||||
PlayerInteractions.executePlayerAction ctx (fun player -> async {
|
||||
executePlayerAction ctx (fun player -> async {
|
||||
if Player.getShields player |> Array.length > 0 then
|
||||
let p = Player.removeExpiredActions player
|
||||
let embed = Embeds.pickDefense "Defend" p false
|
||||
@ -187,7 +188,7 @@ let defend (ctx : IDiscordContext) =
|
||||
})
|
||||
|
||||
let handleDefense (ctx : IDiscordContext) =
|
||||
PlayerInteractions.executePlayerAction ctx (fun player -> async {
|
||||
executePlayerAction ctx (fun player -> async {
|
||||
let tokens = ctx.GetInteractionId().Split("-")
|
||||
let shieldId = int tokens.[1]
|
||||
let shield = Armory.getItem shieldId
|
||||
@ -218,7 +219,7 @@ let handleDefense (ctx : IDiscordContext) =
|
||||
})
|
||||
|
||||
let arsenal (ctx : IDiscordContext) =
|
||||
PlayerInteractions.executePlayerAction ctx (fun player -> async {
|
||||
executePlayerAction ctx (fun player -> async {
|
||||
let updatedPlayer = Player.removeExpiredActions player
|
||||
let builder = DiscordFollowupMessageBuilder()
|
||||
let embed = DiscordEmbedBuilder()
|
||||
|
@ -1,6 +1,5 @@
|
||||
module Degenz.RockPaperScissors
|
||||
|
||||
open System
|
||||
open System.Threading.Tasks
|
||||
open DSharpPlus
|
||||
open DSharpPlus.Entities
|
||||
|
@ -1,7 +1,6 @@
|
||||
module Degenz.SlotMachine
|
||||
|
||||
open System
|
||||
open System.Threading.Tasks
|
||||
open DSharpPlus
|
||||
open DSharpPlus.Entities
|
||||
open DSharpPlus.SlashCommands
|
||||
|
@ -7,6 +7,7 @@ open DSharpPlus.EventArgs
|
||||
open DSharpPlus.SlashCommands
|
||||
open Degenz
|
||||
open Degenz.Messaging
|
||||
open Degenz.PlayerInteractions
|
||||
|
||||
let checkHasSufficientFunds (item : Item) player =
|
||||
if player.Bank - item.Price >= 0<GBT>
|
||||
@ -29,13 +30,13 @@ let checkHasItemsInArsenal itemType player =
|
||||
else Error $"You currently have no {itemType}s in your arsenal to sell!"
|
||||
|
||||
let buy itemType (ctx : IDiscordContext) =
|
||||
PlayerInteractions.executePlayerAction ctx (fun player -> async {
|
||||
executePlayerAction ctx (fun player -> async {
|
||||
let itemStore = Embeds.getBuyItemsEmbed player itemType Armory.battleItems
|
||||
do! ctx.FollowUp itemStore |> Async.AwaitTask
|
||||
})
|
||||
|
||||
let sell itemType (ctx : IDiscordContext) =
|
||||
PlayerInteractions.executePlayerAction ctx (fun player -> async {
|
||||
executePlayerAction ctx (fun player -> async {
|
||||
match checkHasItemsInArsenal itemType player with
|
||||
| Ok _ -> let itemStore = Embeds.getSellEmbed itemType player
|
||||
do! ctx.FollowUp(itemStore) |> Async.AwaitTask
|
||||
@ -44,7 +45,7 @@ let sell itemType (ctx : IDiscordContext) =
|
||||
|
||||
// TODO: When you buy a shield, prompt the user to activate it
|
||||
let handleBuyItem (ctx : IDiscordContext) itemId =
|
||||
PlayerInteractions.executePlayerAction ctx (fun player -> async {
|
||||
executePlayerAction ctx (fun player -> async {
|
||||
let item = Armory.battleItems |> Array.find (fun w -> w.Id = itemId)
|
||||
do! player
|
||||
|> checkHasSufficientFunds item
|
||||
@ -58,7 +59,7 @@ let handleBuyItem (ctx : IDiscordContext) itemId =
|
||||
})
|
||||
|
||||
let handleSell (ctx : IDiscordContext) itemId =
|
||||
PlayerInteractions.executePlayerAction ctx (fun player -> async {
|
||||
executePlayerAction ctx (fun player -> async {
|
||||
let item = Armory.getItem itemId
|
||||
do!
|
||||
player
|
||||
|
@ -7,6 +7,7 @@ open DSharpPlus.Entities
|
||||
open DSharpPlus.EventArgs
|
||||
open DSharpPlus.SlashCommands
|
||||
open Degenz.Messaging
|
||||
open Degenz.PlayerInteractions
|
||||
|
||||
let ThiefCooldown = TimeSpan.FromMinutes(1)
|
||||
let VictimRecovery = TimeSpan.FromHours(1)
|
||||
@ -119,7 +120,7 @@ let calculateWinPercentage amountRequested bank attackerStrength defenderStrengt
|
||||
//calculateWinPercentage 50 200 100 85
|
||||
|
||||
let steal target amount (ctx : IDiscordContext) =
|
||||
PlayerInteractions.executePlayerActionWithTarget target ctx (fun thief victim -> async { do!
|
||||
executePlayerActionWithTarget target ctx (fun thief victim -> async { do!
|
||||
thief
|
||||
|> checkPlayerIsAttackingThemselves victim
|
||||
// |> checkVictimStealingCooldown victim
|
||||
@ -219,7 +220,7 @@ let handleSteal (ctx : IDiscordContext) =
|
||||
}
|
||||
if answer = "yes" then
|
||||
let targetId = uint64 tokens.[2]
|
||||
PlayerInteractions.executePlayerActionWithTargetId true targetId ctx (fun attacker defender -> async {
|
||||
executePlayerActionWithTargetId true targetId ctx (fun attacker defender -> async {
|
||||
do! attacker
|
||||
|> Player.removeExpiredActions
|
||||
// |> checkVictimStealingCooldown defender
|
||||
|
@ -4,7 +4,6 @@ open System.Text
|
||||
open System.Threading.Tasks
|
||||
open DSharpPlus
|
||||
open DSharpPlus.Entities
|
||||
open DSharpPlus.EventArgs
|
||||
open Degenz.Types
|
||||
open Degenz.Messaging
|
||||
|
||||
|
@ -135,9 +135,3 @@ let updateMessageWithGreyedOutButtons (ctx : IDiscordContext) interactiveMessage
|
||||
builder.Content <- interactiveMessage.Message
|
||||
do! ctx.Respond(InteractionResponseType.UpdateMessage, builder) |> Async.AwaitTask
|
||||
}
|
||||
|
||||
let handleResultWithResponse ctx fn (player : Result<PlayerData, string>) =
|
||||
match player with
|
||||
| Ok p -> fn p
|
||||
| Error e -> async { do! sendFollowUpMessage ctx e }
|
||||
|
||||
|
@ -53,6 +53,11 @@ let executePlayerActionWithTargetId defer (targetId : uint64) (ctx : IDiscordCon
|
||||
| _ , None -> do! Messaging.sendFollowUpMessage ctx "Your target is not connected to the network, they must join first by using the /redpill command"
|
||||
} |> Async.StartAsTask :> Task
|
||||
|
||||
let handleResultWithResponse ctx fn (player : Result<PlayerData, string>) =
|
||||
match player with
|
||||
| Ok p -> fn p
|
||||
| Error e -> async { do! Messaging.sendFollowUpMessage ctx e }
|
||||
|
||||
module Commands =
|
||||
let newPlayer nickname (membr : uint64) =
|
||||
let rand = System.Random(System.Guid.NewGuid().GetHashCode())
|
||||
|
Loading…
x
Reference in New Issue
Block a user