2021-10-09 16:57:51 +02:00
|
|
|
var audio, audiostate;
|
|
|
|
var d = Math.random();
|
2021-11-20 12:07:13 +01:00
|
|
|
// choose random bgm to start
|
2021-10-09 16:57:51 +02:00
|
|
|
if (d < 0.50) {
|
|
|
|
audiostate = "mix";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
audiostate = "maobgm";
|
|
|
|
}
|
2021-11-20 12:07:13 +01:00
|
|
|
//handles bgm files to create a continous bgm
|
2021-10-09 16:57:51 +02:00
|
|
|
function audiosegm() {
|
|
|
|
if (audiostate != "mix") {
|
|
|
|
audio = new Audio('assets/music/main.mp3');
|
|
|
|
audiostate = "mix";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
audio = new Audio('assets/music/maobgm.mp3');
|
|
|
|
audiostate = "maobgm";
|
|
|
|
}
|
|
|
|
audio.play();
|
|
|
|
audio.onended = audiosegm;
|
|
|
|
}
|
2021-11-20 12:07:13 +01:00
|
|
|
// plays a sound effect
|
2021-10-09 16:57:51 +02:00
|
|
|
function sef(filename) {
|
|
|
|
new Audio("assets/music/" + filename + ".mp3").play();
|
|
|
|
}
|
|
|
|
$("#playBegin").click(function () {
|
2021-11-20 12:07:13 +01:00
|
|
|
try {// this might fail, expecially on safari
|
2021-10-09 19:34:40 +02:00
|
|
|
document.getElementsByTagName("html")[0].requestFullscreen();
|
2021-11-20 12:07:13 +01:00
|
|
|
} catch (e) { }
|
2021-10-09 16:57:51 +02:00
|
|
|
audiosegm();
|
|
|
|
$(this).fadeOut();
|
|
|
|
});
|
|
|
|
var data = {}, cQuestion = {}, indexeslist = [], indexesProgress = 0, total = 100;
|
2021-11-19 09:07:39 +01:00
|
|
|
$.getJSON("data.json", function (d) {
|
2021-10-09 16:57:51 +02:00
|
|
|
data = d;
|
|
|
|
total = d["initialScore"];
|
|
|
|
$("#counter").html("Social credit score: " + total);
|
|
|
|
for (var i = 0; i < d["questions"].length; i++) {
|
|
|
|
indexeslist.push(i);
|
|
|
|
}
|
|
|
|
shuffle(indexeslist);
|
|
|
|
displayQuestion();
|
|
|
|
});
|
|
|
|
function displayQuestion() {
|
|
|
|
$("html, body").scrollTop(0);
|
|
|
|
if (total < 1) {
|
|
|
|
audio.pause();
|
|
|
|
audio = new Audio('assets/music/anthem.mp3');
|
|
|
|
audio.play();
|
|
|
|
$("#loose").show();
|
|
|
|
}
|
|
|
|
else {
|
2021-11-21 19:06:59 +01:00
|
|
|
|
|
|
|
if(total < 2000) sef("pullup");
|
2021-10-09 16:57:51 +02:00
|
|
|
var index = 0;
|
2021-11-19 09:04:27 +01:00
|
|
|
|
|
|
|
// sends comrad Dwayne to help (or calls him back)
|
2021-11-20 12:07:13 +01:00
|
|
|
if (total > 4000) { // comes when low score
|
2021-11-19 09:04:27 +01:00
|
|
|
$("#rock-approves").hide();
|
2021-11-20 12:07:13 +01:00
|
|
|
$("#rock-disapproves").hide();
|
2021-11-19 09:04:27 +01:00
|
|
|
}
|
2021-11-20 12:07:13 +01:00
|
|
|
else {
|
2021-11-19 09:04:27 +01:00
|
|
|
$("#rock-approves-video").get(0).currentTime = 0;
|
|
|
|
$("#rock-approves").show();
|
2021-11-20 12:07:13 +01:00
|
|
|
}
|
2021-11-19 09:04:27 +01:00
|
|
|
// **************************************
|
2021-11-20 03:51:09 +01:00
|
|
|
// sends comrad baby cha-cha to help (or calls him back)
|
2021-11-20 12:07:13 +01:00
|
|
|
if (indexesProgress != 0) // comes when first question
|
|
|
|
$("#bbchacha").hide();
|
2021-11-20 03:51:09 +01:00
|
|
|
else
|
|
|
|
$("#bbchacha").show();
|
|
|
|
// **************************************
|
2021-11-19 09:04:27 +01:00
|
|
|
|
2021-10-09 16:57:51 +02:00
|
|
|
if (indexesProgress < indexeslist.length) {
|
|
|
|
index = indexeslist[indexesProgress];
|
|
|
|
indexesProgress++;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
shuffle(indexeslist);
|
|
|
|
indexesProgress = 0;
|
|
|
|
index = 0;
|
|
|
|
}
|
|
|
|
cQuestion = data["questions"][index];
|
|
|
|
$("[data-ans=1]").html(data["questions"][index]["answers"][0]["text"]);
|
|
|
|
$("[data-ans=2]").html(data["questions"][index]["answers"][1]["text"]);
|
|
|
|
if (data["questions"][index]["answers"][2]) $("[data-ans=3]").html(data["questions"][index]["answers"][2]["text"]);
|
|
|
|
else $("[data-ans=3]").html("");
|
|
|
|
if (data["questions"][index]["answers"][3]) $("[data-ans=4]").html(data["questions"][index]["answers"][3]["text"]);
|
|
|
|
else $("[data-ans=4]").html("");
|
|
|
|
$("#questionTitle").html(data["questions"][index]["title"]);
|
|
|
|
}
|
|
|
|
}
|
2021-11-19 09:04:27 +01:00
|
|
|
|
|
|
|
// comrad Dwaynes feedback *************************
|
2021-11-20 12:07:13 +01:00
|
|
|
$(".ans").mouseenter(function () {
|
|
|
|
try {
|
|
|
|
var res = cQuestion["answers"][$(this).attr("data-ans") - 1]["effect"];
|
2021-11-19 09:04:27 +01:00
|
|
|
|
2021-11-20 12:07:13 +01:00
|
|
|
if ((total <= 4000) && (res < 0)) {
|
|
|
|
$("#rock-approves").hide();
|
|
|
|
$("#rock-disapproves").show();
|
|
|
|
$("#rock-disapproves-video").get(0).currentTime = 0;
|
|
|
|
$("#rock-disapproves-video").get(0).play();
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
if (e instanceof TypeError) return true;
|
|
|
|
else throw e;
|
2021-11-19 09:04:27 +01:00
|
|
|
}
|
|
|
|
});
|
2021-11-20 12:07:13 +01:00
|
|
|
$(".ans").mouseleave(function () {
|
|
|
|
try {
|
|
|
|
var res = cQuestion["answers"][$(this).attr("data-ans") - 1]["effect"];
|
2021-11-19 09:04:27 +01:00
|
|
|
|
2021-11-20 12:07:13 +01:00
|
|
|
if ((total <= 4000) && (res < 0)) {
|
|
|
|
$("#rock-disapproves").hide();
|
|
|
|
$("#rock-approves").show();
|
|
|
|
$("#rock-approves-video").get(0).currentTime = 0;
|
|
|
|
$("#rock-approves-video").get(0).play();
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
if (e instanceof TypeError) return true;
|
|
|
|
else throw e;
|
2021-11-19 09:04:27 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
// ***8888888************************************8
|
|
|
|
|
2021-10-09 16:57:51 +02:00
|
|
|
$(".ans").click(function () {
|
|
|
|
var res = cQuestion["answers"][$(this).attr("data-ans") - 1]["effect"];
|
|
|
|
total += res;
|
|
|
|
$("#counter").html("Social credit score: " + total);
|
|
|
|
var d = Math.random();
|
|
|
|
if (d < 0.10) {
|
|
|
|
d = Math.random();
|
|
|
|
if (d < 0.30) {
|
|
|
|
$("#mao").fadeIn();
|
|
|
|
$("#mao").fadeOut();
|
|
|
|
sef("mao");
|
|
|
|
}
|
|
|
|
else if (d < 0.60) {
|
|
|
|
$("#xi").fadeIn();
|
|
|
|
$("#xi").fadeOut();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("#square").fadeIn();
|
|
|
|
$("#square").fadeOut();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (res < 0) {
|
|
|
|
$("#wrong").fadeIn();
|
|
|
|
sef("wrong");
|
|
|
|
if (res < -1000) {
|
|
|
|
sef("boo");
|
|
|
|
}
|
|
|
|
$("#wrong").fadeOut();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sef("correct");
|
|
|
|
$("#correct").fadeIn();
|
|
|
|
if (res > 1000) {
|
|
|
|
sef("applause");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
displayQuestion();
|
|
|
|
$("#correct").fadeOut();
|
2021-10-09 19:34:40 +02:00
|
|
|
});
|
2021-11-20 12:07:13 +01:00
|
|
|
|
|
|
|
$('.fadeOutVideo').on('ended', function () {
|
|
|
|
$(this).parent().fadeOut();
|
2021-11-21 18:38:27 +01:00
|
|
|
})
|