Reshape stat types
This commit is contained in:
parent
45fab5ca82
commit
53f60bcf86
@ -17,7 +17,7 @@ let mapBack user : PlayerData =
|
|||||||
Name = user.Name
|
Name = user.Name
|
||||||
Inventory = user.Inventory |> List.choose (fun id -> Armory.weapons |> List.tryFind (fun item -> item.Id = id))
|
Inventory = user.Inventory |> List.choose (fun id -> Armory.weapons |> List.tryFind (fun item -> item.Id = id))
|
||||||
Events = [||]
|
Events = [||]
|
||||||
Stats = [ { Id = StatId.Strength ; Amount = user.Strength ; LastRead = DateTime.UtcNow} ]
|
Stats = { Stats.empty with Strength = { Id = StatId.Strength ; ModMinMax = Range(0, 100) ; Amount = user.Strength; LastRead = DateTime.UtcNow } }
|
||||||
Bank = user.Bank
|
Bank = user.Bank
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ let updatePlayer connStr (player : PlayerData) =
|
|||||||
|> Sql.parameters [
|
|> Sql.parameters [
|
||||||
"did", Sql.string (string player.DiscordId)
|
"did", Sql.string (string player.DiscordId)
|
||||||
"gbt", Sql.int (int player.Bank)
|
"gbt", Sql.int (int player.Bank)
|
||||||
"str", Sql.int (player |> Player.getStat StatId.Strength |> int)
|
"str", Sql.int (player.Stats.Strength.Amount |> int)
|
||||||
"inv", Sql.intArray (player.Inventory |> Array.ofList |> Array.map (fun item -> item.Id))
|
"inv", Sql.intArray (player.Inventory |> Array.ofList |> Array.map (fun item -> item.Id))
|
||||||
]
|
]
|
||||||
|> Sql.query """
|
|> Sql.query """
|
||||||
|
@ -67,7 +67,6 @@ module Inventory =
|
|||||||
inventory |> getShieldItems |> List.tryFind (fun item -> item.Id = id)
|
inventory |> getShieldItems |> List.tryFind (fun item -> item.Id = id)
|
||||||
|
|
||||||
module WeaponClass =
|
module WeaponClass =
|
||||||
// TODO: Find a different place to put this
|
|
||||||
let SameTargetAttackCooldown = System.TimeSpan.FromHours(1)
|
let SameTargetAttackCooldown = System.TimeSpan.FromHours(1)
|
||||||
|
|
||||||
let getClassButtonColor item =
|
let getClassButtonColor item =
|
||||||
@ -107,25 +106,20 @@ module Player =
|
|||||||
|
|
||||||
let modifyBank (player : PlayerData) amount = { player with Bank = max (player.Bank + amount) 0<GBT> }
|
let modifyBank (player : PlayerData) amount = { player with Bank = max (player.Bank + amount) 0<GBT> }
|
||||||
|
|
||||||
let getStat statId player =
|
|
||||||
player.Stats
|
|
||||||
|> List.tryFind (fun stat -> statId = stat.Id)
|
|
||||||
|> Option.map (fun stat -> stat.Amount)
|
|
||||||
|> Option.defaultValue 0
|
|
||||||
|
|
||||||
module PlayerStats =
|
module PlayerStats =
|
||||||
let Strength = { Id = StatId.Strength ; BaseDecayRate = 5.0f ; BaseMinMax = Range(0, 100) }
|
// 4.17f would go from 100 to 0 in roughly 24 hours
|
||||||
let Focus = { Id = StatId.Focus ; BaseDecayRate = 5.0f ; BaseMinMax = Range(0, 100) }
|
let Strength = { Id = StatId.Strength ; BaseDecayRate = 4.17 ; BaseMinMax = Range(0, 100) }
|
||||||
let Luck = { Id = StatId.Luck ; BaseDecayRate = 5.0f ; BaseMinMax = Range(0, 100) }
|
let Focus = { Id = StatId.Focus ; BaseDecayRate = 4.17 ; BaseMinMax = Range(0, 100) }
|
||||||
let Charisma = { Id = StatId.Charisma ; BaseDecayRate = 5.0f ; BaseMinMax = Range(0, 100) }
|
let Luck = { Id = StatId.Luck ; BaseDecayRate = 4.17 ; BaseMinMax = Range(0, 100) }
|
||||||
|
let Charisma = { Id = StatId.Charisma ; BaseDecayRate = 4.17 ; BaseMinMax = Range(0, 100) }
|
||||||
|
|
||||||
let stats = [ Strength ; Focus ; Luck ; Charisma ]
|
let stats = [ Strength ; Focus ; Luck ; Charisma ]
|
||||||
|
|
||||||
let calculateStatDecay (stat : PlayerStat) =
|
let calculateStatDecay (stat : PlayerStat) =
|
||||||
let statConfig = stats |> List.find (fun s -> s.Id = stat.Id)
|
let statConfig = stats |> List.find (fun s -> s.Id = stat.Id)
|
||||||
let hoursElapsed = (DateTime.UtcNow - stat.LastRead).Hours
|
let hoursElapsed = (DateTime.UtcNow - stat.LastRead).Hours
|
||||||
let totalDecay = hoursElapsed * int statConfig.BaseDecayRate
|
let totalDecay = float hoursElapsed * statConfig.BaseDecayRate
|
||||||
{ stat with Amount = max stat.ModMinMax.Start.Value (stat.Amount - totalDecay) ; LastRead = DateTime.UtcNow }
|
{ stat with Amount = max stat.ModMinMax.Start.Value (stat.Amount - int totalDecay) ; LastRead = DateTime.UtcNow }
|
||||||
|
|
||||||
let statConsumableMap =
|
let statConsumableMap =
|
||||||
[ ( StatId.Strength , 12 )
|
[ ( StatId.Strength , 12 )
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
module Degenz.Types
|
module Degenz.Types
|
||||||
|
|
||||||
open System
|
open System
|
||||||
|
open Degenz
|
||||||
|
|
||||||
[<Measure>]
|
[<Measure>]
|
||||||
type mins
|
type mins
|
||||||
@ -25,7 +26,7 @@ type StatId =
|
|||||||
|
|
||||||
type StatConfig = {
|
type StatConfig = {
|
||||||
Id : StatId
|
Id : StatId
|
||||||
BaseDecayRate : single
|
BaseDecayRate : float
|
||||||
BaseMinMax : Range
|
BaseMinMax : Range
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,6 +36,15 @@ type PlayerStat = {
|
|||||||
ModMinMax : Range
|
ModMinMax : Range
|
||||||
LastRead : DateTime
|
LastRead : DateTime
|
||||||
}
|
}
|
||||||
|
with static member empty = { Id = StatId.Strength ; Amount = 0 ; ModMinMax = Range(0, 100) ; LastRead = DateTime.UtcNow}
|
||||||
|
|
||||||
|
type Stats = {
|
||||||
|
Strength : PlayerStat
|
||||||
|
Focus : PlayerStat
|
||||||
|
Luck : PlayerStat
|
||||||
|
Charisma : PlayerStat
|
||||||
|
}
|
||||||
|
with static member empty = { Strength = PlayerStat.empty ; Focus = PlayerStat.empty ; Luck = PlayerStat.empty ; Charisma = PlayerStat.empty }
|
||||||
|
|
||||||
type HackResult =
|
type HackResult =
|
||||||
| Strong
|
| Strong
|
||||||
@ -111,7 +121,7 @@ and PlayerData = {
|
|||||||
Name : string
|
Name : string
|
||||||
Inventory : Inventory
|
Inventory : Inventory
|
||||||
Events : PlayerEvent array
|
Events : PlayerEvent array
|
||||||
Stats : PlayerStat list
|
Stats : Stats
|
||||||
Bank : int<GBT>
|
Bank : int<GBT>
|
||||||
}
|
}
|
||||||
// Achievements : string array
|
// Achievements : string array
|
||||||
@ -122,7 +132,7 @@ with member this.basicPlayer = { Id = this.DiscordId ; Name = this.Name }
|
|||||||
Name = "None"
|
Name = "None"
|
||||||
Inventory = []
|
Inventory = []
|
||||||
Events = [||]
|
Events = [||]
|
||||||
Stats = []
|
Stats = Stats.empty
|
||||||
// Achievements = [||]
|
// Achievements = [||]
|
||||||
// XP = 0
|
// XP = 0
|
||||||
Bank = 0<GBT> }
|
Bank = 0<GBT> }
|
||||||
|
@ -128,9 +128,7 @@ let steal target amount (ctx : IDiscordContext) =
|
|||||||
>>= checkPrizeRequestZero amount
|
>>= checkPrizeRequestZero amount
|
||||||
|> handleResultWithResponse ctx (fun _ -> async {
|
|> handleResultWithResponse ctx (fun _ -> async {
|
||||||
let cappedPrize , winPercentage , wasCapped =
|
let cappedPrize , winPercentage , wasCapped =
|
||||||
// calculateWinPercentage amount (int victim.Bank) thief.Stats.Strength victim.Stats.Strength
|
calculateWinPercentage amount (int victim.Bank) thief.Stats.Strength.Amount victim.Stats.Strength.Amount
|
||||||
// TODO: Readd stats
|
|
||||||
calculateWinPercentage amount (int victim.Bank) 0 0
|
|
||||||
|
|
||||||
let chance = int (winPercentage * 100.0)
|
let chance = int (winPercentage * 100.0)
|
||||||
let buttons =
|
let buttons =
|
||||||
@ -140,8 +138,7 @@ let steal target amount (ctx : IDiscordContext) =
|
|||||||
|
|
||||||
let cappedMsg = if wasCapped then $"They only have {cappedPrize} $GBT though... " else ""
|
let cappedMsg = if wasCapped then $"They only have {cappedPrize} $GBT though... " else ""
|
||||||
let strengthMsg =
|
let strengthMsg =
|
||||||
// TODO: Readd stats
|
match thief.Stats.Strength.Amount - victim.Stats.Strength.Amount with
|
||||||
match 0 - 0 with
|
|
||||||
| diff when diff < -50 -> "much stronger"
|
| diff when diff < -50 -> "much stronger"
|
||||||
| diff when diff < 0 -> "stronger"
|
| diff when diff < 0 -> "stronger"
|
||||||
| diff when diff < 50 -> "weaker"
|
| diff when diff < 50 -> "weaker"
|
||||||
@ -164,8 +161,7 @@ let handleSteal (ctx : IDiscordContext) =
|
|||||||
let targetId = uint64 tokens.[2]
|
let targetId = uint64 tokens.[2]
|
||||||
let targetName = tokens.[3]
|
let targetName = tokens.[3]
|
||||||
let amount = int tokens.[4]
|
let amount = int tokens.[4]
|
||||||
// TODO: Readd stats
|
let prize , winPercentage , _ = calculateWinPercentage amount (int victim.Bank) thief.Stats.Strength.Amount victim.Stats.Strength.Amount
|
||||||
let prize , winPercentage , _ = calculateWinPercentage amount (int victim.Bank) 0 0
|
|
||||||
let prize = int prize * 1<GBT>
|
let prize = int prize * 1<GBT>
|
||||||
|
|
||||||
let rand = Random(Guid.NewGuid().GetHashCode())
|
let rand = Random(Guid.NewGuid().GetHashCode())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user