diff options
| author | JP Appel <jeanpierre.appel01@gmail.com> | 2024-09-13 14:32:15 -0400 |
|---|---|---|
| committer | JP Appel <jeanpierre.appel01@gmail.com> | 2024-09-13 14:32:15 -0400 |
| commit | 51723cfd9a7d31643fa7c14cc2df9d8e9e2bd33d (patch) | |
| tree | 70cc0e0f9d789b4be3d9249c3ecc23608bb9fa10 /economy/heads.go | |
| parent | 8759523157afb38f8565687ebd0e1f29a1af3e42 (diff) | |
Add money and head handling functions
Created types to manage the cannonical coinage of DnD.
First pass at computing computing values for heads.
Diffstat (limited to 'economy/heads.go')
| -rw-r--r-- | economy/heads.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/economy/heads.go b/economy/heads.go new file mode 100644 index 0000000..15c9456 --- /dev/null +++ b/economy/heads.go @@ -0,0 +1,37 @@ +package economy + +import ( + "maps" +) + +type Location uint +type CostFunc func(cr float32, mutiplier float32, modifier float32) Money + +const ( + Field Location = iota + Display + Storage +) + +type Head struct { + Location Location + Conditions struct { + Multipliers map[string]float32 + Modifiers map[string]float32 + } + CR float32 +} + +func (h Head) Value(cost CostFunc) Money { + var multiplier float32 = 1 + for val := range maps.Values(h.Conditions.Multipliers) { + multiplier *= val + } + + var modifier float32 = 0 + for val := range maps.Values(h.Conditions.Modifiers) { + modifier += val + } + + return cost(h.CR, multiplier, modifier) +} |
