Dependancy between flags

This commit is contained in:
nemunaire 2018-12-02 19:21:07 +01:00
commit f9abdd23c6
8 changed files with 111 additions and 1 deletions

View file

@ -124,6 +124,25 @@ func (t Team) CanDownload(f EFile) bool {
}
}
// 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 {
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
}
}
// NbTry retrieves the number of attempts made by the Team to the given challenge.
func NbTry(t *Team, e Exercice) int {
var cnt *int