sync: implement hint dependency on flags

This commit is contained in:
nemunaire 2019-10-26 11:33:30 +02:00
commit 6740256a32
6 changed files with 72 additions and 2 deletions

View file

@ -155,6 +155,25 @@ func (t Team) CanDownload(f EFile) bool {
}
}
// CanSeeHint checks if the Team has access to the given hint.
func (t Team) CanSeeHint(h EHint) bool {
if deps, err := h.GetDepends(); err != nil {
log.Printf("Unable to retrieve flag dependencies: %s\n", err)
return false
} else {
res := true
for _, dep := range deps {
if t.HasPartiallySolved(dep) == nil {
res = false
break
}
}
return res
}
}
// CanSeeFlag checks if the Team has access to the given flag.
func (t Team) CanSeeFlag(k Flag) bool {
if deps, err := k.GetDepends(); err != nil {