using System; using System.Collections.Generic; using Inohara.DT; using MU3.Battle; using MU3.DataStudio; using MU3.Game; using MU3.User; using UnityEngine; namespace Inohara; class Util { public static string GetLamp(BattleResult result) { if(result.playResult == PlayResult.Failed) { return "LOSS"; } if(result.notesComboResult == NotesComboResult.None) { return "CLEAR"; } if(result.notesComboResult == NotesComboResult.FullCombo) { return "FULL COMBO"; } if(result.notesComboResult == NotesComboResult.AllBreak) { return "ALL BREAK"; } return "INVALID"; } public static string GetStringDiff(FumenDifficulty diff) { return diff switch { FumenDifficulty.Basic => "BASIC", FumenDifficulty.Advanced => "ADVANCED", FumenDifficulty.Expert => "EXPERT", FumenDifficulty.Master => "MASTER", FumenDifficulty.Lunatic => "LUNATIC", _ => "INVALID", }; } public static BatchManualScore CreateScore(BattleResult result, SessionInfo info) { var timestampSec = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; return new BatchManualScore { score = result.technicalScore, difficulty = GetStringDiff(info.musicLevel), timeAchieved = (ulong)timestampSec * 1000, matchType = "inGameID", identifier = info.musicData.id.ToString(), bellLamp = result.bellComboResult == BellComboResult.None ? "NONE" : "FULL BELL", noteLamp = GetLamp(result), optional = new BatchManualOptional() { fast = result.numNotesFast, slow = result.numNotesLate, bellCount = result.numBellCatch, totalBellCount = result.numBellAny, damage = result.countDamage, platScore = result.platinumScore }, judgements = new BatchManualJudgements() { cbreak = result.numNotesCBreak, breakMyBonesIWill = result.numNotesBreak, hit = result.numNotesHit, miss = result.numNotesMiss } }; } public static BatchManualPBScore CreatePB(UserFumen fumen) { return new BatchManualPBScore { score = fumen.TechScoreMax, difficulty = GetStringDiff(fumen.Level), matchType = "inGameID", identifier = fumen.MusicId.ToString(), bellLamp = fumen.IsFullBell ? "FULL BELL" : "NONE", noteLamp = fumen.IsAllBreak ? "ALL BREAK" : fumen.IsFullCombo ? "FULL COMBO" : // fumen.isClear is a bool that seems to flag battle victory. Useless // basing this on score is ass but for the most part it will be accurate. fumen.TechScoreMax >= 940000 ? "CLEAR" : "LOSS", optional = new BatchManualPBOptional() {}, judgements = new BatchManualPBJudgements() {} }; } public static string CreateBatch(List scores) { var bm = new BatchManual { meta = new BatchManualMeta { game = "ongeki", playtype = "Single", 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); } }