diff --git a/.gitignore b/.gitignore index 45b2cea..78997a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ localhost-key.pem -localhost.pem \ No newline at end of file +localhost.pem +data/teams.db +data/article.db \ No newline at end of file diff --git a/README.md b/README.md index 0a175a6..d9c08df 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# Chasse au trésor Lycée Pange +# Jeu de pistes Sarreguemines **Auteur :** Antoine WAEHREN ## Crédits -Ce projet utilise le module QR Scanner de NIMIQ : https://github.com/nimiq/qr-scanner \ No newline at end of file +Ce projet utilise le module QR Scanner de NIMIQ : https://github.com/nimiq/qr-scanner diff --git a/answer.php b/answer.php index 00aab09..2d328bc 100644 --- a/answer.php +++ b/answer.php @@ -56,17 +56,6 @@ $stmt->bindValue(":puzzle_id", $art_id); $stmt->bindValue(":team_id", $team_id); $stmt->execute(); - - // On ajoute l'énigme bonus si toutes les autres sont résolues : - $stmt = $database->pdo_teams->prepare("SELECT COUNT(*) FROM solved WHERE team_id == :team_id"); - $stmt->bindValue(":team_id", $team_id); - $stmt->execute(); - - if ($stmt->fetchAll()[0]["COUNT(*)"] == "12") { // Il y a 12 énigmes sans compter la bonus - $stmt = $database->pdo_teams->prepare("UPDATE teams SET bonus = 1 WHERE id = :team_id"); - $stmt->bindValue(":team_id", $team_id); - $stmt->execute(); - } } $data["valid_qr"] = true; diff --git a/article.php b/article.php index 95783fe..fb73093 100644 --- a/article.php +++ b/article.php @@ -5,6 +5,7 @@ $solved = false; $team_id = -1; $art_id = -1; + $art_index = -1; // Index de l'article dans la liste pzorder assignée à l'équipe $database = new Database(); @@ -27,18 +28,30 @@ } else { - // On vérifie si l'énigme bonus n'est pas débloquée : - if (!$database->checkTeamBonus($team_id)) { - // Si c'est celle qui est sélectionnée, on retourne à la liste des énigmes : - if ($art_id == $max_art) { - header("Location: puzzles.php?team=" . $team_id); - die(); - } + // On cherche l'index de l'article dans la liste pzorder assignée à l'équipe : + $stmt = $database->pdo_teams->prepare("SELECT pzorder FROM teams WHERE id == :id"); + $stmt->bindValue(":id", $team_id); + $stmt->execute(); + $result = $stmt->fetch(); + $order = $result["pzorder"]; - // On retire l'énigme bonus du total : - $max_art--; + // Si un ordre d'énigmes n'a pas été défini au préalable pour cette équipe, on en choisit un au hasard : + if (is_null($order)) { + $order = rand(0, sizeof($pzorder)); + $stmt = $database->pdo_teams->prepare("UPDATE teams SET pzorder = :order WHERE id == :id"); + $stmt->bindValue(":id", $team_id); + $stmt->bindValue(":order", $order); + $stmt->execute(); } + $pzo_arr = $pzorder[$order]; + $art_index = array_search($art_id, $pzo_arr); + $prev_art = $pzo_arr[$art_index - 1]; + if ($art_index == 0) { + $prev_art = $pzo_arr[$max_art - 1]; + } + $next_art = $pzo_arr[($art_index + 1) % $max_art]; + // On indique si l'énigme est résolue : $stmt = $database->pdo_teams->prepare("SELECT * FROM solved WHERE (team_id == :team_id AND puzzle_id == :puzzle_id)"); $stmt->bindValue(":team_id", $team_id); @@ -71,15 +84,18 @@
-

+

+ + + - +

@@ -90,7 +106,7 @@

- .png"/> +

