Compare commits
No commits in common. "1ed6dc6185f3086f03333c16e37a35ade4642a67" and "dc88ad2b751959be1cf6579877a3d500e2de367e" have entirely different histories.
1ed6dc6185
...
dc88ad2b75
4 changed files with 10 additions and 101 deletions
|
@ -23,9 +23,8 @@
|
||||||
|
|
||||||
let charts = document.createElement('ul');
|
let charts = document.createElement('ul');
|
||||||
for (const chart of doc.charts) {
|
for (const chart of doc.charts) {
|
||||||
let l = document.createElement('li');
|
let l = document.createElement('li');
|
||||||
l.innerText = `${chart.difficulty} ${chart.rating} - ${chart.name}\n` +
|
l.innerText = `${chart.difficulty} ${chart.rating} - ${chart.name}`
|
||||||
`${chart.steps} steps, ${chart.mines} mines, ${chart.jumps} jumps, ${chart.hands} hands, ${chart.holds} holds, ${chart.rolls} rolls`
|
|
||||||
charts.insertAdjacentElement('beforeend', l);
|
charts.insertAdjacentElement('beforeend', l);
|
||||||
}
|
}
|
||||||
el.insertAdjacentElement('beforeend', charts);
|
el.insertAdjacentElement('beforeend', charts);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
export function parseSM(data: string) {
|
export function parseSM(data: string) {
|
||||||
|
data = data.replace(/[\n\r]/g,'');
|
||||||
|
|
||||||
// steps
|
// steps
|
||||||
const difficulties = [];
|
const difficulties = [];
|
||||||
const steps = data.split('#NOTES:');
|
const steps = data.split('#NOTES:');
|
||||||
|
@ -16,25 +18,11 @@ export function parseSM(data: string) {
|
||||||
diff.rating = Number(stepsSplit[3]);
|
diff.rating = Number(stepsSplit[3]);
|
||||||
diff.radarvalues = stepsSplit[4].split(',').map(v => Number(v));
|
diff.radarvalues = stepsSplit[4].split(',').map(v => Number(v));
|
||||||
|
|
||||||
const chart = stepsSplit[5];
|
|
||||||
diff.rawChart = chart;
|
|
||||||
|
|
||||||
diff.steps = chart.split(/[124]/g).length - 1;
|
|
||||||
diff.mines = chart.split('M').length - 1;
|
|
||||||
diff.jumps = chart.split(/[124]0{0,2}[124]/g).length - 1;
|
|
||||||
diff.hands = chart.split(/[124]0{0,1}[124]0{0,1}[124]/g).length - 1;
|
|
||||||
diff.holds = chart.split('2').length - 1;
|
|
||||||
diff.rolls = chart.split('4').length - 1;
|
|
||||||
|
|
||||||
diff.steps -= diff.jumps; // jumps are counted as 1 step
|
|
||||||
|
|
||||||
difficulties.push(diff);
|
difficulties.push(diff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data = data.replace(/[\n\r]/g,'');
|
|
||||||
|
|
||||||
// metadata
|
// metadata
|
||||||
const lines = data.split(';').filter(l => l.startsWith('#'));
|
const lines = data.split(';').filter(l => l.startsWith('#'));
|
||||||
const obj: any = {};
|
const obj: any = {};
|
||||||
|
|
|
@ -1,118 +1,39 @@
|
||||||
/* eslint-disable no-unused-vars */
|
|
||||||
import * as mongoose from 'mongoose';
|
import * as mongoose from 'mongoose';
|
||||||
|
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
export enum SMVersion {
|
|
||||||
OPENITG,
|
|
||||||
FUCKEXE,
|
|
||||||
NOTITG_V1,
|
|
||||||
NOTITG_V2,
|
|
||||||
NOTITG_V3,
|
|
||||||
NOTITG_V3_1,
|
|
||||||
NOTITG_V4,
|
|
||||||
NOTITG_V4_0_1,
|
|
||||||
STEPMANIA_3_95,
|
|
||||||
STEPMANIA_5_0,
|
|
||||||
STEPMANIA_5_1,
|
|
||||||
STEPMANIA_5_2,
|
|
||||||
STEPMANIA_5_3,
|
|
||||||
}
|
|
||||||
|
|
||||||
const Sample = new Schema({
|
const Sample = new Schema({
|
||||||
start: {type: Number, default: 0},
|
start: {type: Number, default: 0},
|
||||||
length: {type: Number, default: 0}
|
length: {type: Number, default: 0}
|
||||||
});
|
});
|
||||||
|
|
||||||
const UserRating = new Schema({
|
|
||||||
rating: {type: Number, default: 0},
|
|
||||||
createdAt: Date,
|
|
||||||
user: {type: String, default: '00000000-0000-4000-a000-000000000000'}
|
|
||||||
});
|
|
||||||
|
|
||||||
const Chart = new Schema({
|
const Chart = new Schema({
|
||||||
type: {type: String, default: 'dance-single'},
|
type: {type: String, default: 'dance-single'},
|
||||||
name: {type: String, default: ''},
|
name: {type: String, default: ''},
|
||||||
difficulty: {type: String, default: 'Challenge'},
|
difficulty: {type: String, default: 'Challenge'},
|
||||||
radarvalues: [Number],
|
|
||||||
|
|
||||||
rating: {type: Number, default: 0},
|
rating: {type: Number, default: 0},
|
||||||
ratingsVote: {type: [UserRating], default: []},
|
radarvalues: [Number]
|
||||||
|
|
||||||
spoilered: {type: Boolean, default: false},
|
|
||||||
hidden: {type: Boolean, default: false},
|
|
||||||
|
|
||||||
steps: {type: Number, default: 0},
|
|
||||||
mines: {type: Number, default: 0},
|
|
||||||
jumps: {type: Number, default: 0},
|
|
||||||
hands: {type: Number, default: 0},
|
|
||||||
holds: {type: Number, default: 0},
|
|
||||||
rolls: {type: Number, default: 0},
|
|
||||||
});
|
|
||||||
|
|
||||||
const Comment = new Schema({
|
|
||||||
author: {type: String, default: '00000000-0000-4000-a000-000000000000'},
|
|
||||||
createdAt: Date,
|
|
||||||
content: {type: String, default: ''}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const FileSchema = new Schema({
|
const FileSchema = new Schema({
|
||||||
id: {type: Number, default: 0},
|
|
||||||
|
|
||||||
title: {type: String, default: 'unknown'},
|
title: {type: String, default: 'unknown'},
|
||||||
titleTranslit: String,
|
titleTranslit: String,
|
||||||
artist: {type: String, default: 'unknown'},
|
artist: {type: String, default: 'unknown'},
|
||||||
artistTranslit: String,
|
artistTranslit: String,
|
||||||
subtitle: String,
|
subtitle: String,
|
||||||
subtitleTranslit: String,
|
subtitleTranslit: String,
|
||||||
|
|
||||||
credit: String,
|
credit: String,
|
||||||
uploader: {type: String, default: '00000000-0000-4000-a000-000000000000'},
|
uploader: {type: String, default: '00000000-0000-4000-a000-000000000000'},
|
||||||
|
|
||||||
sample: Sample,
|
sample: Sample,
|
||||||
bpms: {type: Object, default: {'0': 0}},
|
bpms: {type: Object, default: {'0': 0}},
|
||||||
|
charts: [Chart]
|
||||||
charts: {type: [Chart], default: []},
|
|
||||||
|
|
||||||
description: {type: String, default: ''},
|
|
||||||
createdAt: Date,
|
|
||||||
smVersion: {type: Number, default: 0}, // see SMVersion enum
|
|
||||||
ytLink: String,
|
|
||||||
customLink: String,
|
|
||||||
hidden: {type: Boolean, default: false},
|
|
||||||
|
|
||||||
comments: {type: [Comment], default: []},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const File = mongoose.model('File', FileSchema);
|
export const File = mongoose.model('File', FileSchema);
|
||||||
|
|
||||||
const UserSchema = new Schema({ // this is pretty much just a discord user lol
|
const UserSchema = new Schema({ // this is pretty much just a discord user lol
|
||||||
id: String, // discord id, cus longass number
|
id: String, // cus longass number
|
||||||
createdAt: Number,
|
approved: Boolean
|
||||||
|
|
||||||
// caching
|
|
||||||
username: {type: String, default: 'User'},
|
|
||||||
discriminator: {type: String, default: '0000'},
|
|
||||||
avatar: String,
|
|
||||||
|
|
||||||
// used internally
|
|
||||||
uuid: {type: String, default: '00000000-0000-4000-a000-000000000000'},
|
|
||||||
|
|
||||||
approvedUpload: {type: Boolean, default: false},
|
|
||||||
approvedRate: {type: Boolean, default: false},
|
|
||||||
approvedComment: {type: Boolean, default: false},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const User = mongoose.model('User', UserSchema);
|
export const User = mongoose.model('User', UserSchema);
|
||||||
|
|
||||||
const PackSchema = new Schema({
|
|
||||||
author: {type: String, default: '00000000-0000-4000-a000-000000000000'},
|
|
||||||
files: {type: [Number], default: []}, // ids
|
|
||||||
name: {type: String, default: 'Pack'},
|
|
||||||
description: {type: String, default: ''},
|
|
||||||
createdAt: Date,
|
|
||||||
|
|
||||||
hidden: {type: Boolean, default: false},
|
|
||||||
});
|
|
||||||
|
|
||||||
export const Pack = mongoose.model('Pack', PackSchema);
|
|
|
@ -2,6 +2,7 @@ import { tmpdir } from 'os';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
const StreamZip = require('node-stream-zip');
|
const StreamZip = require('node-stream-zip');
|
||||||
|
|
||||||
|
import { returnStatic } from './lib/util';
|
||||||
import { parseSM } from './lib/smparse';
|
import { parseSM } from './lib/smparse';
|
||||||
import { File } from './schema';
|
import { File } from './schema';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue