Ajout Table stock_emoji pour ceux créer lors des reproductions

mathis
Mathis MOULIN 2 days ago
parent ebeeac349b
commit 9d8445d422

@ -40,23 +40,47 @@ document.addEventListener('DOMContentLoaded', () => {
} }
} }
function handleAction(type) { async function handleAction(type) {
if (selectedCards.length !== 2) { if (selectedCards.length !== 2) {
alert("Tu dois sélectionner 2 créatures."); alert("Tu dois sélectionner 2 créatures.");
return; return;
} }
const name1 = selectedCards[0].dataset.name; const id1 = selectedCards[0].dataset.id;
const name2 = selectedCards[1].dataset.name; const id2 = selectedCards[1].dataset.id;
if (type === 'reproduction') { if (type === 'reproduction') {
window.location.href = `/fusion/${encodeURIComponent(name1)}/${encodeURIComponent(name2)}`; try {
return; const response = await fetch(`/emoji/fusion/${encodeURIComponent(id1)}/${encodeURIComponent(id2)}`, {
} else if (type === 'combat') { method: 'POST',
console.log(`Combat : ${name1} contre ${name2}`); 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})`);
// Tu peux aussi mettre à jour le DOM ici avec le nouvel enfant
// ex: ajouter une carte, etc.
} catch (error) {
console.error("Erreur lors de la reproduction :", error);
alert("Une erreur est survenue lors de la reproduction.");
}
return; // on quitte ici
}
if (type === 'combat') {
console.log(`Combat : ${id1} contre ${id2}`);
} }
// Réinitialiser après l'action (seulement si pas redirigé) // Réinitialiser si pas redirection
selectedCards.forEach(card => card.classList.remove('selected')); selectedCards.forEach(card => card.classList.remove('selected'));
selectedCards = []; selectedCards = [];
updateSelectionDisplay(); updateSelectionDisplay();

@ -38,31 +38,33 @@ class PopulateDBEmojiAvailableCommand extends Command
$this->connection->executeStatement(' $this->connection->executeStatement('
CREATE TABLE stock_emoji ( CREATE TABLE stock_emoji (
id INT PRIMARY KEY, id INT PRIMARY KEY,
code VARCHAR(255) NOT NULL code VARCHAR(255) NOT NULL,
name VARCHAR(255) NOT NULL
) )
'); ');
// On peuple la table // On peuple la table
$this->connection->executeStatement("INSERT INTO stock_emoji (id, code) VALUES $this->connection->executeStatement("INSERT INTO stock_emoji (id, code, name) VALUES
(1,'🤖'), (1,'🤖','Rodolph'),
(2,'😺'), (2,'😺','Bobette'),
(3,'🧠'), (3,'🧠','Diana'),
(4,'👻'), (4,'👻','Ian'),
(5,'🧟'), (5,'🧟','Alice'),
(6,'🐶'), (6,'🐶','Eric'),
(7,'👽'), (7,'👽','Hannah'),
(8,'🧛'), (8,'🧛','Fiona'),
(9,'🎃'), (9,'🎃','George'),
(10,'🐸'), (10,'🐸','John'),
(11,'⚡'), (11,'⚡','Charlie'),
(12,'💀'), (12,'💀','Benoit'),
(13,'🔥'), (13,'🔥','Sophie'),
(14,'🧙'), (14,'🧙','Bob'),
(15,'🌪️'), (15,'🌪️','Ethan'),
(16,'😎'), (16,'😎','Luna'),
(17,'😁'), (17,'😁','Maxence'),
(18,'🌟'), (18,'🌟','Jasper'),
(19,'😈') (19,'😈','Nora')
"); ");
$output->writeln('Base de données peuplée.'); $output->writeln('Base de données peuplée.');

@ -16,6 +16,9 @@ class StockEmoji
#[ORM\Column(length: 255)] #[ORM\Column(length: 255)]
private ?string $code = null; private ?string $code = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
public function getId(): ?int public function getId(): ?int
{ {
return $this->id; return $this->id;
@ -32,4 +35,16 @@ class StockEmoji
return $this; return $this;
} }
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
} }

@ -103,5 +103,5 @@
{% endblock %} {% endblock %}
{% block javascripts %} {% block javascripts %}
<script src="{{ asset('js/home.js') }}"></script> <script src="{{ asset('js/home.js?v=1.2') }}"></script>
{% endblock %} {% endblock %}
Loading…
Cancel
Save