mirror of
https://github.com/asphyxia-core/plugins.git
synced 2026-03-21 17:34:46 -05:00
Added judge save and modify detail page to load ap_card from game path
This commit is contained in:
parent
b04e723fea
commit
2cac29b513
|
|
@ -115,8 +115,17 @@ export const saveScore: EPR = async (info, data, send) => {
|
|||
longRate: 0,
|
||||
volRate: 0,
|
||||
volforce: 0,
|
||||
judge: [],
|
||||
};
|
||||
|
||||
if (record.judge.length == 0) {
|
||||
console.log("No judge data found, save them for the first time so use current data as baseline.");
|
||||
record.judge = i.numbers('judge', []);
|
||||
if (record.judge.length == 7) {
|
||||
console.log("Judge data length is valid with s-crit.");
|
||||
}
|
||||
}
|
||||
|
||||
const score = i.number('score', 0);
|
||||
const exscore = i.number('exscore', 0);
|
||||
if (score > record.score) {
|
||||
|
|
@ -125,10 +134,23 @@ export const saveScore: EPR = async (info, data, send) => {
|
|||
record.longRate = i.number('long_rate', 0);
|
||||
record.volRate = i.number('vol_rate', 0);
|
||||
}
|
||||
|
||||
if (exscore > record.exscore) {
|
||||
record.exscore = exscore;
|
||||
}
|
||||
|
||||
if (score >= record.score || exscore >= record.exscore) {
|
||||
const newJudge = i.numbers('judge', []);
|
||||
if (newJudge.length == record.judge.length) {
|
||||
for (let j = 0; j < record.judge.length; j++) {
|
||||
if (newJudge[j] > record.judge[j]) {
|
||||
record.judge[j] = newJudge[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const volforce = i.number('volforce', 0);
|
||||
|
||||
if (isNaN(record.volforce) || record.volforce === null) {
|
||||
|
|
@ -140,6 +162,8 @@ export const saveScore: EPR = async (info, data, send) => {
|
|||
record.volforce = volforce;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(i.number('clear_type', 0) == 6 && record.clear >= 4){
|
||||
console.log("Detected Maxxive Clear, but originally UC or PUC, no override.")
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -11,4 +11,6 @@ export interface MusicRecord {
|
|||
longRate: number;
|
||||
volRate: number;
|
||||
volforce: number;
|
||||
|
||||
judge: number[];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,61 @@ function zeroPad(num, places) {
|
|||
return Array(+(zero > 0 && zero)).join("0") + num;
|
||||
}
|
||||
|
||||
function arraybuffer_emit(event, data) {
|
||||
return axios.post(`/emit/${event}`, data ?? {},{responseType: 'arraybuffer', timeout: 3000000});
|
||||
}
|
||||
|
||||
const GRAPHICS_BASE_PATH = 'data/graphics';
|
||||
|
||||
function toGraphicsPath(urlOrPath) {
|
||||
if (!urlOrPath) return urlOrPath;
|
||||
if (urlOrPath.startsWith('static/asset/')) {
|
||||
return `${GRAPHICS_BASE_PATH}/${urlOrPath.substring('static/asset/'.length)}`;
|
||||
}
|
||||
if (urlOrPath.startsWith('data/graphics/')) {
|
||||
return `${GRAPHICS_BASE_PATH}/${urlOrPath.substring('data/graphics/'.length)}`;
|
||||
}
|
||||
return urlOrPath;
|
||||
}
|
||||
|
||||
// Cache blob URLs so repeated re-renders don't refetch the same asset.
|
||||
const assetBlobUrlCache = new Map();
|
||||
|
||||
async function getOrCreateAssetBlobUrl(urlOrPath) {
|
||||
const path = toGraphicsPath(urlOrPath);
|
||||
if (!path) return null;
|
||||
|
||||
const cached = assetBlobUrlCache.get(path);
|
||||
if (cached) return cached;
|
||||
|
||||
try {
|
||||
const res = await arraybuffer_emit('getAssetData', { path });
|
||||
const data = res?.data;
|
||||
if (!data) return null;
|
||||
|
||||
const blobUrl = URL.createObjectURL(new Blob([data], { type: 'image/png' }));
|
||||
assetBlobUrlCache.set(path, blobUrl);
|
||||
return blobUrl;
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('beforeunload', () => {
|
||||
for (const blobUrl of assetBlobUrlCache.values()) {
|
||||
try {
|
||||
URL.revokeObjectURL(blobUrl);
|
||||
} catch (_) {}
|
||||
}
|
||||
assetBlobUrlCache.clear();
|
||||
});
|
||||
|
||||
async function setImgSrcFromAsset(imgEl, urlOrPath) {
|
||||
if (!imgEl) return;
|
||||
const blobUrl = await getOrCreateAssetBlobUrl(urlOrPath);
|
||||
imgEl.setAttribute('src', blobUrl ?? urlOrPath);
|
||||
}
|
||||
|
||||
function isEmptyJson(value) {
|
||||
if (value === null || value === undefined) return true;
|
||||
if (Array.isArray(value)) return value.length === 0;
|
||||
|
|
@ -157,7 +212,7 @@ function getMedal(clear) {
|
|||
|
||||
function getAppealCard(appeal) {
|
||||
let result = appeal_db["appeal_card_data"]["card"].filter(object => object["@id"] == appeal);
|
||||
return "static/asset/ap_card/" + result[0]["info"]["texture"] + ".png"
|
||||
return "data/graphics/ap_card/" + result[0]["info"]["texture"] + ".png"
|
||||
}
|
||||
|
||||
function getSongLevel(musicid, type) {
|
||||
|
|
@ -839,7 +894,11 @@ $(function() {
|
|||
$('<div class="tile is-ancestor is-centered">').append(
|
||||
$('<div class="tile is-parent is-3">').append(
|
||||
$('<article class="tile is-child">').append(
|
||||
$('<img>').attr('src', getAppealCard(profile_data.appeal))
|
||||
(() => {
|
||||
const img = $('<img>');
|
||||
setImgSrcFromAsset(img[0], getAppealCard(profile_data.appeal));
|
||||
return img;
|
||||
})()
|
||||
.css('width', '150px')
|
||||
).css('vertical-align', 'middle')
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user