inohara/Inohara/Util.cs
2024-05-20 07:24:05 +09:00

77 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using MU3.Battle;
using MU3.DataStudio;
using MU3.Game;
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 BatchScore CreateScore(BattleResult result, SessionInfo info) {
var timestampSec = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
return new BatchScore {
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 BatchOptional() {
fast = result.numNotesFast,
slow = result.numNotesLate,
bellCount = result.numBellCatch,
totalBellCount = result.numBellAny,
damage = result.countDamage,
platScore = result.platinumScore
},
judgements = new BatchJudgements() {
cbreak = result.numNotesCBreak,
breakMyBonesIWill = result.numNotesBreak,
hit = result.numNotesHit,
miss = result.numNotesMiss
}
};
}
public static string CreateBatch(List<BatchScore> scores) {
var bm = new BatchManual {
meta = new BatchMeta {
game = "ongeki",
playtype = "Single",
service = "inohara"
},
scores = scores.ToArray()
};
return JsonUtility.ToJson(bm).Replace("breakMyBonesIWill", "break");
}
}