void OnComplete(Level level) { level.Session.BeatBestTimePlatinum(false); var settings = this.InRandomizerSettings; if (settings != null && level.Session.StartedFromBeginning) // how strong can/should we make this condition? { var hash = uint.Parse(settings.Hash); // convert and unconvert, yeah I know level.Session.BeatBestTime = false; if (this.SavedData.BestTimes.TryGetValue(hash, out long prevBest)) { if (level.Session.Time < prevBest) { level.Session.BeatBestTime = true; this.SavedData.BestTimes[hash] = level.Session.Time; } } else { this.SavedData.BestTimes[hash] = level.Session.Time; } if (settings.Rules != Ruleset.Custom) { if (this.SavedData.BestSetSeedTimes.TryGetValue(settings.Rules, out var prevBestSet)) { if (level.Session.Time < prevBestSet.Item1) { level.Session.BeatBestTimePlatinum(true); this.SavedData.BestSetSeedTimes[settings.Rules] = RecordTuple.Create(level.Session.Time, settings.Seed); } } else { this.SavedData.BestSetSeedTimes[settings.Rules] = RecordTuple.Create(level.Session.Time, settings.Seed); } if (level.Session.SeedCleanRandom()) { if (this.SavedData.BestRandomSeedTimes.TryGetValue(settings.Rules, out var prevBestRand)) { if (level.Session.Time < prevBestRand.Item1) { level.Session.BeatBestTimePlatinum(true); this.SavedData.BestRandomSeedTimes[settings.Rules] = RecordTuple.Create(level.Session.Time, settings.Seed); } } else { this.SavedData.BestRandomSeedTimes[settings.Rules] = RecordTuple.Create(level.Session.Time, settings.Seed); } } } this.SaveSettings(); } }
private void AddRecord(Ruleset rules, RecordTuple record) { menu.Add(new TextMenu.Button(Dialog.Clean("MODOPTIONS_RANDOMIZER_RULES_" + rules) + ": " + Dialog.Time(record.Item1) + " (" + record.Item2 + ")").Pressed(() => { Settings.Rules = rules; Settings.SeedType = SeedType.Custom; Settings.Seed = record.Item2; Settings.Enforce(); Overworld.Goto <OuiRandoSettings>(); })); }
private void AddRecord(TextMenu menu, string rules, RecordTuple record, bool isEndless) { string formatted = isEndless ? record.Item1.ToString() : Dialog.Time(record.Item1); menu.Add(new TextMenu.Button(rules + ": " + formatted + " (" + record.Item2 + ")").Pressed(() => { Settings.Rules = rules; Settings.SeedType = SeedType.Custom; Settings.Seed = record.Item2; Settings.Enforce(); Overworld.Goto <OuiRandoSettings>(); })); }
void OnComplete(Level level) { level.Session.BeatBestTimePlatinum(false); var settings = this.InRandomizerSettings; if (settings != null && level.Session.StartedFromBeginning) // how strong can/should we make this condition? { var hash = uint.Parse(settings.Hash); // convert and unconvert, yeah I know level.Session.BeatBestTime = false; if (this.SavedData.BestTimes.TryGetValue(hash, out long prevBest)) { if (level.Session.Time < prevBest) { level.Session.BeatBestTime = true; this.SavedData.BestTimes[hash] = level.Session.Time; } } else { this.SavedData.BestTimes[hash] = level.Session.Time; } if (settings.Rules != Ruleset.Custom) { long submittedValue = settings.Algorithm == LogicType.Endless ? this.CurrentScore : level.Session.Time; Func <long, bool> betterthan = oldval => settings.Algorithm == LogicType.Endless ? (submittedValue > oldval) : (submittedValue < oldval); if (settings.Algorithm != LogicType.Endless || settings.SeedType != SeedType.Random) { // unless we're playing endless, allow random seeds to count toward set seed records if (this.SavedData.BestSetSeedTimes.TryGetValue(settings.Rules, out var prevBestSet)) { if (betterthan(prevBestSet.Item1)) { level.Session.BeatBestTimePlatinum(true); this.SavedData.BestSetSeedTimes[settings.Rules] = RecordTuple.Create(submittedValue, settings.Seed); } } else { this.SavedData.BestSetSeedTimes[settings.Rules] = RecordTuple.Create(submittedValue, settings.Seed); } } if (level.Session.SeedCleanRandom()) { if (this.SavedData.BestRandomSeedTimes.TryGetValue(settings.Rules, out var prevBestRand)) { if (betterthan(prevBestRand.Item1)) { level.Session.BeatBestTimePlatinum(true); this.SavedData.BestRandomSeedTimes[settings.Rules] = RecordTuple.Create(submittedValue, settings.Seed); } } else { this.SavedData.BestRandomSeedTimes[settings.Rules] = RecordTuple.Create(submittedValue, settings.Seed); } } } this.SaveSettings(); } }