// @license magnet:?xt=urn:btih:5305d91886084f776adcf57509a648432709a7c7&dn=x11.txt X11 License

// checking the source code is cheating and now your score is null and void >:c

var questions = {
	"have never broken a bone": false,
	"like Banjo Kazooie: Nuts & Bolts": true,
	"tell people who say \"Linux\" that it's actually \"GNU/Linux\"": false,
	"have never broken a bone": false,
	"joined the Fediverse in August 2018": true,
	"have a habit of buying domain names that I never use": true,
	"have mixed up the phrases \"Middle Earth\" and \"Middle East\" several times": true,
	"am lactose intolerant": true,
	"have never seen a rabbit in real life": true,
	"have never seen a sheep in real life": false,
	"chew my nails": true,
	"am the only person on fedi.lynnesbian.space": false,
	"often mix up my lefts and rights": true,
	"main Isabelle in Smash Ultimate": false,
	"main Mii Swordfighter in Smash Ultimate": true,
	"have accidentally stolen a library book before": true,
	"am allergic to gluten": true,
	"can draw The Cool S": false,
	"have written several games for the TI-84+ calculator": true, // https://git.bune.city/lynnesbian/ti-basic
	"can play the trumpet": true,
	"can play the ukelele": false,
	"never have to look at the keyboard when typing": false,
	"have never owned an Apple device": false,
	"have never used FaceBook": false,
	"do not particularly care for the way LibreJS requires you to annotate your JavaScript files": true,
	"have walked into a tree while reading a book": true,
	"have walked into a tree while using my phone": false,
	"live and die by vim": false,
	"live and die by emacs": false,
	"have a truck driver's license": false,
}

var ranks = [
	"The AntiLynne",
	"Poop martial",
	"Twitter crossposter",
	"Fake gamer",
	"CLASS D LICENSE",
	"Coin flipper",
	"Much to learn",
	"Lucky number sevlynne",
	"Long leggy creacher",
	"The Seer",
	"Gosh Amongst Mortals" // unless you read the JS, in which case you are a poop martial 
]
var score = 0;
var answered = 0;
var ready = false;
var current = null;

function next_question(butotn) {
	let correct = null;
	let gamediv = dgel('quiz');
	if (!ready) {
		ready = true;
	} else {
		correct = butotn.classList.contains("true") == questions[current]
		if (correct) { score++; }
		answered++;
	}

	delete questions[current];

	if (answered < 10) {
		// https://stackoverflow.com/a/15106541
		var qkeys = Object.keys(questions);
		current = qkeys[qkeys.length * Math.random() << 0];

		gamediv.innerHTML = `<div class='quiz-popup ${correct}'></div><h2>Question ${answered + 1}</h2><p>True or false: I ${current}.</p><div id='quiz-buttons'><button class='true' onclick='next_question(this)'>True</button><button class='false' onclick='next_question(this)'>False</button></div>`;
	} else {
		gamediv.innerHTML = `<div class='quiz-popup ${correct}'></div><h2>Finish!</h2><p>You got ${score} points, earning you the rank of "${ranks[score]}"! Thanks for playing!</p><a class='button' onclick='window.location=window.location'>Play again</a>`;
	}
}

window.addEventListener('DOMContentLoaded', (event) => {
	dgel('quiz-questions').innerHTML = Object.keys(questions).length;

	dgel('quiz-start').onclick = next_question;
});

// @license-end