repochecker: Ensure hint and choice_cost are not higher than gain
This commit is contained in:
parent
09c1111135
commit
7fbe2f3f8e
2 changed files with 20 additions and 6 deletions
|
@ -555,13 +555,19 @@ func CheckExerciceFlags(i Importer, exercice *fic.Exercice, files []string, exce
|
|||
}
|
||||
}
|
||||
|
||||
// Check dependency to flag optional flag
|
||||
if fk, ok := flag.Flag.(*fic.FlagKey); ok && fk.BonusGain == 0 {
|
||||
for _, nf := range flag.FlagsDeps {
|
||||
if fk2, ok := flags[nf].Flag.(*fic.FlagKey); ok && fk2.BonusGain != 0 {
|
||||
errs = multierr.Append(errs, NewFlagError(exercice, nil, flag.Line, fmt.Errorf("flag is not optional but depend on flag id=%d which is optional", nf)))
|
||||
if fk, ok := flag.Flag.(*fic.FlagKey); ok {
|
||||
// Check dependency to flag optional flag
|
||||
if fk.BonusGain == 0 {
|
||||
for _, nf := range flag.FlagsDeps {
|
||||
if fk2, ok := flags[nf].Flag.(*fic.FlagKey); ok && fk2.BonusGain != 0 {
|
||||
errs = multierr.Append(errs, NewFlagError(exercice, nil, flag.Line, fmt.Errorf("flag is not optional but depend on flag id=%d which is optional", nf)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if int64(fk.ChoicesCost) >= exercice.Gain {
|
||||
errs = multierr.Append(errs, NewFlagError(exercice, nil, flag.Line, fmt.Errorf("flag's choice_cost is higher than exercice gain")))
|
||||
}
|
||||
}
|
||||
|
||||
// Check dependency loop
|
||||
|
|
Reference in a new issue