Stat decay

This commit is contained in:
Joseph Ferano 2022-02-27 23:13:23 +07:00
parent 7a4bf02563
commit 45fab5ca82
2 changed files with 12 additions and 4 deletions

View File

@ -119,7 +119,14 @@ module PlayerStats =
let Luck = { Id = StatId.Luck ; BaseDecayRate = 5.0f ; BaseMinMax = Range(0, 100) }
let Charisma = { Id = StatId.Charisma ; BaseDecayRate = 5.0f ; BaseMinMax = Range(0, 100) }
let stats = [| Strength ; Focus ; Luck ; Charisma |]
let stats = [ Strength ; Focus ; Luck ; Charisma ]
let calculateStatDecay (stat : PlayerStat) =
let statConfig = stats |> List.find (fun s -> s.Id = stat.Id)
let hoursElapsed = (DateTime.UtcNow - stat.LastRead).Hours
let totalDecay = hoursElapsed * int statConfig.BaseDecayRate
{ stat with Amount = max stat.ModMinMax.Start.Value (stat.Amount - totalDecay) ; LastRead = DateTime.UtcNow }
let statConsumableMap =
[ ( StatId.Strength , 12 )
( StatId.Focus , 13 )

View File

@ -23,15 +23,16 @@ type StatId =
| Luck = 2
| Charisma = 3
type Stat = {
type StatConfig = {
Id : StatId
BaseDecayRate : single
BaseMinMax : Range
}
type ActiveStat = {
type PlayerStat = {
Id : StatId
Amount : int
ModMinMax : Range
LastRead : DateTime
}
@ -110,7 +111,7 @@ and PlayerData = {
Name : string
Inventory : Inventory
Events : PlayerEvent array
Stats : ActiveStat list
Stats : PlayerStat list
Bank : int<GBT>
}
// Achievements : string array