97 lines
3.4 KiB
C#
97 lines
3.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
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 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 BatchScore CreatePB(UserFumen fumen) {
|
|
return new BatchScore {
|
|
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 BatchOptional() {},
|
|
judgements = new BatchJudgements() {}
|
|
};
|
|
}
|
|
|
|
public static string CreateBatch(List<BatchScore> scores, string name) {
|
|
var bm = new BatchManual {
|
|
meta = new BatchMeta {
|
|
game = "ongeki",
|
|
playtype = "Single",
|
|
service = name
|
|
},
|
|
scores = scores.ToArray()
|
|
};
|
|
|
|
return JsonUtility.ToJson(bm).Replace("breakMyBonesIWill", "break");
|
|
}
|
|
} |