Ajout Front Jade v1 WIP

mathis
Mathis MOULIN 2 weeks ago
commit d0bdb9c067

@ -20,3 +20,6 @@ APP_SECRET=e10d1768cebd3187e908e91448a3086a
###< symfony/framework-bundle ###
MESSENGER_TRANSPORT_DSN=sync://
DATABASE_URL="sqlite:///%kernel.project_dir%/var/app.db"
###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$'
###< nelmio/cors-bundle ###

287
composer.lock generated

@ -4,8 +4,175 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "a904471bc7e1136f2c1810044504fcc9",
"content-hash": "e4da0873e331d870ab5d4a8fce5d1fc4",
"packages": [
{
"name": "api-platform/core",
"version": "v3.2.26",
"source": {
"type": "git",
"url": "https://github.com/api-platform/core.git",
"reference": "9edacabcfff3a62c29325e1e91af3269850954cb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/api-platform/core/zipball/9edacabcfff3a62c29325e1e91af3269850954cb",
"reference": "9edacabcfff3a62c29325e1e91af3269850954cb",
"shasum": ""
},
"require": {
"doctrine/inflector": "^1.0 || ^2.0",
"php": ">=8.1",
"psr/cache": "^1.0 || ^2.0 || ^3.0",
"psr/container": "^1.0 || ^2.0",
"symfony/deprecation-contracts": "^3.1",
"symfony/http-foundation": "^6.1 || ^7.0",
"symfony/http-kernel": "^6.1 || ^7.0",
"symfony/property-access": "^6.1 || ^7.0",
"symfony/property-info": "^6.1 || ^7.0",
"symfony/serializer": "^6.1 || ^7.0",
"symfony/translation-contracts": "^3.3",
"symfony/web-link": "^6.1 || ^7.0",
"willdurand/negotiation": "^3.0"
},
"conflict": {
"doctrine/common": "<3.2.2",
"doctrine/dbal": "<2.10",
"doctrine/mongodb-odm": "<2.4",
"doctrine/orm": "<2.14.0",
"doctrine/persistence": "<1.3",
"elasticsearch/elasticsearch": ">=8.0,<8.4",
"phpspec/prophecy": "<1.15",
"phpunit/phpunit": "<9.5",
"symfony/framework-bundle": "6.4.6 || 7.0.6",
"symfony/var-exporter": "<6.1.1"
},
"require-dev": {
"behat/behat": "^3.11",
"behat/mink": "^1.9",
"doctrine/cache": "^1.11 || ^2.1",
"doctrine/common": "^3.2.2",
"doctrine/dbal": "^3.4.0",
"doctrine/doctrine-bundle": "^1.12 || ^2.0",
"doctrine/mongodb-odm": "^2.2",
"doctrine/mongodb-odm-bundle": "^4.0 || ^5.0",
"doctrine/orm": "^2.14 || ^3.0",
"elasticsearch/elasticsearch": "^7.11 || ^8.4",
"friends-of-behat/mink-browserkit-driver": "^1.3.1",
"friends-of-behat/mink-extension": "^2.2",
"friends-of-behat/symfony-extension": "^2.1",
"guzzlehttp/guzzle": "^6.0 || ^7.0",
"jangregor/phpstan-prophecy": "^1.0",
"justinrainbow/json-schema": "^5.2.1",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpdoc-parser": "^1.13",
"phpstan/phpstan": "^1.1",
"phpstan/phpstan-doctrine": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-symfony": "^1.0",
"phpunit/phpunit": "^9.5",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"ramsey/uuid": "^3.9.7 || ^4.0",
"ramsey/uuid-doctrine": "^1.4 || ^2.0",
"sebastian/comparator": "<5.0",
"soyuka/contexts": "v3.3.9",
"soyuka/stubs-mongodb": "^1.0",
"symfony/asset": "^6.1 || ^7.0",
"symfony/browser-kit": "^6.1 || ^7.0",
"symfony/cache": "^6.1 || ^7.0",
"symfony/config": "^6.1 || ^7.0",
"symfony/console": "^6.1 || ^7.0",
"symfony/css-selector": "^6.1 || ^7.0",
"symfony/dependency-injection": "^6.1 || ^7.0.12",
"symfony/doctrine-bridge": "^6.1 || ^7.0",
"symfony/dom-crawler": "^6.1 || ^7.0",
"symfony/error-handler": "^6.1 || ^7.0",
"symfony/event-dispatcher": "^6.1 || ^7.0",
"symfony/expression-language": "^6.1 || ^7.0",
"symfony/finder": "^6.1 || ^7.0",
"symfony/form": "^6.1 || ^7.0",
"symfony/framework-bundle": "^6.1 || ^7.0",
"symfony/http-client": "^6.1 || ^7.0",
"symfony/intl": "^6.1 || ^7.0",
"symfony/maker-bundle": "^1.24",
"symfony/mercure-bundle": "*",
"symfony/messenger": "^6.1 || ^7.0",
"symfony/phpunit-bridge": "^6.1 || ^7.0",
"symfony/routing": "^6.1 || ^7.0",
"symfony/security-bundle": "^6.1 || ^7.0",
"symfony/security-core": "^6.1 || ^7.0",
"symfony/stopwatch": "^6.1 || ^7.0",
"symfony/twig-bundle": "^6.1 || ^7.0",
"symfony/uid": "^6.1 || ^7.0",
"symfony/validator": "^6.1 || ^7.0",
"symfony/web-profiler-bundle": "^6.1 || ^7.0",
"symfony/yaml": "^6.1 || ^7.0",
"twig/twig": "^1.42.3 || ^2.12 || ^3.0",
"webonyx/graphql-php": "^14.0 || ^15.0"
},
"suggest": {
"doctrine/mongodb-odm-bundle": "To support MongoDB. Only versions 4.0 and later are supported.",
"elasticsearch/elasticsearch": "To support Elasticsearch.",
"ocramius/package-versions": "To display the API Platform's version in the debug bar.",
"phpstan/phpdoc-parser": "To support extracting metadata from PHPDoc.",
"psr/cache-implementation": "To use metadata caching.",
"ramsey/uuid": "To support Ramsey's UUID identifiers.",
"symfony/cache": "To have metadata caching when using Symfony integration.",
"symfony/config": "To load XML configuration files.",
"symfony/expression-language": "To use authorization features.",
"symfony/http-client": "To use the HTTP cache invalidation system.",
"symfony/messenger": "To support messenger integration.",
"symfony/security": "To use authorization features.",
"symfony/twig-bundle": "To use the Swagger UI integration.",
"symfony/uid": "To support Symfony UUID/ULID identifiers.",
"symfony/web-profiler-bundle": "To use the data collector.",
"webonyx/graphql-php": "To support GraphQL."
},
"type": "library",
"extra": {
"symfony": {
"require": "^6.1 || ^7.0"
},
"branch-alias": {
"dev-main": "3.3.x-dev"
}
},
"autoload": {
"psr-4": {
"ApiPlatform\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Kévin Dunglas",
"email": "kevin@dunglas.fr",
"homepage": "https://dunglas.fr"
}
],
"description": "Build a fully-featured hypermedia or GraphQL API in minutes!",
"homepage": "https://api-platform.com",
"keywords": [
"Hydra",
"JSON-LD",
"api",
"graphql",
"hal",
"jsonapi",
"openapi",
"rest",
"swagger"
],
"support": {
"issues": "https://github.com/api-platform/core/issues",
"source": "https://github.com/api-platform/core/tree/v3.2.26"
},
"time": "2024-07-19T15:06:38+00:00"
},
{
"name": "doctrine/cache",
"version": "2.2.0",
@ -1392,6 +1559,68 @@
],
"time": "2025-03-24T10:02:05+00:00"
},
{
"name": "nelmio/cors-bundle",
"version": "2.5.0",
"source": {
"type": "git",
"url": "https://github.com/nelmio/NelmioCorsBundle.git",
"reference": "3a526fe025cd20e04a6a11370cf5ab28dbb5a544"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nelmio/NelmioCorsBundle/zipball/3a526fe025cd20e04a6a11370cf5ab28dbb5a544",
"reference": "3a526fe025cd20e04a6a11370cf5ab28dbb5a544",
"shasum": ""
},
"require": {
"psr/log": "^1.0 || ^2.0 || ^3.0",
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
"mockery/mockery": "^1.3.6",
"symfony/phpunit-bridge": "^5.4 || ^6.0 || ^7.0"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"Nelmio\\CorsBundle\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nelmio",
"homepage": "http://nelm.io"
},
{
"name": "Symfony Community",
"homepage": "https://github.com/nelmio/NelmioCorsBundle/contributors"
}
],
"description": "Adds CORS (Cross-Origin Resource Sharing) headers support in your Symfony application",
"keywords": [
"api",
"cors",
"crossdomain"
],
"support": {
"issues": "https://github.com/nelmio/NelmioCorsBundle/issues",
"source": "https://github.com/nelmio/NelmioCorsBundle/tree/2.5.0"
},
"time": "2024-06-24T21:25:28+00:00"
},
{
"name": "phpdocumentor/reflection-common",
"version": "2.2.0",
@ -6913,6 +7142,62 @@
"source": "https://github.com/webmozarts/assert/tree/1.11.0"
},
"time": "2022-06-03T18:03:27+00:00"
},
{
"name": "willdurand/negotiation",
"version": "3.1.0",
"source": {
"type": "git",
"url": "https://github.com/willdurand/Negotiation.git",
"reference": "68e9ea0553ef6e2ee8db5c1d98829f111e623ec2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/willdurand/Negotiation/zipball/68e9ea0553ef6e2ee8db5c1d98829f111e623ec2",
"reference": "68e9ea0553ef6e2ee8db5c1d98829f111e623ec2",
"shasum": ""
},
"require": {
"php": ">=7.1.0"
},
"require-dev": {
"symfony/phpunit-bridge": "^5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"psr-4": {
"Negotiation\\": "src/Negotiation"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "William Durand",
"email": "will+git@drnd.me"
}
],
"description": "Content Negotiation tools for PHP provided as a standalone library.",
"homepage": "http://williamdurand.fr/Negotiation/",
"keywords": [
"accept",
"content",
"format",
"header",
"negotiation"
],
"support": {
"issues": "https://github.com/willdurand/Negotiation/issues",
"source": "https://github.com/willdurand/Negotiation/tree/3.1.0"
},
"time": "2022-01-30T20:08:53+00:00"
}
],
"packages-dev": [

@ -11,4 +11,6 @@ return [
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
];

@ -1,6 +1,6 @@
# see https://symfony.com/doc/current/reference/configuration/framework.html
framework:
secret: '%env(APP_SECRET)%'
secret: "%env(APP_SECRET)%"
#csrf_protection: true
http_method_override: false

@ -0,0 +1,62 @@
<?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);
}
}

