169 lines
5.0 KiB
Go
169 lines
5.0 KiB
Go
package review
|
|
|
|
type Exercise struct {
|
|
ID string // Combination of Name and Variation, e.g. "deadlift" or "deadlift:sumo"
|
|
Name string // Base exercise name, e.g. "deadlift"
|
|
Variation string // Variation, e.g. "sumo", "high bar", etc.
|
|
PrimaryMuscles []string
|
|
SecondaryMuscles []string
|
|
Bodyweight bool // True if bodyweight is a significant load (e.g. pullup, dip)
|
|
Estimate1RM func(float64, int) float64
|
|
}
|
|
|
|
// Helper to generate ID from Name and Variation
|
|
func ExerciseID(name, variation string) string {
|
|
if variation == "" {
|
|
return name
|
|
}
|
|
return name + ":" + variation
|
|
}
|
|
|
|
func IsBodyweight(ss ...string) bool {
|
|
if len(ss) == 0 {
|
|
return false
|
|
}
|
|
name := ss[0]
|
|
var variation string
|
|
if len(ss) > 1 {
|
|
variation = ss[1]
|
|
}
|
|
return GetExercise(name, variation).Bodyweight
|
|
}
|
|
|
|
func GetEstimate1RM(ss ...string) func(float64, int) float64 {
|
|
if len(ss) == 0 {
|
|
return Epley1RM
|
|
}
|
|
name := ss[0]
|
|
var variation string
|
|
if len(ss) > 1 {
|
|
variation = ss[1]
|
|
}
|
|
ret := GetExercise(name, variation).Estimate1RM
|
|
if ret == nil {
|
|
return Epley1RM
|
|
} else {
|
|
return ret
|
|
}
|
|
}
|
|
|
|
var Exercises = []*Exercise{
|
|
{
|
|
ID: ExerciseID("deadlift", ""),
|
|
Name: "deadlift",
|
|
Variation: "",
|
|
PrimaryMuscles: []string{"back", "glutes", "hamstrings"},
|
|
SecondaryMuscles: []string{"forearms", "traps"},
|
|
Bodyweight: false,
|
|
Estimate1RM: Epley1RM,
|
|
},
|
|
{
|
|
ID: ExerciseID("deadlift", "sumo"),
|
|
Name: "deadlift",
|
|
Variation: "sumo",
|
|
PrimaryMuscles: []string{"back", "glutes", "hamstrings", "adductors"},
|
|
SecondaryMuscles: []string{"forearms", "traps"},
|
|
Bodyweight: false,
|
|
Estimate1RM: Epley1RM,
|
|
},
|
|
{
|
|
ID: ExerciseID("squat", ""),
|
|
Name: "squat",
|
|
Variation: "",
|
|
PrimaryMuscles: []string{"quadriceps", "glutes"},
|
|
SecondaryMuscles: []string{"hamstrings", "lower back"},
|
|
Bodyweight: false,
|
|
Estimate1RM: Epley1RM,
|
|
},
|
|
{
|
|
ID: ExerciseID("squat", "high bar"),
|
|
Name: "squat",
|
|
Variation: "high bar",
|
|
PrimaryMuscles: []string{"quadriceps", "glutes"},
|
|
SecondaryMuscles: []string{"hamstrings", "lower back"},
|
|
Bodyweight: false,
|
|
Estimate1RM: Epley1RM,
|
|
},
|
|
{
|
|
ID: ExerciseID("hack squat", ""),
|
|
Name: "hack squat",
|
|
Variation: "",
|
|
PrimaryMuscles: []string{"quadriceps", "glutes"},
|
|
SecondaryMuscles: []string{"hamstrings"},
|
|
Bodyweight: false,
|
|
Estimate1RM: Epley1RM,
|
|
},
|
|
{
|
|
ID: ExerciseID("dip", ""),
|
|
Name: "dip",
|
|
Variation: "",
|
|
PrimaryMuscles: []string{"chest", "triceps"},
|
|
SecondaryMuscles: []string{"shoulders"},
|
|
Bodyweight: true,
|
|
Estimate1RM: Epley1RM,
|
|
},
|
|
{
|
|
ID: ExerciseID("chinup", ""),
|
|
Name: "chinup",
|
|
Variation: "",
|
|
PrimaryMuscles: []string{"back", "biceps"},
|
|
SecondaryMuscles: []string{"forearms"},
|
|
Bodyweight: true,
|
|
Estimate1RM: Epley1RM,
|
|
},
|
|
{
|
|
ID: ExerciseID("pullup", ""),
|
|
Name: "pullup",
|
|
Variation: "",
|
|
PrimaryMuscles: []string{"back", "biceps"},
|
|
SecondaryMuscles: []string{"forearms"},
|
|
Bodyweight: true,
|
|
Estimate1RM: Epley1RM,
|
|
},
|
|
{
|
|
ID: ExerciseID("row", "barbell"),
|
|
Name: "row",
|
|
Variation: "barbell",
|
|
PrimaryMuscles: []string{"back", "lats", "rhomboids"},
|
|
SecondaryMuscles: []string{"biceps", "forearms"},
|
|
Bodyweight: false,
|
|
Estimate1RM: Epley1RM,
|
|
},
|
|
{
|
|
ID: ExerciseID("row", "dumbbell"),
|
|
Name: "row",
|
|
Variation: "dumbbell",
|
|
PrimaryMuscles: []string{"back", "lats", "rhomboids"},
|
|
SecondaryMuscles: []string{"biceps", "forearms"},
|
|
Bodyweight: false,
|
|
Estimate1RM: Epley1RM,
|
|
},
|
|
{
|
|
ID: ExerciseID("row", "chest supported"),
|
|
Name: "row",
|
|
Variation: "chest supported",
|
|
PrimaryMuscles: []string{"back", "lats", "rhomboids"},
|
|
SecondaryMuscles: []string{"biceps", "forearms"},
|
|
Bodyweight: false,
|
|
Estimate1RM: Epley1RM,
|
|
},
|
|
}
|
|
|
|
func GetExercise(ss ...string) *Exercise {
|
|
if len(ss) == 0 {
|
|
return &Exercise{}
|
|
}
|
|
name := ss[0]
|
|
var variation string
|
|
if len(ss) > 1 {
|
|
variation = ss[1]
|
|
}
|
|
for _, e := range(Exercises) {
|
|
if (e.Name == name && e.Variation == variation) {
|
|
return e
|
|
}
|
|
}
|
|
return &Exercise{}
|
|
}
|
|
|