diff options
author | GrailFinder <wohilas@gmail.com> | 2024-04-11 07:13:48 +0300 |
---|---|---|
committer | GrailFinder <wohilas@gmail.com> | 2024-04-11 07:13:48 +0300 |
commit | 9b160dcc0315aaf54a8b4588be9d2a0c98084cf0 (patch) | |
tree | f1068c6b70612d41a76b947370808cf147e45382 /internal/models/models.go | |
parent | 499dcd25aa8d1f878b379e2ca8f94417807c4afb (diff) |
Enha: make html elements to react; repeatable separation
Diffstat (limited to 'internal/models/models.go')
-rw-r--r-- | internal/models/models.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/internal/models/models.go b/internal/models/models.go index 58191a2..a2b3628 100644 --- a/internal/models/models.go +++ b/internal/models/models.go @@ -12,7 +12,7 @@ const ( type ( UserScore struct { Username string - Actions []Action + Actions []*Action BurnTime time.Time Score int8 } @@ -26,3 +26,15 @@ type ( Username string } ) + +func (us *UserScore) UpdateScore(act *Action) { + switch act.Type { + case ActionTypePlus: + us.Score += int8(act.Magnitude) + if !act.Repeatable { + act.Done = true + } + case ActionTypeMinus: + us.Score -= int8(act.Magnitude) + } +} |