@ -0,0 +1,71 @@
<?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);
}
}

@ -0,0 +1,90 @@
<?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);
}
}

@ -0,0 +1,31 @@
<?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
}
}

@ -1,5 +1,7 @@
document.addEventListener('DOMContentLoaded', () => {
// Copie tout ici
let selectedCards = [];
function toggleSelection(card) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

@ -3,20 +3,16 @@ document.addEventListener('DOMContentLoaded', () => {
const right = document.querySelector('.right-emoji');
const winnerText = document.getElementById('winner-text');
const winnerSide = window.winnerSide;
const loserSide = window.loserSide;
fetch(`localhost:8000/emojis/fight/${id1}/${id2}`)
.then(response => response.json())
.then(data => {
const { leftEmoji, rightEmoji, winner } = data;
function insertEmojiOrImage(el) {
const value = el.dataset.content;
if (/^https?:\/\//.test(value)) {
const img = document.createElement('img');
img.src = value;
img.className = 'emoji-img';
el.appendChild(img);
} else {
el.textContent = value;
}
}
left.dataset.content = leftEmoji;
right.dataset.content = rightEmoji;
window.winnerSide = winner === 'left' ? 'left' : 'right';
window.loserSide = winner === 'left' ? 'right' : 'left';
insertEmojiOrImage(left);
insertEmojiOrImage(right);
@ -35,20 +31,31 @@ document.addEventListener('DOMContentLoaded', () => {
left.classList.remove('fight-animation');
right.classList.remove('fight-animation');
const loser = loserSide === 'left' ? left : right;
const loser = window.loserSide === 'left' ? left : right;
loser.classList.add('loser-fly-up');
const winner = winnerSide === 'left' ? left : right;
winner.classList.add('winner-center', 'winner-crown');
const winnerEl = window.winnerSide === 'left' ? left : right;
winnerEl.classList.add('winner-center', 'winner-crown');
let name = winner.dataset.content;
//check if name is an image URL or an emoji
let name = winnerEl.dataset.content;
if (/^https?:\/\//.test(name)) {
winnerText.innerHTML = `<img src="${name}" style="width:64px">a gagné ! 🎉`;
}
else {
} else {
winnerText.textContent = `${name} a gagné ! 🎉`;
}
winnerText.style.display = 'block';
}, 1500);
}, 3000);
});
function insertEmojiOrImage(el) {
const value = el.dataset.content;
if (/^https?:\/\//.test(value)) {
const img = document.createElement('img');
img.src = value;
img.className = 'emoji-img';
el.appendChild(img);
} else {
el.textContent = value;
}
}
});

