public async Task<Tuple<List<Song>, int>> GetSongs() { var raw = await m_doc.Load(); var hdoc = new HtmlDocument(); hdoc.LoadHtml(raw); var rows = hdoc.DocumentNode.SelectNodes("//article/section/div/table/tbody/tr"); var songs = new Dictionary<string, Song>(); int failed = 0; foreach(var row in rows) { var columns = row.SelectNodes("td"); try { var duration = columns[DurationColumn].InnerText.Trim().Split(':'); var title = string.Join(" ", columns[TitleColumn].InnerText.Trim() .Split(new[] { "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()) .ToArray()); if (duration.Length < 2) { // まだプレイ時間のデータがない場合は2分と想定する duration = new[] { "2", "00" }; } var data = new SongData(columns[DifficultyColumn].InnerText.Trim().ToSongDifficulty(), int.Parse(columns[LevelColumn].InnerText.Trim()), int.Parse(columns[NotesColumn].InnerText.Trim()), int.Parse(duration[0])*60+int.Parse(duration[1])); var type = columns[TypeColumn].InnerText.Trim().ToSongType(); if (!songs.ContainsKey(title)) { songs[title] = new Song(title, type); } songs[title].Data[data.Difficulty] = data; } catch(Exception e) { failed++; continue; } } return Tuple.Create(songs.Values.OrderBy(x => x.Title).ToList(), failed); }
public async Task<Note[]> GetPattern(Song s, SongDifficulty d, int expectedNotes) { var title = NormalizeTitle(s.Title); var songIdMap = await GetSongIdMap(false); if (songIdMap == null || !songIdMap.ContainsKey(title)) { songIdMap = await GetSongIdMap(true); if (songIdMap == null || !songIdMap.ContainsKey(title)) { return null; } } foreach (var info in songIdMap[title]) { if ((int)info.GetType().GetProperty(d.ToString()).GetValue(info) != 0) { var id = $"{info.Id:d3}_{DifficultyIndex[d]}"; var pattern = await GetPattern(id); if (pattern != null && expectedNotes == pattern.Length) { return pattern; } } } return null; }
private double GetSkillTriggerProbability(OwnedIdol idol, IIdol center, IIdol guestCenter, Song song) { if (idol == null || idol.Skill == null) { return 0; } var rate = idol.Skill.EstimateProbability(idol.SkillLevel); if (center != null && center.CenterEffect is CenterEffect.SkillTriggerProbabilityUp) { var e = center.CenterEffect as CenterEffect.SkillTriggerProbabilityUp; rate *= 1+(e.Targets.HasFlag(idol.Category) ? e.Rate : 0); } if (guestCenter != null && guestCenter.CenterEffect is CenterEffect.SkillTriggerProbabilityUp) { var e = guestCenter.CenterEffect as CenterEffect.SkillTriggerProbabilityUp; rate *= 1+(e.Targets.HasFlag(idol.Category) ? e.Rate : 0); } if (song != null && song.Type.HasFlag(idol.Category)) { rate *= 1.3; } return Math.Min(rate, 1.0); }
private double GetSkillTriggerProbability(OwnedIdol idol, IIdol center, IIdol guestCenter, Song song) { if (idol == null || idol.Skill == null) { return(0); } var rate = idol.Skill.EstimateProbability(idol.SkillLevel); if (center != null && center.CenterEffect is CenterEffect.SkillTriggerProbabilityUp) { var e = center.CenterEffect as CenterEffect.SkillTriggerProbabilityUp; rate *= 1 + (e.Targets.HasFlag(idol.Category) ? e.Rate : 0); } if (guestCenter != null && guestCenter.CenterEffect is CenterEffect.SkillTriggerProbabilityUp) { var e = guestCenter.CenterEffect as CenterEffect.SkillTriggerProbabilityUp; rate *= 1 + (e.Targets.HasFlag(idol.Category) ? e.Rate : 0); } if (song != null && song.Type.HasFlag(idol.Category)) { rate *= 1.3; } return(Math.Min(rate, 1.0)); }