inohara/Inohara/Util.cs

111 lines
3.8 KiB
C#
Raw Normal View History

2024-05-19 22:24:05 +00:00
using System;
using System.Collections.Generic;
using Inohara.DT;
2024-05-19 22:24:05 +00:00
using MU3.Battle;
using MU3.DataStudio;
using MU3.Game;
2024-05-20 17:25:56 +00:00
using MU3.User;
2024-05-19 22:24:05 +00:00
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) {
2024-05-19 22:24:05 +00:00
var timestampSec = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
return new BatchManualScore {
2024-05-19 22:24:05 +00:00
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() {
2024-05-19 22:24:05 +00:00
fast = result.numNotesFast,
slow = result.numNotesLate,
bellCount = result.numBellCatch,
totalBellCount = result.numBellAny,
damage = result.countDamage,
platScore = result.platinumScore
},
judgements = new BatchManualJudgements() {
2024-05-19 22:24:05 +00:00
cbreak = result.numNotesCBreak,
breakMyBonesIWill = result.numNotesBreak,
hit = result.numNotesHit,
miss = result.numNotesMiss
}
};
}
public static BatchManualPBScore CreatePB(UserFumen fumen) {
return new BatchManualPBScore {
2024-05-20 17:25:56 +00:00
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() {}
2024-05-20 17:25:56 +00:00
};
}
public static string CreateBatch(List<BatchManualScore> scores) {
2024-05-19 22:24:05 +00:00
var bm = new BatchManual {
meta = new BatchManualMeta {
2024-05-19 22:24:05 +00:00
game = "ongeki",
playtype = "Single",
service = "inohara"
2024-05-19 22:24:05 +00:00
},
scores = scores.ToArray()
};
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);
}
2024-05-19 22:24:05 +00:00
}