Compare commits

..

No commits in common. "main" and "1.0.0-pre.2" have entirely different histories.

8 changed files with 108 additions and 147 deletions

View File

@ -1,47 +0,0 @@
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;
}

View File

@ -1,34 +0,0 @@
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 {}

View File

@ -1,19 +0,0 @@
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;
}

View File

@ -1,16 +0,0 @@
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;
}

92
Inohara/DataTypes.cs Normal file
View File

@ -0,0 +1,92 @@
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;
}

View File

@ -11,7 +11,6 @@ using MU3.Util;
using UnityEngine; using UnityEngine;
using UnityEngine.Networking; using UnityEngine.Networking;
using UnityEngine.UI; using UnityEngine.UI;
using Inohara.DT;
namespace Inohara; namespace Inohara;
@ -32,7 +31,7 @@ public class Exporter: SingletonMonoBehaviour<Exporter> {
private readonly Dictionary<string, string> _tokens = new(); private readonly Dictionary<string, string> _tokens = new();
private string _currToken = ""; private string _currToken = "";
private readonly Font _arial = Resources.GetBuiltinResource<Font>("Arial.ttf"); private readonly Font _arial = Resources.GetBuiltinResource<Font>("Arial.ttf");
private List<BatchManualScore> _scores = new(); private List<BatchScore> _scores = new();
private void Log(object o, bool drawText) { private void Log(object o, bool drawText) {
Debug.Log("[Inohara] " + o.ToString()); Debug.Log("[Inohara] " + o.ToString());
@ -181,7 +180,7 @@ public class Exporter: SingletonMonoBehaviour<Exporter> {
req.SetRequestHeader("Content-Type", "application/json"); req.SetRequestHeader("Content-Type", "application/json");
_scores.Add(Util.CreateScore(result, info)); _scores.Add(Util.CreateScore(result, info));
var batch = Util.CreateBatch(_scores); var batch = Util.CreateBatch(_scores, "inohara");
byte[] jsonToSend = new UTF8Encoding().GetBytes(batch); byte[] jsonToSend = new UTF8Encoding().GetBytes(batch);
req.uploadHandler = new UploadHandlerRaw(jsonToSend); req.uploadHandler = new UploadHandlerRaw(jsonToSend);
@ -234,7 +233,7 @@ public class Exporter: SingletonMonoBehaviour<Exporter> {
} }
var userMusic = Singleton<UserManager>.instance.userMusic; var userMusic = Singleton<UserManager>.instance.userMusic;
var scores = new List<BatchManualPBScore>(); var scores = new List<BatchScore>();
foreach(var x in userMusic.Values) { foreach(var x in userMusic.Values) {
foreach(var y in x.UserFumen) { foreach(var y in x.UserFumen) {
if(y != null) { if(y != null) {
@ -242,7 +241,7 @@ public class Exporter: SingletonMonoBehaviour<Exporter> {
} }
} }
} }
var batch = Util.CreatePBBatch(scores); var batch = Util.CreateBatch(scores, "inohara-pb");
using StreamWriter writer = new(Path.Combine(Application.dataPath, "../batch-manual.json")); using StreamWriter writer = new(Path.Combine(Application.dataPath, "../batch-manual.json"));
writer.Write(batch); writer.Write(batch);

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Inohara.DT;
using MU3.Battle; using MU3.Battle;
using MU3.DataStudio; using MU3.DataStudio;
using MU3.Game; using MU3.Game;
@ -37,9 +36,9 @@ class Util {
}; };
} }
public static BatchManualScore CreateScore(BattleResult result, SessionInfo info) { public static BatchScore CreateScore(BattleResult result, SessionInfo info) {
var timestampSec = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; var timestampSec = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
return new BatchManualScore { return new BatchScore {
score = result.technicalScore, score = result.technicalScore,
difficulty = GetStringDiff(info.musicLevel), difficulty = GetStringDiff(info.musicLevel),
timeAchieved = (ulong)timestampSec * 1000, timeAchieved = (ulong)timestampSec * 1000,
@ -47,7 +46,7 @@ class Util {
identifier = info.musicData.id.ToString(), identifier = info.musicData.id.ToString(),
bellLamp = result.bellComboResult == BellComboResult.None ? "NONE" : "FULL BELL", bellLamp = result.bellComboResult == BellComboResult.None ? "NONE" : "FULL BELL",
noteLamp = GetLamp(result), noteLamp = GetLamp(result),
optional = new BatchManualOptional() { optional = new BatchOptional() {
fast = result.numNotesFast, fast = result.numNotesFast,
slow = result.numNotesLate, slow = result.numNotesLate,
bellCount = result.numBellCatch, bellCount = result.numBellCatch,
@ -55,7 +54,7 @@ class Util {
damage = result.countDamage, damage = result.countDamage,
platScore = result.platinumScore platScore = result.platinumScore
}, },
judgements = new BatchManualJudgements() { judgements = new BatchJudgements() {
cbreak = result.numNotesCBreak, cbreak = result.numNotesCBreak,
breakMyBonesIWill = result.numNotesBreak, breakMyBonesIWill = result.numNotesBreak,
hit = result.numNotesHit, hit = result.numNotesHit,
@ -64,8 +63,8 @@ class Util {
}; };
} }
public static BatchManualPBScore CreatePB(UserFumen fumen) { public static BatchScore CreatePB(UserFumen fumen) {
return new BatchManualPBScore { return new BatchScore {
score = fumen.TechScoreMax, score = fumen.TechScoreMax,
difficulty = GetStringDiff(fumen.Level), difficulty = GetStringDiff(fumen.Level),
matchType = "inGameID", matchType = "inGameID",
@ -78,34 +77,21 @@ class Util {
// basing this on score is ass but for the most part it will be accurate. // basing this on score is ass but for the most part it will be accurate.
fumen.TechScoreMax >= 940000 ? "CLEAR" : fumen.TechScoreMax >= 940000 ? "CLEAR" :
"LOSS", "LOSS",
optional = new BatchManualPBOptional() {}, optional = new BatchOptional() {},
judgements = new BatchManualPBJudgements() {} judgements = new BatchJudgements() {}
}; };
} }
public static string CreateBatch(List<BatchManualScore> scores) { public static string CreateBatch(List<BatchScore> scores, string name) {
var bm = new BatchManual { var bm = new BatchManual {
meta = new BatchManualMeta { meta = new BatchMeta {
game = "ongeki", game = "ongeki",
playtype = "Single", playtype = "Single",
service = "inohara" service = name
}, },
scores = scores.ToArray() scores = scores.ToArray()
}; };
return JsonUtility.ToJson(bm).Replace("breakMyBonesIWill", "break"); return JsonUtility.ToJson(bm).Replace("breakMyBonesIWill", "break");
} }
public static string CreatePBBatch(List<BatchManualPBScore> scores) {
var bm = new BatchManualPB {
meta = new BatchManualPBMeta {
game = "ongeki",
playtype = "Single",
service = "inohara-pb"
},
scores = scores.ToArray()
};
return JsonUtility.ToJson(bm);
}
} }

View File

@ -7,7 +7,7 @@ Enable = true
Timeout = 3 Timeout = 3
# Tachi instance base URL # Tachi instance base URL
BaseUrl = https://kamai.tachi.ac BaseUrl = https://kamai.tachi.ac/
# Tachi status endpoint # Tachi status endpoint
Status = /api/v1/status Status = /api/v1/status