Compare commits

..

No commits in common. "bd8275f7ae6610a078ad2ffdc7b27f8d46eb0bbd" and "af909f9e2052b23a60022135a539d14243c4d376" have entirely different histories.

13 changed files with 72 additions and 95 deletions

2
.gitignore vendored
View File

@ -1,4 +1,2 @@
localhost-key.pem
localhost.pem
data/teams.db
data/article.db

View File

@ -1,4 +1,4 @@
# Jeu de pistes Sarreguemines
# Chasse au trésor Lycée Pange
**Auteur :** Antoine WAEHREN

View File

@ -56,6 +56,17 @@
$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;

View File

@ -5,7 +5,6 @@
$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();
@ -28,30 +27,18 @@
}
else {
// 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 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();
}
// 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();
// On retire l'énigme bonus du total :
$max_art--;
}
$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);
@ -84,18 +71,15 @@
</header>
<main>
<header>
<h1><?= $tr["page_title"]["article"] . $art_id ?></h1>
<h1><?= $tr["page_title"]["article"] . $art_id . " : " . $article["title"] ?></h1>
<h2><?= $article["text"] ?></h2>
<section>
<a href="article.php?team=<?= $team_id ?>&id=<?= $prev_art ?>">
<button><?= $tr["article"]["prev_but"] ?></button>
</a>
<a href="puzzles.php?team=<?= $team_id ?>">
<button><?= $tr["article"]["back_but"] ?></button>
</a>
<a href="article.php?team=<?= $team_id ?>&id=<?= $next_art ?>">
<!-- <a href="article.php?team=<?= $team_id ?>&id=<?= ($art_id % $max_art) + 1 ?>">
<button><?= $tr["article"]["next_but"] ?></button>
</a>
</a> -->
</section>
<?php if ($solved) : ?>
<p><?= $tr["article"]["success"] ?></p>
@ -106,7 +90,7 @@
<article>
<?php if ($solved) : ?>
<p><?= $article["answer"] ?></p>
<h1><?= $article["reward"] ?></h1>
<img src="images/map/puzzles/<?= $article["id"] ?>.png"/>
<?php else : ?>
<button><?= $tr["article"]["qr_but"] ?></button>
<p></p> <!-- Emplacement du message d'erreur JS concernant la caméra. !-->

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,6 @@
require_once "require/base.php";
$puzzles = array();
$order = 0;
$team_id = -1;
$database = new Database();
@ -32,26 +31,23 @@
false
);
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles");
// 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->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();
}
}
}
@ -82,12 +78,8 @@
<article>
<p><?= $tr["puzzles"]["message"]?></p>
<ul>
<?php foreach ($pzorder[$order] as $pzid) : ?>
<?php foreach ($puzzles as $puzzle) : ?>
<?php if ($puzzle["id"] == $pzid) : ?>
<li><a href="article.php?team=<?= $team_id ?>&id=<?= $puzzle["id"] ?>"><?= $tr["page_title"]["article"] . $puzzle["id"] ?></a></li>
<?php endif; ?>
<?php endforeach; ?>
<?php foreach ($puzzles as $puzzle) : ?>
<li><a href="article.php?team=<?= $team_id ?>&id=<?= $puzzle["id"] ?>"><?= $tr["page_title"]["article"] . $puzzle["id"] . " : " . $puzzle["title"] ?></a></li>
<?php endforeach; ?>
</ul>
</article>

View File

@ -1,6 +1,5 @@
<?php
require_once "database.php";
require_once "puzzles_order.php";
$rq_path = "require/";

View File

@ -17,7 +17,6 @@
"answer" TEXT NOT NULL,
"location" TEXT NOT NULL,
"code" TEXT NOT NULL,
"reward" TEXT NOT NULL,
PRIMARY KEY("id" AUTOINCREMENT)
)');
@ -25,7 +24,7 @@
$this->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,
"pzorder" INTEGER,
"bonus" INTEGER NOT NULL,
PRIMARY KEY("id" AUTOINCREMENT)
)');
@ -58,6 +57,12 @@
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(*)"];

View File

@ -1,45 +1,44 @@
<?php
$tr = [
"tab_title" => [
"home" => "Home - Citizen's journey",
"team_confirm" => "Team confirmation - Citizen's journey",
"puzzles" => "Puzzles list - Citizen's journey",
"article" => "Puzzle - Citizen's journey"
"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"
],
"page_title" => [
"home" => "Citizen's journey",
"home" => "Code Hunt",
"team_confirm" => "Team confirmation",
"puzzles" => "Puzzles list for team n°",
"article" => "Puzzle n°"
],
"home" => [
"subtitle" => "Welcome to the Citizen's journey!",
"message" => "Enter your team number to begin:",
"subtitle" => "Welcome to the code hunt of Lycée Jean de Pange of Sarreguemines !",
"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",
"prev_but" => "🡰 Prev.",
"next_but" => "Next 🡲",
"next_but" => "Next puzzle",
"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" => "Citizen's journey",
"title" => "Code Hunt Pange",
"home" => "Home"
],
"footer" => [

View File

@ -1,19 +1,19 @@
<?php
$tr = [
"tab_title" => [
"home" => "Accueil - Parcours citoyen",
"team_confirm" => "Confirmation du choix d'équipe - Parcours citoyen",
"puzzles" => "Liste des énigmes - Parcours citoyen",
"article" => "Énigme - Parcours citoyen"
"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"
],
"page_title" => [
"home" => "Parcours citoyen",
"home" => "Chasse au code",
"team_confirm" => "Confirmation du choix d'équipe",
"puzzles" => "Liste des puzzles pour l'équipe n°",
"article" => "Énigme n°"
],
"home" => [
"subtitle" => "Bienvenue dans le Parcours citoyen !",
"subtitle" => "Bienvenue à la chasse au code du Lycée Jean de Pange de Sarreguemines !",
"message" => "Pour commencer, veuillez entrer le numéro de votre équipe :",
"team" => "Numéro d'équipe...",
"button" => "Valider"
@ -27,8 +27,7 @@
"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",
"prev_but" => "🡰 Préc.",
"next_but" => "Suiv. 🡲",
"next_but" => "Énigme suivante",
"qr_but" => "Scanner le QR code",
"cam_sel" => "Caméra sélectionnée :",
"f_cam" => "Caméra avant",
@ -39,11 +38,11 @@
"map_desc" => "Voici la carte des emplacements des énigmes que vous avez résolues :"
],
"nav" => [
"title" => "Parcours citoyen",
"title" => "Chasse au code Pange",
"home" => "Accueil"
],
"footer" => [
"text" => "Lycée Jean de Pange Sarreguemines<br><a href='https://forge.chapril.org/Antux/JeuPistesSarreguemines'>Code source</a>"
"text" => "Lycée Jean de Pange Sarreguemines<br><a href='https://forge.chapril.org/antux18/ChasseTresorPange'>Code source</a>"
]
];
?>

View File

@ -1,9 +0,0 @@
<?php
$pzorder = [
[7,4,3,2,5,8,9,6,10,1],
[10,6,8,5,2,7,4,3,9,1],
[5,2,7,4,3,6,8,10,9,1],
[3,6,8,10,9,4,7,5,2,1],
[9,6,10,4,7,8,5,3,2,1]
]
?>

View File

@ -149,7 +149,6 @@ main header section {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
gap: 15px;
}