diff --git a/Inohara.DT/BatchManual.cs b/Inohara.DT/BatchManual.cs new file mode 100644 index 0000000..d82e95d --- /dev/null +++ b/Inohara.DT/BatchManual.cs @@ -0,0 +1,47 @@ +using System; + +namespace Inohara.DT; + +[Serializable] +public struct BatchManual { + public BatchManualMeta meta; + public BatchManualScore[] scores; +} + +[Serializable] +public struct BatchManualMeta { + public string game; + public string playtype; + public string service; +} + +[Serializable] +public struct BatchManualScore { + public int score; + public string difficulty; + public UInt64 timeAchieved; + public string noteLamp; + public string bellLamp; + public string matchType; + public string identifier; + public BatchManualJudgements judgements; + public BatchManualOptional optional; +} + +[Serializable] +public struct BatchManualJudgements { + public int cbreak; + public int breakMyBonesIWill; + public int hit; + public int miss; +} + +[Serializable] +public struct BatchManualOptional { + public int fast; + public int slow; + public int bellCount; + public int totalBellCount; + public int damage; + public int platScore; +} diff --git a/Inohara.DT/BatchManualPB.cs b/Inohara.DT/BatchManualPB.cs new file mode 100644 index 0000000..f1680ef --- /dev/null +++ b/Inohara.DT/BatchManualPB.cs @@ -0,0 +1,34 @@ +using System; + +namespace Inohara.DT; + +[Serializable] +public struct BatchManualPB { + public BatchManualPBMeta meta; + public BatchManualPBScore[] scores; +} + +[Serializable] +public struct BatchManualPBMeta { + public string game; + public string playtype; + public string service; +} + +[Serializable] +public struct BatchManualPBScore { + public int score; + public string difficulty; + public string noteLamp; + public string bellLamp; + public string matchType; + public string identifier; + public BatchManualPBJudgements judgements; + public BatchManualPBOptional optional; +} + +[Serializable] +public struct BatchManualPBJudgements {} + +[Serializable] +public struct BatchManualPBOptional {} diff --git a/Inohara.DT/BatchResponse.cs b/Inohara.DT/BatchResponse.cs new file mode 100644 index 0000000..f2448dd --- /dev/null +++ b/Inohara.DT/BatchResponse.cs @@ -0,0 +1,19 @@ +using System; + +namespace Inohara.DT; + +[Serializable] +public struct BatchResponse { + public bool success; + public BatchResponseBody body; +} + +[Serializable] +public struct BatchResponseBody { + public string url; +} + +[Serializable] +public struct BatchResponse2 { + public bool success; +} \ No newline at end of file diff --git a/Inohara.DT/StatusResponse.cs b/Inohara.DT/StatusResponse.cs new file mode 100644 index 0000000..5abd507 --- /dev/null +++ b/Inohara.DT/StatusResponse.cs @@ -0,0 +1,16 @@ +using System; + +namespace Inohara.DT; + +[Serializable] +public struct StatusResponse { + public bool success; + public StatusBody body; +} + +[Serializable] +public struct StatusBody { + public string version; + public string whoami; + public string[] permissions; +} \ No newline at end of file diff --git a/Inohara/DataTypes.cs b/Inohara/DataTypes.cs deleted file mode 100644 index d47cfa9..0000000 --- a/Inohara/DataTypes.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System; - -namespace Inohara; - -/** - * Batch manual - */ - -[Serializable] -public struct BatchManual { - public BatchMeta meta; - public BatchScore[] scores; -} - -[Serializable] -public struct BatchMeta { - public string game; - public string playtype; - public string service; -} - -[Serializable] -public struct BatchScore { - public int score; - public string difficulty; - public UInt64? timeAchieved; - public string noteLamp; - public string bellLamp; - public string matchType; - public string identifier; - public BatchJudgements judgements; - public BatchOptional optional; -} - -[Serializable] -public struct BatchJudgements { - public int? cbreak; - public int? breakMyBonesIWill; - public int? hit; - public int? miss; -} - -[Serializable] -public struct BatchOptional { - public int? fast; - public int? slow; - public int? bellCount; - public int? totalBellCount; - public int? damage; - public int? platScore; -} - -/** - * BM response 1 - */ - -[Serializable] -public struct BatchResponse { - public bool success; - public BatchResponseBody body; -} - -[Serializable] -public struct BatchResponseBody { - public string url; -} - -/** - * BM response 2 - */ - -[Serializable] -public struct BatchResponse2 { - public bool success; -} - -/** - * API status response - */ - -[Serializable] -public struct StatusResponse { - public bool success; - public StatusBody body; -} - -[Serializable] -public struct StatusBody { - public string version; - public string whoami; - public string[] permissions; -} \ No newline at end of file diff --git a/Inohara/Exporter.cs b/Inohara/Exporter.cs index 794dc76..daa4306 100644 --- a/Inohara/Exporter.cs +++ b/Inohara/Exporter.cs @@ -11,6 +11,7 @@ using MU3.Util; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; +using Inohara.DT; namespace Inohara; @@ -31,7 +32,7 @@ public class Exporter: SingletonMonoBehaviour { private readonly Dictionary _tokens = new(); private string _currToken = ""; private readonly Font _arial = Resources.GetBuiltinResource("Arial.ttf"); - private List _scores = new(); + private List _scores = new(); private void Log(object o, bool drawText) { Debug.Log("[Inohara] " + o.ToString()); @@ -180,7 +181,7 @@ public class Exporter: SingletonMonoBehaviour { req.SetRequestHeader("Content-Type", "application/json"); _scores.Add(Util.CreateScore(result, info)); - var batch = Util.CreateBatch(_scores, "inohara"); + var batch = Util.CreateBatch(_scores); byte[] jsonToSend = new UTF8Encoding().GetBytes(batch); req.uploadHandler = new UploadHandlerRaw(jsonToSend); @@ -233,7 +234,7 @@ public class Exporter: SingletonMonoBehaviour { } var userMusic = Singleton.instance.userMusic; - var scores = new List(); + var scores = new List(); foreach(var x in userMusic.Values) { foreach(var y in x.UserFumen) { if(y != null) { @@ -241,7 +242,7 @@ public class Exporter: SingletonMonoBehaviour { } } } - var batch = Util.CreateBatch(scores, "inohara-pb"); + var batch = Util.CreatePBBatch(scores); using StreamWriter writer = new(Path.Combine(Application.dataPath, "../batch-manual.json")); writer.Write(batch); diff --git a/Inohara/Util.cs b/Inohara/Util.cs index 9d7325d..f608e30 100644 --- a/Inohara/Util.cs +++ b/Inohara/Util.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Inohara.DT; using MU3.Battle; using MU3.DataStudio; using MU3.Game; @@ -36,9 +37,9 @@ class Util { }; } - public static BatchScore CreateScore(BattleResult result, SessionInfo info) { + public static BatchManualScore CreateScore(BattleResult result, SessionInfo info) { var timestampSec = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; - return new BatchScore { + return new BatchManualScore { score = result.technicalScore, difficulty = GetStringDiff(info.musicLevel), timeAchieved = (ulong)timestampSec * 1000, @@ -46,7 +47,7 @@ class Util { identifier = info.musicData.id.ToString(), bellLamp = result.bellComboResult == BellComboResult.None ? "NONE" : "FULL BELL", noteLamp = GetLamp(result), - optional = new BatchOptional() { + optional = new BatchManualOptional() { fast = result.numNotesFast, slow = result.numNotesLate, bellCount = result.numBellCatch, @@ -54,7 +55,7 @@ class Util { damage = result.countDamage, platScore = result.platinumScore }, - judgements = new BatchJudgements() { + judgements = new BatchManualJudgements() { cbreak = result.numNotesCBreak, breakMyBonesIWill = result.numNotesBreak, hit = result.numNotesHit, @@ -63,8 +64,8 @@ class Util { }; } - public static BatchScore CreatePB(UserFumen fumen) { - return new BatchScore { + public static BatchManualPBScore CreatePB(UserFumen fumen) { + return new BatchManualPBScore { score = fumen.TechScoreMax, difficulty = GetStringDiff(fumen.Level), matchType = "inGameID", @@ -77,21 +78,34 @@ class Util { // basing this on score is ass but for the most part it will be accurate. fumen.TechScoreMax >= 940000 ? "CLEAR" : "LOSS", - optional = new BatchOptional() {}, - judgements = new BatchJudgements() {} + optional = new BatchManualPBOptional() {}, + judgements = new BatchManualPBJudgements() {} }; } - public static string CreateBatch(List scores, string name) { + public static string CreateBatch(List scores) { var bm = new BatchManual { - meta = new BatchMeta { + meta = new BatchManualMeta { game = "ongeki", playtype = "Single", - service = name + service = "inohara" }, scores = scores.ToArray() }; return JsonUtility.ToJson(bm).Replace("breakMyBonesIWill", "break"); } + + public static string CreatePBBatch(List scores) { + var bm = new BatchManualPB { + meta = new BatchManualPBMeta { + game = "ongeki", + playtype = "Single", + service = "inohara-pb" + }, + scores = scores.ToArray() + }; + + return JsonUtility.ToJson(bm); + } } \ No newline at end of file