TDL/types.go

81 lines
1.2 KiB
Go
Raw Normal View History

2020-11-04 22:27:06 +01:00
package main
import (
"encoding/json"
)
type TDL struct {
Lifts []Lift
Plates []Plate
SetTemplates []SetTemplate
TrainingDays []TrainingDay
}
func (t TDL) JSON() []byte {
tmp, err := json.MarshalIndent(t, "", " ")
if err != nil {
panic(err)
}
return tmp
}
func (t TDL) Clone() TDL {
t2 := TDL{}
// an actual deep copy might be a little faster
// - but this one is good enough.
err := json.Unmarshal(t.JSON(), &t2)
if err != nil {
panic(err)
}
return t2
}
type Lift struct {
Name string
Max float64
Increment float64
IncrementPercent bool
Bar float64
}
type Plate struct {
Weight float64
Amount int
}
type SetTemplate struct {
Name string
Items []SetTemplateItem
}
type SetTemplateItem struct {
Set Set
ReferenceName string
Amount int
}
type Set struct {
Reps int
Percentage float64
PlusWeight float64
Amount int
Notice string
}
type TrainingDay struct {
Items []TrainingDayItem
}
type TrainingDayItem struct {
LiftSchedule LiftSchedule
Raw string
}
type LiftSchedule struct {
LiftName string
Items []SetTemplateItem
Increase bool
IncreaseAmount float64
IncreasePercent bool
}