implement choices_cost

This commit is contained in:
nemunaire 2018-12-02 23:18:32 +01:00
commit 476f0f553c
18 changed files with 180 additions and 24 deletions

View file

@ -42,6 +42,7 @@ type myTeamFlag struct {
Solved *time.Time `json:"found,omitempty"`
Soluce string `json:"soluce,omitempty"`
Choices map[string]string `json:"choices,omitempty"`
ChoicesCost int64 `json:"choices_cost,omitempty"`
}
type myTeamExercice struct {
ThemeId int64 `json:"theme_id"`
@ -199,11 +200,13 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
flag.Help = k.Help
if choices, err := k.GetChoices(); err != nil {
return nil, err
} else {
} else if t == nil || k.ChoicesCost == 0 || t.SeeChoices(k) {
flag.Choices = map[string]string{}
for _, c := range choices {
flag.Choices[c.Value] = c.Label
}
} else {
flag.ChoicesCost = k.ChoicesCost
}
}