Tout fonction reproduction fonction en back et front

mathis
Mathis MOULIN 1 week ago
parent b7e08bb775
commit 51b56c44b3

@ -1,62 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250529204111 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->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);
}
}

@ -1,71 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250530163653 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() 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, 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);
}
}

@ -1,90 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250610074721 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->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);
}
}

@ -1,31 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250610074733 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
}
}

@ -54,51 +54,54 @@ document.addEventListener('DOMContentLoaded', () => {
const idUser = document.getElementById('user-data').dataset.userId; const idUser = document.getElementById('user-data').dataset.userId;
if (type === 'reproduction') { if (type === 'reproduction') {
try { // try {
const response = await fetch(`/emojis/fusion/${encodeURIComponent(idUser)}/${encodeURIComponent(id1)}/${encodeURIComponent(id2)}`, { // const response = await fetch(`/emojis/fusion/${encodeURIComponent(idUser)}/${encodeURIComponent(id1)}/${encodeURIComponent(id2)}`, {
method: 'GET', // method: 'GET',
headers: { // headers: {
'Accept': 'application/json' // 'Accept': 'application/json'
} // }
}); // });
if (!response.ok) { // if (!response.ok) {
throw new Error("Erreur serveur : " + response.status); // throw new Error("Erreur serveur : " + response.status);
} // }
const data = await response.json(); // const data = await response.json();
//alert(`Succès : ${data.message} (ID : ${data.childId})`); // //alert(`Succès : ${data.message} (ID : ${data.childId})`);
// Rajout de la nouvelle carte dans la collection // // Rajout de la nouvelle carte dans la collection
// const container = document.getElementById('collection-container'); // ou lid réel // // const container = document.getElementById('collection-container'); // ou lid réel
// const color = getRarityColor(data.rarity); // fonction ci-dessous // // const color = getRarityColor(data.rarity); // fonction ci-dessous
// const newCard = document.createElement('div'); // // const newCard = document.createElement('div');
// newCard.className = `emoji-card ${color}`; // // newCard.className = `emoji-card ${color}`;
// newCard.setAttribute('data-id', data.childId); // // newCard.setAttribute('data-id', data.childId);
// newCard.innerHTML = ` // // newCard.innerHTML = `
// <div class="emoji-level">Level ${data.fightsWon}</div> // // <div class="emoji-level">Level ${data.fightsWon}</div>
// <div class="emoji">${data.code}</div> // // <div class="emoji">${data.code}</div>
// <div class="emoji-name ${color}">${data.name}</div> // // <div class="emoji-name ${color}">${data.name}</div>
// <div class="detail-icon" data-id="${data.childId}"></div> // // <div class="detail-icon" data-id="${data.childId}"></div>
// <div class="detail-icon-hierarchy" data-id="${data.childId}">👨‍👩‍👧‍👦</div> // // <div class="detail-icon-hierarchy" data-id="${data.childId}">👨‍👩‍👧‍👦</div>
// <div class="popup" id="popup-${data.childId}"></div> // // <div class="popup" id="popup-${data.childId}"></div>
// <div class="popup" id="popup-hiera-${data.childId}"></div> // // <div class="popup" id="popup-hiera-${data.childId}"></div>
// `; // // `;
// container.appendChild(newCard); // // container.appendChild(newCard);
// Réinitialisation de la séléction // // Réinitialisation de la séléction
selectedCards.forEach(card => card.classList.remove('selected')); // selectedCards.forEach(card => card.classList.remove('selected'));
selectedCards = []; // selectedCards = [];
updateSelectionDisplay(); // updateSelectionDisplay();
} catch (error) {
console.error("Erreur lors de la reproduction :", error); window.location.href = `https://localhost:8000/reproduction/${encodeURIComponent(idUser)}/${encodeURIComponent(id1)}/${encodeURIComponent(id2)}`;
alert("Une erreur est survenue lors de la reproduction.");
} // } catch (error) {
// console.error("Erreur lors de la reproduction :", error);
// alert("Une erreur est survenue lors de la reproduction.");
// }
return; // on quitte ici return; // on quitte ici
} }

@ -5,59 +5,63 @@ document.addEventListener('DOMContentLoaded', () => {
const childText = document.getElementById('child-text'); const childText = document.getElementById('child-text');
const heartGif = document.getElementById('heart-gif'); 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(response => response.json())
.then(data => { .then(data => {
child_emoji=data['baby']; child_emoji=data['baby'];
left.dataset.content=data['mommy']; left.dataset.content=data['mommy'];
right.dataset.content=data['daddy']; right.dataset.content=data['daddy'];
function insertEmojiOrImage(el) { function insertEmojiOrImage(el) {
const value = el.dataset.content; const value = el.dataset.content;
console.log(value) console.log(value)
if (/^https?:\/\//.test(value)) { if (/^https?:\/\//.test(value)) {
const img = document.createElement('img'); const img = document.createElement('img');
img.src = value; img.src = value;
img.className = 'emoji-img'; img.className = 'emoji-img';
el.appendChild(img); el.appendChild(img);
} else { } else {
el.textContent = value; el.textContent = value;
}
} }
}
insertEmojiOrImage(left); insertEmojiOrImage(left);
insertEmojiOrImage(right); insertEmojiOrImage(right);
left.classList.add('slide-in-left'); left.classList.add('slide-in-left');
right.classList.add('slide-in-right'); right.classList.add('slide-in-right');
setTimeout(() => { setTimeout(() => {
if (/^https?:\/\//.test(child_emoji)) { if (/^https?:\/\//.test(child_emoji)) {
emojiHtml = ` emojiHtml = `
<div class="emoji-glow-img"> <div class="emoji-glow-img">
<img src="${child_emoji}" style="width:64px; height:64px"> <img src="${child_emoji}" style="width:64px; height:64px">
</div>`;
} else {
emojiHtml = `
<span class="emoji-glow-text" data-emoji="${child_emoji}">${child_emoji}</span>`;
}
childText.innerHTML = `
<div class="emoji-wrapper">
${emojiHtml}
</div>`; </div>`;
} else { childText.classList.add('growing-animation');
emojiHtml = ` childText.style.display = 'block';
<span class="emoji-glow-text" data-emoji="${child_emoji}">${child_emoji}</span>`; heartGif.style.display = 'block';
} heartGif.classList.add('fade-in');
}, 3000);
})
.catch(error => {
console.error('Erreur:', error);
});
childText.innerHTML = ` document.getElementById('btn-retour').addEventListener('click', () => {
<div class="emoji-wrapper"> window.location.href = `https://localhost:8000/`;
${emojiHtml}
</div>`;
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);
}); });
}); });

@ -151,4 +151,29 @@ body {
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: 100% 100%; background-size: 100% 100%;
z-index: -1; 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 quil soit toujours au-dessus */
}
.btn-retour:hover {
transform: translateX(-50%) scale(1.05);
background-color: #e0d1b3;
} }

@ -194,7 +194,9 @@ class EmojiController extends AbstractController
return new JsonResponse([ return new JsonResponse([
'message' => 'Child created', 'message' => 'Child created',
'childId' => $child->getId() 'mommy' => $child->getParent1()->getCode(),
'daddy' => $child->getParent2()->getCode(),
'baby' => $child->getCode()
]); ]);
} }

@ -23,11 +23,12 @@ class ReproductionController extends AbstractController
// ]); // ]);
// } // }
#[Route('/reproduction/{id1}/{id2}', name: 'app_reproduction_with_params')] #[Route('/reproduction/{idUser}/{id1}/{id2}', name: 'app_reproduction_with_params')]
public function reproductionWithParams(int $id1, int $id2): Response public function reproductionWithParams(int $idUser, int $id1, int $id2): Response
{ {
return $this->render('reproduction/index.html.twig', [ return $this->render('reproduction/index.html.twig', [
'idUser' => $idUser,
'left_emoji' => $id1, 'left_emoji' => $id1,
'right_emoji' => $id2, 'right_emoji' => $id2,
]); ]);

@ -175,5 +175,5 @@
{% endblock %} {% endblock %}
{% block javascripts %} {% block javascripts %}
<script src="{{ asset('js/home.js?v=1.4') }}"></script> <script src="{{ asset('js/home.js?v=1.8') }}"></script>
{% endblock %} {% endblock %}

@ -4,22 +4,28 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Emoji Reproduction</title> <title>Emoji Reproduction</title>
<link rel="stylesheet" href="{{ asset('style/reproduction.css') }}" /> <link rel="stylesheet" href="{{ asset('style/reproduction.css?v=1.7') }}" />
</head> </head>
<body> <body>
<div class="field"> <div class="field">
<div class="emoji left-emoji"></div> <div class="emoji left-emoji"></div>
<div class="emoji right-emoji"></div> <div class="emoji right-emoji"></div>
</div> </div>
<div id="child-text"></div> <div id="child-text"></div>
<div id="heart-gif"></div> <div id="heart-gif"></div>
<script>
id_left={{ left_emoji }};
id_right={{ right_emoji }};
</script>
<script src="{{ asset('script/reproduction.js') }}"></script> <div>
<button id="btn-retour" class="btn-retour">🏠 Retour à la collection</button>
</div>
</body> <script>
id_user={{ idUser }};
id_left={{ left_emoji }};
id_right={{ right_emoji }};
</script>
<script src="{{ asset('script/reproduction.js?v=1.5') }}"></script>
</body>
</html> </html>

Loading…
Cancel
Save