From 0e5222e5cc116b1badab0fd5896415f7b4f6cb71 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Sun, 4 Dec 2016 18:58:53 +0100 Subject: [PATCH] backend: new option that unlock all challenges --- backend/main.go | 1 + libfic/team.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/main.go b/backend/main.go index 599642a6..532d3f78 100644 --- a/backend/main.go +++ b/backend/main.go @@ -47,6 +47,7 @@ func main() { flag.StringVar(&TeamsDir, "teams", "../TEAMS", "Base directory where save teams JSON files") flag.StringVar(&fic.FilesDir, "files", "/files", "Request path prefix to reach files") var skipFullGeneration = flag.Bool("skipFullGeneration", false, "Skip initial full generation (safe to skip after start)") + flag.BoolVar(&fic.UnlockedChallenges, "unlockedChallenges", false, "Make all challenges accessible without having to validate previous level") flag.Parse() log.SetPrefix("[backend] ") diff --git a/libfic/team.go b/libfic/team.go index 5db84293..ecd1a69d 100644 --- a/libfic/team.go +++ b/libfic/team.go @@ -6,6 +6,8 @@ import ( "time" ) +var UnlockedChallenges bool + type Team struct { Id int64 `json:"id"` InitialName string `json:"initialName"` @@ -143,7 +145,7 @@ func GetTryRank() ([]int64, error) { } func (t Team) HasAccess(e Exercice) bool { - if e.Depend == nil { + if e.Depend == nil || UnlockedChallenges { return true } else { ed := Exercice{}