Files
imposter/oneshot.js
2025-12-13 18:30:19 +01:00

61 lines
1.9 KiB
JavaScript

import sqlite3 from "sqlite3";
// Öffne die Datenbank
const db = new sqlite3.Database("imposter.db");
// Erstelle die Tabelle, falls sie nicht existiert
db.run(`CREATE TABLE IF NOT EXISTS words (
id INTEGER PRIMARY KEY AUTOINCREMENT,
word TEXT NOT NULL,
imposterWord TEXT NOT NULL,
inUse BOOL
)`);
// Array mit sinnvollen Wortpaaren für das Imposter-Spiel
const wordPairs = [
{ word: "Hund", imposterWord: "Tier" },
{ word: "Auto", imposterWord: "Fahrzeug" },
{ word: "Haus", imposterWord: "Gebäude" },
{ word: "Apfel", imposterWord: "Obst" },
{ word: "Buch", imposterWord: "Lesen" },
{ word: "Computer", imposterWord: "Technik" },
{ word: "Meer", imposterWord: "Wasser" },
{ word: "Berg", imposterWord: "Natur" },
{ word: "Schule", imposterWord: "Lernen" },
{ word: "Musik", imposterWord: "Klang" },
{ word: "Sonne", imposterWord: "Licht" },
{ word: "Mond", imposterWord: "Nacht" },
{ word: "Baum", imposterWord: "Pflanze" },
{ word: "Flugzeug", imposterWord: "Fliegen" },
{ word: "Zug", imposterWord: "Reisen" },
{ word: "Pizza", imposterWord: "Essen" },
{ word: "Fußball", imposterWord: "Sport" },
{ word: "Kino", imposterWord: "Film" },
{ word: "Telefon", imposterWord: "Kommunikation" },
{ word: "Uhr", imposterWord: "Zeit" }
];
// Füge jedes Wortpaar in die Datenbank ein
wordPairs.forEach(pair => {
db.run(
`INSERT INTO words (word, imposterWord, inUse) VALUES (?, ?, ?)`,
[pair.word, pair.imposterWord, 0],
function(err) {
if (err) {
console.error("Fehler beim Einfügen:", err);
} else {
console.log(`Eingefügt: ${pair.word} - ${pair.imposterWord}`);
}
}
);
});
// Schließe die Datenbank nach allen Operationen
db.close((err) => {
if (err) {
console.error("Fehler beim Schließen der DB:", err);
} else {
console.log("Datenbank erfolgreich gefüllt und geschlossen.");
}
});