Commit 2eb9d931 authored by nanahira's avatar nanahira

add song mods

parent b1adf1b6
...@@ -12,9 +12,9 @@ class Controller{ ...@@ -12,9 +12,9 @@ class Controller{
} }
if(selectedSong.type === "tja"){ if(selectedSong.type === "tja"){
this.parsedSongData = new ParseTja(songData, selectedSong.difficulty, selectedSong.stars, selectedSong.offset) this.parsedSongData = new ParseTja(songData, selectedSong.difficulty, selectedSong.stars, selectedSong.offset, false, selectedSong.mods)
}else{ }else{
this.parsedSongData = new ParseOsu(songData, selectedSong.difficulty, selectedSong.stars, selectedSong.offset) this.parsedSongData = new ParseOsu(songData, selectedSong.difficulty, selectedSong.stars, selectedSong.offset, false, selectedSong.mods)
} }
this.offset = this.parsedSongData.soundOffset this.offset = this.parsedSongData.soundOffset
......
...@@ -199,7 +199,7 @@ ...@@ -199,7 +199,7 @@
var reader = new FileReader() var reader = new FileReader()
var promise = pageEvents.load(reader).then(event => { var promise = pageEvents.load(reader).then(event => {
var data = event.target.result.replace(/\0/g, "").split("\n") var data = event.target.result.replace(/\0/g, "").split("\n")
var tja = new ParseTja(data, "oni", 0, 0, true) var tja = new ParseTja(data, "oni", 0, 0, true, null)
var songObj = { var songObj = {
id: index + 1, id: index + 1,
type: "tja", type: "tja",
...@@ -283,7 +283,7 @@ ...@@ -283,7 +283,7 @@
var reader = new FileReader() var reader = new FileReader()
var promise = pageEvents.load(reader).then(event => { var promise = pageEvents.load(reader).then(event => {
var data = event.target.result.replace(/\0/g, "").split("\n") var data = event.target.result.replace(/\0/g, "").split("\n")
var osu = new ParseOsu(data, "oni", 0, 0, true); var osu = new ParseOsu(data, "oni", 0, 0, true, null);
var dir = file.webkitRelativePath.toLowerCase() var dir = file.webkitRelativePath.toLowerCase()
dir = dir.slice(0, dir.lastIndexOf("/") + 1) dir = dir.slice(0, dir.lastIndexOf("/") + 1)
var songObj = { var songObj = {
......
class ParseOsu{ class ParseOsu{
constructor(fileContent, difficulty, stars, offset, metaOnly){ constructor(fileContent, difficulty, stars, offset, metaOnly, mods){
this.osu = { this.osu = {
OFFSET: 0, OFFSET: 0,
MSPERBEAT: 1, MSPERBEAT: 1,
...@@ -54,6 +54,10 @@ class ParseOsu{ ...@@ -54,6 +54,10 @@ class ParseOsu{
this.difficulty = this.parseDifficulty() this.difficulty = this.parseDifficulty()
this._difficulty = difficulty; this._difficulty = difficulty;
this.stars = stars this.stars = stars
this.mods = mods || {
speed: 1,
shuffle: 0
};
if(!metaOnly){ if(!metaOnly){
this.timingPoints = this.parseTiming() this.timingPoints = this.parseTiming()
this.circles = this.parseCircles() this.circles = this.parseCircles()
...@@ -183,7 +187,7 @@ class ParseOsu{ ...@@ -183,7 +187,7 @@ class ParseOsu{
measures.push({ measures.push({
ms: ms, ms: ms,
originalMS: ms, originalMS: ms,
speed: speed, speed: speed * this.mods.speed,
visible: true visible: true
}) })
} }
...@@ -282,7 +286,7 @@ class ParseOsu{ ...@@ -282,7 +286,7 @@ class ParseOsu{
start: start + this.offset, start: start + this.offset,
type: "balloon", type: "balloon",
txt: strings.note.balloon, txt: strings.note.balloon,
speed: speed, speed: speed * this.mods.speed,
endTime: endTime + this.offset, endTime: endTime + this.offset,
requiredHits: requiredHits, requiredHits: requiredHits,
gogoTime: gogoTime, gogoTime: gogoTime,
...@@ -309,7 +313,7 @@ class ParseOsu{ ...@@ -309,7 +313,7 @@ class ParseOsu{
start: start + this.offset, start: start + this.offset,
type: type, type: type,
txt: txt, txt: txt,
speed: speed, speed: speed * this.mods.speed,
endTime: endTime + this.offset, endTime: endTime + this.offset,
gogoTime: gogoTime, gogoTime: gogoTime,
beatMS: beatMS beatMS: beatMS
...@@ -338,13 +342,31 @@ class ParseOsu{ ...@@ -338,13 +342,31 @@ class ParseOsu{
}else{ }else{
emptyValue = true emptyValue = true
} }
if(!emptyValue){ if (!emptyValue) {
if (Math.random() < this.mods.shuffle) {
switch (type) {
case "don":
type = "ka";
break;
case "ka":
type = "don";
break;
case "daiDon":
type = "daiKa";
break;
case "daiKa":
type = "daiDon";
break;
default:
break;
}
}
circles.push(new Circle({ circles.push(new Circle({
id: circleID, id: circleID,
start: start + this.offset, start: start + this.offset,
type: type, type: type,
txt: txt, txt: txt,
speed: speed, speed: speed * this.mods.speed,
gogoTime: gogoTime, gogoTime: gogoTime,
beatMS: beatMS beatMS: beatMS
})) }))
......
class ParseTja{ class ParseTja{
constructor(file, difficulty, stars, offset, metaOnly){ constructor(file, difficulty, stars, offset, metaOnly, mods){
this.data = [] this.data = []
for(let line of file){ for(let line of file){
line = line.replace(/\/\/.*/, "").trim() line = line.replace(/\/\/.*/, "").trim()
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
this.difficulty = difficulty this.difficulty = difficulty
this.stars = stars this.stars = stars
this.offset = (offset || 0) * -1000 this.offset = (offset || 0) * -1000
this.mods = mods || {
speed: 1,
shuffle: 0
};
this.soundOffset = 0 this.soundOffset = 0
this.noteTypes = { this.noteTypes = {
"0": {name: false, txt: false}, "0": {name: false, txt: false},
...@@ -185,7 +189,7 @@ ...@@ -185,7 +189,7 @@
this.measures.push({ this.measures.push({
ms: ms, ms: ms,
originalMS: ms, originalMS: ms,
speed: speed, speed: speed * this.mods.speed,
visible: barLine, visible: barLine,
branch: currentBranch, branch: currentBranch,
branchFirst: branchFirstMeasure branchFirst: branchFirstMeasure
...@@ -214,13 +218,31 @@ ...@@ -214,13 +218,31 @@
//console.log(note_chain.length); //console.log(note_chain.length);
var note = currentMeasure[i] var note = currentMeasure[i]
if (note.type) { if (note.type) {
circleID++ circleID++;
if (Math.random() < this.mods.shuffle) {
switch (note.type) {
case "don":
note.type = "ka";
break;
case "ka":
note.type = "don";
break;
case "daiDon":
note.type = "daiKa";
break;
case "daiKa":
note.type = "daiDon";
break;
default:
break;
}
}
var circleObj = new Circle({ var circleObj = new Circle({
id: circleID, id: circleID,
start: note.start, start: note.start,
type: note.type, type: note.type,
txt: note.txt, txt: note.txt,
speed: note.bpm * note.scroll / 60, speed: note.bpm * note.scroll * this.mods.speed / 60,
gogoTime: note.gogo, gogoTime: note.gogo,
endTime: note.endTime, endTime: note.endTime,
requiredHits: note.requiredHits, requiredHits: note.requiredHits,
......
...@@ -204,7 +204,7 @@ class SongSelect{ ...@@ -204,7 +204,7 @@ class SongSelect{
iconFill: "#d9f19f", iconFill: "#d9f19f",
letterSpacing: 0 letterSpacing: 0
}] }]
this.optionsList = [strings.none, strings.auto, strings.netplay] this.optionsList = [strings.none, strings.auto, strings.netplay, strings.songMods.x2, strings.songMods.x3, strings.songMods.x4, strings.songMods.reverse, strings.songMods.half_shuffle, strings.songMods.shuffle]
this.draw = new CanvasDraw() this.draw = new CanvasDraw()
this.songTitleCache = new CanvasCache() this.songTitleCache = new CanvasCache()
...@@ -670,6 +670,10 @@ class SongSelect{ ...@@ -670,6 +670,10 @@ class SongSelect{
} }
var autoplay = false var autoplay = false
var multiplayer = false var multiplayer = false
var mods = {
speed: 1,
shuffle: 0
}
if(p2.session || this.state.options === 2){ if(p2.session || this.state.options === 2){
multiplayer = true multiplayer = true
}else if(this.state.options === 1){ }else if(this.state.options === 1){
...@@ -679,6 +683,16 @@ class SongSelect{ ...@@ -679,6 +683,16 @@ class SongSelect{
}else if(p2.socket.readyState === 1 && !assets.customSongs){ }else if(p2.socket.readyState === 1 && !assets.customSongs){
multiplayer = ctrl multiplayer = ctrl
} }
if (this.state.options > 2 && this.state.options < 6) {
mods.speed = this.state.options - 1;
} else if (this.state.options === 6) {
mods.shuffle = 1;
} else if (this.state.options === 7) {
mods.shuffle = 0.25;
} else if (this.state.options === 8) {
mods.shuffle = 0.5;
}
new LoadSong({ new LoadSong({
"title": selectedSong.title, "title": selectedSong.title,
...@@ -688,7 +702,8 @@ class SongSelect{ ...@@ -688,7 +702,8 @@ class SongSelect{
"type": selectedSong.type, "type": selectedSong.type,
"offset": selectedSong.offset, "offset": selectedSong.offset,
"songSkin": selectedSong.songSkin, "songSkin": selectedSong.songSkin,
"stars": selectedSong.stars[difficulty] "stars": selectedSong.stars[difficulty],
"mods": mods
}, autoplay, multiplayer, touch) }, autoplay, multiplayer, touch)
} }
toOptions(moveBy){ toOptions(moveBy){
......
...@@ -31,6 +31,14 @@ ...@@ -31,6 +31,14 @@
this.none = "なし" this.none = "なし"
this.auto = "オート" this.auto = "オート"
this.netplay = "ネットプレイ" this.netplay = "ネットプレイ"
this.songMods = {
x2: "ばいそく",
x3: "さんばい",
x4: "よんばい",
reverse: "あべこべ",
half_shuffle: "きまぐれ",
shuffle: "でたらめ"
}
this.easy = "かんたん" this.easy = "かんたん"
this.normal = "ふつう" this.normal = "ふつう"
this.hard = "むずかしい" this.hard = "むずかしい"
...@@ -187,6 +195,14 @@ function StringsEn(){ ...@@ -187,6 +195,14 @@ function StringsEn(){
this.none = "None" this.none = "None"
this.auto = "Auto" this.auto = "Auto"
this.netplay = "Netplay" this.netplay = "Netplay"
this.songMods = {
x2: "x2 Speed",
x3: "x3 Speed",
x4: "x4 Speed",
reverse: "Reverse",
half_shuffle: "Half Shuffle",
shuffle: "Shuffle"
}
this.easy = "Easy" this.easy = "Easy"
this.normal = "Normal" this.normal = "Normal"
this.hard = "Hard" this.hard = "Hard"
...@@ -343,6 +359,14 @@ function StringsCn(){ ...@@ -343,6 +359,14 @@ function StringsCn(){
this.none = "" this.none = ""
this.auto = "自动" this.auto = "自动"
this.netplay = "网络对战" this.netplay = "网络对战"
this.songMods = {
x2: "二倍速",
x3: "三倍速",
x4: "四倍速",
reverse: "颠倒",
half_shuffle: "随兴",
shuffle: "随意"
}
this.easy = "简单" this.easy = "简单"
this.normal = "普通" this.normal = "普通"
this.hard = "困难" this.hard = "困难"
...@@ -503,6 +527,14 @@ function StringsTw(){ ...@@ -503,6 +527,14 @@ function StringsTw(){
this.normal = "普通" this.normal = "普通"
this.hard = "困難" this.hard = "困難"
this.oni = "魔王" this.oni = "魔王"
this.songMods = {
x2: "二倍速",
x3: "三倍速",
x4: "四倍速",
reverse: "顛倒",
half_shuffle: "隨興",
shuffle: "隨意"
}
this.songBranch = "有譜面分歧" this.songBranch = "有譜面分歧"
this.sessionStart = "開始多人模式!" this.sessionStart = "開始多人模式!"
this.sessionEnd = "結束多人模式" this.sessionEnd = "結束多人模式"
...@@ -655,6 +687,14 @@ function StringsKo(){ ...@@ -655,6 +687,14 @@ function StringsKo(){
this.none = "없음" this.none = "없음"
this.auto = "오토" this.auto = "오토"
this.netplay = "넷 플레이" this.netplay = "넷 플레이"
this.songMods = {
x2: "x2 Speed",
x3: "x3 Speed",
x4: "x4 Speed",
reverse: "Reverse",
half_shuffle: "Half Shuffle",
shuffle: "Shuffle"
}
this.easy = "쉬움" this.easy = "쉬움"
this.normal = "보통" this.normal = "보통"
this.hard = "어려움" this.hard = "어려움"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment