private void SetScore(ScoreSet scoreSet, int index, int value) { scoreSet[index].Score = value; if (value < 0) { return; } //Console.WriteLine("test"); scoreSet[index].Pace = scoreSet.GetScoreTotal() - scoreSet.GetCurrentComparisonTotal(); if (scoreSet[index].Pace < 0) { scoreSet[index].Status = PaceStatus.Behind; } else { scoreSet[index].Status = PaceStatus.Ahead; } if (value > best[index].Comparison) { scoreSet[index].Status = PaceStatus.Gold; } }
public void beforeTest() { this.set = new Mock <ISet>(); this.game = new Mock <IGame>(); //game.Setup(g => g.GameWonHandler).Returns(new System.Collections.Generic.List<Point>()); set.Setup(s => s.CurrentGame).Returns(game.Object); this.scoreSet = new ScoreSet(set.Object); }
public TrackerData(FileReader file) { this.file = file; ValidateFile(file); comparisonIndex = Int32.Parse(file["comparison_index"]); scores = new ScoreSet(file, "Best Run"); best = new ScoreSet(file, "Top Scores"); foreach (string section in file.Sections) { if (!IsComparison(file, section)) { continue; } comparisons.Add(new ScoreSet(file, section)); } /*if (file.ContainsKey("IL Syncing") && file["IL Syncing"] == "on") * { * bool updateComparisons = false; * foreach (string filename in ScoreTracker.files) * { * FileReader syncFile = new FileReader(filename, SortingStyle.Unsort); * if (file["game"] != syncFile["game"] || syncFile["IL Syncing"] != "on") * continue; * bool doAdd = false; * foreach (ScoreEntry score in best) * { * if (syncFile.ContainsKey("Top Scores", score.Name)) * { * doAdd = true; * if (score.Comparison > Int32.Parse(syncFile["Top Scores", score.Name])) * syncFile["Top Scores", score.Name] = "" + score.Comparison; * if (score.Comparison < Int32.Parse(syncFile["Top Scores", score.Name])) * { * score.Comparison = Int32.Parse(syncFile["Top Scores", score.Name]); * updateComparisons = true; * } * } * } * if (doAdd) * { * syncFiles.Add(syncFile); * } * syncFile.Save(); * } * if (updateComparisons) * { * best.SaveComparisons(); * } * }*/ file.Save(); }
public ScoreSetViewModel(ScoreSet scoreSet) { ILocalizationService locService = Application.Current.GetService <ILocalizationService>(); GradePoint = scoreSet.GradePoint; GradePointDisplay = locService.Format("OverallGradePointFormat", scoreSet.GradePoint); HasTerms = scoreSet.Terms.Count > 0; Terms = new CollectionViewSource() { IsSourceGrouped = true, ItemsPath = new PropertyPath("Courses"), Source = scoreSet.Terms.Reverse <Term>().Select(x => new TermViewModel(x, locService)).ToList() }; }
public Task SetScoreAsync(ScoreSet score) => SetRecordDataAsync(score.IsSecondMajor ? RecordType.ScoreSecondMajor : RecordType.ScoreMajor, score);
public override void Initialize() { _gameSong = (GameSong)Core.Cookies["CurrentSong"]; var currentGameType = (GameType)Core.Cookies["CurrentGameType"]; _performanceBar = new PerformanceBar { Metrics = Core.Metrics, Players = Core.Players, GameType = currentGameType }; _performanceBar.SetPosition(); _lifeBarSet = new LifeBarSet(Core.Metrics, Core.Players, currentGameType); _lifeBarSet.BlazingEnded += ((sender, e) => _noteBarSet.CancelReverse((int)e.Object)); _levelbarSet = new LevelBarSet(Core.Metrics, Core.Players, currentGameType); _hitsBarSet = new HitsBarSet(Core.Metrics, Core.Players, currentGameType); _scoreSet = new ScoreSet(Core.Metrics, Core.Players, currentGameType); _noteJudgementSet = new NoteJudgementSet(Core.Metrics, Core.Players, currentGameType, _lifeBarSet, _scoreSet); _countdownSet = new CountdownSet(Core.Metrics, Core.Players, currentGameType); _beatlineSet = new BeatlineSet(Core.Metrics, Core.Players, currentGameType); _gmBarSet = new GrooveMomentumBarSet(Core.Metrics, Core.Players, currentGameType); _hitAggregator = new BeatlineHitAggregator(Core.Players, currentGameType); _hitAggregator.HitsAggregated += HitsAggregated; _noteBarSet = new NoteBarSet(Core.Metrics, Core.Players, currentGameType); _noteBarSet.PlayerFaulted += (PlayerFaulted); _noteBarSet.PlayerArrowHit += (PlayerArrowHit); _songTimeLine = new SongTimeLine { Position = Core.Metrics["MainGameSongTimeline", 0], Size = Core.Metrics["MainGameSongTimeline.Size", 0] }; _beatlineSet.NoteMissed += BeatlineNoteMissed; _beatlineSet.CPUNoteHit += BeatlineNoteCPUHit; _recordReplayer = new RecordReplayer(currentGameType); _recordReplayer.LoadRecord(_gameSong.GetHashCode(), currentGameType); _recordReplayer.Position = Core.Metrics["RecordReplayer", GetFreeLocation()]; _recordReplayer.Size = Core.Metrics["RecordReplayer.Size", 0]; _displayState = 0; _songLoadDelay = 0.0; _lastLifeRecord = 0.5; _lastUpdate = 0.0; for (int x = 0; x < PLAYER_COUNT; x++) { _lifeBarSet.Reset(); Core.Players[x].ResetStats(); } _noteBarSet.InitNoteBars(); _startTime = null; _dspActive = false; _panic = Core.Cookies.ContainsKey("Panic"); _beatlineSet.EndingPhrase = _gameSong.GetEndingTimeInPhrase(); _beatlineSet.Bpm = _gameSong.CurrentBPM(0.0); _beatlineSet.AddTimingPointMarkers(_gameSong); _beatlineSet.SetSpeeds(); _noteBarSet.Visible = true; _visualBackground = new VisualizerBackground { Size = Core.Metrics["VisualizerBackground.Size", 0], AudioManager = Core.Audio, Position = Core.Metrics["VisualizerBackground", 0], SongChannel = (int)Core.Cookies["GameSongChannel"], MaxBrightness = Convert.ToByte(Core.Settings["BackgroundAnimation"]) }; InitSprites(); base.Initialize(); }
public void UpdateScores() { ScoreSet set = ScoreTracker.Data.GetScoreSet(); for (int i = 0; i < panels.Count; i++) { panels[i].entry = set[i]; panels[i].UpdatePanel(); } TrackerData run = ScoreTracker.Data; int total = run.GetScoreSet(0).GetComparisonTotal(); if (ScoreTracker.config["casual_mode"] == "0") { total = run.GetScoreSet().GetComparisonTotal(); } int sob = run.GetScoreSet(1).GetComparisonTotal(); if (ScoreTracker.config["layout"] == "0") { sobScoreName.Text = "SoB:"; if (ScoreTracker.Data.GetComparisonIndex() == 0 || ScoreTracker.config["casual_mode"] == "1") { topScoreName.Text = "Top:"; } else if (ScoreTracker.Data.GetComparisonIndex() == 1) { topScoreName.Text = "-"; } else { topScoreName.Text = "Cmp:"; } } else { sobScoreName.Text = "Sum of Best:"; if (ScoreTracker.Data.GetComparisonIndex() == 0 || ScoreTracker.config["casual_mode"] == "1") { topScoreName.Text = "Top:"; } else if (ScoreTracker.Data.GetComparisonIndex() == 1) { topScoreName.Text = "-"; } else { topScoreName.Text = "Comparison:"; } } if (ScoreTracker.Data.GetComparisonIndex() != 1) { topScore.Text = "" + total; } else { topScore.Text = "-"; } sobScore.Text = "" + sob; sobScore.Text = "" + ScoreTracker.Tracker.GetSOB(); if (!ScoreTracker.Tracker.IsRunning() && ScoreTracker.config["layout"] == "0") { currentScore.Text = ""; } else { currentScore.Text = "" + ScoreTracker.Tracker.GetTotalScore(); if (ScoreTracker.Tracker.GetTotalScore() == 0) { currentScore.Text = "-"; } } Color p = ScoreTracker.colors["text_color"]; if (ScoreTracker.Tracker.IsRunning() && ScoreTracker.config["casual_mode"] == "0") { p = GetPaceColor(ScoreTracker.Tracker.GetCurrentPace()); } currentScore.ForeColor = p; currentScoreName.Text = "Total:"; }
private ScoreSet ParsePage(string page, bool isSecondMajor, string signedInUser) { if (string.IsNullOrWhiteSpace(page)) { throw new FormatException("Page is empty."); } string studentId = GetScorePageProperty(page, "学号", "&") ?? signedInUser; string?name = GetScorePageProperty(page, "姓名", "&"); if (name == null) { return(new ScoreSet(signedInUser) { IsSecondMajor = isSecondMajor }); } _ = int.TryParse(GetScorePageProperty(page, "年级", "&"), out int admissionYear); ScoreSet set = new ScoreSet(studentId) { IsSecondMajor = isSecondMajor, Terms = GetTerms(page) }; string substring = page; int startIndex = page.IndexOf("<table"); if (startIndex < 0) { throw new FormatException("Cannot find score tables in the document."); } substring = substring.Substring(startIndex + 1); Regex tableStartRegex = new Regex("<table.*?<table.*?>(.*?)</table(.*)", RegexOptions.CultureInvariant); Regex trRegex = new Regex("<tr .*?>(.*?)</tr>", RegexOptions.CultureInvariant); Regex tdRegex = new Regex("<td .*?>(.*?)<br></td>", RegexOptions.CultureInvariant); foreach (Term term in set.Terms) { Match tableMatch = tableStartRegex.Match(substring); if (!tableMatch.Success) { throw new FormatException("Encountered unexpected score table format: cannot locate tables."); } string currentTable = tableMatch.FirstGroupValue(); MatchCollection rows = trRegex.Matches(currentTable); for (int i = 1; i < rows.Count; i++) { string row = rows[i].FirstGroupValue(); MatchCollection cols = tdRegex.Matches(row); if (cols.Count < 11) { throw new FormatException("Encountered unexpected score table format: too few columns."); } Course course = new Course(name: cols[1].FirstGroupValue()) { Credit = double.Parse(cols[2].FirstGroupValue()), Category = cols[3].FirstGroupValue(), IsInitialTake = !"重修".Equals(cols[5].FirstGroupValue(), StringComparison.Ordinal), IsSecondMajor = "辅修".Equals(cols[7].FirstGroupValue(), StringComparison.Ordinal), Comment = cols[8].FirstGroupValue(), Lecturer = cols[9].FirstGroupValue(), ObtainedTime = DateTimeOffset.Parse($"{cols[10].FirstGroupValue()} +8") }; int score; switch (cols[6].FirstGroupValue()) { case "优秀": score = 95; break; case "良好": score = 85; break; case "中等": score = 75; break; case "及格": score = 65; break; case "不及格": score = 50; break; case "合格": score = 85; break; case "不合格": score = 50; break; default: score = (int)double.Parse(cols[6].FirstGroupValue()); break; } course.Score = score; term.Courses.Add(course); } substring = tableMatch.Groups[2].Value; } return(set); }
public Task <DataAccessResult> SetScoreAsync(ScoreSet scoreSet) => SetResourceAsync(scoreSet);
public This TestScore(Source entity, ScoreSet scores) { AddCondition(Condition.EntityScores(entity, scores)); return(this as This); }
public static Condition EntityScores(Source entity, ScoreSet scores) { return(New("entity_scores").Set("entity", Utils.LowerCase(entity.ToString())).Set("scores", scores)); }