parent
4faf5aeca4
commit
00bb454e99
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/ScienceQuest.iml" filepath="$PROJECT_DIR$/.idea/ScienceQuest.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="PhpProjectSharedConfiguration" php_language_level="7.4">
|
||||||
|
<option name="suggestChangeDefaultLanguageLevel" value="false" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,4 @@
|
|||||||
|
vendor/
|
||||||
|
composer.lock
|
||||||
|
js/bootstrap*.js*
|
||||||
|
css/bootstrap*.css*
|
@ -1,21 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace config;
|
namespace config;
|
||||||
|
|
||||||
//gen
|
$config = [
|
||||||
$rep=__DIR__.'/../';
|
"rep" => __DIR__.'/../',
|
||||||
|
"db" => ["dsn" => 'pgsql:host=localhost;dbname=dbrebeuret',
|
||||||
// liste des modules à inclure
|
"login" => 'rebeuret',
|
||||||
|
"mdp" => 'achanger'],
|
||||||
//$dConfig['includes']= array('controleur/Validation.php');
|
"templates" => ["index" => 'vues/index.php',
|
||||||
|
"pseudo" => 'pseudo.html',
|
||||||
|
"pendu" => "pendu.html",
|
||||||
//BD
|
"penduScore" => 'penduScore.html']
|
||||||
|
];
|
||||||
$base = 'mysql:host=localhost;dbname=sae';
|
|
||||||
$login = 'root';
|
|
||||||
$mdp = '';
|
|
||||||
//Vues
|
|
||||||
|
|
||||||
$vues['index']='vues/index.php';
|
|
||||||
|
|
||||||
?>
|
?>
|
@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace controller;
|
||||||
|
|
||||||
|
use model\ConfigurationJeu;
|
||||||
|
use model\Joueur;
|
||||||
|
use model\MdlPendu;
|
||||||
|
use model\MdlScientifique;
|
||||||
|
use config\Validation;
|
||||||
|
use model\ValidationException;
|
||||||
|
|
||||||
|
class PenduController{
|
||||||
|
private array $dVue;
|
||||||
|
private array $dVueErreur;
|
||||||
|
private MdlPendu $pendu;
|
||||||
|
public function __construct(Joueur $role, ConfigurationJeu $configJeu)
|
||||||
|
{
|
||||||
|
$this->dVue = [];
|
||||||
|
$this->dVueErreur = [];
|
||||||
|
if(isset($_SESSION['pendu']) && Validation::valMdlPendu($_SESSION['pendu'], $this->dVueErreur)){
|
||||||
|
$this->pendu = $_SESSION['pendu'];
|
||||||
|
}else{
|
||||||
|
$this->reinit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_POST['lettre'])){
|
||||||
|
try{
|
||||||
|
$this->pendu->jouerLettre($_POST['lettre']);
|
||||||
|
}catch (ValidationException $e){
|
||||||
|
$this->dVueErreur[] = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->pendu->aGagne()){
|
||||||
|
$this->renderAgagne();
|
||||||
|
}elseif($this->pendu->aPerdu()){
|
||||||
|
$this->renderAPerdu();
|
||||||
|
}else{
|
||||||
|
$this->renderJeu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function reinit(){
|
||||||
|
$mdlScientifique = new MdlScientifique();
|
||||||
|
$scientifique = $mdlScientifique->getRandom();
|
||||||
|
$this->pendu = new MdlPendu($scientifique);
|
||||||
|
$_SESSION['pendu'] = $this->pendu;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function renderJeu(){
|
||||||
|
global $twig, $config;
|
||||||
|
$this->dVue['decouvert'] = $this->pendu->getDecouvert();
|
||||||
|
$this->dVue['essaisRestant'] = $this->pendu->getEssaisRestant();
|
||||||
|
$lettreUtilisees = $this->pendu->getLettreUtilisees();
|
||||||
|
sort($lettreUtilisees);
|
||||||
|
$this->dVue['lettresUtilisees'] = $lettreUtilisees;
|
||||||
|
echo $twig->render($config['templates']['pendu'], ['dVue' => $this->dVue, 'dVueErreur'=>$this->dVueErreur]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function renderAgagne(){
|
||||||
|
$this->dVue['messageScore'] = "Vous avez gagné !";
|
||||||
|
$this->renderScore();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function renderAPerdu(){
|
||||||
|
$this->dVue['messageScore'] = "Vous avez perdu !";
|
||||||
|
$this->renderScore();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function renderScore(){
|
||||||
|
global $twig, $config;
|
||||||
|
$this->dVue['nbTours'] = $this->pendu->getNbTours();
|
||||||
|
$this->dVue['nbFails'] = $this->pendu->getNbFails();
|
||||||
|
$scientifique = $this->pendu->getScientifique();
|
||||||
|
$dScientifique = [];
|
||||||
|
$dScientifique['nom'] = $scientifique->getNom();
|
||||||
|
$dScientifique['prenom'] = $scientifique->getPrenom();
|
||||||
|
$dScientifique['sexe'] = $scientifique->getSexe()->getLibelle();
|
||||||
|
$dScientifique['thematique'] = $scientifique->getThematique()->getLibelle();
|
||||||
|
$dScientifique['dateNaiss'] = $scientifique->getDateNaiss()->format('d/m/Y');
|
||||||
|
$this->dVue['scientifique'] = $dScientifique;
|
||||||
|
unset($_SESSION['pendu']);
|
||||||
|
|
||||||
|
echo $twig->render($config['templates']['penduScore'], ["dVue" => $this->dVue]);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
namespace controller;
|
||||||
|
|
||||||
|
use config\Validation;
|
||||||
|
use model\IdSessionDoubleException;
|
||||||
|
use model\PseudoDejaPrisException;
|
||||||
|
use model\ValidationException;
|
||||||
|
use model\MdlInvite;
|
||||||
|
|
||||||
|
class PseudoController{
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
global $twig, $config;
|
||||||
|
$dVue = [];
|
||||||
|
$dVueErreur = [];
|
||||||
|
|
||||||
|
if(isset($_POST["pseudo"])){
|
||||||
|
try{
|
||||||
|
$mdlInvite = new MdlInvite();
|
||||||
|
$pseudo = $_POST["pseudo"];
|
||||||
|
$pseudo = Validation::valPseudo($pseudo, $dVueErreur);
|
||||||
|
$role = $mdlInvite->insertInvite($pseudo, session_id());
|
||||||
|
}catch(ValidationException $e){
|
||||||
|
|
||||||
|
}catch(PseudoDejaPrisException $e){
|
||||||
|
$dVueErreur[] = "Pseudo déjà pris";
|
||||||
|
}catch(IdSessionDoubleException $e){
|
||||||
|
try{
|
||||||
|
$role = $mdlInvite->setPseudo($e->getIdJoueur(), $pseudo);
|
||||||
|
}catch(PseudoDejaPrisException $e){
|
||||||
|
$dVueErreur[] = "Pseudo déjà pris";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($role)){
|
||||||
|
$_SESSION['role'] = $role;
|
||||||
|
header('Location: jouer');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo $twig->render($config['templates']['pseudo'], ["dVue" => $dVue, "dVueErreur" => $dVueErreur]);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,182 @@
|
|||||||
|
-- Testé sous pgsql 15
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS Reponse;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS Question;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS Admin;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS Partie;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS Jeu;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS Decouvrir;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS Utilisateur;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS Invite;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS Joueur;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS Indice;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS Scientifique;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS Thematique;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS Difficulte;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS Sexe;
|
||||||
|
|
||||||
|
|
||||||
|
-- THEMATIQUE
|
||||||
|
|
||||||
|
CREATE TABLE Thematique(
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
libelle varchar(128) NOT NULL UNIQUE
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- DIFFICULTE
|
||||||
|
|
||||||
|
CREATE TABLE Difficulte(
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
libelle varchar(128) NOT NULL UNIQUE
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- SEXE
|
||||||
|
|
||||||
|
CREATE TABLE Sexe(
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
libelle varchar(128) NOT NULL UNIQUE
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- SCIENTIFIQUE
|
||||||
|
|
||||||
|
CREATE TABLE Scientifique(
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
nom varchar(128) NOT NULL,
|
||||||
|
prenom varchar(128) NOT NULL,
|
||||||
|
photo varchar(512) NOT NULL,
|
||||||
|
dateNaissance date NOT NULL,
|
||||||
|
descriptif text NOT NULL,
|
||||||
|
ratioTrouvee numeric(5,4),
|
||||||
|
idThematique integer REFERENCES Thematique(id),
|
||||||
|
idDifficulte integer REFERENCES Difficulte(id),
|
||||||
|
idSexe integer REFERENCES Sexe(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- INDICE
|
||||||
|
|
||||||
|
CREATE TABLE Indice(
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
libelle varchar(512) NOT NULL UNIQUE,
|
||||||
|
idScientifique integer REFERENCES Scientifique(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- QUESTION
|
||||||
|
|
||||||
|
CREATE TABLE Question(
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
question varchar(256) NOT NULL UNIQUE
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- REPONSE
|
||||||
|
|
||||||
|
CREATE TABLE Reponse(
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
reponse varchar(255) NOT NULL,
|
||||||
|
idQuestion integer REFERENCES Question(id),
|
||||||
|
idScientifique integer REFERENCES Scientifique(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- ADMIN
|
||||||
|
|
||||||
|
CREATE TABLE Admin(
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
email varchar(255) NOT NULL UNIQUE,
|
||||||
|
password varchar(255) NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- JOUEUR
|
||||||
|
|
||||||
|
CREATE TABLE Joueur(
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
pseudo varchar(255) NOT NULL UNIQUE
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- Invite
|
||||||
|
|
||||||
|
CREATE TABLE Invite(
|
||||||
|
idJoueur integer PRIMARY KEY REFERENCES Joueur(id),
|
||||||
|
idSession varchar(255) NOT NULL UNIQUE
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- Utilisateur
|
||||||
|
|
||||||
|
CREATE TABLE Utilisateur(
|
||||||
|
idJoueur integer PRIMARY KEY REFERENCES Joueur(id),
|
||||||
|
email varchar(255) NOT NULL UNIQUE,
|
||||||
|
password varchar(255) NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- Decouvrir
|
||||||
|
|
||||||
|
CREATE TABLE Decouvrir(
|
||||||
|
idUtilisateur integer REFERENCES Utilisateur(idJoueur),
|
||||||
|
idScientifique integer REFERENCES Scientifique(id),
|
||||||
|
PRIMARY KEY (idUtilisateur, idScientifique)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- Jeu
|
||||||
|
|
||||||
|
CREATE TABLE Jeu(
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
nom varchar(128) NOT NULL UNIQUE,
|
||||||
|
nbrParties integer NOT NULL DEFAULT 0
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- Partie
|
||||||
|
|
||||||
|
CREATE TABLE Partie(
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
codeInvitation varchar(10) NOT NULL UNIQUE,
|
||||||
|
idJoueur integer REFERENCES Joueur(id),
|
||||||
|
idJeu integer REFERENCES Jeu(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- INSERTS
|
||||||
|
|
||||||
|
INSERT INTO Jeu(nom) VALUES ('Qui-est-ce ?'),('Kahoot'), ('Pendu');
|
||||||
|
|
||||||
|
INSERT INTO Difficulte(libelle) VALUES ('Facile'),('Intermédiaire'),('Difficile');
|
||||||
|
|
||||||
|
INSERT INTO Sexe(libelle) VALUES ('Homme'),('Femme');
|
||||||
|
|
||||||
|
INSERT INTO Thematique(libelle) VALUES ('Nucléaire'),('Mathématiques');
|
||||||
|
|
||||||
|
INSERT INTO Scientifique(nom, prenom, photo, dateNaissance, descriptif, ratioTrouvee, idThematique, idDifficulte, idSexe)
|
||||||
|
VALUES
|
||||||
|
('nomToto', 'prenomToto', '', CURRENT_DATE, 'desc', 0, 1, 1, 1),
|
||||||
|
('nomTiti', 'prenomTiti', '', CURRENT_DATE, 'desc', 0, 2, 2, 2);
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO Joueur(id,pseudo) VALUES (1337, 'moi, le meilleur joueur du monde');
|
||||||
|
INSERT INTO Utilisateur(idJoueur,email,password) VALUES (1337, 'joueur','$2y$10$juGnlWC9cS19popEKLZsYeir0Jl39k6hDl0dpaCix00FDcdiEbtmS');
|
||||||
|
-- mdp = test
|
||||||
|
|
||||||
|
INSERT INTO Admin(id,email,password) VALUES (1, 'admin','$2y$10$juGnlWC9cS19popEKLZsYeir0Jl39k6hDl0dpaCix00FDcdiEbtmS');
|
||||||
|
-- mdp = test
|
@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace model;
|
|
||||||
|
|
||||||
class ModelAdmin {
|
|
||||||
public static function isAdmin() {
|
|
||||||
if(!isset($_SESSION['admin'])
|
|
||||||
|| !$_SESSION['admin']
|
|
||||||
|| !isset($_SESSION['email'])
|
|
||||||
|| $_SESSION['email'] == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function logout() {
|
|
||||||
global $basePath;
|
|
||||||
|
|
||||||
session_unset();
|
|
||||||
session_destroy();
|
|
||||||
$_SESSION = array();
|
|
||||||
header("Location: .");
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class IdSessionDoubleException extends \RuntimeException
|
||||||
|
{
|
||||||
|
private int $idJoueur;
|
||||||
|
private string $idSession;
|
||||||
|
|
||||||
|
public function __construct($idJoueur, $idSession)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->idJoueur=$idJoueur;
|
||||||
|
$this->idSession=$idSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIdJoueur():int{
|
||||||
|
return $this->idJoueur;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIdSession(): string{
|
||||||
|
return $this->idSession;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace controller;
|
namespace model;
|
||||||
|
|
||||||
class LoginException extends \Exception
|
class LoginException extends \Exception
|
||||||
{
|
{
|
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class PseudoDejaPrisException extends \RuntimeException
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class ValidationException extends \RuntimeException{
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class DifficulteGateway
|
||||||
|
{
|
||||||
|
private $con;
|
||||||
|
|
||||||
|
function __construct(Connection $con) {
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
public function getAll() : array
|
||||||
|
{
|
||||||
|
$this->con->executeQuery("SELECT id, libelle FROM Difficulte;");
|
||||||
|
return $this->con->getResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFromId(int $id): array
|
||||||
|
{
|
||||||
|
$this->con->executeQuery("SELECT id, libelle FROM Difficulte WHERE id=:id;",
|
||||||
|
[':id' => [$id, $this->con::PARAM_INT]]);
|
||||||
|
return $this->con->getOneResult();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class InviteGateway extends JoueurGateway
|
||||||
|
{
|
||||||
|
|
||||||
|
function __construct(Connection $con) {
|
||||||
|
parent::__construct($con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFromIdSession($idSession): array|bool
|
||||||
|
{
|
||||||
|
$this->con->executeQuery("SELECT idJoueur, pseudo, idSession FROM Invite JOIN Joueur ON id=idJoueur WHERE idSession = :idSession;",
|
||||||
|
[":idSession" => [$idSession, $this->con::PARAM_STR]]);
|
||||||
|
return $this->con->getOneResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFromId($id): array|bool
|
||||||
|
{
|
||||||
|
$this->con->executeQuery("SELECT idJoueur, pseudo, idSession FROM Invite JOIN Joueur ON id=idJoueur WHERE id = :id;",
|
||||||
|
[":id" => [$id, $this->con::PARAM_INT]]);
|
||||||
|
return $this->con->getOneResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function insertInvite(string $pseudo, string $idSession): int{
|
||||||
|
$row = $this->getFromIdSession($idSession);
|
||||||
|
if($row != false){
|
||||||
|
throw new IdSessionDoubleException($row['idjoueur'], $row['idsession']);
|
||||||
|
}else{
|
||||||
|
$id = $this->insertJoueur($pseudo);
|
||||||
|
$this->con->executeQuery("INSERT INTO Invite(idJoueur, idSession) VALUES(:id, :idSession);",
|
||||||
|
[":id" => [$id, $this->con::PARAM_INT],
|
||||||
|
":idSession" => [$idSession, $this->con::PARAM_STR]]);
|
||||||
|
return $id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
|
||||||
|
class JeuGateway
|
||||||
|
{
|
||||||
|
private $con;
|
||||||
|
|
||||||
|
function __construct(Connection $con) {
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
public function getAll() : array
|
||||||
|
{
|
||||||
|
$this->con->executeQuery("SELECT id, nom, nbrparties FROM Jeu;");
|
||||||
|
return $this->con->getResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFromId(int $id): array
|
||||||
|
{
|
||||||
|
$this->con->executeQuery("SELECT id, nom, nbrparties FROM Jeu WHERE id=:id;",
|
||||||
|
[':id' => [$id, $this->con::PARAM_INT]]);
|
||||||
|
return $this->con->getOneResult();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
abstract class JoueurGateway
|
||||||
|
{
|
||||||
|
protected $con;
|
||||||
|
|
||||||
|
function __construct(Connection $con) {
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getFromPseudo($pseudo): array|bool
|
||||||
|
{
|
||||||
|
$this->con->executeQuery("SELECT id, pseudo FROM Joueur WHERE pseudo = :pseudo;",
|
||||||
|
[":pseudo" => [$pseudo, $this->con::PARAM_STR]]);
|
||||||
|
return $this->con->getOneResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function insertJoueur(string $pseudo): int{
|
||||||
|
if($this->getFromPseudo($pseudo) != false){
|
||||||
|
throw new PseudoDejaPrisException();
|
||||||
|
}else{
|
||||||
|
$this->con->executeQuery("INSERT INTO Joueur(pseudo) VALUES(:pseudo);",
|
||||||
|
[":pseudo" => [$pseudo, $this->con::PARAM_STR]]);
|
||||||
|
return $this->getFromPseudo($pseudo)["id"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPseudo(int $id, string $pseudo){
|
||||||
|
if($this->getFromPseudo($pseudo) != false){
|
||||||
|
throw new PseudoDejaPrisException();
|
||||||
|
}else{
|
||||||
|
$this->con->executeQuery("UPDATE Joueur SET pseudo=:pseudo WHERE id=:id",
|
||||||
|
[":pseudo" => [$pseudo, $this->con::PARAM_STR],
|
||||||
|
":id" => [$id, $this->con::PARAM_INT]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class ScientifiqueGateway
|
||||||
|
{
|
||||||
|
private $con;
|
||||||
|
|
||||||
|
function __construct(Connection $con) {
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRandom(): array|bool{
|
||||||
|
$this->con->executeQuery(
|
||||||
|
"SELECT id, nom, prenom, photo, dateNaissance, descriptif, ratiotrouvee, idthematique, iddifficulte, idsexe FROM Scientifique ORDER BY RANDOM() LIMIT 1;");
|
||||||
|
return $this->con->getOneResult();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class SexeGateway
|
||||||
|
{
|
||||||
|
private $con;
|
||||||
|
|
||||||
|
function __construct(Connection $con) {
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFromId(int $id): array
|
||||||
|
{
|
||||||
|
$this->con->executeQuery("SELECT id, libelle FROM Sexe WHERE id=:id;",
|
||||||
|
[':id' => [$id, $this->con::PARAM_INT]]);
|
||||||
|
return $this->con->getOneResult();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class ThematiqueGateway
|
||||||
|
{
|
||||||
|
private $con;
|
||||||
|
|
||||||
|
function __construct(Connection $con) {
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFromId(int $id): array
|
||||||
|
{
|
||||||
|
$this->con->executeQuery("SELECT id, libelle FROM Thematique WHERE id=:id;",
|
||||||
|
[':id' => [$id, $this->con::PARAM_INT]]);
|
||||||
|
return $this->con->getOneResult();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class MdlAdmin extends MdlBase{
|
||||||
|
private AdminGateway $gw;
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
parent::__construct();
|
||||||
|
$this->gw = new AdminGateway($this->con);
|
||||||
|
}
|
||||||
|
public function login(string $username, string $password): bool{
|
||||||
|
return $this->gw->login($username, $password);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isAdmin() {
|
||||||
|
if(!isset($_SESSION['admin'])
|
||||||
|
|| !$_SESSION['admin']
|
||||||
|
|| !isset($_SESSION['email'])
|
||||||
|
|| $_SESSION['email'] == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function logout() {
|
||||||
|
global $basePath;
|
||||||
|
|
||||||
|
session_unset();
|
||||||
|
session_destroy();
|
||||||
|
$_SESSION = array();
|
||||||
|
header("Location: .");
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
public function setPseudo(int $id, string $pseudo): User{
|
||||||
|
$this->gw->setPseudo($id, $pseudo);
|
||||||
|
return $this->getFromId($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function insertInvite(string $pseudo, string $idSession): User{
|
||||||
|
$id = $this->gw->insertInvite($pseudo, $idSession);
|
||||||
|
return $this->getFromId($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFromId(int $id): User{
|
||||||
|
$row = $this->gw->getFromId($id);
|
||||||
|
return new Invite($row['idjoueur'], $row['pseudo'], $row['idsession']);
|
||||||
|
}*/
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
abstract class MdlBase{
|
||||||
|
protected Connection $con;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
$this->con = new Connection($config["db"]["dsn"], $config["db"]["login"], $config["db"]["mdp"]);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class MdlDifficulte extends MdlBase{
|
||||||
|
private DifficulteGateway $gw;
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
parent::__construct();
|
||||||
|
$this->gw = new DifficulteGateway($this->con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAll(): array{
|
||||||
|
$listDifficulte = [];
|
||||||
|
foreach($this->gw->getAll() as $row){
|
||||||
|
$listDifficulte[] = new Difficulte($row['id'], $row['libelle']);
|
||||||
|
}
|
||||||
|
return $listDifficulte;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFromId(int $id): Difficulte{
|
||||||
|
$row = $this->gw->getFromId($id);
|
||||||
|
return new Difficulte($row['id'], $row['libelle']);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class MdlInvite extends MdlBase{
|
||||||
|
private InviteGateway $gw;
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
parent::__construct();
|
||||||
|
$this->gw = new InviteGateway($this->con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPseudo(int $id, string $pseudo): Invite{
|
||||||
|
$this->gw->setPseudo($id, $pseudo);
|
||||||
|
return $this->getFromId($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function insertInvite(string $pseudo, string $idSession): Invite{
|
||||||
|
$id = $this->gw->insertInvite($pseudo, $idSession);
|
||||||
|
return $this->getFromId($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFromId(int $id): Invite{
|
||||||
|
$row = $this->gw->getFromId($id);
|
||||||
|
return new Invite($row['idjoueur'], $row['pseudo'], $row['idsession']);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class MdlJeu extends MdlBase{
|
||||||
|
private JeuGateway $gw;
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
parent::__construct();
|
||||||
|
$this->gw = new JeuGateway($this->con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAll(): array{
|
||||||
|
$listJeu = [];
|
||||||
|
foreach($this->gw->getAll() as $row){
|
||||||
|
$listJeu[] = new Jeu($row['id'], $row['nom'], $row['nbrparties']);
|
||||||
|
}
|
||||||
|
return $listJeu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFromId(int $id): Jeu{
|
||||||
|
$row = $this->gw->getFromId($id);
|
||||||
|
return new Jeu($row['id'], $row['nom'], $row['nbrparties']);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class MdlPendu{
|
||||||
|
private Scientifique $scientifiqueATrouver;
|
||||||
|
private string $aTrouver;
|
||||||
|
private int $nbFail;
|
||||||
|
private int $nbTours;
|
||||||
|
private array $lettreExceptees;
|
||||||
|
private array $lettreUtilisees;
|
||||||
|
|
||||||
|
private static $nbFailsMax = 8;
|
||||||
|
|
||||||
|
public function __construct(Scientifique $scientifiqueATrouver){
|
||||||
|
$this->scientifiqueATrouver = $scientifiqueATrouver;
|
||||||
|
$this->aTrouver = strtr($scientifiqueATrouver->getPrenom()." ".$scientifiqueATrouver->getNom(), 'áàâäãåçéèêëíìîïñóòôöõúùûüýÿ', 'aaaaaaceeeeiiiinooooouuuuyy'); #suppression des accents
|
||||||
|
$this->nbFail = 0;
|
||||||
|
$this->nbTours = 0;
|
||||||
|
$this->lettreExceptees = [' ', '-'];
|
||||||
|
$this->lettreUtilisees = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function jouerLettre(string $lettre): string{
|
||||||
|
$lettre = strtolower($lettre);
|
||||||
|
if(strlen($lettre) != 1){ throw new ValidationException("Veuillez fournir une seule lettre");}
|
||||||
|
if(!ctype_alpha($lettre)){ throw new ValidationException("Veuillez fournir une caractère alphabétique");}
|
||||||
|
if(in_array($lettre, $this->lettreUtilisees)){ throw new ValidationException("Vous avez déjà joué cette lettre");}
|
||||||
|
$this->nbTours += 1;
|
||||||
|
|
||||||
|
if(!str_contains($this->aTrouver, $lettre)){
|
||||||
|
$this->nbFail += 1;
|
||||||
|
}
|
||||||
|
$this->lettreUtilisees[] = $lettre;
|
||||||
|
return $this->getDecouvert();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getScientifique(): Scientifique
|
||||||
|
{
|
||||||
|
return $this->scientifiqueATrouver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLettreUtilisees(): array{
|
||||||
|
return $this->lettreUtilisees;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getATrouver(): string
|
||||||
|
{
|
||||||
|
return $this->aTrouver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDecouvert(): string
|
||||||
|
{
|
||||||
|
$decouvert = '';
|
||||||
|
foreach(str_split($this->aTrouver) as $lettre){
|
||||||
|
if(in_array(strtolower($lettre), $this->lettreUtilisees) || in_array(strtolower($lettre), $this->lettreExceptees)){
|
||||||
|
$decouvert.=$lettre;
|
||||||
|
}else{
|
||||||
|
$decouvert.="_";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $decouvert;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNbTours():int{
|
||||||
|
return $this->nbTours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNbFails():int{
|
||||||
|
return $this->nbFail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEssaisRestant():int{
|
||||||
|
return $this::$nbFailsMax - $this->nbFail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function aGagne(): bool{
|
||||||
|
return $this->getDecouvert() == $this->getATrouver();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function aPerdu(): bool{
|
||||||
|
return $this->getEssaisRestant() <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
|
class MdlScientifique extends MdlBase{
|
||||||
|
private ScientifiqueGateway $gw;
|
||||||
|
private MdlSexe $mdlSexe;
|
||||||
|
private MdlDifficulte $mdlDifficulte;
|
||||||
|
private MdlThematique $mdlThematique;
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
parent::__construct();
|
||||||
|
$this->gw = new ScientifiqueGateway($this->con);
|
||||||
|
$this->mdlSexe = new MdlSexe();
|
||||||
|
$this->mdlDifficulte = new MdlDifficulte();
|
||||||
|
$this->mdlThematique = new MdlThematique();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRandom(): Scientifique{
|
||||||
|
$row = $this->gw->getRandom();
|
||||||
|
if($row == false) throw new RuntimeException("Erreur aucun scientifique trouvé");
|
||||||
|
$sexe = $this->mdlSexe->getFromId($row['idsexe']);
|
||||||
|
$difficulte = $this->mdlDifficulte->getFromId($row['iddifficulte']);
|
||||||
|
$thematique = $this->mdlThematique->getFromId($row['idthematique']);
|
||||||
|
|
||||||
|
return new Scientifique($row['id'],
|
||||||
|
$row['nom'],
|
||||||
|
$row['prenom'],
|
||||||
|
$row['photo'],
|
||||||
|
new DateTime($row['datenaissance']),
|
||||||
|
$row['descriptif'],
|
||||||
|
$row['ratiotrouvee'],
|
||||||
|
$thematique,
|
||||||
|
$difficulte,
|
||||||
|
$sexe);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class MdlSexe extends MdlBase{
|
||||||
|
private SexeGateway $gw;
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
parent::__construct();
|
||||||
|
$this->gw = new SexeGateway($this->con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFromId(int $id): Sexe{
|
||||||
|
$row = $this->gw->getFromId($id);
|
||||||
|
return new Sexe($row['id'], $row['libelle']);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class MdlThematique extends MdlBase{
|
||||||
|
private ThematiqueGateway $gw;
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
parent::__construct();
|
||||||
|
$this->gw = new ThematiqueGateway($this->con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFromId(int $id): Thematique{
|
||||||
|
$row = $this->gw->getFromId($id);
|
||||||
|
return new Thematique($row['id'], $row['libelle']);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class MdlUser extends MdlBase{
|
||||||
|
private UserGateway $gw;
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
parent::__construct();
|
||||||
|
$this->gw = new UserGateway($this->con);
|
||||||
|
}
|
||||||
|
public function login(string $username, string $password): bool{
|
||||||
|
return $this->gw->login($username, $password);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
public function setPseudo(int $id, string $pseudo): User{
|
||||||
|
$this->gw->setPseudo($id, $pseudo);
|
||||||
|
return $this->getFromId($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function insertInvite(string $pseudo, string $idSession): User{
|
||||||
|
$id = $this->gw->insertInvite($pseudo, $idSession);
|
||||||
|
return $this->getFromId($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFromId(int $id): User{
|
||||||
|
$row = $this->gw->getFromId($id);
|
||||||
|
return new Invite($row['idjoueur'], $row['pseudo'], $row['idsession']);
|
||||||
|
}*/
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class ConfigurationJeu{
|
||||||
|
private Difficulte $difficulte;
|
||||||
|
private Jeu $jeu;
|
||||||
|
|
||||||
|
public function __construct(Jeu $jeu, Difficulte $difficulte){
|
||||||
|
$this->jeu = $jeu;
|
||||||
|
$this->difficulte = $difficulte;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDifficulte(): Difficulte{
|
||||||
|
return $this->difficulte;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getJeu(): Jeu{
|
||||||
|
return $this->jeu;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class Difficulte
|
||||||
|
{
|
||||||
|
private int $id;
|
||||||
|
private string $libelle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id
|
||||||
|
* @param string $libelle
|
||||||
|
*/
|
||||||
|
public function __construct(int $id, string $libelle)
|
||||||
|
{
|
||||||
|
$this->id=$id;
|
||||||
|
$this->libelle=$libelle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getId(): int{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getLibelle(): string{
|
||||||
|
return $this->libelle;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class Invite extends Joueur{
|
||||||
|
private string $idSession;
|
||||||
|
|
||||||
|
public function __construct(int $id, string $pseudo, string $idSession)
|
||||||
|
{
|
||||||
|
parent::__construct($id,$pseudo);
|
||||||
|
$this->idSession = $idSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIdSession(): string
|
||||||
|
{
|
||||||
|
return $this->idSession;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class Jeu
|
||||||
|
{
|
||||||
|
private int $id;
|
||||||
|
private string $nom;
|
||||||
|
private int $nbrParties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id
|
||||||
|
* @param string $nom
|
||||||
|
* @param string $nbParties
|
||||||
|
*/
|
||||||
|
public function __construct(int $id, string $nom, int $nbrParties)
|
||||||
|
{
|
||||||
|
$this->id=$id;
|
||||||
|
$this->nom=$nom;
|
||||||
|
$this->nbrParties=$nbrParties;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getId(): int{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getNom(): string{
|
||||||
|
return $this->nom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getNbParties():int{
|
||||||
|
return $this->nbrParties;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function incrementNbParties(): int{
|
||||||
|
$this->nbrParties += 1;
|
||||||
|
return $this->nbrParties;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
|
||||||
|
abstract class Joueur{
|
||||||
|
private int $id;
|
||||||
|
private string $pseudo;
|
||||||
|
|
||||||
|
public function __construct(int $id, string $pseudo){
|
||||||
|
$this->id=$id;
|
||||||
|
$this->pseudo=$pseudo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId(): int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPseudo(): String
|
||||||
|
{
|
||||||
|
return $this->pseudo;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,132 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
|
||||||
|
class Scientifique
|
||||||
|
{
|
||||||
|
private int $id;
|
||||||
|
private string $nom;
|
||||||
|
private string $prenom;
|
||||||
|
private string $photo;
|
||||||
|
private DateTime $dateNaiss;
|
||||||
|
private string $descriptif;
|
||||||
|
private float $ratioTrouvee;
|
||||||
|
private Thematique $thematique;
|
||||||
|
private Difficulte $difficulte;
|
||||||
|
private Sexe $sexe;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id
|
||||||
|
* @param string $nom
|
||||||
|
* @param string $prenom
|
||||||
|
* @param string $photo
|
||||||
|
* @param string $descriptif
|
||||||
|
* @param Thematique $thematique
|
||||||
|
* @param Difficulte $difficulte
|
||||||
|
* @param Sexe $sexe
|
||||||
|
*/
|
||||||
|
public function __construct(int $id,
|
||||||
|
string $nom,
|
||||||
|
string $prenom,
|
||||||
|
string $photo,
|
||||||
|
DateTime $dateNaiss,
|
||||||
|
string $descriptif,
|
||||||
|
float $ratioTrouvee,
|
||||||
|
Thematique $thematique,
|
||||||
|
Difficulte $difficulte,
|
||||||
|
Sexe $sexe)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
$this->nom = $nom;
|
||||||
|
$this->prenom = $prenom;
|
||||||
|
$this->photo = $photo;
|
||||||
|
$this->ratioTrouvee = $ratioTrouvee;
|
||||||
|
$this->descriptif = $descriptif;
|
||||||
|
$this->dateNaiss = $dateNaiss;
|
||||||
|
$this->thematique = $thematique;
|
||||||
|
$this->difficulte = $difficulte;
|
||||||
|
$this->sexe = $sexe;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getId(): int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getNom(): string
|
||||||
|
{
|
||||||
|
return $this->nom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPrenom(): string
|
||||||
|
{
|
||||||
|
return $this->prenom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPhoto(): string
|
||||||
|
{
|
||||||
|
return $this->photo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDescriptif(): string
|
||||||
|
{
|
||||||
|
return $this->descriptif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return DateTime
|
||||||
|
*/
|
||||||
|
public function getDateNaiss(): DateTime
|
||||||
|
{
|
||||||
|
return $this->dateNaiss;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public function getRatioTrouvee(): float
|
||||||
|
{
|
||||||
|
return $this->ratioTrouvee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Thematique
|
||||||
|
*/
|
||||||
|
public function getThematique(): Thematique
|
||||||
|
{
|
||||||
|
return $this->thematique;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Difficulte
|
||||||
|
*/
|
||||||
|
public function getDifficulte(): Difficulte
|
||||||
|
{
|
||||||
|
return $this->difficulte;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Sexe
|
||||||
|
*/
|
||||||
|
public function getSexe(): Sexe
|
||||||
|
{
|
||||||
|
return $this->sexe;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class Sexe
|
||||||
|
{
|
||||||
|
private int $id;
|
||||||
|
private string $libelle;
|
||||||
|
|
||||||
|
public function __construct(int $id, string $libelle)
|
||||||
|
{
|
||||||
|
$this->id=$id;
|
||||||
|
$this->libelle=$libelle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId():int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLibelle(): string
|
||||||
|
{
|
||||||
|
return $this->libelle;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class Thematique
|
||||||
|
{
|
||||||
|
private int $id;
|
||||||
|
private string $libelle;
|
||||||
|
|
||||||
|
public function __construct(int $id, string $libelle)
|
||||||
|
{
|
||||||
|
$this->id=$id;
|
||||||
|
$this->libelle=$libelle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId():int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLibelle(): string
|
||||||
|
{
|
||||||
|
return $this->libelle;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class Utilisateur extends Joueur{
|
||||||
|
private string $email;
|
||||||
|
private string $motDePasse; #hash du mot de passe
|
||||||
|
|
||||||
|
public function __construct(int $id, string $pseudo, string $email, string $motDePasse)
|
||||||
|
{
|
||||||
|
parent::__construct($id,$pseudo);
|
||||||
|
$this->email = $email;
|
||||||
|
$this->motDePasse = $motDePasse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEmail(): string
|
||||||
|
{
|
||||||
|
return $this->email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMotDePasse(): string
|
||||||
|
{
|
||||||
|
return $this->motDePasse;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Pendu</title>
|
||||||
|
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||||
|
<style>
|
||||||
|
p,
|
||||||
|
label {
|
||||||
|
font:
|
||||||
|
1rem 'Fira Sans',
|
||||||
|
sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
margin: 0.4rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<br><br><br>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<p></p>
|
||||||
|
<form action="" method="post">
|
||||||
|
<fieldset>
|
||||||
|
{% if dVue.decouvert is defined %}
|
||||||
|
<div>
|
||||||
|
<h1>
|
||||||
|
{{dVue.decouvert}}
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
{% endif %}
|
||||||
|
{% if dVue.essaisRestant is defined %}
|
||||||
|
<p>Il vous reste {{dVue.essaisRestant}} essais</p>
|
||||||
|
{% endif %}
|
||||||
|
{% if dVue.lettresUtilisees is defined %}
|
||||||
|
<h5>Lettres utilisées</h5>
|
||||||
|
<div>
|
||||||
|
{%for lettre in dVue.lettresUtilisees %}
|
||||||
|
{{lettre}}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<legend>Votre lettre</legend>
|
||||||
|
{% if dVueErreur|length > 0 %}
|
||||||
|
<div>
|
||||||
|
<h5>Erreur : </h5>
|
||||||
|
{% for erreur in dVueErreur %}
|
||||||
|
<p>{{erreur}}</p>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div>
|
||||||
|
<input required type="text" name="lettre">
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<input type="submit" value="Valider">
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</center>
|
||||||
|
|
||||||
|
<script src="js/bootstrap.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,49 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Pendu - Score</title>
|
||||||
|
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||||
|
<style>
|
||||||
|
p,
|
||||||
|
label {
|
||||||
|
font:
|
||||||
|
1rem 'Fira Sans',
|
||||||
|
sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
margin: 0.4rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<br><br><br>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
{% if dVue.messageScore is defined %}
|
||||||
|
<h1>{{dVue.messageScore}}</h1>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if dVue.nbTours is defined and dVue.nbFails is defined %}
|
||||||
|
<p>Vous avez fais {{dVue.nbTours}} essais et {{dVue.nbFails}} erreur(s)</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if dVue.scientifique is defined %}
|
||||||
|
<h2>Le scientifique a trouvé été {{dVue.scientifique.prenom}} {{dVue.scientifique.nom}}</h2>
|
||||||
|
<div>
|
||||||
|
<h3>Voici quelques informations à son sujet</h3>
|
||||||
|
<p>Né(e) le : {{dVue.scientifique.dateNaiss}}</p>
|
||||||
|
<p>Sexe : {{dVue.scientifique.sexe}}</p>
|
||||||
|
<p>Domaine : {{dVue.scientifique.thematique}}</p>
|
||||||
|
<p>{{dVue.scientifique.descriptif}}</p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<a href=".">Retour à l'accueil</a>
|
||||||
|
</center>
|
||||||
|
|
||||||
|
<script src="js/bootstrap.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,48 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Saisir Pseudo</title>
|
||||||
|
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||||
|
<style>
|
||||||
|
p,
|
||||||
|
label {
|
||||||
|
font:
|
||||||
|
1rem 'Fira Sans',
|
||||||
|
sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
margin: 0.4rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<br><br><br>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<p></p>
|
||||||
|
<form action="" method="post">
|
||||||
|
<fieldset>
|
||||||
|
<legend>Veuillez choisir votre pseudo</legend>
|
||||||
|
{% if dVueErreur|length > 0 %}
|
||||||
|
<div>
|
||||||
|
<h5>Erreur : </h5>
|
||||||
|
{% for erreur in dVueErreur %}
|
||||||
|
<p>{{erreur}}</p>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div>
|
||||||
|
<input required type="text" name="pseudo" id="txt_pseudo">
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<input type="submit" value="Valider">
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</center>
|
||||||
|
|
||||||
|
<script src="js/bootstrap.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1 +0,0 @@
|
|||||||
Subproject commit ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb
|
|
@ -1 +0,0 @@
|
|||||||
Subproject commit 42292d99c55abe617799667f454222c54c60e229
|
|
@ -1 +0,0 @@
|
|||||||
Subproject commit a0ce373a0ca3bf6c64b9e3e2124aca502ba39554
|
|
Loading…
Reference in new issue