@ -1,12 +1,19 @@
document.addEventListener('DOMContentLoaded', () => {
const left = document.querySelector('.left-emoji');
const right = document.querySelector('.right-emoji');
const childText = document.getElementById('child-text');
const heartGif = document.getElementById('heart-gif');
fetch(`http://localhost:8000/emojis/fusion/${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;
@ -49,4 +56,8 @@ document.addEventListener('DOMContentLoaded', () => {
}, 3000);
})
.catch(error => {
console.error('Erreur:', error);
});
});

@ -31,26 +31,14 @@ class CombatController extends AbstractController
return preg_match($emojiRegex, $str) === 1 && mb_strlen($str, 'UTF-8') === 1;
}
#[Route('/combat-{leftEmoji}-{rightEmoji}-{winner}', name: 'app_combat_with_params', requirements: ['leftEmoji' => '.+', 'rightEmoji' => '.+'])]
public function combatWithParams(string $leftEmoji, string $rightEmoji, string $winner): Response
#[Route('/combat/{idLeft}/{idRight}', name: 'app_combat_with_params', requirements: ['leftEmoji' => '.+', 'rightEmoji' => '.+'])]
public function combatWithParams(string $idLeft, string $idRight): Response
// Example : /combat-🐱-🐶-left
// or /combat-🐌_☀%EF%B8%8F-🐌_☀%EF%B8%8F-left
{
$loser = ($winner === 'left') ? 'right' : 'left';
// Validate emoji
if (!$this->isEmoji($leftEmoji)) {
$leftEmoji = 'https://emojik.vercel.app/s/' . $leftEmoji;
}
if (!$this->isEmoji($rightEmoji)) {
$rightEmoji = 'https://emojik.vercel.app/s/' . $rightEmoji;
}
return $this->render('combat/index.html.twig', [
'left_emoji' => $leftEmoji,
'right_emoji' => $rightEmoji,
'winner' => $winner,
'loser' => $loser,
'idLeft' => $idLeft,
'idRight' => $idRight,
]);
}

@ -8,18 +8,29 @@ use Symfony\Component\Routing\Annotation\Route;
class ReproductionController extends AbstractController
{
#[Route('/reproduction', name: 'app_reproduction')]
public function index(): Response
// #[Route('/reproduction', name: 'app_reproduction')]
// public function index(): Response
// {
// $leftEmoji = '🐶'; // Emoji de gauche
// $rightEmoji = '🐱'; // Emoji de droite
// $childEmoji = 'https://emojik.vercel.app/s/%F0%9F%90%88_%F0%9F%90%95'; // Emoji enfant
// // $childEmoji = '🐱';
// return $this->render('reproduction/index.html.twig', [
// 'left_emoji' => $leftEmoji,
// 'right_emoji' => $rightEmoji,
// 'child_emoji' => $childEmoji
// ]);
// }
#[Route('/reproduction/{id1}/{id2}', name: 'app_reproduction_with_params')]
public function reproductionWithParams(int $id1, int $id2): Response
{
$leftEmoji = '🐶'; // Emoji de gauche
$rightEmoji = '🐱'; // Emoji de droite
$childEmoji = 'https://emojik.vercel.app/s/%F0%9F%90%88_%F0%9F%90%95'; // Emoji enfant
// $childEmoji = '🐱';
return $this->render('reproduction/index.html.twig', [
'left_emoji' => $leftEmoji,
'right_emoji' => $rightEmoji,
'child_emoji' => $childEmoji
'left_emoji' => $id1,
'right_emoji' => $id2,
]);
}
}

@ -1,4 +1,18 @@
{
"api-platform/core": {
"version": "3.2",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "3.2",
"ref": "696d44adc3c0d4f5d25a2f1c4f3700dd8a5c6db9"
},
"files": [
"config/packages/api_platform.yaml",
"config/routes/api_platform.yaml",
"src/ApiResource/.gitignore"
]
},
"doctrine/deprecations": {
"version": "1.1",
"recipe": {
@ -35,6 +49,18 @@
"./migrations/.gitignore"
]
},
"nelmio/cors-bundle": {
"version": "2.5",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "1.5",
"ref": "6bea22e6c564fba3a1391615cada1437d0bde39c"
},
"files": [
"config/packages/nelmio_cors.yaml"
]
},
"phpunit/phpunit": {
"version": "9.6",
"recipe": {

@ -4,22 +4,22 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Emoji Fight</title>
<link rel="stylesheet" href="style/combat.css" />
<link rel="stylesheet" href="{{ asset('style/combat.css') }}" />
</head>
<body>
<div class="arena">
<div class="emoji left-emoji" data-content="{{ left_emoji }}"></div>
<div class="emoji right-emoji" data-content="{{ right_emoji }}"></div>
<div class="emoji left-emoji" data-content=""></div>
<div class="emoji right-emoji" data-content=""></div>
</div>
<div id="winner-text"></div>
<script>
window.winnerSide = '{{ winner }}';
window.loserSide = '{{ loser }}';
const id1 = {{ idLeft }};
const id2 = {{ idRight }};
</script>
<script src="script/combat.js"></script>
<script src="{{ asset('script/combat.js') }}"></script>
</body>
</html>

@ -1,24 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Emoji Reproduction</title>
<link rel="stylesheet" href="style/reproduction.css" />
</head>
<body>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Emoji Reproduction</title>
<link rel="stylesheet" href="{{ asset('style/reproduction.css') }}" />
</head>
<body>
<div class="field">
<div class="emoji left-emoji" data-content="{{ left_emoji }}"></div>
<div class="emoji right-emoji" data-content="{{ right_emoji }}"></div>
</div>
<div id="child-text"></div>
<div id="heart-gif"></div>
<script>
child_emoji = "{{child_emoji}}"
</script>
<div class="field">
<div class="emoji left-emoji"></div>
<div class="emoji right-emoji"></div>
</div>
<div id="child-text"></div>
<div id="heart-gif"></div>
<script>
id_left={{ left_emoji }};
id_right={{ right_emoji }};
</script>
<script src="script/reproduction.js"></script>
<script src="{{ asset('script/reproduction.js') }}"></script>
</body>
</html>
</body>
</html>

Loading…
Cancel
Save