private PhraseIteration AddTestPhrase(string name, int time) { testArrangement.Phrases.Add(new Phrase(name, 0, PhraseMask.None)); var phraseIter = new PhraseIteration(time, testArrangement.Phrases.Count - 1); testArrangement.PhraseIterations.Add(phraseIter); return(phraseIter); }
public void Apply(InstrumentalArrangement arrangement, Action <string> Log) { // Increase the number attribute of any following noguitar sections foreach (var section in arrangement.Sections.Where(s => s.Name == "noguitar")) { ++section.Number; } // Add the removed noguitar section back var newFirstSection = new Section("noguitar", _firstNGSectionTime, 1); arrangement.Sections.Insert(0, newFirstSection); // Add a new NG phrase as the last phrase arrangement.Phrases.Add(new Phrase("NG", maxDifficulty: 0, PhraseMask.None)); // Recreate the removed phrase iteration (with the phrase id of the new NG phrase) var newNGPhraseIteration = new PhraseIteration(_firstNGSectionTime, arrangement.Phrases.Count - 1); // Add after the first phraseIteration (COUNT) arrangement.PhraseIterations.Insert(1, newNGPhraseIteration); Log("Restored first noguitar section."); }
public void GeneratePhraseIterationsData(IAttributes attribute, dynamic song, GameVersion gameVersion) { if (song.PhraseIterations == null) { return; } for (int i = 0; i < song.PhraseIterations.Length; i++) { var phraseIteration = song.PhraseIterations[i]; var phrase = song.Phrases[phraseIteration.PhraseId]; var endTime = i >= song.PhraseIterations.Length - 1 ? song.SongLength : song.PhraseIterations[i + 1].Time; var phraseIt = new PhraseIteration(); phraseIt.StartTime = phraseIteration.Time; phraseIt.EndTime = endTime; phraseIt.PhraseIndex = phraseIteration.PhraseId; phraseIt.Name = phrase.Name; phraseIt.MaxDifficulty = phrase.MaxDifficulty; if (gameVersion == GameVersion.RS2012) { phraseIt.MaxScorePerDifficulty = new List <float>(); } attribute.PhraseIterations.Add(phraseIt); } var noteCnt = 0; foreach (var y in attribute.PhraseIterations) { if (song.Levels[y.MaxDifficulty].Notes != null) { if (gameVersion == GameVersion.RS2012) { noteCnt += GetNoteCount(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes); } else { noteCnt += GetNoteCount2014(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes); } } if (song.Levels[y.MaxDifficulty].Chords != null) { noteCnt += GetChordCount(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Chords); } } attribute.Score_MaxNotes = noteCnt; attribute.Score_PNV = ((float)attribute.TargetScore) / noteCnt; foreach (var y in attribute.PhraseIterations) { var phrase = song.Phrases[y.PhraseIndex]; for (int o = 0; o <= phrase.MaxDifficulty; o++) { var multiplier = ((float)(o + 1)) / (phrase.MaxDifficulty + 1); var pnv = attribute.Score_PNV; var noteCount = 0; if (song.Levels[o].Chords != null) { if (gameVersion == GameVersion.RS2012) { noteCnt += GetNoteCount(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes); } else { noteCnt += GetNoteCount2014(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes); } } if (song.Levels[o].Chords != null) { noteCount += GetChordCount(y.StartTime, y.EndTime, song.Levels[o].Chords); } if (gameVersion == GameVersion.RS2012) { var score = pnv * noteCount * multiplier; y.MaxScorePerDifficulty.Add(score); } } } }
private void parsePhraseIterations(Song2014 xml, Sng2014File sng) { sng.PhraseIterations = new PhraseIterationSection(); sng.PhraseIterations.Count = xml.PhraseIterations.Length; sng.PhraseIterations.PhraseIterations = new PhraseIteration[sng.PhraseIterations.Count]; for (int i = 0; i < sng.PhraseIterations.Count; i++) { var piter = xml.PhraseIterations[i]; var p = new PhraseIteration(); p.PhraseId = piter.PhraseId; p.StartTime = piter.Time; if (i + 1 < sng.PhraseIterations.Count) p.NextPhraseTime = xml.PhraseIterations[i + 1].Time; else p.NextPhraseTime = xml.SongLength; // default to (0, 0, max) // they use Medium (previous) value if there is hero=3 missing p.Difficulty[2] = xml.Phrases[p.PhraseId].MaxDifficulty; if (piter.HeroLevels != null) foreach (var h in piter.HeroLevels) p.Difficulty[h.Hero-1] = h.Difficulty; sng.PhraseIterations.PhraseIterations[i] = p; } }
public void SlideOutEvent_CreatesHandshape() { const int chordTime = 20222; const int sustainTime = 3000; var phrase = new Phrase("test", (byte)(testArrangement.Levels.Count - 1), PhraseMask.None); testArrangement.Phrases.Add(phrase); var phraseIter = new PhraseIteration(chordTime, testArrangement.Phrases.Count - 1); testArrangement.PhraseIterations.Add(phraseIter); var template = new ChordTemplate(); template.SetFingering(1, 3, 3, -1, -1, -1); template.SetFrets(1, 3, 4, -1, -1, -1); testArrangement.ChordTemplates.Add(template); short chordId = (short)(testArrangement.ChordTemplates.Count - 1); var chord = new Chord { ChordId = chordId, Time = chordTime, ChordNotes = new List <Note> { new Note { String = 0, Fret = 1, SlideUnpitchTo = 5, Sustain = sustainTime }, new Note { String = 1, Fret = 3, SlideUnpitchTo = 7, Sustain = sustainTime }, new Note { String = 2, Fret = 3, SlideUnpitchTo = 7, Sustain = sustainTime } } }; var hardestLevel = testArrangement.Levels.Last(); var handshape = new HandShape(chordId, chordTime, chordTime + sustainTime); hardestLevel.Chords.Add(chord); hardestLevel.HandShapes.Add(handshape); testArrangement.Events.Add(new Event("so", chordTime)); int handShapeCount = hardestLevel.HandShapes.Count; int chordTemplateCount = testArrangement.ChordTemplates.Count; new CustomEventPostProcessor(new List <ImproverMessage>()).Apply(testArrangement, nullLog); testArrangement.Events.Should().NotContain(ev => ev.Code == "so"); hardestLevel.HandShapes.Should().HaveCount(handShapeCount + 1); testArrangement.ChordTemplates.Should().HaveCount(chordTemplateCount + 1); handshape.EndTime.Should().BeLessThan(chordTime + sustainTime); }
public void GeneratePhraseIterationsData(IAttributes attribute, dynamic song, GameVersion gameVersion) { if (song.PhraseIterations == null) return; for (int i = 0; i < song.PhraseIterations.Length; i++) { var phraseIteration = song.PhraseIterations[i]; var phrase = song.Phrases[phraseIteration.PhraseId]; var endTime = i >= song.PhraseIterations.Length - 1 ? song.SongLength : song.PhraseIterations[i + 1].Time; var phraseIt = new PhraseIteration(); phraseIt.StartTime = phraseIteration.Time; phraseIt.EndTime = endTime; phraseIt.PhraseIndex = phraseIteration.PhraseId; phraseIt.Name = phrase.Name; phraseIt.MaxDifficulty = phrase.MaxDifficulty; if (gameVersion == GameVersion.RS2012) phraseIt.MaxScorePerDifficulty = new List<float>(); attribute.PhraseIterations.Add(phraseIt); } var noteCnt = 0; foreach (var y in attribute.PhraseIterations) { if (song.Levels[y.MaxDifficulty].Notes != null) { if (gameVersion == GameVersion.RS2012) noteCnt += GetNoteCount(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes); else noteCnt += GetNoteCount2014(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes); } if (song.Levels[y.MaxDifficulty].Chords != null ) { noteCnt += GetChordCount(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Chords); } } attribute.Score_MaxNotes = noteCnt; attribute.Score_PNV = ((float)attribute.TargetScore) / noteCnt; foreach (var y in attribute.PhraseIterations) { var phrase = song.Phrases[y.PhraseIndex]; for (int o = 0; o <= phrase.MaxDifficulty; o++) { var multiplier = ((float)(o + 1)) / (phrase.MaxDifficulty + 1); var pnv = attribute.Score_PNV; var noteCount = 0; if (song.Levels[o].Chords != null) { if (gameVersion == GameVersion.RS2012) noteCnt += GetNoteCount(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes); else noteCnt += GetNoteCount2014(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes); } if (song.Levels[o].Chords != null) noteCount += GetChordCount(y.StartTime, y.EndTime, song.Levels[o].Chords); if (gameVersion == GameVersion.RS2012) { var score = pnv * noteCount * multiplier; y.MaxScorePerDifficulty.Add(score); } } } }