Ajout Table stock_emoji pour ceux créer lors des reproductions

mathis
Mathis MOULIN 13 hours ago
parent ebeeac349b
commit 9d8445d422

@ -40,23 +40,47 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
function handleAction(type) {
async function handleAction(type) {
if (selectedCards.length !== 2) {
alert("Tu dois sélectionner 2 créatures.");
return;
}
const name1 = selectedCards[0].dataset.name;
const name2 = selectedCards[1].dataset.name;
const id1 = selectedCards[0].dataset.id;
const id2 = selectedCards[1].dataset.id;
if (type === 'reproduction') {
window.location.href = `/fusion/${encodeURIComponent(name1)}/${encodeURIComponent(name2)}`;
return;
} else if (type === 'combat') {
console.log(`Combat : ${name1} contre ${name2}`);
try {
const response = await fetch(`/emoji/fusion/${encodeURIComponent(id1)}/${encodeURIComponent(id2)}`, {
method: 'POST',
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 = [];
updateSelectionDisplay();

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

@ -16,6 +16,9 @@ class StockEmoji
#[ORM\Column(length: 255)]
private ?string $code = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
public function getId(): ?int
{
return $this->id;
@ -32,4 +35,16 @@ class StockEmoji
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 %}
{% block javascripts %}
<script src="{{ asset('js/home.js') }}"></script>
<script src="{{ asset('js/home.js?v=1.2') }}"></script>
{% endblock %}
Loading…
Cancel
Save