Esempio n. 1
0
        public void TestDecodeBeatmapLyric()
        {
            using (var resStream = TestResources.OpenBeatmapResource("karaoke-file-samples"))
                using (var stream = new LineBufferedReader(resStream))
                {
                    var decoder = Decoder.GetDecoder <Beatmap>(stream);
                    Assert.AreEqual(typeof(KaraokeLegacyBeatmapDecoder), decoder.GetType());

                    var working = new TestWorkingBeatmap(decoder.Decode(stream));

                    Assert.AreEqual(1, working.BeatmapInfo.BeatmapVersion);
                    Assert.AreEqual(1, working.Beatmap.BeatmapInfo.BeatmapVersion);
                    Assert.AreEqual(1, working.GetPlayableBeatmap(new KaraokeRuleset().RulesetInfo, Array.Empty <Mod>()).BeatmapInfo.BeatmapVersion);

                    // Test lyric part decode result
                    var lyrics = working.Beatmap.HitObjects.OfType <Lyric>();
                    Assert.AreEqual(54, lyrics.Count());

                    // Test note decode part
                    var notes = working.Beatmap.HitObjects.OfType <Note>().Where(x => x.Display).ToList();
                    Assert.AreEqual(36, notes.Count);

                    testNote("た", 0, note: notes[0]);
                    testNote("だ", 0, note: notes[1]);
                    testNote("か", 0, note: notes[2]); // 風,か
                    testNote("ぜ", 0, note: notes[3]); // 風,ぜ
                    testNote("に", 1, note: notes[4]);
                    testNote("揺", 2, note: notes[5]);
                    testNote("ら", 3, note: notes[6]);
                    testNote("れ", 4, true, notes[7]);
                    testNote("て", 3, note: notes[8]);
                }
        }
Esempio n. 2
0
        public static GameplayState Create(Ruleset ruleset, IReadOnlyList <Mod>?mods = null, Score?score = null)
        {
            var beatmap         = new TestBeatmap(ruleset.RulesetInfo);
            var workingBeatmap  = new TestWorkingBeatmap(beatmap);
            var playableBeatmap = workingBeatmap.GetPlayableBeatmap(ruleset.RulesetInfo, mods);

            return(new GameplayState(playableBeatmap, ruleset, mods, score));
        }
Esempio n. 3
0
        public void TestDecodeBeatmapVersion()
        {
            using (var resStream = TestResources.OpenResource("beatmap-version.osu"))
                using (var stream = new LineBufferedReader(resStream))
                {
                    var decoder = Decoder.GetDecoder <Beatmap>(stream);
                    var working = new TestWorkingBeatmap(decoder.Decode(stream));

                    Assert.AreEqual(6, working.BeatmapInfo.BeatmapVersion);
                    Assert.AreEqual(6, working.Beatmap.BeatmapInfo.BeatmapVersion);
                    Assert.AreEqual(6, working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo, Array.Empty <Mod>()).BeatmapInfo.BeatmapVersion);
                }
        }
        public void TestDecodeBeatmapVersion()
        {
            using (var resStream = Resource.OpenResource("beatmap-version.osu"))
                using (var stream = new StreamReader(resStream))
                {
                    var decoder = Decoder.GetDecoder <Beatmap>(stream);

                    stream.BaseStream.Position = 0;
                    stream.DiscardBufferedData();

                    var working = new TestWorkingBeatmap(decoder.Decode(stream));

                    Assert.AreEqual(6, working.BeatmapInfo.BeatmapVersion);
                    Assert.AreEqual(6, working.Beatmap.BeatmapInfo.BeatmapVersion);
                    Assert.AreEqual(6, working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapVersion);
                }
        }
Esempio n. 5
0
        public RulesetFactory(Beatmap beatmap, int modeNumber = 0)
        {
            var workingBeatmap = new TestWorkingBeatmap(beatmap);
            var rulesetId      = workingBeatmap.BeatmapInfo.RulesetID;

            Ruleset = GetRuleset(workingBeatmap.BeatmapInfo.RulesetID);
            workingBeatmap.BeatmapInfo.Ruleset = Ruleset.RulesetInfo;

            var playableBeatmap = workingBeatmap.GetPlayableBeatmap(Ruleset.RulesetInfo);

            //Convert beatmaps
            if (rulesetId == 0 && modeNumber != rulesetId)
            {
                Ruleset         = GetRuleset(modeNumber);
                playableBeatmap = Ruleset.CreateBeatmapConverter(playableBeatmap).Convert();
            }

            workingBeatmap = new TestWorkingBeatmap(playableBeatmap);
            workingBeatmap.BeatmapInfo.Ruleset = Ruleset.RulesetInfo;

            WorkingBeatmap = workingBeatmap;
        }