Can Unlock challenge up to a certain level

This commit is contained in:
nemunaire 2022-06-08 16:37:25 +02:00
commit 0a8d0dad30
5 changed files with 22 additions and 1 deletions

View file

@ -11,6 +11,9 @@ import (
// UnlockedChallengeDepth is the number of challenges to unlock ahead (0: only the next one, -1: all)
var UnlockedChallengeDepth int
// UnlockedChallengeUpTo is the number of level to unlock
var UnlockedChallengeUpTo int
// WchoiceCoefficient is the current coefficient applied on the cost of changing flag into choices
var WChoiceCoefficient = 1.0
@ -117,6 +120,13 @@ func (t *Team) HasAccess(e *Exercice) bool {
return true
}
if UnlockedChallengeUpTo > 1 {
lvl, err := e.GetLevel()
if err == nil && lvl <= UnlockedChallengeUpTo {
return true
}
}
for i := UnlockedChallengeDepth; i >= 0; i-- {
// An exercice without dependency is accessible
if e.Depend == nil {