Commit 2eb9d931 authored by nanahira's avatar nanahira

add song mods

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