JSFiddle - React, Tailwind, and code Playground
JavaScript
$.fn.game = function(){
var game=this;
game.startTime = 0;
game.endTime = 0;
game.score=0;
game.wrongAnswer=0;
game.scoreCorrect=3;
game.scoreWrong=0;
game.streak=0;
game.last=0;
game.level=0;
game.lifelines=2;
game.log=[];
// ifttt
game.vibratorEnabled=0;
game.magnetsEnabled=0;
game.motionEnabled=0;
game.hueEnabled=0;
game.punished=0;
game.punishCount=0;
game.motionTriggers=0;
game.totalQuestions = 100;//Math.floor(Math.random() * 30) + 100;
game.success = 100;//Math.floor(Math.random() * 100) + 19;
game.domInfo = 0;
game.updateScore = function(){
}
game.over = function(){
game.endTime = new Date().getTime();
totalTime = game.formatTime(game.endTime-game.startTime);
$('#game *').remove();
var message = "<h1>Game over</h1><p>You were locked up for "+totalTime+"!</p>";
game.punishCount=1;
game.reward();
game.logger('--- Game Over ---');
game.logger('Score: '+game.score);
game.logger('Passing score: '+game.success);
game.logger('Total game time: '+totalTime);
if(game.score>=game.success){
// You passed and will now be free.
game.logger('You PASSED and will now be free.');
/* Release mechanic.
--------------------
In this case a photo of the padlock combination that was uploaded before starting the game.
Or if you have eletro magnets you can turn those off here.
*/
message += "<p><img src='reward/01.jpg'/></p>";
}else{
// You failed and will have to retry.
game.logger('You FAILED to get enough points! You will have to continue until you do');
game.punish();
message += "<p><button id='restart'>Try again</button></p>";
}
$('<div id="over">'+message+'</div>').appendTo(game);
}
game.generateQuestion = function(){
}
game.nextQuestion = function(){
}
game.checkAnswer = function(answer){
};
game.pickPunishment = function(){
}
game.handlePunishment = function(punishment){
}
game.nextQuestionMaybe = function(){
}
game.punish =...