- One empty scene; App builds the canvas, safe-area layout and a shared 5x6 Grid in code. Pages (Intro, Main, Choose, Play, Account, Settings) replace 5 scenes, 5 prefabs and the per-cell spawner/display components. - Packs: the game reads Rhyculator/package/ (with All files access) or the app folder, like a plugged-in USB stick. Zips stay where they are and are extracted to a cache keyed by name/size/mtime; folders are read directly. Scans run every second on a background thread. Old songs/ imports and inbox zips are migrated automatically. - Download packs by 8-char code from the new pack website, or via rhyculator://pack/<code> links; opened/shared zips go into the package folder. - Play: pause/resume/retry, auto-pause on background, combo and progress bar; judging and scoring unchanged. Choose page fits 9:16 screens; empty state, pack delete. Android back key handled everywhere. - Slimming: removed TextMesh Pro, unused 2D/Timeline/VisualScripting/etc. packages and modules, scene template, unused sprites; menu theme wav (20MB) -> ogg (2.3MB). Build profile replaced by explicit settings in BuildAndroid. - Tests: PackLibrary/PackReader/migration/serializer tests (39 passing). Co-Authored-By: Claude Opus 5.5 <[email protected]>
120 lines
4.2 KiB
C#
120 lines
4.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.IO.Compression;
|
|
using System.Text;
|
|
using NUnit.Framework;
|
|
|
|
public class MiniJsonTests
|
|
{
|
|
[Test]
|
|
public void Parses_nested_values()
|
|
{
|
|
var o = MiniJson.AsObject(MiniJson.Parse("{\"a\":1,\"b\":[true,null,\"x\\n\\u0041\"],\"c\":{\"d\":-2.5e1}}"));
|
|
Assert.AreEqual(1.0, MiniJson.GetNumber(o, "a"));
|
|
var b = MiniJson.AsList(o["b"]);
|
|
Assert.AreEqual(true, b[0]);
|
|
Assert.IsNull(b[1]);
|
|
Assert.AreEqual("x\nA", b[2]);
|
|
Assert.AreEqual(-25.0, MiniJson.GetNumber(MiniJson.AsObject(o["c"]), "d"));
|
|
}
|
|
|
|
[Test]
|
|
public void Missing_keys_are_distinguishable_from_zero()
|
|
{
|
|
var o = MiniJson.AsObject(MiniJson.Parse("{\"pos\":{\"x\":0,\"y\":0}}"));
|
|
Assert.IsNotNull(MiniJson.Get(o, "pos"));
|
|
Assert.IsNull(MiniJson.Get(o, "path"));
|
|
Assert.IsFalse(MiniJson.TryGetNumber(o, "end", out _));
|
|
Assert.AreEqual(7, MiniJson.GetInt(o, "end", 7));
|
|
}
|
|
|
|
[TestCase("{\"a\":}")]
|
|
[TestCase("[1,2")]
|
|
[TestCase("{\"a\":1} x")]
|
|
[TestCase("")]
|
|
public void Rejects_malformed_json(string json)
|
|
{
|
|
Assert.Throws<FormatException>(() => MiniJson.Parse(json));
|
|
}
|
|
}
|
|
|
|
public class ChartLoaderTests
|
|
{
|
|
// Maker 統一格式:tap、hold、slide,加上三顆應該被略過的音符
|
|
const string Chart =
|
|
"{\"format\":1,\"divisor\":4,\"notes\":[" +
|
|
"{\"t\":1000,\"lane\":\"L\",\"type\":\"tap\",\"pos\":{\"x\":0,\"y\":3}}," +
|
|
"{\"t\":2000,\"lane\":\"R\",\"type\":\"hold\",\"end\":2500,\"pos\":{\"x\":3,\"y\":1},\"locked\":true}," +
|
|
"{\"t\":3000,\"lane\":\"L\",\"type\":\"slide\",\"end\":3400,\"path\":[{\"x\":0,\"y\":0},{\"x\":1,\"y\":1},{\"x\":2,\"y\":2}]}," +
|
|
"{\"t\":4000,\"lane\":\"M\",\"type\":\"tap\"}," + // 未配置座標
|
|
"{\"t\":5000,\"type\":\"tap\",\"pos\":{\"x\":9,\"y\":0}}," + // 超出格子
|
|
"{\"t\":6000,\"type\":\"spin\",\"pos\":{\"x\":1,\"y\":1}}]}"; // 不認識的型別
|
|
|
|
[Test]
|
|
public void Parses_unified_format_and_skips_unusable_notes()
|
|
{
|
|
var ev = ChartLoader.Parse(Chart, 0, out int skipped);
|
|
Assert.AreEqual(3, skipped);
|
|
Assert.AreEqual(5, ev.Count);
|
|
|
|
Assert.AreEqual("tap", ev[0].type);
|
|
Assert.AreEqual(1.0, ev[0].hitTime, 1e-9);
|
|
Assert.AreEqual((0, 3), (ev[0].x, ev[0].y));
|
|
|
|
Assert.AreEqual("hold", ev[1].type);
|
|
Assert.AreEqual(500, ev[1].holdMs);
|
|
|
|
// slide:第一格在 t、最後一格在 end,中間平均分布
|
|
Assert.AreEqual("slide", ev[2].type);
|
|
Assert.AreEqual(3.0, ev[2].hitTime, 1e-9);
|
|
Assert.AreEqual(3.2, ev[3].hitTime, 1e-9);
|
|
Assert.AreEqual(3.4, ev[4].hitTime, 1e-9);
|
|
Assert.AreEqual((2, 2), (ev[4].x, ev[4].y));
|
|
}
|
|
|
|
[Test]
|
|
public void Applies_pack_offset()
|
|
{
|
|
var ev = ChartLoader.Parse(Chart, 30, out _);
|
|
Assert.AreEqual(1.03, ev[0].hitTime, 1e-9);
|
|
Assert.AreEqual(3.43, ev[4].hitTime, 1e-9);
|
|
}
|
|
|
|
[Test]
|
|
public void Accepts_bare_note_array()
|
|
{
|
|
var ev = ChartLoader.Parse("[{\"t\":500,\"type\":\"tap\",\"pos\":{\"x\":2,\"y\":2}}]", 0, out int skipped);
|
|
Assert.AreEqual(1, ev.Count);
|
|
Assert.AreEqual(0, skipped);
|
|
}
|
|
}
|
|
|
|
public class SongInfoTests
|
|
{
|
|
[Test]
|
|
public void Parses_config()
|
|
{
|
|
var s = SongInfo.FromConfig(
|
|
"{\"id\":\"my-song\",\"name\":\"N\",\"artist\":\"A\",\"bpm\":174.5,\"beat_offset\":1216,\"offset\":-10," +
|
|
"\"preview_start\":60000,\"easy_num\":4,\"hard_num\":15}", "x");
|
|
Assert.AreEqual("my-song", s.id);
|
|
Assert.AreEqual(174.5, s.bpm);
|
|
Assert.AreEqual(-10, s.offsetMs);
|
|
Assert.AreEqual(60000, s.previewStartMs);
|
|
Assert.AreEqual(15000, s.previewLengthMs); // 預設值
|
|
Assert.AreEqual(4, s.levelNum[1]);
|
|
Assert.AreEqual(0, s.levelNum[2]);
|
|
Assert.AreEqual(15, s.levelNum[3]);
|
|
}
|
|
|
|
[TestCase("{\"id\":\"Bad ID\",\"name\":\"N\"}")]
|
|
[TestCase("{\"id\":\"ok-id\"}")]
|
|
[TestCase("[1,2]")]
|
|
public void Rejects_invalid_config(string json)
|
|
{
|
|
Assert.Throws<FormatException>(() => SongInfo.FromConfig(json, "x"));
|
|
}
|
|
}
|
|
|