package models import "time" type ActionType string const ( ActionTypePlus ActionType = "ActionTypePlus" ActionTypeMinus ActionType = "ActionTypeMinus" ) type ( UserScore struct { Username string Actions []*Action BurnTime time.Time Score int8 } Action struct { ID uint32 Name string Magnitude uint8 Repeatable bool Type ActionType Done bool 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) } }