Stat decay
This commit is contained in:
parent
7a4bf02563
commit
45fab5ca82
@ -119,7 +119,14 @@ module PlayerStats =
|
|||||||
let Luck = { Id = StatId.Luck ; BaseDecayRate = 5.0f ; BaseMinMax = Range(0, 100) }
|
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 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 =
|
let statConsumableMap =
|
||||||
[ ( StatId.Strength , 12 )
|
[ ( StatId.Strength , 12 )
|
||||||
( StatId.Focus , 13 )
|
( StatId.Focus , 13 )
|
||||||
|
@ -23,15 +23,16 @@ type StatId =
|
|||||||
| Luck = 2
|
| Luck = 2
|
||||||
| Charisma = 3
|
| Charisma = 3
|
||||||
|
|
||||||
type Stat = {
|
type StatConfig = {
|
||||||
Id : StatId
|
Id : StatId
|
||||||
BaseDecayRate : single
|
BaseDecayRate : single
|
||||||
BaseMinMax : Range
|
BaseMinMax : Range
|
||||||
}
|
}
|
||||||
|
|
||||||
type ActiveStat = {
|
type PlayerStat = {
|
||||||
Id : StatId
|
Id : StatId
|
||||||
Amount : int
|
Amount : int
|
||||||
|
ModMinMax : Range
|
||||||
LastRead : DateTime
|
LastRead : DateTime
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +111,7 @@ and PlayerData = {
|
|||||||
Name : string
|
Name : string
|
||||||
Inventory : Inventory
|
Inventory : Inventory
|
||||||
Events : PlayerEvent array
|
Events : PlayerEvent array
|
||||||
Stats : ActiveStat list
|
Stats : PlayerStat list
|
||||||
Bank : int<GBT>
|
Bank : int<GBT>
|
||||||
}
|
}
|
||||||
// Achievements : string array
|
// Achievements : string array
|
||||||
|
Loading…
x
Reference in New Issue
Block a user