renew puzzle sessions during provisional rating period
parent
44ce134c6b
commit
0ab871e09f
|
@ -21,6 +21,8 @@ private case class PuzzleSession(
|
|||
)
|
||||
def next = copy(positionInPath = positionInPath + 1)
|
||||
|
||||
def brandNew = positionInPath == 0
|
||||
|
||||
override def toString = s"$path:$positionInPath"
|
||||
}
|
||||
|
||||
|
@ -175,10 +177,15 @@ final class PuzzleSessionApi(
|
|||
theme: PuzzleTheme.Key
|
||||
): Fu[PuzzleSession] =
|
||||
sessions.getFuture(user.id, _ => createSessionFor(user, theme)) flatMap { current =>
|
||||
if (current.path.theme == theme) fuccess(current)
|
||||
if (current.path.theme == theme && !shouldChangeSession(user, current)) fuccess(current)
|
||||
else createSessionFor(user, theme, current.difficulty) tap { sessions.put(user.id, _) }
|
||||
}
|
||||
|
||||
private def shouldChangeSession(user: User, session: PuzzleSession) = !session.brandNew && {
|
||||
val perf = user.perfs.puzzle
|
||||
perf.clueless || (perf.provisional && perf.nb % 5 == 0)
|
||||
}
|
||||
|
||||
private def createSessionFor(
|
||||
user: User,
|
||||
theme: PuzzleTheme.Key,
|
||||
|
|
Loading…
Reference in New Issue