IDK Button implemented + new buzzers

This commit is contained in:
Samuel Kent
2023-03-26 12:33:18 +11:00
parent 8925d9eb29
commit 85247cf8c8
21 changed files with 91 additions and 16 deletions
+29 -4
View File
@@ -1,9 +1,16 @@
function userInfoToClient(userInfo) {
$("#PlayersList").find("ul").html("");
$("#ChasersList").find("ul").html("");
for (const user in userInfo) {
const userId = user.replaceAll(" ","_");
$("#"+userInfo[user].teamName+"List").find("ul").append("<li id="+userId+">"+"<img src="+userInfo[user].buzzerId+".png data-buzzerId="+userInfo[user].buzzerId+" class=userListBuzzerSelections>"+user+"<var></var></li>");
console.log($("#userListPanel").find("#"+userId));
if ($("#userListPanel").find("#"+userId).length >= 1) {
//update buzzer icon of existing user
$("#userListPanel").find("#"+userId).find("img").attr("data-buzzerId",userInfo[user].buzzerId);
$("#userListPanel").find("#"+userId).find("img").attr("src", userInfo[user].buzzerId+".png");
}
else {
//new user
$("#"+userInfo[user].teamName+"List").find("ul").append("<li id="+userId+">"+"<img src="+userInfo[user].buzzerId+".png data-buzzerId="+userInfo[user].buzzerId+" class=userListBuzzerSelections>"+user+"<var></var></li>");
}
}
}
@@ -16,12 +23,17 @@ function gameStateToClient(currentTeam, currentScore) {
$("#currentScore").html(currentScore);
}
function clearBuzzers() {
$("#firstBuzz").html("");
$("#userListPanel").find("var").html("");
}
function buzzInfoToClient(buzzInfo) {
//play sound for first buzz in
if ($("#firstBuzz").html() == "") {
$("#firstBuzz").html(buzzInfo[0].userName);
const userId = buzzInfo[0].userName.replaceAll(" ","_");
let buzzerId = $("#userListPanel").find("#"+userId).find("img").attr("data-buzzerId")
let buzzerId = $("#userListPanel").find("#"+userId).find("img").attr("data-buzzerId");
let buzzerSound = new Audio(buzzerId+".wav");
buzzerSound.play();
}
@@ -33,6 +45,19 @@ function buzzInfoToClient(buzzInfo) {
}
}
function idkListToClient(idkList) {
idkList.forEach((userName) => {
const userId = userName.replaceAll(" ","_");
$("#userListPanel").find("#"+userId).find("var").html("<div style='display: inline; font-family: Times New Roman; font-size: 20px;'> ¯\\\_(ツ)_/¯</div>");
});
}
function passToClient(teamName) {
let passSound = new Audio("PikminDeath.wav");
passSound.play();
$("#firstBuzz").html(teamName+" have Passed!");
}
function selectBuzzer(buzzerId) {
if (buzzerId == "Mystery") {
buzzerId = buzzerOptions[Math.floor(Math.random()*(buzzerOptions.length-1))];