diff --git a/data/article.db b/data/article.db index 10f51c9..507c973 100644 Binary files a/data/article.db and b/data/article.db differ diff --git a/data/teams.db b/data/teams.db index 27d92d3..c819427 100644 Binary files a/data/teams.db and b/data/teams.db differ diff --git a/puzzles.php b/puzzles.php index de4076a..d7f0cbd 100644 --- a/puzzles.php +++ b/puzzles.php @@ -2,6 +2,7 @@ require_once "require/base.php"; $puzzles = array(); + $order = 0; $team_id = -1; $database = new Database(); @@ -31,23 +32,26 @@ false ); - // On vérifie si l'équipe a débloqué l'énigme bonus : - $stmt = $database->pdo_teams->prepare("SELECT * FROM teams WHERE id = :id"); - $stmt->bindValue(":id", $team_id); - $stmt->execute(); - - // Si c'est le cas, on affiche toutes les énigmes : - if ($stmt->fetchAll()[0][1] == 1) { - $stmt = $database->pdo_article->prepare("SELECT * FROM puzzles"); - } - - // Sinon, on cache la bonus : - else { - $stmt = $database->pdo_article->prepare("SELECT * FROM puzzles WHERE id <> 13"); - } + $stmt = $database->pdo_article->prepare("SELECT * FROM puzzles"); $stmt->execute(); $puzzles = $stmt->fetchAll(); + + // Recherche de l'ordre des énigmes : + $stmt = $database->pdo_teams->prepare("SELECT pzorder FROM teams WHERE id == :id"); + $stmt->bindValue(":id", $team_id); + $stmt->execute(); + $result = $stmt->fetch(); + $order = $result["pzorder"]; + + // Si un ordre d'énigmes n'a pas été défini au préalable pour cette équipe, on en choisit un au hasard : + if (is_null($order)) { + $order = rand(0, sizeof($pzorder)); + $stmt = $database->pdo_teams->prepare("UPDATE teams SET pzorder = :order WHERE id == :id"); + $stmt->bindValue(":id", $team_id); + $stmt->bindValue(":order", $order); + $stmt->execute(); + } } } @@ -78,8 +82,12 @@

    - -
  • ">
  • + + + +
  • ">
  • + +
