diff --git a/migrations/Version20250529204111.php b/migrations/Version20250529204111.php deleted file mode 100644 index 40ae60a..0000000 --- a/migrations/Version20250529204111.php +++ /dev/null @@ -1,62 +0,0 @@ -addSql(<<<'SQL' - CREATE TEMPORARY TABLE __temp__emoji AS SELECT id, nom, code, intelligence FROM emoji - SQL); - $this->addSql(<<<'SQL' - DROP TABLE emoji - SQL); - $this->addSql(<<<'SQL' - CREATE TABLE emoji (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, rarity_id INTEGER NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, intelligence DOUBLE PRECISION NOT NULL, strength DOUBLE PRECISION NOT NULL, toughness DOUBLE PRECISION NOT NULL, speed DOUBLE PRECISION NOT NULL, fights_won INTEGER NOT NULL, CONSTRAINT FK_B64BF632F3747573 FOREIGN KEY (rarity_id) REFERENCES rarity (id) NOT DEFERRABLE INITIALLY IMMEDIATE) - SQL); - $this->addSql(<<<'SQL' - INSERT INTO emoji (id, name, code, intelligence) SELECT id, nom, code, intelligence FROM __temp__emoji - SQL); - $this->addSql(<<<'SQL' - DROP TABLE __temp__emoji - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_B64BF632F3747573 ON emoji (rarity_id) - SQL); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql(<<<'SQL' - CREATE TEMPORARY TABLE __temp__emoji AS SELECT id, name, code, intelligence FROM emoji - SQL); - $this->addSql(<<<'SQL' - DROP TABLE emoji - SQL); - $this->addSql(<<<'SQL' - CREATE TABLE emoji (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nom VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, intelligence DOUBLE PRECISION NOT NULL, force DOUBLE PRECISION NOT NULL, robustesse DOUBLE PRECISION NOT NULL, vitesse DOUBLE PRECISION NOT NULL, nb_combat_gagne INTEGER NOT NULL, rarete INTEGER NOT NULL) - SQL); - $this->addSql(<<<'SQL' - INSERT INTO emoji (id, nom, code, intelligence) SELECT id, name, code, intelligence FROM __temp__emoji - SQL); - $this->addSql(<<<'SQL' - DROP TABLE __temp__emoji - SQL); - } -} diff --git a/migrations/Version20250530163653.php b/migrations/Version20250530163653.php deleted file mode 100644 index 938c369..0000000 --- a/migrations/Version20250530163653.php +++ /dev/null @@ -1,71 +0,0 @@ -addSql(<<<'SQL' - CREATE TEMPORARY TABLE __temp__emoji AS SELECT id, rarity_id, name, code, intelligence, strength, toughness, speed, fights_won FROM emoji - SQL); - $this->addSql(<<<'SQL' - DROP TABLE emoji - SQL); - $this->addSql(<<<'SQL' - CREATE TABLE emoji (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, rarity_id INTEGER NOT NULL, parent1_id INTEGER DEFAULT NULL, parent2_id INTEGER DEFAULT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, intelligence DOUBLE PRECISION NOT NULL, strength DOUBLE PRECISION NOT NULL, toughness DOUBLE PRECISION NOT NULL, speed DOUBLE PRECISION NOT NULL, fights_won INTEGER NOT NULL, CONSTRAINT FK_B64BF632F3747573 FOREIGN KEY (rarity_id) REFERENCES rarity (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_B64BF632861B2665 FOREIGN KEY (parent1_id) REFERENCES emoji (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_B64BF63294AE898B FOREIGN KEY (parent2_id) REFERENCES emoji (id) NOT DEFERRABLE INITIALLY IMMEDIATE) - SQL); - $this->addSql(<<<'SQL' - INSERT INTO emoji (id, rarity_id, name, code, intelligence, strength, toughness, speed, fights_won) SELECT id, rarity_id, name, code, intelligence, strength, toughness, speed, fights_won FROM __temp__emoji - SQL); - $this->addSql(<<<'SQL' - DROP TABLE __temp__emoji - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_B64BF632F3747573 ON emoji (rarity_id) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_B64BF632861B2665 ON emoji (parent1_id) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_B64BF63294AE898B ON emoji (parent2_id) - SQL); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql(<<<'SQL' - CREATE TEMPORARY TABLE __temp__emoji AS SELECT id, rarity_id, name, code, strength, toughness, intelligence, speed, fights_won FROM emoji - SQL); - $this->addSql(<<<'SQL' - DROP TABLE emoji - SQL); - $this->addSql(<<<'SQL' - CREATE TABLE emoji (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, rarity_id INTEGER NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, strength DOUBLE PRECISION NOT NULL, toughness DOUBLE PRECISION NOT NULL, intelligence DOUBLE PRECISION NOT NULL, speed DOUBLE PRECISION NOT NULL, fights_won INTEGER NOT NULL, CONSTRAINT FK_B64BF632F3747573 FOREIGN KEY (rarity_id) REFERENCES rarity (id) NOT DEFERRABLE INITIALLY IMMEDIATE) - SQL); - $this->addSql(<<<'SQL' - INSERT INTO emoji (id, rarity_id, name, code, strength, toughness, intelligence, speed, fights_won) SELECT id, rarity_id, name, code, strength, toughness, intelligence, speed, fights_won FROM __temp__emoji - SQL); - $this->addSql(<<<'SQL' - DROP TABLE __temp__emoji - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_B64BF632F3747573 ON emoji (rarity_id) - SQL); - } -} diff --git a/migrations/Version20250610074721.php b/migrations/Version20250610074721.php deleted file mode 100644 index e2b9c07..0000000 --- a/migrations/Version20250610074721.php +++ /dev/null @@ -1,90 +0,0 @@ -addSql(<<<'SQL' - CREATE TABLE stock_emoji (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, code VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL) - SQL); - $this->addSql(<<<'SQL' - CREATE TABLE user (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, username VARCHAR(180) NOT NULL, roles CLOB NOT NULL --(DC2Type:json) - , password VARCHAR(255) NOT NULL) - SQL); - $this->addSql(<<<'SQL' - CREATE UNIQUE INDEX UNIQ_8D93D649F85E0677 ON user (username) - SQL); - $this->addSql(<<<'SQL' - CREATE TABLE posseder (user_id INTEGER NOT NULL, emoji_id INTEGER NOT NULL, PRIMARY KEY(user_id, emoji_id), CONSTRAINT FK_62EF7CBAA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_62EF7CBAE2462A5B FOREIGN KEY (emoji_id) REFERENCES emoji (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_62EF7CBAA76ED395 ON posseder (user_id) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_62EF7CBAE2462A5B ON posseder (emoji_id) - SQL); - $this->addSql(<<<'SQL' - CREATE TEMPORARY TABLE __temp__rarity AS SELECT id, name, drop_rate FROM rarity - SQL); - $this->addSql(<<<'SQL' - DROP TABLE rarity - SQL); - $this->addSql(<<<'SQL' - CREATE TABLE rarity (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name VARCHAR(50) NOT NULL, drop_rate DOUBLE PRECISION NOT NULL) - SQL); - $this->addSql(<<<'SQL' - INSERT INTO rarity (id, name, drop_rate) SELECT id, name, drop_rate FROM __temp__rarity - SQL); - $this->addSql(<<<'SQL' - DROP TABLE __temp__rarity - SQL); - $this->addSql(<<<'SQL' - CREATE UNIQUE INDEX UNIQ_B7C0BE465E237E06 ON rarity (name) - SQL); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql(<<<'SQL' - DROP TABLE stock_emoji - SQL); - $this->addSql(<<<'SQL' - DROP TABLE user - SQL); - $this->addSql(<<<'SQL' - DROP TABLE posseder - SQL); - $this->addSql(<<<'SQL' - CREATE TEMPORARY TABLE __temp__rarity AS SELECT id, name, drop_rate FROM rarity - SQL); - $this->addSql(<<<'SQL' - DROP TABLE rarity - SQL); - $this->addSql(<<<'SQL' - CREATE TABLE rarity (id INTEGER DEFAULT NULL, name VARCHAR(255) NOT NULL, drop_rate DOUBLE PRECISION NOT NULL, PRIMARY KEY(id)) - SQL); - $this->addSql(<<<'SQL' - INSERT INTO rarity (id, name, drop_rate) SELECT id, name, drop_rate FROM __temp__rarity - SQL); - $this->addSql(<<<'SQL' - DROP TABLE __temp__rarity - SQL); - } -} diff --git a/migrations/Version20250610074733.php b/migrations/Version20250610074733.php deleted file mode 100644 index e631119..0000000 --- a/migrations/Version20250610074733.php +++ /dev/null @@ -1,31 +0,0 @@ - { const idUser = document.getElementById('user-data').dataset.userId; if (type === 'reproduction') { - try { - const response = await fetch(`/emojis/fusion/${encodeURIComponent(idUser)}/${encodeURIComponent(id1)}/${encodeURIComponent(id2)}`, { - method: 'GET', - headers: { - 'Accept': 'application/json' - } - }); - - if (!response.ok) { - throw new Error("Erreur serveur : " + response.status); - } - - const data = await response.json(); - - //alert(`Succès : ${data.message} (ID : ${data.childId})`); - - // Rajout de la nouvelle carte dans la collection - // const container = document.getElementById('collection-container'); // ou l’id réel - - // const color = getRarityColor(data.rarity); // fonction ci-dessous - - // const newCard = document.createElement('div'); - // newCard.className = `emoji-card ${color}`; - // newCard.setAttribute('data-id', data.childId); - // newCard.innerHTML = ` - //
Level ${data.fightsWon}
- //
${data.code}
- //
${data.name}
- //
ℹ️
- //
👨‍👩‍👧‍👦
- // - // - // `; - - // container.appendChild(newCard); - - - // Réinitialisation de la séléction - selectedCards.forEach(card => card.classList.remove('selected')); - selectedCards = []; - updateSelectionDisplay(); - } catch (error) { - console.error("Erreur lors de la reproduction :", error); - alert("Une erreur est survenue lors de la reproduction."); - } + // try { + // const response = await fetch(`/emojis/fusion/${encodeURIComponent(idUser)}/${encodeURIComponent(id1)}/${encodeURIComponent(id2)}`, { + // method: 'GET', + // headers: { + // 'Accept': 'application/json' + // } + // }); + + // if (!response.ok) { + // throw new Error("Erreur serveur : " + response.status); + // } + + // const data = await response.json(); + + // //alert(`Succès : ${data.message} (ID : ${data.childId})`); + + // // Rajout de la nouvelle carte dans la collection + // // const container = document.getElementById('collection-container'); // ou l’id réel + + // // const color = getRarityColor(data.rarity); // fonction ci-dessous + + // // const newCard = document.createElement('div'); + // // newCard.className = `emoji-card ${color}`; + // // newCard.setAttribute('data-id', data.childId); + // // newCard.innerHTML = ` + // //
Level ${data.fightsWon}
+ // //
${data.code}
+ // //
${data.name}
+ // //
ℹ️
+ // //
👨‍👩‍👧‍👦
+ // // + // // + // // `; + + // // container.appendChild(newCard); + + + // // Réinitialisation de la séléction + // selectedCards.forEach(card => card.classList.remove('selected')); + // selectedCards = []; + // updateSelectionDisplay(); + + window.location.href = `https://localhost:8000/reproduction/${encodeURIComponent(idUser)}/${encodeURIComponent(id1)}/${encodeURIComponent(id2)}`; + + // } catch (error) { + // console.error("Erreur lors de la reproduction :", error); + // alert("Une erreur est survenue lors de la reproduction."); + // } return; // on quitte ici } diff --git a/public/script/reproduction.js b/public/script/reproduction.js index 218f8d3..b1b0fc5 100644 --- a/public/script/reproduction.js +++ b/public/script/reproduction.js @@ -5,59 +5,63 @@ document.addEventListener('DOMContentLoaded', () => { const childText = document.getElementById('child-text'); const heartGif = document.getElementById('heart-gif'); - fetch(`http://localhost:8000/emojis/fusion/${id_left}/${id_right}`) + fetch(`https://localhost:8000/emojis/fusion/${id_user}/${id_left}/${id_right}`) .then(response => response.json()) .then(data => { child_emoji=data['baby']; left.dataset.content=data['mommy']; right.dataset.content=data['daddy']; - function insertEmojiOrImage(el) { - const value = el.dataset.content; - console.log(value) - if (/^https?:\/\//.test(value)) { - const img = document.createElement('img'); - img.src = value; - img.className = 'emoji-img'; - el.appendChild(img); - } else { - el.textContent = value; + function insertEmojiOrImage(el) { + const value = el.dataset.content; + console.log(value) + if (/^https?:\/\//.test(value)) { + const img = document.createElement('img'); + img.src = value; + img.className = 'emoji-img'; + el.appendChild(img); + } else { + el.textContent = value; + } } - } - insertEmojiOrImage(left); - insertEmojiOrImage(right); + insertEmojiOrImage(left); + insertEmojiOrImage(right); - left.classList.add('slide-in-left'); - right.classList.add('slide-in-right'); + left.classList.add('slide-in-left'); + right.classList.add('slide-in-right'); - setTimeout(() => { - + setTimeout(() => { + - if (/^https?:\/\//.test(child_emoji)) { - emojiHtml = ` -
- + if (/^https?:\/\//.test(child_emoji)) { + emojiHtml = ` +
+ +
`; + } else { + emojiHtml = ` + ${child_emoji}`; + } + + childText.innerHTML = ` +
+ ${emojiHtml} +
`; - } else { - emojiHtml = ` - ${child_emoji}`; - } + childText.classList.add('growing-animation'); + childText.style.display = 'block'; + heartGif.style.display = 'block'; + heartGif.classList.add('fade-in'); + + + }, 3000); + }) + .catch(error => { + console.error('Erreur:', error); + }); - childText.innerHTML = ` -
- ${emojiHtml} - -
`; - childText.classList.add('growing-animation'); - childText.style.display = 'block'; - heartGif.style.display = 'block'; - heartGif.classList.add('fade-in'); - - - }, 3000); - }) - .catch(error => { - console.error('Erreur:', error); + document.getElementById('btn-retour').addEventListener('click', () => { + window.location.href = `https://localhost:8000/`; }); -}); +}); \ No newline at end of file diff --git a/public/style/reproduction.css b/public/style/reproduction.css index f24658d..81eee5e 100644 --- a/public/style/reproduction.css +++ b/public/style/reproduction.css @@ -151,4 +151,29 @@ body { background-repeat: no-repeat; background-size: 100% 100%; z-index: -1; +} + +/* Bouton de retour */ + +.btn-retour { + position: absolute; + top: 20px; + left: 50%; + transform: translateX(-50%); + + padding: 10px 25px; + font-size: 1.1rem; + font-weight: bold; + background-color: #f2e6c9; + border: 2px solid #000; + border-radius: 8px; + cursor: pointer; + box-shadow: 2px 2px 0 #000; + transition: transform 0.2s ease; + z-index: 9999; /* pour qu’il soit toujours au-dessus */ +} + +.btn-retour:hover { + transform: translateX(-50%) scale(1.05); + background-color: #e0d1b3; } \ No newline at end of file diff --git a/src/Controller/EmojiController.php b/src/Controller/EmojiController.php index 9de8891..a6f08bd 100644 --- a/src/Controller/EmojiController.php +++ b/src/Controller/EmojiController.php @@ -194,7 +194,9 @@ class EmojiController extends AbstractController return new JsonResponse([ 'message' => 'Child created', - 'childId' => $child->getId() + 'mommy' => $child->getParent1()->getCode(), + 'daddy' => $child->getParent2()->getCode(), + 'baby' => $child->getCode() ]); } diff --git a/src/Controller/ReproductionController.php b/src/Controller/ReproductionController.php index 876b6d6..762f936 100644 --- a/src/Controller/ReproductionController.php +++ b/src/Controller/ReproductionController.php @@ -23,11 +23,12 @@ class ReproductionController extends AbstractController // ]); // } - #[Route('/reproduction/{id1}/{id2}', name: 'app_reproduction_with_params')] - public function reproductionWithParams(int $id1, int $id2): Response + #[Route('/reproduction/{idUser}/{id1}/{id2}', name: 'app_reproduction_with_params')] + public function reproductionWithParams(int $idUser, int $id1, int $id2): Response { return $this->render('reproduction/index.html.twig', [ + 'idUser' => $idUser, 'left_emoji' => $id1, 'right_emoji' => $id2, ]); diff --git a/templates/home/index.html.twig b/templates/home/index.html.twig index 099ad8e..70ca18e 100644 --- a/templates/home/index.html.twig +++ b/templates/home/index.html.twig @@ -175,5 +175,5 @@ {% endblock %} {% block javascripts %} - + {% endblock %} \ No newline at end of file diff --git a/templates/reproduction/index.html.twig b/templates/reproduction/index.html.twig index 2cdefc4..7749091 100644 --- a/templates/reproduction/index.html.twig +++ b/templates/reproduction/index.html.twig @@ -4,22 +4,28 @@ Emoji Reproduction - + - + -
-
-
-
-
-
- +
+
+
+
+
+
- +
+ +
- + + + + +