diff options
Diffstat (limited to 'internal/models')
-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) + } +} |