でたらめを実装する
This commit is contained in:
@@ -514,9 +514,11 @@
|
||||
}else{
|
||||
|
||||
var string = line.toUpperCase().split("")
|
||||
|
||||
|
||||
const abekobe = localStorage.getItem("abekobe") ?? "false";
|
||||
const detarame = parseFloat(localStorage.getItem("detarame") ?? "0", 10);
|
||||
|
||||
for(let symbol of string){
|
||||
const abekobe = localStorage.getItem("abekobe") ?? "false";
|
||||
|
||||
if (abekobe === "true") {
|
||||
if (symbol === "1") {
|
||||
@@ -534,6 +536,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (detarame > 0) {
|
||||
const randomValue = Math.random() * 100;
|
||||
if (randomValue < detarame) {
|
||||
|
||||
const first = ["1", "2"];
|
||||
const second = ["3", "4", "A", "B"];
|
||||
if (first.includes(symbol)) {
|
||||
const firstIndex = Math.floor(Math.random() * first.length);
|
||||
symbol = first[firstIndex];
|
||||
} else if (second.includes(symbol)) {
|
||||
const secondIndex = Math.floor(Math.random() * second.length);
|
||||
symbol = second[secondIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var error = false
|
||||
switch(symbol){
|
||||
|
||||
|
||||
@@ -256,6 +256,12 @@ class SongSelect{
|
||||
action: "abekobe",
|
||||
});
|
||||
|
||||
this.songs.push({
|
||||
title: "でたらめ",
|
||||
skin: this.songSkin.customSettings,
|
||||
action: "detarame",
|
||||
});
|
||||
|
||||
this.songs.push({
|
||||
title: strings.back,
|
||||
skin: this.songSkin.back,
|
||||
@@ -961,6 +967,20 @@ class SongSelect{
|
||||
}
|
||||
localStorage.setItem("abekobe", abekobe);
|
||||
}, 100);
|
||||
} else if (currentSong.action === "detarame") {
|
||||
this.playSound("se_don");
|
||||
setTimeout(() => {
|
||||
let detarame = localStorage.getItem("detarame") ?? "0";
|
||||
const input = prompt("でたらめになる確率をパーセントで入力してね!", detarame);
|
||||
if (input === null) {
|
||||
// キャンセル
|
||||
} else if (input === "") {
|
||||
input = "0";
|
||||
} else {
|
||||
detarame = input;
|
||||
}
|
||||
localStorage.setItem("detarame", detarame);
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
this.pointer(false)
|
||||
|
||||
Reference in New Issue
Block a user