public ChumonButton(EPuzzleUserInfo userInfo, Chumon chumon, bool longName = false) { var mondaiResult = userInfo.MondaiResults.GetBest(chumon.Id); var shoyou = null == mondaiResult ? TimeSpan.Zero : mondaiResult.所要時間; _userInfo = userInfo; Chumon = chumon; Text = longName ? Chumon.LongName : Chumon.Name; Name = chumon.Id; }
public MondaiDocument GetMondaiDocument() { var mondaiDocument = new MondaiDocument(); var documentElement = GetElement("document"); mondaiDocument.Id = documentElement.GetElement("id").Value; mondaiDocument.Name = documentElement.GetElement("title").Value; var daimonItems = documentElement.GetElements("daimon").Select(daimonElement => { var daimon = new Daimon() { Id = daimonElement.GetElement("id").Value, Name = daimonElement.GetElement("title").Value, }; var chumonItems = daimonElement.Items.Where(xx => "chumon" == xx.Name).Select(chumonElement => { var chumon = new Chumon() { Id = chumonElement.GetElement("id").Value, Name = chumonElement.GetElement("title").Value, IsOptional = "true" == chumonElement.GetValue("optional"), IsShuffled = "true" == chumonElement.GetValue("shuffle"), }; // 入力ミスの検査 var optional = chumonElement.GetValue("optional"); var shuffle = chumonElement.GetValue("shuffle"); var flag = (null == optional || "true" == optional || "false" == optional) && (null == shuffle || "true" == shuffle || "false" == shuffle); if (!flag) throw new EmpException("optional, shuffleにはtrue, falseのみ指定できます"); chumon.HelpIds = chumonElement.GetValues("helpId").Where(x => !string.IsNullOrWhiteSpace(x)).ToArray(); var shomonItems = chumonElement.Items.Where(x => "shomon" == x.Name || "ankimon" == x.Name).Select ( shomonElement => { switch (shomonElement.Name) { case "shomon" : { return (EigoTestMondai)CreateShomon(shomonElement); } case "ankimon" : { return (EigoTestMondai)CreateAnkimon(shomonElement); } default : { throw new InvalidOperationException(); } } } ); chumon.Items = shomonItems.ToList(); // chumon.GetTimeLimit() = chumon.制限時間の計算(); return chumon; }).Cast<EigoTestMondai>(); daimon.Items = chumonItems.ToList(); return daimon; }).Cast<EigoTestMondai>(); mondaiDocument.Items = daimonItems.ToList(); return mondaiDocument; }
private DateTime 復習猶予期間と最終プレイ時間を足す(Chumon chumon) { if (null == chumon) throw new ArgumentNullException(); var newest = _userInfo.MondaiResults.GetNewest(chumon.Id); if (null == newest) return EPuzzleTime.Now; return newest.StartTime + (TimeSpan)chumon.復習までの猶予期間を取得(_userInfo); }
// Static members public static string GetString(MondaiResult mondaiResult, Chumon chumon, EPuzzleUserInfo userInfo) { var text = string.Format ( @"({0}日前) {1} {2:00}:{3:00} ({4})", (int)Math.Round((EPuzzleTime.Now - mondaiResult.EndTime).TotalDays), mondaiResult.EndTime.ToString("yyyy/MM/dd(ddd) HH:mm"), (int)mondaiResult.所要時間.TotalMinutes, (int)mondaiResult.所要時間.Seconds, chumon.GetGradeString(mondaiResult.所要時間, userInfo) ); return text; }
// Static members public static bool プレイ期間が指定期間以下(TimeSpan duration, Chumon chumon, EPuzzleUserInfo userInfo) { var oldest = userInfo.MondaiResults.GetOldest(chumon.Id); if (null == oldest) return false; var newest = userInfo.MondaiResults.GetNewest(chumon.Id); return newest.StartTime - oldest.StartTime <= duration; }
private TimeSpan 復習までの猶予期間を取得(Chumon chumon, EPuzzleUserInfo userInfo, double grade) { var d = 復習までの猶予期間を取得(grade); foreach (var p in 期間における復習猶予期間の最大値) { if (プレイ期間が指定期間以下(p.First, chumon, userInfo)) { return Min(d, p.Second); } } return d; }
public override bool 復習判定_2(Chumon chumon, EPuzzleUserInfo userInfo) { var d = 復習までの猶予期間を取得(chumon, userInfo); if (null == d) return false; var t = userInfo.MondaiResults.GetNewest(chumon.Id).EndTime; var x = t + d; var now = EPuzzleTime.Now; if (userInfo.TreatChumonsThatWillExpireTodayAsOnesThatHaveAlreadyExpired) { now = userInfo.GetStartTimeOfTheDay(now) + TimeSpan.FromDays(1d); } return x < now; }
public override TimeSpan? 復習までの猶予期間を取得(Chumon chumon, EPuzzleUserInfo userInfo) { var mondaiResults = 復習判定期間のMondaiResultを取得する(chumon.Id, userInfo); if (!mondaiResults.Any()) return null; var newest = userInfo.MondaiResults.GetNewest(chumon.Id); var duration = GetAverageOfMondaiResults(newest.StartTime - 復習判定期間, mondaiResults); var grade = chumon.GetGrade(duration, userInfo); return 復習までの猶予期間を取得(chumon, userInfo, grade); }
public virtual bool 復習判定_2(Chumon chumon, EPuzzleUserInfo userInfo) { var mondaiResult = chumon.最低の結果を取得(userInfo, 復習判定期間); if (null == mondaiResult) return false; var grade = chumon.GetGrade(mondaiResult.所要時間, userInfo); var d = 復習までの猶予期間を取得(grade); // var t = userInfo.MondaiResults.GetLast(chumon.Id).EndTime; var t = userInfo.MondaiResults.GetNewest(chumon.Id).EndTime; return t + d < EPuzzleTime.Now; }
public virtual TimeSpan? 復習までの猶予期間を取得(Chumon chumon, EPuzzleUserInfo userInfo) { throw new NotSupportedException(); }
public virtual bool 合格判定(Chumon chumon, EPuzzleUserInfo userInfo) { double? grade = chumon.GetBestGrade(userInfo); if (null == grade) return false; return この値より大きいグレードは不合格 >= (double)grade; }
protected abstract TimeSpan GetTimeLimit(Chumon chumon);
protected override TimeSpan GetTimeLimit(Chumon chumon) { return chumon.Items.Aggregate(TimeSpan.Zero, (total, next) => { total += GetTimeLimit(next) + TimeSpan.FromSeconds(1d); return total; }); }
public static void Chumonを開始する(Chumon chumon, WindowState parent) { var window = parent.Window; window.WindowStateWhichHasStartedChumon = parent; if (chumon.IsShuffled) { chumon.Shuffle(); } // var chumonState = WindowState.Create(window, chumon.Items[0]); var chumonState = window.CreateMondaiState(chumon.Items[0]); Fish.Test.TestUtility.Set("nextShomonState", chumonState); var clickDeKaishi = new ClickDeKaishiState(window, parent, chumonState, chumon.Name); var helpItems = window.EPuzzleData.HelpDocumentSet.GetItems(chumon.HelpIds). Concat(new [] { window.EPuzzleData.HelpDocumentSet.GetItemAndNotThrowTheException(chumon.Id) }).Where(x => null != x).ToArray(); if (helpItems.Any() && !window.EPuzzleData.CurrentUserInfo.MondaiResults.HasItem(chumon.Id)) { window.State = WindowState.FoFi(parent, new HelpItemState(window, helpItems, 0, clickDeKaishi)); } else { window.State = clickDeKaishi; } }
// GetPoint()は強制的に期間を限定するが、GetPoints2()は最古の結果からの全期間 public static IEnumerable<PointF> GetPoints2(Chumon chumon, double minGrade, double maxGrade, RectangleF rectangle, MondaiResult[] mondaiResults, EPuzzleUserInfo userInfo) { if (!mondaiResults.Any()) return Enumerable.Empty<PointF>(); var items = mondaiResults.OrderByDescending(x => x.StartTime).ToArray(); var t0 = items.Last().StartTime; var duration = EPuzzleTime.Now - t0; var points = items.Select(mondaiResult => { var grade = chumon.GetGrade(mondaiResult, userInfo); if (grade < minGrade) { grade = minGrade; } else if (grade > maxGrade) { grade = maxGrade; } grade -= minGrade; grade /= maxGrade - minGrade; var t = (mondaiResult.StartTime - t0).Ticks / (double)duration.Ticks; return new PointF((float)(t * rectangle.Width + rectangle.Left), (float)(grade * rectangle.Height + rectangle.Top)); }); return points; }