Compare commits
3 Commits
0477eb207e
...
63298248c7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63298248c7 | ||
|
|
1cb51dd802 | ||
|
|
3b100eaf11 |
@@ -11,73 +11,60 @@
|
|||||||
<h1>Flashcards Generator</h1>
|
<h1>Flashcards Generator</h1>
|
||||||
</header>
|
</header>
|
||||||
<div class="main-wrapper">
|
<div class="main-wrapper">
|
||||||
<div id="startScreen">
|
<div class="section-title" id="title">
|
||||||
<div class="section-title" id="title">
|
<div class="content">
|
||||||
<div class="content">
|
<label for="inputText" class="inputText">Sende deine Wortliste an ChatGPT mit folgender Anweisung:</label>
|
||||||
<label for="inputText" class="inputText">Sende deine Wortliste an ChatGPT mit folgender Anweisung:</label>
|
|
||||||
</div>
|
|
||||||
<div id="aufgabe_fuer_gpt">
|
|
||||||
<pre id="formatText">
|
|
||||||
Bitte formatiere meine Wortliste exakt nach folgendem Schema.
|
|
||||||
Jeder Eintrag muss durch eine Leerzeile getrennt sein.
|
|
||||||
|
|
||||||
Englisches Wort
|
|
||||||
[IPA-Transkription]
|
|
||||||
Beispielsatz auf Englisch
|
|
||||||
Deutsche Übersetzung des Wortes
|
|
||||||
Beispielsatz auf Deutsch
|
|
||||||
</pre>
|
|
||||||
<button id="copyButton" style="position: absolute; top: 5px; right: 5px; cursor: pointer;">📋</button>
|
|
||||||
</div>
|
|
||||||
<div id="inputHinweis">
|
|
||||||
<div class="content">
|
|
||||||
<label for="inputText" class="section-title">Füge deinen Text hier ein:</label>
|
|
||||||
<textarea id="inputText" placeholder="Hier Text einfügen..."></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="button-wrapper">
|
<div id="aufgabe_fuer_gpt">
|
||||||
<button id="kartenErstellen">Karten erstellen</button>
|
<pre id="formatText">
|
||||||
|
Bitte formatiere meine Wortliste exakt nach folgendem Schema.
|
||||||
|
Jeder Eintrag muss durch eine Leerzeile getrennt sein.
|
||||||
|
|
||||||
|
Englisches Wort
|
||||||
|
[IPA-Transkription]
|
||||||
|
Beispielsatz auf Englisch
|
||||||
|
Deutsche Übersetzung des Wortes
|
||||||
|
Beispielsatz auf Deutsch
|
||||||
|
</pre>
|
||||||
|
<button id="copyButton" style="position: absolute; top: 5px; right: 5px; cursor: pointer;">📋</button>
|
||||||
|
</div>
|
||||||
|
<div id="inputHinweis">
|
||||||
|
<div class="content">
|
||||||
|
<label for="inputText" class="section-title">Füge deinen Text hier ein:</label>
|
||||||
|
<textarea id="inputText" placeholder="Hier Text einfügen..."></textarea>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="button-wrapper">
|
||||||
<div id="modusAuswahlSeite" style="display:none;">
|
<button id="kartenErstellen">Karten erstellen</button>
|
||||||
|
</div>
|
||||||
|
<div id="modusAuswahlSeite" style="display:none">
|
||||||
<h2>Wählt einen Modus:</h2>
|
<h2>Wählt einen Modus:</h2>
|
||||||
<button class="modus-btn" data-modus="druck">📄 PDF erstellen</button>
|
<button class="modus-btn" data-modus="druck">📄 PDF erstellen</button>
|
||||||
<button class="modus-btn" data-modus="training_einfach">🃏 Online-Training</button>
|
<button class="modus-btn" data-modus="training_einfach">🃏 Online-Training</button>
|
||||||
<button class="modus-btn" data-modus="statistik">📊 Statistik</button>
|
<button class="modus-btn" data-modus="statistik">📊 Statistik</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="pdfPages">
|
<div id="pdfPages" class="modus-view">
|
||||||
<div id="kartenContainer"></div>
|
<div id="kartenContainer"></div>
|
||||||
<div class="button-wrapper">
|
<div class="button-wrapper">
|
||||||
<button id="druckenBtn" style="display:none;">Drucken</button>
|
<button id="druckenBtn" style="display:none;">Drucken</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="onlineTraining">
|
<div id="onlineTraining" class="modus-view">
|
||||||
|
|
||||||
<div id="trainingLevels" class="training-view">
|
<div id="trainingLevels">
|
||||||
<h3 class="training-title">Wählt eine Trainingsart:</h3>
|
<h3>Wählt einen Schwierigkeitsgrad:</h3>
|
||||||
|
<button class="level-btn" data-level="leicht">🟢 Leicht</button>
|
||||||
<div class="buttons-row">
|
<button class="level-btn" data-level="mittel">🟡 Mittel</button>
|
||||||
<button class="level-btn" data-level="flip">Karte umdrehen</button>
|
<button class="level-btn" data-level="schwer">🔴 Schwer</button>
|
||||||
<button class="level-btn" data-level="multiple">Multiple Choice</button>
|
|
||||||
<button class="level-btn" data-level="matching">Zuordnen</button>
|
|
||||||
<button class="level-btn" data-level="hint">Mit Hinweis schreiben</button>
|
|
||||||
<button class="level-btn" data-level="write">Frei schreiben</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="trainingFlip" class="training-view hidden"></div>
|
<div id="trainingLeicht" class="training-view modus-view"></div>
|
||||||
<div id="trainingMatching" class="training-view hidden"></div>
|
<div id="trainingMittel" class="training-view"></div>
|
||||||
<div id="trainingMultiple" class="training-view hidden"></div>
|
<div id="trainingSchwer" class="training-view"></div>
|
||||||
<div id="trainingHint" class="training-view hidden"></div>
|
|
||||||
<div id="trainingWrite" class="training-view hidden"></div>
|
|
||||||
|
|
||||||
<div class="button-wrapper">
|
|
||||||
<button id="checkBtn" style="display:none;" onclick="pruefeRunde()">Überprüfen</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="trainingContainer" style="display:none; text-align:center; margin-top:30px;"></div>
|
<div id="trainingContainer" style="display:none; text-align:center; margin-top:30px;"></div>
|
||||||
|
|||||||
@@ -1,15 +1,5 @@
|
|||||||
let parsedArray = [];
|
let parsedArray = [];
|
||||||
|
|
||||||
// Mischt ein Array zufällig mit dem Fisher-Yates-Algorithmus
|
|
||||||
// und gibt das gemischte Array zurück.
|
|
||||||
function mischeArray(array) {
|
|
||||||
for (let i = array.length - 1; i > 0; i--) {
|
|
||||||
const j = Math.floor(Math.random() * (i + 1));
|
|
||||||
[array[i], array[j]] = [array[j], array[i]];
|
|
||||||
}
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('copyButton').addEventListener('click', () => {
|
document.getElementById('copyButton').addEventListener('click', () => {
|
||||||
const text = document.getElementById('formatText').innerText;
|
const text = document.getElementById('formatText').innerText;
|
||||||
|
|
||||||
@@ -20,7 +10,6 @@ document.getElementById('copyButton').addEventListener('click', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Analysiert den eingegebenen Text und wandelt ihn in ein Array von Wort-Objekten um.
|
|
||||||
function parseWordText(inputText) {
|
function parseWordText(inputText) {
|
||||||
const wortBlocks = inputText.trim().split("\n\n");
|
const wortBlocks = inputText.trim().split("\n\n");
|
||||||
const wortListe = [];
|
const wortListe = [];
|
||||||
@@ -34,7 +23,6 @@ function parseWordText(inputText) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const wortObj = {
|
const wortObj = {
|
||||||
id: crypto.randomUUID(),
|
|
||||||
englisch: lines[0],
|
englisch: lines[0],
|
||||||
ipa: lines[1],
|
ipa: lines[1],
|
||||||
beispielEN: lines[2],
|
beispielEN: lines[2],
|
||||||
@@ -48,7 +36,6 @@ function parseWordText(inputText) {
|
|||||||
return wortListe;
|
return wortListe;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gibt beide Seiten als Objekt zurück.
|
|
||||||
function createPagePair() {
|
function createPagePair() {
|
||||||
const frontPage = document.createElement("div");
|
const frontPage = document.createElement("div");
|
||||||
frontPage.className = "page page-front";
|
frontPage.className = "page page-front";
|
||||||
@@ -60,6 +47,9 @@ function createPagePair() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const button = document.getElementById("kartenErstellen");
|
const button = document.getElementById("kartenErstellen");
|
||||||
|
const onlineContainer = document.getElementById("kartenContainer");
|
||||||
|
const frontPage = document.querySelector(".page_front");
|
||||||
|
const backPage = document.querySelector(".page_back");
|
||||||
|
|
||||||
button.addEventListener("click", () => {
|
button.addEventListener("click", () => {
|
||||||
const inputText = document.getElementById("inputText").value;
|
const inputText = document.getElementById("inputText").value;
|
||||||
@@ -72,26 +62,38 @@ button.addEventListener("click", () => {
|
|||||||
|
|
||||||
alert("Karten erfolgreich erstellt!");
|
alert("Karten erfolgreich erstellt!");
|
||||||
|
|
||||||
|
showView("modusAuswahlSeite");
|
||||||
|
|
||||||
|
document.getElementById("title").style.display = "none";
|
||||||
|
button.style.display = "none";
|
||||||
|
|
||||||
document.getElementById("startScreen").style.display = "none";
|
|
||||||
document.getElementById("modusAuswahlSeite").style.display = "block";
|
document.getElementById("modusAuswahlSeite").style.display = "block";
|
||||||
});
|
});
|
||||||
|
|
||||||
// Erstellt druckfertige PDF-Seiten mit jeweils 8 Karten pro Seite.
|
document.querySelectorAll(".modus-btn").forEach(button => {
|
||||||
function createPDFPages(wordArray) {
|
button.addEventListener("click", () => {
|
||||||
|
const modus = button.dataset.modus;
|
||||||
|
|
||||||
|
if (modus === "druck") {
|
||||||
|
createPDFPages(parsedArray);
|
||||||
|
} else {
|
||||||
|
console.log("Gewählter Modus:", modus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function createPDFPages(wordArray) {
|
||||||
const kartenContainer = document.getElementById("kartenContainer");
|
const kartenContainer = document.getElementById("kartenContainer");
|
||||||
const druckenBtn = document.getElementById("druckenBtn");
|
|
||||||
|
|
||||||
kartenContainer.innerHTML = "";
|
kartenContainer.innerHTML = "";
|
||||||
kartenContainer.style.display = "flex";
|
kartenContainer.style.display = "flex";
|
||||||
kartenContainer.style.flexDirection = "column";
|
kartenContainer.style.flexDirection = "column";
|
||||||
|
|
||||||
for (let i = 0; i < wordArray.length; i += 8) {
|
for (let i = 0; i < parsedArray.length; i += 8) {
|
||||||
|
|
||||||
const { frontPage, backPage } = createPagePair();
|
const { frontPage, backPage } = createPagePair();
|
||||||
|
|
||||||
wordArray.slice(i, i + 8).forEach((karte) => {
|
parsedArray.slice(i, i + 8).forEach((karte) => {
|
||||||
|
|
||||||
const frontCard = document.createElement("div");
|
const frontCard = document.createElement("div");
|
||||||
frontCard.className = "card card-en";
|
frontCard.className = "card card-en";
|
||||||
@@ -113,31 +115,28 @@ function createPDFPages(wordArray) {
|
|||||||
|
|
||||||
kartenContainer.appendChild(frontPage);
|
kartenContainer.appendChild(frontPage);
|
||||||
kartenContainer.appendChild(backPage);
|
kartenContainer.appendChild(backPage);
|
||||||
|
document.getElementById("druckenBtn").style.display = "block";
|
||||||
}
|
}
|
||||||
|
|
||||||
druckenBtn.style.display = "block";
|
|
||||||
|
|
||||||
alert("PDF-Seiten wurden erstellt! Du kannst sie jetzt drucken.");
|
alert("PDF-Seiten wurden erstellt! Du kannst sie jetzt drucken.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
document.getElementById("druckenBtn").addEventListener("click", () => {
|
document.getElementById("druckenBtn").addEventListener("click", () => {
|
||||||
window.print();
|
window.print();
|
||||||
});
|
});
|
||||||
|
|
||||||
const modusBtns = document.querySelectorAll('.modus-btn');
|
const modusBtns = document.querySelectorAll('.modus-btn');
|
||||||
|
const trainingLevels = document.getElementById('trainingLevels');
|
||||||
|
|
||||||
modusBtns.forEach(btn => {
|
modusBtns.forEach(btn => {
|
||||||
btn.addEventListener('click', () => {
|
btn.addEventListener('click', () => {
|
||||||
const modus = btn.dataset.modus;
|
const modus = btn.dataset.modus;
|
||||||
|
|
||||||
if (modus === 'druck') {
|
if (modus === 'druck') {
|
||||||
showMode('pdfPages');
|
showView('pdfPages');
|
||||||
createPDFPages(parsedArray);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (modus === 'training_einfach') {
|
else if (modus === 'training_einfach') {
|
||||||
showMode('onlineTraining');
|
showView('trainingLevels');
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (modus === 'statistik') {
|
else if (modus === 'statistik') {
|
||||||
@@ -146,739 +145,165 @@ modusBtns.forEach(btn => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Blendet alle Trainingslevel-Ansichten aus
|
let trainingsZustand = {
|
||||||
function showMode(id) {
|
modus: "leicht",
|
||||||
|
quelleKarten: [],
|
||||||
|
aktiveKarten: [],
|
||||||
|
gelernt: [],
|
||||||
|
nichtGelernt: [],
|
||||||
|
};
|
||||||
|
|
||||||
document.getElementById("pdfPages").style.display = "none";
|
function startLeichtTraining() {
|
||||||
document.getElementById("onlineTraining").style.display = "none";
|
console.log("🔥 startLeichtTraining вызвана");
|
||||||
|
|
||||||
document.getElementById(id).style.display = "block";
|
if (!parsedArray || parsedArray.length === 0) {
|
||||||
}
|
alert("Нет карточек для тренировки");
|
||||||
|
|
||||||
function showLevel(id) {
|
|
||||||
document.querySelectorAll("#onlineTraining .training-view").forEach(view => {
|
|
||||||
if (view.id !== "trainingLevels") {
|
|
||||||
view.classList.add("hidden");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById(id).classList.remove("hidden");
|
|
||||||
}
|
|
||||||
|
|
||||||
document.querySelectorAll(".level-btn").forEach(btn => {
|
|
||||||
btn.addEventListener("click", () => {
|
|
||||||
const type = btn.dataset.level;
|
|
||||||
console.log("Trainingsart:", type);
|
|
||||||
|
|
||||||
if (type === "flip") {
|
|
||||||
showLevel("trainingFlip");
|
|
||||||
startFlipTraining();
|
|
||||||
document.getElementById("checkBtn").style.display = "none";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type === "matching") {
|
|
||||||
showLevel("trainingMatching");
|
|
||||||
startMittelTraining();
|
|
||||||
document.getElementById("checkBtn").style.display = "block";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type === "multiple") {
|
|
||||||
showLevel("trainingMultiple");
|
|
||||||
startMultipleTraining();
|
|
||||||
document.getElementById("checkBtn").style.display = "none";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type === "hint") {
|
|
||||||
showLevel("trainingHint");
|
|
||||||
startHintTraining();
|
|
||||||
document.getElementById("checkBtn").style.display = "none";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type === "write") {
|
|
||||||
showLevel("trainingWrite");
|
|
||||||
startWriteTraining();
|
|
||||||
document.getElementById("checkBtn").style.display = "none";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
class TrainingsEngine {
|
|
||||||
|
|
||||||
constructor(kartenListe) {
|
|
||||||
this.kartenQueue = [];
|
|
||||||
this.letzteKarteId = null;
|
|
||||||
this.gelernt = [];
|
|
||||||
this.nichtGelernt = [];
|
|
||||||
|
|
||||||
// Initialisierung aller Richtungen
|
|
||||||
kartenListe.forEach(karte => {
|
|
||||||
["EN_DE", "DE_EN"].forEach(richtung => {
|
|
||||||
this.kartenQueue.push({
|
|
||||||
karte: karte,
|
|
||||||
richtung: richtung,
|
|
||||||
korrektInFolge: 0,
|
|
||||||
versuche: 0,
|
|
||||||
maxVersuche: 3,
|
|
||||||
status: "learning"
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
this.#mischeQueue();
|
|
||||||
}
|
|
||||||
|
|
||||||
//ÖFFENTLICHE API
|
|
||||||
|
|
||||||
naechstesElement() {
|
|
||||||
if (this.kartenQueue.length === 0) return null;
|
|
||||||
|
|
||||||
// Verhindert direkte Wiederholung derselben Karte
|
|
||||||
if (
|
|
||||||
this.kartenQueue.length > 1 &&
|
|
||||||
this.kartenQueue[0].karte.id === this.letzteKarteId
|
|
||||||
) {
|
|
||||||
const alternativeIndex = this.kartenQueue.findIndex(
|
|
||||||
el => el.karte.id !== this.letzteKarteId
|
|
||||||
);
|
|
||||||
|
|
||||||
if (alternativeIndex !== -1) {
|
|
||||||
const [element] = this.kartenQueue.splice(alternativeIndex, 1);
|
|
||||||
this.kartenQueue.unshift(element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const aktuellesElement = this.kartenQueue.shift();
|
|
||||||
this.letzteKarteId = aktuellesElement.karte.id;
|
|
||||||
|
|
||||||
return aktuellesElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
antwortVerarbeiten(element, istKorrekt) {
|
|
||||||
if (!element || element.status !== "learning") return;
|
|
||||||
|
|
||||||
element.versuche++;
|
|
||||||
|
|
||||||
if (istKorrekt) {
|
|
||||||
element.korrektInFolge++;
|
|
||||||
|
|
||||||
if (element.korrektInFolge >= 3) {
|
|
||||||
element.status = "gelernt";
|
|
||||||
this.gelernt.push(element);
|
|
||||||
this.kartenQueue = this.kartenQueue.filter(e => e !== element);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.#wiederEinreihen(element, 8, 10);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
element.korrektInFolge = 0;
|
|
||||||
element.maxVersuche = 5;
|
|
||||||
|
|
||||||
if (element.versuche >= element.maxVersuche) {
|
|
||||||
element.status = "nichtGelernt";
|
|
||||||
this.nichtGelernt.push(element);
|
|
||||||
this.kartenQueue = this.kartenQueue.filter(e => e !== element);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.#wiederEinreihen(element, 2, 3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
istBeendet() {
|
|
||||||
return this.kartenQueue.length === 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
statistik() {
|
|
||||||
const alle = [...this.kartenQueue];
|
|
||||||
|
|
||||||
return {
|
|
||||||
verbleibend: this.kartenQueue.length,
|
|
||||||
gelernt: alle.filter(e => e.status === "gelernt").length,
|
|
||||||
nichtGelernt: alle.filter(e => e.status === "nichtGelernt").length
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
exportiereZustand() {
|
|
||||||
return JSON.stringify({
|
|
||||||
kartenQueue: this.kartenQueue,
|
|
||||||
letzteKarteId: this.letzteKarteId
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ladeZustand(json) {
|
|
||||||
const daten = JSON.parse(json);
|
|
||||||
this.kartenQueue = daten.kartenQueue;
|
|
||||||
this.letzteKarteId = daten.letzteKarteId;
|
|
||||||
}
|
|
||||||
|
|
||||||
//PRIVATE METHODEN
|
|
||||||
#wiederEinreihen(element, minAbstand, maxAbstand) {
|
|
||||||
const zufall =
|
|
||||||
Math.floor(Math.random() * (maxAbstand - minAbstand + 1)) + minAbstand;
|
|
||||||
|
|
||||||
const position = Math.min(zufall, this.kartenQueue.length);
|
|
||||||
this.kartenQueue.splice(position, 0, element);
|
|
||||||
}
|
|
||||||
|
|
||||||
#mischeQueue() {
|
|
||||||
for (let i = this.kartenQueue.length - 1; i > 0; i--) {
|
|
||||||
const j = Math.floor(Math.random() * (i + 1));
|
|
||||||
[this.kartenQueue[i], this.kartenQueue[j]] =
|
|
||||||
[this.kartenQueue[j], this.kartenQueue[i]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let flipEngine;
|
|
||||||
|
|
||||||
function startFlipTraining() {
|
|
||||||
flipEngine = new TrainingsEngine(parsedArray);
|
|
||||||
zeigeNaechsteFlipKarte();
|
|
||||||
}
|
|
||||||
|
|
||||||
function zeigeNaechsteFlipKarte() {
|
|
||||||
const element = flipEngine.naechstesElement();
|
|
||||||
|
|
||||||
const container = document.getElementById("trainingFlip");
|
|
||||||
container.innerHTML = "";
|
|
||||||
|
|
||||||
if (!element) {
|
|
||||||
container.classList.remove("hidden");
|
|
||||||
container.innerHTML = `<div style="text-align:center; font-size: 24px; margin-top:20px;">🎉 Training beendet!<br>Gelernt: ${flipEngine.gelernt.length}<br>Nicht gelernt: ${flipEngine.nichtGelernt.length}</div>`;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trainingsZustand.quelleKarten = [...parsedArray];
|
||||||
|
trainingsZustand.aktiveKarten = [];
|
||||||
|
trainingsZustand.gelernt = [];
|
||||||
|
trainingsZustand.nichtGelernt = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < 3; i++) {
|
||||||
|
if (trainingsZustand.quelleKarten.length > 0) {
|
||||||
|
const karte = trainingsZustand.quelleKarten.shift();
|
||||||
|
karte.versuche = 0;
|
||||||
|
trainingsZustand.aktiveKarten.push(karte);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
zeigeNaechsteKarte();
|
||||||
|
}
|
||||||
|
|
||||||
|
function zeigeNaechsteKarte() {
|
||||||
|
if (
|
||||||
|
trainingsZustand.aktiveKarten.length === 0 &&
|
||||||
|
trainingsZustand.quelleKarten.length === 0
|
||||||
|
) {
|
||||||
|
alert(`Training beendet!
|
||||||
|
Gelernt: ${trainingsZustand.gelernt.length}
|
||||||
|
Nicht gelernt: ${trainingsZustand.nichtGelernt.length}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const index = Math.floor(
|
||||||
|
Math.random() * trainingsZustand.aktiveKarten.length
|
||||||
|
);
|
||||||
|
|
||||||
|
trainingsZustand.aktuelleKarte =
|
||||||
|
trainingsZustand.aktiveKarten[index];
|
||||||
|
|
||||||
|
renderLeichtKarte(trainingsZustand.aktuelleKarte);
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderLeichtKarte(karte) {
|
||||||
|
const container = document.getElementById("trainingLeicht");
|
||||||
|
container.innerHTML = "";
|
||||||
|
|
||||||
const cardEl = document.createElement("div");
|
const cardEl = document.createElement("div");
|
||||||
cardEl.className = "training-card";
|
cardEl.className = "training-card";
|
||||||
|
|
||||||
cardEl.innerHTML = `
|
cardEl.innerHTML = `
|
||||||
<div class="training-card-inner">
|
<div class="training-card-inner">
|
||||||
|
<div class="training-front">
|
||||||
<div class="training-front">
|
<h2>${karte.englisch}</h2>
|
||||||
<div class="card-top">
|
<div class="ipa">${karte.ipa}</div>
|
||||||
<h2>${element.richtung === "EN_DE" ? element.karte.englisch : element.karte.deutsch}</h2>
|
<div class="example">${karte.beispielEN}</div>
|
||||||
${element.richtung === "EN_DE" && element.karte.ipa
|
</div>
|
||||||
? `<div class="ipa">${element.karte.ipa}</div>`
|
<div class="training-back">
|
||||||
: ``
|
<h2>${karte.deutsch}</h2>
|
||||||
}
|
<div class="example">${karte.beispielDE}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-example">
|
</div>
|
||||||
${element.richtung === "EN_DE"
|
`;
|
||||||
? element.karte.beispielEN || ""
|
|
||||||
: element.karte.beispielDE || ""
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="training-back">
|
|
||||||
<div class="card-top">
|
|
||||||
<h2>${element.richtung === "EN_DE" ? element.karte.deutsch : element.karte.englisch}</h2>
|
|
||||||
${element.richtung !== "EN_DE" && element.karte.ipa
|
|
||||||
? `<div class="ipa">${element.karte.ipa}</div>`
|
|
||||||
: ``
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
<div class="card-example">
|
|
||||||
${element.richtung === "EN_DE"
|
|
||||||
? element.karte.beispielDE || ""
|
|
||||||
: element.karte.beispielEN || ""
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
cardEl.onclick = () => cardEl.classList.toggle("flip");
|
cardEl.onclick = () => cardEl.classList.toggle("flip");
|
||||||
|
|
||||||
const actions = document.createElement("div");
|
const actions = document.createElement("div");
|
||||||
actions.className = "training-actions";
|
actions.className = "training-actions";
|
||||||
const knowBtn = document.createElement("button");
|
actions.innerHTML = `
|
||||||
knowBtn.innerText = "Weiß ich";
|
<button id="knowBtn">✔️ Weiß ich</button>
|
||||||
const dontKnowBtn = document.createElement("button");
|
<button id="dontKnowBtn">❌ Weiß ich nicht</button>
|
||||||
dontKnowBtn.innerText = "Weiß ich nicht";
|
`;
|
||||||
|
|
||||||
knowBtn.onclick = () => {
|
actions.querySelector("#knowBtn").onclick = () => antworteAufKarte(true);
|
||||||
flipEngine.antwortVerarbeiten(element, true);
|
actions.querySelector("#dontKnowBtn").onclick = () => antworteAufKarte(false);
|
||||||
zeigeNaechsteFlipKarte();
|
|
||||||
};
|
|
||||||
dontKnowBtn.onclick = () => {
|
|
||||||
flipEngine.antwortVerarbeiten(element, false);
|
|
||||||
zeigeNaechsteFlipKarte();
|
|
||||||
};
|
|
||||||
|
|
||||||
actions.appendChild(knowBtn);
|
|
||||||
actions.appendChild(dontKnowBtn);
|
|
||||||
|
|
||||||
container.appendChild(cardEl);
|
container.appendChild(cardEl);
|
||||||
container.appendChild(actions);
|
container.appendChild(actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
let multipleEngine;
|
function antworteAufKarte(weißIch) {
|
||||||
|
const karte = trainingsZustand.aktuelleKarte;
|
||||||
function startMultipleTraining() {
|
|
||||||
multipleEngine = new TrainingsEngine(parsedArray);
|
if (weißIch) {
|
||||||
zeigeNaechsteMultipleKarte();
|
trainingsZustand.gelernt.push(karte);
|
||||||
}
|
trainingsZustand.aktiveKarten = trainingsZustand.aktiveKarten.filter(k => k !== karte);
|
||||||
|
} else {
|
||||||
let aktuelleKarte = null;
|
karte.versuche++;
|
||||||
let ersteAntwort = true;
|
if (karte.versuche >= 5) {
|
||||||
|
trainingsZustand.nichtGelernt.push(karte);
|
||||||
function zeigeNaechsteMultipleKarte() {
|
trainingsZustand.aktiveKarten = trainingsZustand.aktiveKarten.filter(k => k !== karte);
|
||||||
const container = document.getElementById("trainingMultiple");
|
|
||||||
container.innerHTML = "";
|
|
||||||
|
|
||||||
const element = multipleEngine.naechstesElement();
|
|
||||||
|
|
||||||
if (!element) {
|
|
||||||
container.innerHTML = `<div style="text-align:center; font-size: 24px; margin-top:20px;">🎉 Training beendet!<br>Gelernt: ${multipleEngine.gelernt.length}<br>Nicht gelernt: ${multipleEngine.nichtGelernt.length}</div>`;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
aktuelleKarte = element;
|
|
||||||
ersteAntwort = true;
|
|
||||||
|
|
||||||
const frage = document.createElement("div");
|
|
||||||
frage.className = "multiple-frage";
|
|
||||||
frage.innerHTML = `<h2>${element.richtung === "EN_DE" ? element.karte.englisch : element.karte.deutsch}</h2>`;
|
|
||||||
container.appendChild(frage);
|
|
||||||
|
|
||||||
const optionen = generiereMultipleOptionen(element);
|
|
||||||
const optionContainer = document.createElement("div");
|
|
||||||
optionContainer.className = "multiple-optionen";
|
|
||||||
|
|
||||||
optionen.forEach(text => {
|
|
||||||
const btn = document.createElement("button");
|
|
||||||
btn.className = "multiple-option";
|
|
||||||
btn.innerText = text;
|
|
||||||
|
|
||||||
btn.onclick = () => {
|
|
||||||
const korrektText = element.richtung === "EN_DE" ? element.karte.deutsch : element.karte.englisch;
|
|
||||||
const istKorrekt = (text === korrektText);
|
|
||||||
|
|
||||||
if (istKorrekt) {
|
|
||||||
btn.style.backgroundColor = "#a8f0a8";
|
|
||||||
if (ersteAntwort) multipleEngine.antwortVerarbeiten(element, true);
|
|
||||||
setTimeout(() => zeigeNaechsteMultipleKarte(), 500);
|
|
||||||
|
|
||||||
} else if (ersteAntwort) {
|
|
||||||
btn.style.backgroundColor = "#f5a8a8";
|
|
||||||
btn.style.textDecoration = "line-through";
|
|
||||||
multipleEngine.antwortVerarbeiten(element, false);
|
|
||||||
ersteAntwort = false;
|
|
||||||
} else {
|
|
||||||
btn.style.backgroundColor = "#f5a8a8";
|
|
||||||
btn.style.textDecoration = "line-through";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
optionContainer.appendChild(btn);
|
|
||||||
});
|
|
||||||
|
|
||||||
container.appendChild(optionContainer);
|
|
||||||
}
|
|
||||||
function generiereMultipleOptionen(element) {
|
|
||||||
const korrekt = element.richtung === "EN_DE" ? element.karte.deutsch : element.karte.englisch;
|
|
||||||
|
|
||||||
const falscheOptionen = parsedArray
|
|
||||||
.filter(k => k.id !== element.karte.id)
|
|
||||||
.map(k => element.richtung === "EN_DE" ? k.deutsch : k.englisch);
|
|
||||||
|
|
||||||
mischeArray(falscheOptionen);
|
|
||||||
|
|
||||||
const optionen = [korrekt, ...falscheOptionen.slice(0, 4)];
|
|
||||||
return mischeArray(optionen);
|
|
||||||
}
|
|
||||||
|
|
||||||
function mischeArray(array) {
|
|
||||||
for (let i = array.length - 1; i > 0; i--) {
|
|
||||||
const j = Math.floor(Math.random() * (i + 1));
|
|
||||||
[array[i], array[j]] = [array[j], array[i]];
|
|
||||||
}
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
let hintEngine;
|
|
||||||
|
|
||||||
function startHintTraining() {
|
|
||||||
hintEngine = new TrainingsEngine(parsedArray);
|
|
||||||
zeigeNaechsteHintKarte();
|
|
||||||
}
|
|
||||||
|
|
||||||
function zeigeNaechsteHintKarte() {
|
|
||||||
const container = document.getElementById("trainingHint");
|
|
||||||
container.innerHTML = "";
|
|
||||||
|
|
||||||
const element = hintEngine.naechstesElement();
|
|
||||||
|
|
||||||
if (!element) {
|
|
||||||
container.innerHTML = `
|
|
||||||
<div style="text-align:center; font-size: 24px; margin-top:20px;">
|
|
||||||
🎉 Training beendet!<br>
|
|
||||||
Gelernt: ${hintEngine.gelernt.length}<br>
|
|
||||||
Nicht gelernt: ${hintEngine.nichtGelernt.length}
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const korrekt = element.richtung === "EN_DE" ? element.karte.deutsch : element.karte.englisch;
|
|
||||||
|
|
||||||
const frage = document.createElement("div");
|
|
||||||
frage.className = "hint-frage";
|
|
||||||
frage.innerText = element.richtung === "EN_DE" ? element.karte.englisch : element.karte.deutsch;
|
|
||||||
container.appendChild(frage);
|
|
||||||
|
|
||||||
const clue = document.createElement("div");
|
|
||||||
clue.className = "hint-clue";
|
|
||||||
clue.innerText = erstelleClue(korrekt);
|
|
||||||
container.appendChild(clue);
|
|
||||||
|
|
||||||
const input = document.createElement("input");
|
|
||||||
input.className = "hint-input";
|
|
||||||
input.placeholder = "Schreibe die Übersetzung...";
|
|
||||||
input.autofocus = true;
|
|
||||||
input.style.fontSize = "18px";
|
|
||||||
input.style.padding = "5px 10px";
|
|
||||||
input.style.border = "2px solid #005b5b";
|
|
||||||
input.style.borderRadius = "6px";
|
|
||||||
input.style.width = "300px";
|
|
||||||
input.style.caretColor = "#005b5b";
|
|
||||||
container.appendChild(input);
|
|
||||||
|
|
||||||
const feedback = document.createElement("div");
|
|
||||||
feedback.className = "hint-feedback";
|
|
||||||
feedback.style.marginTop = "10px";
|
|
||||||
container.appendChild(feedback);
|
|
||||||
|
|
||||||
const button = document.createElement("button");
|
|
||||||
button.className = "hint-button";
|
|
||||||
button.innerText = "Überprüfen";
|
|
||||||
container.appendChild(button);
|
|
||||||
|
|
||||||
let phase = "check";
|
|
||||||
|
|
||||||
const pruefeAntwort = () => {
|
|
||||||
if (phase === "check") {
|
|
||||||
const userAnswer = input.value.trim();
|
|
||||||
if (!userAnswer) return;
|
|
||||||
|
|
||||||
const istKorrekt = userAnswer.toLowerCase() === korrekt.toLowerCase();
|
|
||||||
hintEngine.antwortVerarbeiten(element, istKorrekt);
|
|
||||||
|
|
||||||
if (istKorrekt) {
|
|
||||||
input.style.backgroundColor = "#a8f0a8";
|
|
||||||
setTimeout(() => zeigeNaechsteHintKarte(), 500);
|
|
||||||
} else {
|
|
||||||
input.style.backgroundColor = "#f5a8a8";
|
|
||||||
feedback.innerText = `Korrekte Antwort: ${korrekt}`;
|
|
||||||
button.innerText = "Weiter";
|
|
||||||
phase = "next";
|
|
||||||
}
|
|
||||||
} else if (phase === "next") {
|
|
||||||
zeigeNaechsteHintKarte();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
button.onclick = pruefeAntwort;
|
|
||||||
|
|
||||||
input.addEventListener("keydown", (e) => {
|
|
||||||
if (e.key === "Enter") {
|
|
||||||
e.preventDefault();
|
|
||||||
pruefeAntwort();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
input.focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
function erstelleClue(text) {
|
|
||||||
if (text.length === 1) return "*";
|
|
||||||
|
|
||||||
const chars = text.split("");
|
|
||||||
let clue = chars.map(char => (char === " " ? " " : "*"));
|
|
||||||
|
|
||||||
const visibleIndices = [];
|
|
||||||
while (visibleIndices.length < Math.max(1, Math.floor(chars.length / 2))) {
|
|
||||||
const idx = Math.floor(Math.random() * chars.length);
|
|
||||||
if (chars[idx] !== " " && !visibleIndices.includes(idx)) {
|
|
||||||
visibleIndices.push(idx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
visibleIndices.forEach(idx => {
|
|
||||||
clue[idx] = chars[idx];
|
|
||||||
});
|
|
||||||
|
|
||||||
return clue.join("");
|
|
||||||
}
|
|
||||||
|
|
||||||
let writeEngine;
|
|
||||||
|
|
||||||
function startWriteTraining() {
|
|
||||||
writeEngine = new TrainingsEngine(parsedArray);
|
|
||||||
zeigeNaechsteWriteKarte();
|
|
||||||
}
|
|
||||||
|
|
||||||
function zeigeNaechsteWriteKarte() {
|
|
||||||
const container = document.getElementById("trainingWrite");
|
|
||||||
container.innerHTML = "";
|
|
||||||
|
|
||||||
const element = writeEngine.naechstesElement();
|
|
||||||
|
|
||||||
if (!element) {
|
|
||||||
container.innerHTML = `
|
|
||||||
<div style="text-align:center; font-size: 24px; margin-top:20px;">
|
|
||||||
🎉 Training beendet!<br>
|
|
||||||
Gelernt: ${writeEngine.gelernt.length}<br>
|
|
||||||
Nicht gelernt: ${writeEngine.nichtGelernt.length}
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const korrekt = element.richtung === "EN_DE" ? element.karte.deutsch : element.karte.englisch;
|
|
||||||
|
|
||||||
const frage = document.createElement("div");
|
|
||||||
frage.className = "hint-frage";
|
|
||||||
frage.innerHTML = element.richtung === "EN_DE" ? element.karte.englisch : element.karte.deutsch;
|
|
||||||
container.appendChild(frage);
|
|
||||||
|
|
||||||
const input = document.createElement("input");
|
|
||||||
input.className = "hint-input";
|
|
||||||
input.placeholder = "Schreibe die Übersetzung...";
|
|
||||||
input.autofocus = true;
|
|
||||||
input.style.fontSize = "18px";
|
|
||||||
input.style.padding = "5px 10px";
|
|
||||||
input.style.border = "2px solid #005b5b";
|
|
||||||
input.style.borderRadius = "6px";
|
|
||||||
input.style.width = "300px";
|
|
||||||
input.style.caretColor = "#005b5b";
|
|
||||||
container.appendChild(input);
|
|
||||||
|
|
||||||
const feedback = document.createElement("div");
|
|
||||||
feedback.className = "hint-feedback";
|
|
||||||
feedback.style.marginTop = "10px";
|
|
||||||
container.appendChild(feedback);
|
|
||||||
|
|
||||||
const button = document.createElement("button");
|
|
||||||
button.className = "hint-button";
|
|
||||||
button.innerText = "Überprüfen";
|
|
||||||
container.appendChild(button);
|
|
||||||
|
|
||||||
let phase = "check";
|
|
||||||
|
|
||||||
const pruefeAntwort = () => {
|
|
||||||
if (phase === "check") {
|
|
||||||
const userAnswer = input.value.trim();
|
|
||||||
if (!userAnswer) return;
|
|
||||||
|
|
||||||
const istKorrekt = userAnswer.toLowerCase() === korrekt.toLowerCase();
|
|
||||||
writeEngine.antwortVerarbeiten(element, istKorrekt);
|
|
||||||
|
|
||||||
if (istKorrekt) {
|
|
||||||
input.style.backgroundColor = "#a8f0a8";
|
|
||||||
setTimeout(() => zeigeNaechsteWriteKarte(), 500);
|
|
||||||
} else {
|
|
||||||
input.style.backgroundColor = "#f5a8a8";
|
|
||||||
feedback.innerText = `Korrekte Antwort: ${korrekt}`;
|
|
||||||
button.innerText = "Weiter";
|
|
||||||
phase = "next";
|
|
||||||
}
|
|
||||||
} else if (phase === "next") {
|
|
||||||
zeigeNaechsteWriteKarte();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
button.onclick = pruefeAntwort;
|
|
||||||
input.addEventListener("keydown", (e) => {
|
|
||||||
if (e.key === "Enter") {
|
|
||||||
e.preventDefault();
|
|
||||||
pruefeAntwort();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
input.focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
let matchingEngine;
|
|
||||||
let matchingRunde = 0;
|
|
||||||
let linkeKarten = [];
|
|
||||||
let rechteKarten = [];
|
|
||||||
let aktuelleRichtung = "EN_DE";
|
|
||||||
|
|
||||||
function startMittelTraining() {
|
|
||||||
matchingEngine = new TrainingsEngine(parsedArray);
|
|
||||||
matchingRunde = 0;
|
|
||||||
ladeMatchingRunde();
|
|
||||||
}
|
|
||||||
|
|
||||||
function ladeMatchingRunde() {
|
|
||||||
const container = document.getElementById("trainingMatching");
|
|
||||||
container.innerHTML = "";
|
|
||||||
|
|
||||||
aktuelleRichtung = matchingRunde % 2 === 0 ? "EN_DE" : "DE_EN";
|
|
||||||
matchingRunde++;
|
|
||||||
|
|
||||||
const learningCards = matchingEngine.kartenQueue.filter(e => e.status === "learning");
|
|
||||||
|
|
||||||
linkeKarten = learningCards
|
|
||||||
.reduce((acc, el) => {
|
|
||||||
if (!acc.find(a => a.karte.id === el.karte.id)) acc.push(el);
|
|
||||||
return acc;
|
|
||||||
}, [])
|
|
||||||
.slice(0, 4);
|
|
||||||
|
|
||||||
rechteKarten = mischeArray([...linkeKarten]);
|
|
||||||
|
|
||||||
const linksDiv = document.createElement("div");
|
|
||||||
linksDiv.className = "spalte-links";
|
|
||||||
|
|
||||||
const rechtsDiv = document.createElement("div");
|
|
||||||
rechtsDiv.className = "spalte-rechts";
|
|
||||||
|
|
||||||
linkeKarten.forEach(k => {
|
|
||||||
const dropZone = document.createElement("div");
|
|
||||||
dropZone.className = "training-card drop-zone";
|
|
||||||
dropZone.dataset.id = k.karte.id;
|
|
||||||
|
|
||||||
dropZone.innerHTML = `
|
|
||||||
<div class="card-top">
|
|
||||||
<h3>${aktuelleRichtung === "EN_DE" ? k.karte.englisch : k.karte.deutsch}</h3>
|
|
||||||
${aktuelleRichtung === "EN_DE" && k.karte.ipa ? `<div class="ipa">${k.karte.ipa}</div>` : ""}
|
|
||||||
</div>
|
|
||||||
<div class="card-example">
|
|
||||||
${aktuelleRichtung === "EN_DE" ? k.karte.beispielEN || "" : k.karte.beispielDE || ""}
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
linksDiv.appendChild(dropZone);
|
|
||||||
});
|
|
||||||
|
|
||||||
rechteKarten.forEach((k, index) => {
|
|
||||||
const ziehKarte = document.createElement("div");
|
|
||||||
ziehKarte.className = "training-card zieh-karte";
|
|
||||||
ziehKarte.draggable = true;
|
|
||||||
ziehKarte.dataset.index = index;
|
|
||||||
|
|
||||||
const zeigeEnglisch = aktuelleRichtung === "DE_EN";
|
|
||||||
ziehKarte.innerHTML = `
|
|
||||||
<div class="card-top">
|
|
||||||
<h3>${zeigeEnglisch ? k.karte.englisch : k.karte.deutsch}</h3>
|
|
||||||
${zeigeEnglisch && k.karte.ipa ? `<div class="ipa">${k.karte.ipa}</div>` : ""}
|
|
||||||
</div>
|
|
||||||
<div class="card-example">
|
|
||||||
${zeigeEnglisch ? k.karte.beispielEN || "" : k.karte.beispielDE || ""}
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
ziehKarte.addEventListener("dragstart", e => e.dataTransfer.setData("draggedIndex", index));
|
|
||||||
ziehKarte.addEventListener("dragover", e => e.preventDefault());
|
|
||||||
ziehKarte.addEventListener("drop", e => {
|
|
||||||
e.preventDefault();
|
|
||||||
const draggedIndex = Number(e.dataTransfer.getData("draggedIndex"));
|
|
||||||
swapZiehKarten(draggedIndex, index, linksDiv, rechtsDiv);
|
|
||||||
});
|
|
||||||
|
|
||||||
rechtsDiv.appendChild(ziehKarte);
|
|
||||||
});
|
|
||||||
|
|
||||||
container.appendChild(linksDiv);
|
|
||||||
container.appendChild(rechtsDiv);
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderMatchingRechts(linksDiv, rechtsDiv) {
|
|
||||||
rechtsDiv.innerHTML = "";
|
|
||||||
|
|
||||||
rechteKarten.forEach((k, index) => {
|
|
||||||
const ziehKarte = document.createElement("div");
|
|
||||||
ziehKarte.className = "training-card zieh-karte";
|
|
||||||
ziehKarte.draggable = true;
|
|
||||||
ziehKarte.dataset.index = index;
|
|
||||||
|
|
||||||
const zeigeEnglisch = (aktuelleRichtung === "DE_EN");
|
|
||||||
ziehKarte.innerHTML = `
|
|
||||||
<div class="card-top">
|
|
||||||
<h3>${zeigeEnglisch ? k.karte.englisch : k.karte.deutsch}</h3>
|
|
||||||
${zeigeEnglisch && k.karte.ipa
|
|
||||||
? `<div class="ipa">${k.karte.ipa}</div>`
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
<div class="card-example">
|
|
||||||
${zeigeEnglisch
|
|
||||||
? k.karte.beispielEN || ""
|
|
||||||
: k.karte.beispielDE || ""
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
ziehKarte.addEventListener("dragstart", e => e.dataTransfer.setData("draggedIndex", index));
|
|
||||||
ziehKarte.addEventListener("dragover", e => e.preventDefault());
|
|
||||||
ziehKarte.addEventListener("drop", e => {
|
|
||||||
e.preventDefault();
|
|
||||||
const draggedIndex = Number(e.dataTransfer.getData("draggedIndex"));
|
|
||||||
swapZiehKarten(draggedIndex, index, linksDiv, rechtsDiv);
|
|
||||||
});
|
|
||||||
|
|
||||||
rechtsDiv.appendChild(ziehKarte);
|
|
||||||
});
|
|
||||||
|
|
||||||
const container = document.getElementById("trainingMatching");
|
|
||||||
container.appendChild(linksDiv);
|
|
||||||
container.appendChild(rechtsDiv);
|
|
||||||
}
|
|
||||||
|
|
||||||
function swapZiehKarten(fromIndex, toIndex, linksDiv, rechtsDiv) {
|
|
||||||
const temp = rechteKarten[fromIndex];
|
|
||||||
rechteKarten[fromIndex] = rechteKarten[toIndex];
|
|
||||||
rechteKarten[toIndex] = temp;
|
|
||||||
renderMatchingRechts(linksDiv, rechtsDiv);
|
|
||||||
}
|
|
||||||
|
|
||||||
function pruefeRunde() {
|
|
||||||
const ziehElemente = document.querySelectorAll(".zieh-karte");
|
|
||||||
|
|
||||||
linkeKarten.forEach((k, index) => {
|
|
||||||
const gezogene = rechteKarten[index];
|
|
||||||
const elementDiv = ziehElemente[index];
|
|
||||||
|
|
||||||
if (k.karte.id === gezogene.karte.id) {
|
|
||||||
elementDiv.style.backgroundColor = "#a8f0a8";
|
|
||||||
matchingEngine.antwortVerarbeiten(gezogene, true);
|
|
||||||
} else {
|
} else {
|
||||||
elementDiv.style.backgroundColor = "#f5a8a8";
|
trainingsZustand.aktiveKarten.push(trainingsZustand.aktiveKarten.splice(trainingsZustand.aktiveKarten.indexOf(karte), 1)[0]);
|
||||||
matchingEngine.antwortVerarbeiten(gezogene, false);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trainingsZustand.aktiveKarten.length < 3 && trainingsZustand.quelleKarten.length > 0) {
|
||||||
|
let neueKarte = trainingsZustand.quelleKarten.shift();
|
||||||
|
neueKarte.versuche = 0;
|
||||||
|
trainingsZustand.aktiveKarten.push(neueKarte);
|
||||||
|
}
|
||||||
|
|
||||||
|
zeigeNaechsteKarte();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showView(id) {
|
||||||
|
document.querySelectorAll(".modus-view").forEach(view => {
|
||||||
|
view.style.display = "none";
|
||||||
});
|
});
|
||||||
|
|
||||||
const learningLeft = matchingEngine.kartenQueue.length;
|
const active = document.getElementById(id);
|
||||||
const gelerntCount = matchingEngine.gelernt.length;
|
if (active) {
|
||||||
const nichtGelerntCount = matchingEngine.nichtGelernt.length;
|
active.style.display = "block";
|
||||||
|
|
||||||
if (learningLeft === 0) {
|
|
||||||
const container = document.getElementById("trainingMatching");
|
|
||||||
container.innerHTML = `
|
|
||||||
<div style="text-align:center; font-size: 24px; margin-top:20px;">
|
|
||||||
🎉 Training beendet!<br>
|
|
||||||
Gelernt: ${gelerntCount}<br>
|
|
||||||
Nicht gelernt: ${nichtGelerntCount}
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
const checkBtn = document.getElementById("checkBtn");
|
|
||||||
if (checkBtn) checkBtn.style.display = "none";
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
ladeMatchingRunde();
|
|
||||||
}, 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mischeArray(array) {
|
function showTrainingLevel(id) {
|
||||||
for (let i = array.length - 1; i > 0; i--) {
|
document.querySelectorAll(".training-view").forEach(view => {
|
||||||
const j = Math.floor(Math.random() * (i + 1));
|
view.style.display = "none";
|
||||||
[array[i], array[j]] = [array[j], array[i]];
|
});
|
||||||
|
|
||||||
|
const active = document.getElementById(id);
|
||||||
|
if (active) {
|
||||||
|
active.style.display = "block";
|
||||||
}
|
}
|
||||||
return array;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.querySelectorAll(".level-btn").forEach(btn => {
|
||||||
|
btn.addEventListener("click", () => {
|
||||||
|
const level = btn.dataset.level;
|
||||||
|
|
||||||
|
if (level === "leicht") {
|
||||||
|
showTrainingLevel("trainingLeicht");
|
||||||
|
startLeichtTraining();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (level === "mittel") {
|
||||||
|
showTrainingLevel("trainingMittel");
|
||||||
|
startMittelTraining();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (level === "schwer") {
|
||||||
|
showTrainingLevel("trainingSchwer");
|
||||||
|
startSchwerTraining();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
document
|
||||||
|
.querySelector(".modus-btn[data-modus='training_einfach']")
|
||||||
|
.addEventListener("click", () => {
|
||||||
|
showView("onlineTraining");
|
||||||
|
});
|
||||||
|
|||||||
@@ -281,53 +281,14 @@ h1 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#trainingFlip .training-card {
|
|
||||||
height: 180px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#trainingMatching .training-card {
|
|
||||||
height: 100px;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
margin: 0;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.training-card {
|
.training-card {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
|
height: 180px;
|
||||||
margin: 10px auto;
|
margin: 10px auto;
|
||||||
perspective: 1000px;
|
perspective: 1000px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#trainingMatching .drop-zone,
|
|
||||||
#trainingMatching .zieh-karte {
|
|
||||||
min-height: 120px;
|
|
||||||
max-height: 120px;
|
|
||||||
width: 300px;
|
|
||||||
background: #fff;
|
|
||||||
border: 2px solid #666;
|
|
||||||
border-radius: 8px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
padding: 5px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
#trainingMatching .drop-zone h2,
|
|
||||||
#trainingMatching .zieh-karte h2,
|
|
||||||
#trainingMatching .drop-zone .ipa,
|
|
||||||
#trainingMatching .zieh-karte .ipa,
|
|
||||||
#trainingMatching .drop-zone .example,
|
|
||||||
#trainingMatching .zieh-karte .example {
|
|
||||||
margin: 2px 0;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.training-card-inner {
|
.training-card-inner {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@@ -352,42 +313,8 @@ h1 {
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: flex-start;
|
justify-content: center;
|
||||||
align-items: stretch;
|
gap: 10px;
|
||||||
}
|
|
||||||
|
|
||||||
.card-top {
|
|
||||||
display: inline-flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
gap: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-top h2 {
|
|
||||||
margin: 0;
|
|
||||||
line-height: 1.1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-top h3 {
|
|
||||||
margin: 0;
|
|
||||||
line-height: 1.1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-top .ipa {
|
|
||||||
margin: 0;
|
|
||||||
line-height: 1.1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-example {
|
|
||||||
margin-top: auto;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 15px;
|
|
||||||
line-height: 1.4;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ipa {
|
|
||||||
font-size: 16px;
|
|
||||||
color: #555;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.training-back {
|
.training-back {
|
||||||
@@ -407,229 +334,33 @@ h1 {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pdfPages,
|
.training-front h2 {
|
||||||
#onlineTraining {
|
margin-bottom: 4px;
|
||||||
|
margin-top: -25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.training-front .ipa {
|
||||||
|
font-size: 16px;
|
||||||
|
color: #555;
|
||||||
|
margin-bottom: 34px;
|
||||||
|
margin-top: -12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.training-front .example {
|
||||||
|
font-size: 15px;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.training-back h2 {
|
||||||
|
margin-bottom: 54px;
|
||||||
|
margin-top: -28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modus-view {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#trainingMatching {
|
.training-view {
|
||||||
display: flex;
|
display: none;
|
||||||
justify-content: center;
|
margin-top: 25px;
|
||||||
gap: 10px;
|
|
||||||
align-items: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hidden {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spalte-links {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: stretch;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spalte-rechts {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: stretch;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drop-zone, .zieh-karte {
|
|
||||||
padding: 10px;
|
|
||||||
margin: 10px 0;
|
|
||||||
background: #fff;
|
|
||||||
border: 2px solid #666;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.zieh-karte {
|
|
||||||
cursor: grab;
|
|
||||||
}
|
|
||||||
|
|
||||||
#checkBtn {
|
|
||||||
width: 500px;
|
|
||||||
height: 100px;
|
|
||||||
font-size: 46px;
|
|
||||||
font-weight: 600;
|
|
||||||
font-family: -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
||||||
color: #dc6743;
|
|
||||||
border: none;
|
|
||||||
border-radius: 8px;
|
|
||||||
cursor: pointer;
|
|
||||||
box-sizing: border-box;
|
|
||||||
background: linear-gradient(rgba(255,255,255,0.7), rgba(255,255,255,0.9)), url("verified.jfif");
|
|
||||||
background-repeat: repeat;
|
|
||||||
background-size: 80px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#trainingMultiple {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-start;
|
|
||||||
gap: 20px;
|
|
||||||
margin-top: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.multiple-frage {
|
|
||||||
text-align: center;
|
|
||||||
font-size: 28px;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.multiple-optionen {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 10px;
|
|
||||||
width: 300px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.multiple-option {
|
|
||||||
padding: 10px 15px;
|
|
||||||
font-size: 16px;
|
|
||||||
cursor: pointer;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
border-radius: 5px;
|
|
||||||
background-color: #f0f0f0;
|
|
||||||
text-align: center;
|
|
||||||
transition: background-color 0.2s, transform 0.1s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.multiple-option:hover {
|
|
||||||
background-color: #e0e0e0;
|
|
||||||
transform: scale(1.03);
|
|
||||||
}
|
|
||||||
|
|
||||||
.multiple-option[disabled] {
|
|
||||||
text-decoration: line-through;
|
|
||||||
background-color: #f5a8a8;
|
|
||||||
color: #800;
|
|
||||||
}
|
|
||||||
|
|
||||||
#trainingHint {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
gap: 20px;
|
|
||||||
margin-top: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hint-frage {
|
|
||||||
text-align: center;
|
|
||||||
font-size: 28px;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hint-input {
|
|
||||||
width: 300px;
|
|
||||||
font-size: 18px;
|
|
||||||
padding: 10px;
|
|
||||||
text-align: center;
|
|
||||||
border-radius: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hint-button {
|
|
||||||
padding: 10px 15px;
|
|
||||||
font-size: 16px;
|
|
||||||
cursor: pointer;
|
|
||||||
border-radius: 6px;
|
|
||||||
border: none;
|
|
||||||
background-color: #005b5b;
|
|
||||||
color: white;
|
|
||||||
transition: 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hint-button:hover {
|
|
||||||
background-color: #007070;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hint-feedback {
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 600;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hint-clue {
|
|
||||||
font-size: 20px;
|
|
||||||
letter-spacing: 2px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
color: #555;
|
|
||||||
text-align: center;
|
|
||||||
font-family: monospace;
|
|
||||||
}
|
|
||||||
|
|
||||||
#trainingWrite {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-start;
|
|
||||||
gap: 20px;
|
|
||||||
margin-top: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#trainingWrite .schwer-frage {
|
|
||||||
text-align: center;
|
|
||||||
font-size: 28px;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
#trainingWrite input[type="text"] {
|
|
||||||
font-size: 18px;
|
|
||||||
border-radius: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#trainingWrite button {
|
|
||||||
padding: 10px 15px;
|
|
||||||
font-size: 16px;
|
|
||||||
cursor: pointer;
|
|
||||||
border-radius: 6px;
|
|
||||||
border: none;
|
|
||||||
background-color: #005b5b;
|
|
||||||
color: white;
|
|
||||||
transition: 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
#trainingWrite button:hover {
|
|
||||||
background-color: #007070;
|
|
||||||
}
|
|
||||||
|
|
||||||
#trainingLevels {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 15px;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.training-title {
|
|
||||||
margin: 0 0 10px 0;
|
|
||||||
font-size: 20px;
|
|
||||||
font-weight: 600;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
#trainingLevels .buttons-row {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#trainingLevels .buttons-row .level-btn {
|
|
||||||
flex: 1;
|
|
||||||
padding: 12px 0;
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 600;
|
|
||||||
border: none;
|
|
||||||
border-radius: 8px;
|
|
||||||
background-color: #f0f0f0;
|
|
||||||
cursor: pointer;
|
|
||||||
text-align: center;
|
|
||||||
transition: background-color 0.2s, transform 0.1s;
|
|
||||||
}
|
|
||||||
|
|
||||||
#trainingLevels .buttons-row .level-btn:hover {
|
|
||||||
background-color: #e0e0e0;
|
|
||||||
transform: scale(1.02);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB |
@@ -1,299 +1,370 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const SEG = { a:0, b:1, c:2, d:3, e:4, f:5, g:6 };
|
// Die Namen der 7 Segmente (a bis g)
|
||||||
const segNames = ["a","b","c","d","e","f","g"];
|
const SEGMENT_NAMEN = ["a", "b", "c", "d", "e", "f", "g"];
|
||||||
|
|
||||||
function maskFromSegments(list){
|
// Ein Mapping: Welches Segment hat welchen "Bit Wert"?
|
||||||
let m = 0;
|
// a=1, b=2, c=4, d=8 ... das sind Zweierpotenzen.
|
||||||
for(const s of list) m |= (1 << SEG[s]);
|
const SEGMENT_INDEX = { a:0, b:1, c:2, d:3, e:4, f:5, g:6 };
|
||||||
return m;
|
|
||||||
|
// Diese Funktion rechnet eine Liste von Segmenten (z.B. "a", "b") in eine Zahl um.
|
||||||
|
function erstelleMuster(listeVonSegmenten) {
|
||||||
|
let muster = 0;
|
||||||
|
for (const segmentBuchstabe of listeVonSegmenten) {
|
||||||
|
// 1 << X bedeutet: Schiebe die 1 um X Stellen nach links
|
||||||
|
// Das | (ODER) fügt das Bit hinzu.
|
||||||
|
muster = muster | (1 << SEGMENT_INDEX[segmentBuchstabe]);
|
||||||
|
}
|
||||||
|
return muster;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hier speichern wir das Muster für jede Ziffer von 0 bis 9
|
||||||
const DIGIT_MASK = [
|
// bitmasking: Jede Ziffer ist eine Kombination von Segmenten die an sind
|
||||||
maskFromSegments(["a","b","c","d","e","f"]),
|
const ZIFFERN_MUSTER = [
|
||||||
maskFromSegments(["b","c"]),
|
erstelleMuster(["a","b","c","d","e","f"]), // 0
|
||||||
maskFromSegments(["a","b","d","e","g"]),
|
erstelleMuster(["b","c"]), // 1
|
||||||
maskFromSegments(["a","b","c","d","g"]),
|
erstelleMuster(["a","b","d","e","g"]), // 2
|
||||||
maskFromSegments(["b","c","f","g"]),
|
erstelleMuster(["a","b","c","d","g"]), // 3
|
||||||
maskFromSegments(["a","c","d","f","g"]),
|
erstelleMuster(["b","c","f","g"]), // 4
|
||||||
maskFromSegments(["a","c","d","e","f","g"]),
|
erstelleMuster(["a","c","d","f","g"]), // 5
|
||||||
maskFromSegments(["a","b","c"]),
|
erstelleMuster(["a","c","d","e","f","g"]), // 6
|
||||||
maskFromSegments(["a","b","c","d","e","f","g"]),
|
erstelleMuster(["a","b","c"]), // 7
|
||||||
maskFromSegments(["a","b","c","d","f","g"])
|
erstelleMuster(["a","b","c","d","e","f","g"]), // 8
|
||||||
|
erstelleMuster(["a","b","c","d","f","g"]) // 9
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Eine Rückwärts Suche: Welches Muster gehört zu welcher Zahl?
|
||||||
const MASK_TO_DIGIT = new Map(DIGIT_MASK.map((m,d)=>[m,d]));
|
// Wir bauen eine Map (Liste), um das schnell zu finden.
|
||||||
|
const MUSTER_ZU_ZAHL = new Map();
|
||||||
|
ZIFFERN_MUSTER.forEach((muster, zahl) => {
|
||||||
|
MUSTER_ZU_ZAHL.set(muster, zahl);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
function removableTargetsFromDigit(d){
|
|
||||||
const start = DIGIT_MASK[d];
|
|
||||||
const res = [];
|
|
||||||
for(let t=0;t<=9;t++){
|
|
||||||
const target = DIGIT_MASK[t];
|
|
||||||
if((target & start) === target){
|
|
||||||
|
|
||||||
const removed = popcount(start ^ target);
|
|
||||||
res.push({to:t, removed});
|
// Zählt, wie viele Bits in einer Zahl auf 1 stehen.
|
||||||
}
|
// (Also: Wie viele Streichhölzer sind an?)
|
||||||
|
function zaehleStreichhoelzer(zahl) {
|
||||||
|
let anzahl = 0;
|
||||||
|
// Solange die Zahl nicht 0 ist
|
||||||
|
while (zahl > 0) {
|
||||||
|
// Ein kleiner Trick um das letzte Bit zu löschen und zu zählen
|
||||||
|
zahl = zahl & (zahl - 1);
|
||||||
|
anzahl++;
|
||||||
}
|
}
|
||||||
return res;
|
return anzahl;
|
||||||
}
|
}
|
||||||
|
|
||||||
function popcount(x){
|
// Gibt eine zufällige Zahl zwischen min und max zurück
|
||||||
x = x >>> 0;
|
function zufallsZahl(min, max) {
|
||||||
let c = 0;
|
|
||||||
while(x){ x &= (x-1); c++; }
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
function randInt(min, max){ // inclusive
|
|
||||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||||
}
|
}
|
||||||
function pick(arr){ return arr[randInt(0, arr.length-1)]; }
|
|
||||||
|
|
||||||
let level = 1;
|
// Wählt ein zufälliges Element aus einer Liste
|
||||||
let targetRemove = 2;
|
function wähleZufällig(liste) {
|
||||||
let current = null;
|
return liste[zufallsZahl(0, liste.length - 1)];
|
||||||
let solution = null;
|
|
||||||
let removedSoFar = 0;
|
|
||||||
|
|
||||||
|
|
||||||
let removedSet = new Set();
|
|
||||||
|
|
||||||
const elEq = document.getElementById("equation");
|
|
||||||
const elRemovedGrid = document.getElementById("removedGrid");
|
|
||||||
const elRemovedCount = document.getElementById("removedCount");
|
|
||||||
const elPileCount = document.getElementById("pileCount");
|
|
||||||
const elLvl = document.getElementById("lvl");
|
|
||||||
const elTarget = document.getElementById("target");
|
|
||||||
const elGoalN = document.getElementById("goalN");
|
|
||||||
const elTruthDot = document.getElementById("truthDot");
|
|
||||||
const elTruthText = document.getElementById("truthText");
|
|
||||||
const elHint = document.getElementById("hint");
|
|
||||||
|
|
||||||
document.getElementById("btnNew").addEventListener("click", () => {
|
|
||||||
level++;
|
|
||||||
generateLevel();
|
|
||||||
});
|
|
||||||
document.getElementById("btnReset").addEventListener("click", () => {
|
|
||||||
|
|
||||||
resetPlayState();
|
|
||||||
renderEquation();
|
|
||||||
updateTruthUI();
|
|
||||||
});
|
|
||||||
|
|
||||||
function segmentsFromMask(mask){
|
|
||||||
const set = new Set();
|
|
||||||
for(let i=0;i<7;i++){
|
|
||||||
if(mask & (1<<i)) set.add(segNames[i]);
|
|
||||||
}
|
|
||||||
return set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayedMaskForDigit(digitValue, digitIndex){
|
// Findet alle Zahlen, aus denen man 'basisZahl' machen kann, indem man Hölzer entfernt.
|
||||||
let mask = DIGIT_MASK[digitValue];
|
// Beispiel: Aus einer 8 kann man eine 0 machen (Mitte wegnehmen).
|
||||||
for(const s of segNames){
|
// Aber aus einer 1 kann man keine 8 machen (man müsste hinzufügen).
|
||||||
const key = digitIndex + "-" + s;
|
function findeMoeglicheUrsprungsZiffern(basisZahl) {
|
||||||
if(removedSet.has(key)){
|
const basisMuster = ZIFFERN_MUSTER[basisZahl];
|
||||||
mask &= ~(1 << SEG[s]);
|
const moegliche = [];
|
||||||
|
|
||||||
|
for (let z = 0; z <= 9; z++) {
|
||||||
|
const vergleichsMuster = ZIFFERN_MUSTER[z];
|
||||||
|
|
||||||
|
// Wenn das vergleichsMuster ALLE Striche vom basisMuster hat:
|
||||||
|
if ((vergleichsMuster & basisMuster) === basisMuster) {
|
||||||
|
moegliche.push(z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mask;
|
return moegliche;
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayedDigitValue(digitValue, digitIndex){
|
|
||||||
const mask = displayedMaskForDigit(digitValue, digitIndex);
|
|
||||||
return MASK_TO_DIGIT.has(mask) ? MASK_TO_DIGIT.get(mask) : null;
|
|
||||||
|
let aktuellesLevel = 1;
|
||||||
|
let zielAnzahlLoeschen = 2; // Wie viele muss man löschen?
|
||||||
|
let anzahlGeloescht = 0; // Wie viele hat der Spieler schon gelöscht?
|
||||||
|
|
||||||
|
// Hier speichern wir die aktuellen Zahlen auf dem Bildschirm
|
||||||
|
let aktuelleGleichung = { A: 0, B: 0, C: 0 };
|
||||||
|
|
||||||
|
// Hier merken wir uns, welche Striche der Spieler angeklickt hat.
|
||||||
|
// Format: "Index-Segment", z.B. "0-a" (Erste Ziffer, Segment a)
|
||||||
|
let geloeschteStreichhoelzer = new Set();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const elGleichung = document.getElementById("equation");
|
||||||
|
const elGeloeschtGrid = document.getElementById("removedGrid");
|
||||||
|
const elZaehlerGeloescht = document.getElementById("removedCount");
|
||||||
|
const elStapelZaehler = document.getElementById("pileCount");
|
||||||
|
const elLevelAnzeige = document.getElementById("lvl");
|
||||||
|
const elZielAnzeige = document.getElementById("target");
|
||||||
|
const elZielText = document.getElementById("goalN");
|
||||||
|
const elWahrheitPunkt = document.getElementById("truthDot");
|
||||||
|
const elWahrheitText = document.getElementById("truthText");
|
||||||
|
const elHinweis = document.getElementById("hint");
|
||||||
|
|
||||||
|
// Buttons aktivieren
|
||||||
|
document.getElementById("btnNew").addEventListener("click", () => {
|
||||||
|
aktuellesLevel++;
|
||||||
|
starteNeuesLevel();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById("btnReset").addEventListener("click", () => {
|
||||||
|
// Level neu starten (aber gleiches Level)
|
||||||
|
setzeSpielZurueck();
|
||||||
|
zeichneGleichung();
|
||||||
|
pruefeObWahr();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function setzeSpielZurueck() {
|
||||||
|
geloeschteStreichhoelzer.clear(); // Liste leeren
|
||||||
|
anzahlGeloescht = 0;
|
||||||
|
elGeloeschtGrid.innerHTML = ""; // Anzeige leeren
|
||||||
|
updateZaehlerAnzeige();
|
||||||
}
|
}
|
||||||
|
|
||||||
function equationIsTrue(){
|
function updateZaehlerAnzeige() {
|
||||||
|
elZaehlerGeloescht.textContent = anzahlGeloescht;
|
||||||
|
elStapelZaehler.textContent = anzahlGeloescht;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Berechnet, welche Zahl gerade angezeigt wird (basierend auf dem was gelöscht wurde)
|
||||||
|
function berechneAngezeigteZahl(originalZahl, positionIndex) {
|
||||||
|
let maske = ZIFFERN_MUSTER[originalZahl];
|
||||||
|
|
||||||
|
// Wir gehen alle 7 Segmente durch
|
||||||
|
for (const seg of SEGMENT_NAMEN) {
|
||||||
|
const schluessel = positionIndex + "-" + seg;
|
||||||
|
|
||||||
|
// Wenn dieses Segment gelöscht wurde...
|
||||||
|
if (geloeschteStreichhoelzer.has(schluessel)) {
|
||||||
|
// ... dann schalten wir das Bit in der Maske aus (mit & ~)
|
||||||
|
maske = maske & ~(1 << SEGMENT_INDEX[seg]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schauen, ob das resultierende Muster eine gültige Zahl ist
|
||||||
|
if (MUSTER_ZU_ZAHL.has(maske)) {
|
||||||
|
return MUSTER_ZU_ZAHL.get(maske);
|
||||||
|
} else {
|
||||||
|
return null; // Keine gültige Zahl (Kaputt)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prüft: Ist A + B = C ?
|
||||||
|
function istGleichungWahr() {
|
||||||
|
const a = berechneAngezeigteZahl(aktuelleGleichung.A, 0);
|
||||||
|
const b = berechneAngezeigteZahl(aktuelleGleichung.B, 1);
|
||||||
|
const c = berechneAngezeigteZahl(aktuelleGleichung.C, 2);
|
||||||
|
|
||||||
|
// Wenn irgendeine Zahl ungültig ist, ist die Gleichung falsch
|
||||||
|
if (a === null || b === null || c === null) return false;
|
||||||
|
|
||||||
const a = displayedDigitValue(current.A, 0);
|
|
||||||
const b = displayedDigitValue(current.B, 1);
|
|
||||||
const c = displayedDigitValue(current.C, 2);
|
|
||||||
if(a === null || b === null || c === null) return false;
|
|
||||||
return (a + b) === c;
|
return (a + b) === c;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTruthUI(){
|
function pruefeObWahr() {
|
||||||
const ok = equationIsTrue();
|
const istWahr = istGleichungWahr();
|
||||||
elTruthDot.classList.toggle("ok", ok);
|
|
||||||
elTruthText.textContent = ok ? "Equation is TRUE" : "Equation is FALSE";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (istWahr) {
|
||||||
function resetPlayState(){
|
elWahrheitPunkt.classList.add("ok");
|
||||||
removedSet.clear();
|
elWahrheitText.textContent = "Gleichung ist WAHR";
|
||||||
removedSoFar = 0;
|
} else {
|
||||||
elRemovedGrid.innerHTML = "";
|
elWahrheitPunkt.classList.remove("ok");
|
||||||
syncRemovedCounts();
|
elWahrheitText.textContent = "Gleichung ist FALSCH";
|
||||||
}
|
|
||||||
|
|
||||||
function syncRemovedCounts(){
|
|
||||||
elRemovedCount.textContent = String(removedSoFar);
|
|
||||||
elPileCount.textContent = String(removedSoFar);
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderDigit(digitValue, digitIndex, color){
|
|
||||||
const digit = document.createElement("div");
|
|
||||||
digit.className = "digit";
|
|
||||||
|
|
||||||
const baseMask = DIGIT_MASK[digitValue];
|
|
||||||
const baseSegs = segmentsFromMask(baseMask);
|
|
||||||
|
|
||||||
for(const s of segNames){
|
|
||||||
if(!baseSegs.has(s)) continue;
|
|
||||||
|
|
||||||
const seg = document.createElement("div");
|
|
||||||
seg.className = "seg " + s;
|
|
||||||
seg.style.background = color;
|
|
||||||
|
|
||||||
const key = digitIndex + "-" + s;
|
|
||||||
if(removedSet.has(key)) seg.classList.add("removed");
|
|
||||||
|
|
||||||
seg.addEventListener("click", () => {
|
|
||||||
if(removedSet.has(key)) return;
|
|
||||||
if(removedSoFar >= targetRemove) return;
|
|
||||||
|
|
||||||
removedSet.add(key);
|
|
||||||
removedSoFar++;
|
|
||||||
|
|
||||||
|
|
||||||
seg.classList.add("removed");
|
|
||||||
|
|
||||||
|
|
||||||
const clone = document.createElement("div");
|
|
||||||
clone.className = "removedSeg";
|
|
||||||
clone.style.background = color;
|
|
||||||
elRemovedGrid.appendChild(clone);
|
|
||||||
|
|
||||||
syncRemovedCounts();
|
|
||||||
updateTruthUI();
|
|
||||||
|
|
||||||
if(removedSoFar === targetRemove){
|
|
||||||
if(equationIsTrue()){
|
|
||||||
elHint.innerHTML = "<b>Solved!</b> You removed exactly the target and made the equation true. Click <b>New level</b>.";
|
|
||||||
} else {
|
|
||||||
elHint.innerHTML = " <b>Not solved.</b> You used all removals but the equation isn’t true. Click <b>Reset level</b> to try again.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
digit.appendChild(seg);
|
|
||||||
}
|
}
|
||||||
return digit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderEquation(){
|
|
||||||
elEq.innerHTML = "";
|
|
||||||
|
|
||||||
const colors = [
|
// Erstellt das HTML für EINE Ziffer
|
||||||
"linear-gradient(180deg,#ff6b6b,#d64545)",
|
function erstelleZifferHTML(zahlenWert, positionIndex, farbe) {
|
||||||
"linear-gradient(180deg,#6bcBff,#3a7bd5)",
|
const zifferContainer = document.createElement("div");
|
||||||
"linear-gradient(180deg,#6bffb3,#1fae63)"
|
zifferContainer.className = "digit";
|
||||||
|
|
||||||
|
// Welche Segmente hat die Zahl ursprünglich?
|
||||||
|
const maske = ZIFFERN_MUSTER[zahlenWert];
|
||||||
|
|
||||||
|
for (let i = 0; i < 7; i++) {
|
||||||
|
const segName = SEGMENT_NAMEN[i];
|
||||||
|
|
||||||
|
// Prüfen: Hat die Zahl dieses Segment? (Bit Test)
|
||||||
|
const hatSegment = (maske & (1 << i)) !== 0;
|
||||||
|
|
||||||
|
if (hatSegment) {
|
||||||
|
const segElement = document.createElement("div");
|
||||||
|
segElement.className = "seg " + segName;
|
||||||
|
segElement.style.background = farbe;
|
||||||
|
|
||||||
|
// Eindeutige ID für dieses Segment (z.B. "0-a")
|
||||||
|
const id = positionIndex + "-" + segName;
|
||||||
|
|
||||||
|
// Wenn schon gelöscht, Klasse hinzufügen
|
||||||
|
if (geloeschteStreichhoelzer.has(id)) {
|
||||||
|
segElement.classList.add("removed");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Klick Event (Hier passiert die Action!)
|
||||||
|
segElement.addEventListener("click", () => {
|
||||||
|
// Abbruch wenn schon weg oder Limit erreicht
|
||||||
|
if (geloeschteStreichhoelzer.has(id)) return;
|
||||||
|
if (anzahlGeloescht >= zielAnzahlLoeschen) return;
|
||||||
|
|
||||||
|
// Löschen durchführen
|
||||||
|
geloeschteStreichhoelzer.add(id);
|
||||||
|
anzahlGeloescht++;
|
||||||
|
segElement.classList.add("removed");
|
||||||
|
|
||||||
|
// Kleines Streichholz in den Mülleimer animieren
|
||||||
|
const clone = document.createElement("div");
|
||||||
|
clone.className = "removedSeg";
|
||||||
|
clone.style.background = farbe;
|
||||||
|
elGeloeschtGrid.appendChild(clone);
|
||||||
|
|
||||||
|
updateZaehlerAnzeige();
|
||||||
|
pruefeObWahr();
|
||||||
|
|
||||||
|
// Gewinn Prüfung
|
||||||
|
if (anzahlGeloescht === zielAnzahlLoeschen) {
|
||||||
|
if (istGleichungWahr()) {
|
||||||
|
elHinweis.innerHTML = "<b>Gelöst!</b> Super gemacht. Klicke auf <b>Neu level</b>.";
|
||||||
|
} else {
|
||||||
|
elHinweis.innerHTML = "<b>Nicht gelöst.</b> Alle Züge verbraucht, aber Gleichung falsch. <b>Reset</b>?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
zifferContainer.appendChild(segElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return zifferContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
function zeichneGleichung() {
|
||||||
|
elGleichung.innerHTML = ""; // Alles löschen
|
||||||
|
|
||||||
|
const farben = [
|
||||||
|
"linear-gradient(180deg,#ff6b6b,#d64545)", // Rot für A
|
||||||
|
"linear-gradient(180deg,#6bcBff,#3a7bd5)", // Blau für B
|
||||||
|
"linear-gradient(180deg,#6bffb3,#1fae63)" // Grün für C
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Gruppe A bauen
|
||||||
const g1 = document.createElement("div");
|
const g1 = document.createElement("div");
|
||||||
g1.className = "group";
|
g1.className = "group";
|
||||||
g1.appendChild(renderDigit(current.A, 0, colors[0]));
|
g1.appendChild(erstelleZifferHTML(aktuelleGleichung.A, 0, farben[0]));
|
||||||
|
|
||||||
|
// Plus Zeichen
|
||||||
const plus = document.createElement("div");
|
const plus = document.createElement("div");
|
||||||
plus.className = "symbol";
|
plus.className = "symbol";
|
||||||
plus.textContent = "+";
|
plus.textContent = "+";
|
||||||
|
|
||||||
|
// Gruppe B bauen
|
||||||
const g2 = document.createElement("div");
|
const g2 = document.createElement("div");
|
||||||
g2.className = "group";
|
g2.className = "group";
|
||||||
g2.appendChild(renderDigit(current.B, 1, colors[1]));
|
g2.appendChild(erstelleZifferHTML(aktuelleGleichung.B, 1, farben[1]));
|
||||||
|
|
||||||
|
// Ist Gleich Zeichen
|
||||||
const eq = document.createElement("div");
|
const eq = document.createElement("div");
|
||||||
eq.className = "symbol";
|
eq.className = "symbol";
|
||||||
eq.textContent = "=";
|
eq.textContent = "=";
|
||||||
|
|
||||||
|
// Gruppe C bauen
|
||||||
const g3 = document.createElement("div");
|
const g3 = document.createElement("div");
|
||||||
g3.className = "group";
|
g3.className = "group";
|
||||||
g3.appendChild(renderDigit(current.C, 2, colors[2]));
|
g3.appendChild(erstelleZifferHTML(aktuelleGleichung.C, 2, farben[2]));
|
||||||
|
|
||||||
elEq.appendChild(g1);
|
// Alles zusammenfügen
|
||||||
elEq.appendChild(plus);
|
elGleichung.appendChild(g1);
|
||||||
elEq.appendChild(g2);
|
elGleichung.appendChild(plus);
|
||||||
elEq.appendChild(eq);
|
elGleichung.appendChild(g2);
|
||||||
elEq.appendChild(g3);
|
elGleichung.appendChild(eq);
|
||||||
|
elGleichung.appendChild(g3);
|
||||||
|
|
||||||
updateTruthUI();
|
pruefeObWahr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function generateLevel(){
|
// 7. LEVEL GENERATOR (Das Gehirn)
|
||||||
resetPlayState();
|
// Hier wird ein Level gebaut, das garantiert lösbar ist.
|
||||||
|
|
||||||
|
|
||||||
targetRemove = Math.min(2 + Math.floor(Math.log2(level + 1)), 6);
|
function starteNeuesLevel() {
|
||||||
|
setzeSpielZurueck();
|
||||||
|
|
||||||
|
// Ziel berechnen: Level 1-2 -> 2 löschen, danach evtl mehr. Max 6.
|
||||||
|
zielAnzahlLoeschen = Math.min(2 + Math.floor(Math.log2(aktuellesLevel + 1)), 6);
|
||||||
|
|
||||||
let tries = 0;
|
let versuche = 0;
|
||||||
while(true){
|
|
||||||
tries++;
|
// Endlosschleife, bis wir ein passendes Level finden
|
||||||
if(tries > 5000){
|
while (true) {
|
||||||
targetRemove = Math.max(2, targetRemove - 1);
|
versuche++;
|
||||||
tries = 0;
|
// Sicherheitsnetz: Wenn es zu lange dauert, Ziel senken
|
||||||
|
if (versuche > 5000) {
|
||||||
|
zielAnzahlLoeschen = Math.max(2, zielAnzahlLoeschen - 1);
|
||||||
|
versuche = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const As = randInt(0, 9);
|
// 1. Wir denken uns eine KORREKTE Lösung aus (z.B. 3 + 5 = 8)
|
||||||
const Bs = randInt(0, 9);
|
const lsgA = zufallsZahl(0, 9);
|
||||||
const Cs = As + Bs;
|
const lsgB = zufallsZahl(0, 9);
|
||||||
if(Cs < 0 || Cs > 9) continue;
|
const lsgC = lsgA + lsgB;
|
||||||
|
|
||||||
|
if (lsgC > 9) continue; // Ergebnis darf nur 1 stellig sein (0-9)
|
||||||
|
|
||||||
const Achoices = superDigits(As);
|
// 2. Wir suchen Zahlen, die mehr Striche haben als unsere Lösung
|
||||||
const Bchoices = superDigits(Bs);
|
// (Aus denen man die Lösung "schnitzen" kann)
|
||||||
const Cchoices = superDigits(Cs);
|
const moeglicheA = findeMoeglicheUrsprungsZiffern(lsgA);
|
||||||
|
const moeglicheB = findeMoeglicheUrsprungsZiffern(lsgB);
|
||||||
|
const moeglicheC = findeMoeglicheUrsprungsZiffern(lsgC);
|
||||||
|
|
||||||
const Ashow = pick(Achoices);
|
// Eine zufällige Auswahl treffen
|
||||||
const Bshow = pick(Bchoices);
|
const startA = wähleZufällig(moeglicheA);
|
||||||
const Cshow = pick(Cchoices);
|
const startB = wähleZufällig(moeglicheB);
|
||||||
|
const startC = wähleZufällig(moeglicheC);
|
||||||
|
|
||||||
const need =
|
// 3. Berechnen: Wie viele Striche müssen weg, um zur Lösung zu kommen?
|
||||||
popcount(DIGIT_MASK[Ashow] ^ DIGIT_MASK[As]) +
|
// XOR (^) zeigt den Unterschied an.
|
||||||
popcount(DIGIT_MASK[Bshow] ^ DIGIT_MASK[Bs]) +
|
const diffA = zaehleStreichhoelzer(ZIFFERN_MUSTER[startA] ^ ZIFFERN_MUSTER[lsgA]);
|
||||||
popcount(DIGIT_MASK[Cshow] ^ DIGIT_MASK[Cs]);
|
const diffB = zaehleStreichhoelzer(ZIFFERN_MUSTER[startB] ^ ZIFFERN_MUSTER[lsgB]);
|
||||||
|
const diffC = zaehleStreichhoelzer(ZIFFERN_MUSTER[startC] ^ ZIFFERN_MUSTER[lsgC]);
|
||||||
|
|
||||||
if(need !== targetRemove) continue;
|
const gesamtWeg = diffA + diffB + diffC;
|
||||||
|
|
||||||
|
// Passt das zu unserem Ziel?
|
||||||
|
if (gesamtWeg !== zielAnzahlLoeschen) continue;
|
||||||
|
|
||||||
const shownTrue = (Ashow + Bshow) === Cshow;
|
// 4. Wichtig: Die angezeigte Start Gleichung muss FALSCH sein.
|
||||||
if(shownTrue) continue;
|
// Sonst gibt es ja nichts zu rätseln.
|
||||||
|
if ((startA + startB) === startC) continue;
|
||||||
|
|
||||||
solution = { A: As, B: Bs, C: Cs };
|
// Gefunden! Speichern.
|
||||||
current = { A: Ashow, B: Bshow, C: Cshow };
|
aktuelleGleichung = { A: startA, B: startB, C: startC };
|
||||||
break;
|
break; // Schleife beenden
|
||||||
}
|
}
|
||||||
|
|
||||||
elLvl.textContent = String(level);
|
// UI Updates
|
||||||
elTarget.textContent = String(targetRemove);
|
elLevelAnzeige.textContent = aktuellesLevel;
|
||||||
elGoalN.textContent = String(targetRemove);
|
elZielAnzeige.textContent = zielAnzahlLoeschen;
|
||||||
|
elZielText.textContent = zielAnzahlLoeschen;
|
||||||
|
|
||||||
elHint.innerHTML =
|
elHinweis.innerHTML =
|
||||||
`Level <b>${level}</b>: Make the equation true by removing <b>${targetRemove}</b> match(es). ` +
|
`Level <b>${aktuellesLevel}</b>: Mache die Gleichung wahr, indem du <b>${zielAnzahlLoeschen}</b> Streichhölzer entfernst.`;
|
||||||
`You can only remove sticks (click them).`;
|
|
||||||
|
|
||||||
renderEquation();
|
zeichneGleichung();
|
||||||
syncRemovedCounts();
|
|
||||||
updateTruthUI();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function superDigits(baseDigit){
|
// Spiel starten!
|
||||||
const base = DIGIT_MASK[baseDigit];
|
starteNeuesLevel();
|
||||||
const res = [];
|
|
||||||
for(let d=0; d<=9; d++){
|
|
||||||
const m = DIGIT_MASK[d];
|
|
||||||
if((m & base) === base){
|
|
||||||
res.push(d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
generateLevel();
|
|
||||||
Reference in New Issue
Block a user