public static Memorization Update(Memorization knowledgeLicense, KnowledgeQualities knowledgeQuality, double complexity) { if (IsOkButBeforeTime(knowledgeLicense, knowledgeQuality)) { knowledgeQuality = KnowledgeQualities.StillRemember; } return(KnowledgeLicenseProviders[knowledgeQuality].Grant(knowledgeLicense, complexity)); }
/// <summary> /// </summary> /// <param name="currentMemorization">Complexity of the game from 0 to 1]</param> /// <param name="complexity"></param> /// <returns></returns> public virtual Memorization Grant(Memorization currentMemorization, double complexity) { if (complexity > 1.0 || complexity < 0.0) { throw new ArgumentOutOfRangeException(nameof(complexity)); } int days = Ebbinghaus(currentMemorization.Period, complexity); currentMemorization.RepeatTime = DateTime.UtcNow.AddDays(days); return(currentMemorization); }
private static bool IsBefore(Memorization knowledgeLicense) { return(knowledgeLicense.RepeatTime > DateTime.UtcNow.AddDays(DAYS_GRANTING_TIMESPAN)); }
private static bool IsOkButBeforeTime(Memorization knowledgeLicense, KnowledgeQualities knowledgeQuality) { return(knowledgeQuality.Equals(KnowledgeQualities.EasyToRemember) && IsBefore(knowledgeLicense)); }