diff --git a/require/base.php b/require/base.php index 7c2d9d7..0edc066 100644 --- a/require/base.php +++ b/require/base.php @@ -1,5 +1,6 @@ pdo_teams = new PDO("sqlite:" . dirname(__FILE__) . $data_path . "teams.db"); $this->pdo_teams->query('CREATE TABLE IF NOT EXISTS "teams" ( "id" INTEGER NOT NULL UNIQUE, - "bonus" INTEGER NOT NULL, + "pzorder" INTEGER, PRIMARY KEY("id" AUTOINCREMENT) )'); @@ -57,12 +58,6 @@ return $query->fetch()["COUNT(*)"]; } - function checkTeamBonus(int $team) { - // $team doit être une équipe existante : - $query = $this->pdo_teams->query("SELECT bonus FROM teams WHERE id = " . $team); - return $query->fetch()[0] == 1; - } - // public function getTeamsNb() { // $query = $this->pdo_teams->query("SELECT COUNT(*) FROM teams"); // return $query->fetch()["COUNT(*)"]; diff --git a/require/locales/en.php b/require/locales/en.php index 61bc898..dbef657 100644 --- a/require/locales/en.php +++ b/require/locales/en.php @@ -1,44 +1,45 @@ [ - "home" => "Home - Lycée Pange Code Hunt", - "team_confirm" => "Team confirmation - Lycée Pange Code Hunt", - "puzzles" => "Puzzles list - Lycée Pange Code Hunt", - "article" => "Puzzle - Lycée Pange Code Hunt" + "home" => "Home - Citizen's journey", + "team_confirm" => "Team confirmation - Citizen's journey", + "puzzles" => "Puzzles list - Citizen's journey", + "article" => "Puzzle - Citizen's journey" ], "page_title" => [ - "home" => "Code Hunt", + "home" => "Citizen's journey", "team_confirm" => "Team confirmation", "puzzles" => "Puzzles list for team n°", "article" => "Puzzle n°" ], "home" => [ - "subtitle" => "Welcome to the code hunt of Lycée Jean de Pange of Sarreguemines !", - "message" => "Enter your team number to begin :", + "subtitle" => "Welcome to the Citizen's journey!", + "message" => "Enter your team number to begin:", "team" => "Team number...", "button" => "OK" ], "team_confirm" => [ "subtitle" => "Please make sure you selected the right team.", - "message" => "Your name must appear on the following list : ", + "message" => "Your name must appear on the following list: ", "button" => "Yes, this is my team !" ], "article" => [ "message" => "This puzzle describes a specific place. Head to that place, then scan the QR code you'll find there.", "success" => "Well done ! Your team solved this puzzle !", "back_but" => "Puzzle list", - "next_but" => "Next puzzle", + "prev_but" => "🡰 Prev.", + "next_but" => "Next 🡲", "qr_but" => "Scan QR code", - "cam_sel" => "Selected camera :", + "cam_sel" => "Selected camera:", "f_cam" => "Front camera", "r_cam" => "Rear camera" ], "puzzles" => [ - "message" => "Select a puzzle in the list below :", - "map_desc" => "Here is a map showing the location of the puzzles you already solved :" + "message" => "Select a puzzle in the list below:", + "map_desc" => "Here is a map showing the location of the puzzles you already solved:" ], "nav" => [ - "title" => "Code Hunt Pange", + "title" => "Citizen's journey", "home" => "Home" ], "footer" => [ diff --git a/require/locales/fr.php b/require/locales/fr.php index 3433df2..be0fba4 100644 --- a/require/locales/fr.php +++ b/require/locales/fr.php @@ -1,19 +1,19 @@ [ - "home" => "Accueil - Chasse au code Lycée Pange", - "team_confirm" => "Confirmation du choix d'équipe - Chasse au code Lycée Pange", - "puzzles" => "Liste des énigmes - Chasse au code Lycée Pange", - "article" => "Énigme - Chasse au code Lycée Pange" + "home" => "Accueil - Parcours citoyen", + "team_confirm" => "Confirmation du choix d'équipe - Parcours citoyen", + "puzzles" => "Liste des énigmes - Parcours citoyen", + "article" => "Énigme - Parcours citoyen" ], "page_title" => [ - "home" => "Chasse au code", + "home" => "Parcours citoyen", "team_confirm" => "Confirmation du choix d'équipe", "puzzles" => "Liste des puzzles pour l'équipe n°", "article" => "Énigme n°" ], "home" => [ - "subtitle" => "Bienvenue à la chasse au code du Lycée Jean de Pange de Sarreguemines !", + "subtitle" => "Bienvenue dans le Parcours citoyen !", "message" => "Pour commencer, veuillez entrer le numéro de votre équipe :", "team" => "Numéro d'équipe...", "button" => "Valider" @@ -27,7 +27,8 @@ "message" => "Cette énigme décrit un endroit précis. Dirigez-vous vers cet endroit, puis scannez le QR code que vous-y trouverez.", "success" => "Bien joué ! Votre équipe a résolu cette énigme !", "back_but" => "Liste des énigmes", - "next_but" => "Énigme suivante", + "prev_but" => "🡰 Préc.", + "next_but" => "Suiv. 🡲", "qr_but" => "Scanner le QR code", "cam_sel" => "Caméra sélectionnée :", "f_cam" => "Caméra avant", @@ -38,11 +39,11 @@ "map_desc" => "Voici la carte des emplacements des énigmes que vous avez résolues :" ], "nav" => [ - "title" => "Chasse au code Pange", + "title" => "Parcours citoyen", "home" => "Accueil" ], "footer" => [ - "text" => "Lycée Jean de Pange Sarreguemines
Code source" + "text" => "Lycée Jean de Pange Sarreguemines
Code source" ] ]; ?> \ No newline at end of file diff --git a/require/puzzles_order.php b/require/puzzles_order.php new file mode 100644 index 0000000..35c6aad --- /dev/null +++ b/require/puzzles_order.php @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/style.css b/style.css index d35b9b1..afb7608 100644 --- a/style.css +++ b/style.css @@ -149,6 +149,7 @@ main header section { display: flex; flex-direction: row; justify-content: center; + align-items: center; gap: 15px; }