Added mystery buzzer

This commit is contained in:
Samuel Kent
2022-12-28 16:32:41 +11:00
parent ed1e492bb4
commit 6b3507cd18
4 changed files with 14 additions and 9 deletions
+12 -3
View File
@@ -1,5 +1,6 @@
let buzzerOptions = ["Kirbeep","MPYosh","MPDog","MPCat","Wow","Ooh","MarioBoing","TheNumberEight","Mystery"];
function setupBuzzerOptions() {
let buzzerOptions = ["Kirbeep","MPYosh","MPDog","MPCat","Wow","Ooh","MarioBoing","TheNumberEight"];
buzzerOptions.forEach((buzzerName) => {
$("#buzzerOptions").append("<img id='"+buzzerName+"' src='"+buzzerName+".png'>");
});
@@ -9,8 +10,6 @@ function setupBuzzerOptions() {
function userInfoToClient(userInfo) {
$("#PlayersList").find("ul").html("");
$("#ChasersList").find("ul").html("");
console.log(userInfo);
for (const user in userInfo) {
const userId = user.replaceAll(" ","_");
$("#"+userInfo[user].teamName+"List").find("ul").append("<li id="+userId+">"+user+"<var></var></li>");
@@ -40,4 +39,14 @@ function buzzInfoToClient(buzzInfo, buzzerSound) {
const userId = buzzInfo[i].userName.replaceAll(" ","_");
$("#userListPanel").find("#"+userId).find("var").html(" ("+buzzInfo[i].lateTime/1000+")");
}
}
function selectBuzzer(buzzerId) {
if (buzzerId == "Mystery") {
buzzerId = buzzerOptions[Math.floor(Math.random()*8)];
}
buzzerSound = new Audio(buzzerId+".wav");
$("#buzzer").attr("src", buzzerId+".png" );
buzzerSound.play();
return buzzerSound;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

+1 -2
View File
@@ -44,8 +44,7 @@
});
$("#buzzerOptions").contents().mousedown(function() {
buzzerSound = new Audio($(this).attr("id")+".wav");
buzzerSound.play();
buzzerSound = selectBuzzer($(this).attr("id"));
});
});
</script>
+1 -4
View File
@@ -20,7 +20,6 @@
let buzzerOptions = setupBuzzerOptions();
let buzzerSound = new Audio(buzzerOptions[0]+".wav");
console.log(buzzerSound);
$("#buzzer").attr("src", buzzerOptions[0]+".png" );
$("#buzzer").css("opacity", "0.2");
let buzzable = false;
@@ -77,9 +76,7 @@
}
$("#buzzerOptions").contents().mousedown(function() {
buzzerSound = new Audio($(this).attr("id")+".wav");
$("#buzzer").attr("src", $(this).attr("id")+".png" );
buzzerSound.play();
buzzerSound = selectBuzzer($(this).attr("id"));
});
});
</script>