diff --git a/.env b/.env
index 6a26ebf..95a49dd 100644
--- a/.env
+++ b/.env
@@ -19,4 +19,7 @@ APP_ENV=dev
APP_SECRET=e10d1768cebd3187e908e91448a3086a
###< symfony/framework-bundle ###
MESSENGER_TRANSPORT_DSN=sync://
-DATABASE_URL="sqlite:///%kernel.project_dir%/var/app.db"
\ No newline at end of file
+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 ###
diff --git a/composer.lock b/composer.lock
index 392aa68..d097da2 100644
--- a/composer.lock
+++ b/composer.lock
@@ -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": [
diff --git a/config/bundles.php b/config/bundles.php
index 0457f99..c53d482 100644
--- a/config/bundles.php
+++ b/config/bundles.php
@@ -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],
];
diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml
index 7853e9e..3ef8da6 100644
--- a/config/packages/framework.yaml
+++ b/config/packages/framework.yaml
@@ -1,24 +1,24 @@
# see https://symfony.com/doc/current/reference/configuration/framework.html
framework:
- secret: '%env(APP_SECRET)%'
- #csrf_protection: true
- http_method_override: false
+ secret: "%env(APP_SECRET)%"
+ #csrf_protection: true
+ http_method_override: false
- # Enables session support. Note that the session will ONLY be started if you read or write from it.
- # Remove or comment this section to explicitly disable session support.
- session:
- handler_id: null
- cookie_secure: auto
- cookie_samesite: lax
- storage_factory_id: session.storage.factory.native
+ # Enables session support. Note that the session will ONLY be started if you read or write from it.
+ # Remove or comment this section to explicitly disable session support.
+ session:
+ handler_id: null
+ cookie_secure: auto
+ cookie_samesite: lax
+ storage_factory_id: session.storage.factory.native
- #esi: true
- #fragments: true
- php_errors:
- log: true
+ #esi: true
+ #fragments: true
+ php_errors:
+ log: true
when@test:
- framework:
- test: true
- session:
- storage_factory_id: session.storage.factory.mock_file
+ framework:
+ test: true
+ session:
+ storage_factory_id: session.storage.factory.mock_file
diff --git a/config/packages/routing.yaml b/config/packages/routing.yaml
index 4b766ce..c0f1474 100644
--- a/config/packages/routing.yaml
+++ b/config/packages/routing.yaml
@@ -1,12 +1,12 @@
framework:
- router:
- utf8: true
+ router:
+ utf8: true
- # Configure how to generate URLs in non-HTTP contexts, such as CLI commands.
- # See https://symfony.com/doc/current/routing.html#generating-urls-in-commands
- #default_uri: http://localhost
+ # Configure how to generate URLs in non-HTTP contexts, such as CLI commands.
+ # See https://symfony.com/doc/current/routing.html#generating-urls-in-commands
+ #default_uri: http://localhost
when@prod:
- framework:
- router:
- strict_requirements: null
+ framework:
+ router:
+ strict_requirements: null
diff --git a/migrations/Version20250529204111.php b/migrations/Version20250529204111.php
new file mode 100644
index 0000000..40ae60a
--- /dev/null
+++ b/migrations/Version20250529204111.php
@@ -0,0 +1,62 @@
+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
new file mode 100644
index 0000000..938c369
--- /dev/null
+++ b/migrations/Version20250530163653.php
@@ -0,0 +1,71 @@
+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
new file mode 100644
index 0000000..e2b9c07
--- /dev/null
+++ b/migrations/Version20250610074721.php
@@ -0,0 +1,90 @@
+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
new file mode 100644
index 0000000..e631119
--- /dev/null
+++ b/migrations/Version20250610074733.php
@@ -0,0 +1,31 @@
+ {
- // Copie tout ici
+
+
+
let selectedCards = [];
function toggleSelection(card) {
diff --git a/public/media/boxing_ring.jpg b/public/media/boxing_ring.jpg
new file mode 100644
index 0000000..79e8d58
Binary files /dev/null and b/public/media/boxing_ring.jpg differ
diff --git a/public/script/combat.js b/public/script/combat.js
index 587438a..26d77d7 100644
--- a/public/script/combat.js
+++ b/public/script/combat.js
@@ -3,8 +3,49 @@ 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;
+
+ left.dataset.content = leftEmoji;
+ right.dataset.content = rightEmoji;
+
+ window.winnerSide = winner === 'left' ? 'left' : 'right';
+ window.loserSide = winner === 'left' ? 'right' : 'left';
+
+ insertEmojiOrImage(left);
+ insertEmojiOrImage(right);
+
+ left.classList.add('slide-in-left');
+ right.classList.add('slide-in-right');
+
+ setTimeout(() => {
+ left.style.left = '100px';
+ right.style.left = '300px';
+
+ left.classList.add('fight-animation');
+ right.classList.add('fight-animation');
+
+ setTimeout(() => {
+ left.classList.remove('fight-animation');
+ right.classList.remove('fight-animation');
+
+ const loser = window.loserSide === 'left' ? left : right;
+ loser.classList.add('loser-fly-up');
+ const winnerEl = window.winnerSide === 'left' ? left : right;
+ winnerEl.classList.add('winner-center', 'winner-crown');
+
+ let name = winnerEl.dataset.content;
+ if (/^https?:\/\//.test(name)) {
+ winnerText.innerHTML = `a gagné ! 🎉`;
+ } else {
+ winnerText.textContent = `${name} a gagné ! 🎉`;
+ }
+ winnerText.style.display = 'block';
+ }, 1500);
+ }, 3000);
+ });
function insertEmojiOrImage(el) {
const value = el.dataset.content;
@@ -17,38 +58,4 @@ document.addEventListener('DOMContentLoaded', () => {
el.textContent = value;
}
}
-
- insertEmojiOrImage(left);
- insertEmojiOrImage(right);
-
- left.classList.add('slide-in-left');
- right.classList.add('slide-in-right');
-
- setTimeout(() => {
- left.style.left = '100px';
- right.style.left = '300px';
-
- left.classList.add('fight-animation');
- right.classList.add('fight-animation');
-
- setTimeout(() => {
- left.classList.remove('fight-animation');
- right.classList.remove('fight-animation');
-
- const loser = loserSide === 'left' ? left : right;
- loser.classList.add('loser-fly-up');
- const winner = winnerSide === 'left' ? left : right;
- winner.classList.add('winner-center', 'winner-crown');
-
- let name = winner.dataset.content;
- //check if name is an image URL or an emoji
- if (/^https?:\/\//.test(name)) {
- winnerText.innerHTML = `
a gagné ! 🎉`;
- }
- else {
- winnerText.textContent = `${name} a gagné ! 🎉`;
- }
- winnerText.style.display = 'block';
- }, 1500);
- }, 3000);
});
diff --git a/public/script/reproduction.js b/public/script/reproduction.js
index 1eb69ea..218f8d3 100644
--- a/public/script/reproduction.js
+++ b/public/script/reproduction.js
@@ -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');
-
-
- function insertEmojiOrImage(el) {
+
+ 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);
+ });
});
diff --git a/src/Controller/CombatController.php b/src/Controller/CombatController.php
index eff9d14..86da458 100644
--- a/src/Controller/CombatController.php
+++ b/src/Controller/CombatController.php
@@ -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,
]);
}
diff --git a/src/Controller/ReproductionController.php b/src/Controller/ReproductionController.php
index 8f6dc0a..876b6d6 100644
--- a/src/Controller/ReproductionController.php
+++ b/src/Controller/ReproductionController.php
@@ -8,18 +8,29 @@ use Symfony\Component\Routing\Annotation\Route;
class ReproductionController extends AbstractController
{
- #[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 = '🐱';
+ // #[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
+ {
+
return $this->render('reproduction/index.html.twig', [
- 'left_emoji' => $leftEmoji,
- 'right_emoji' => $rightEmoji,
- 'child_emoji' => $childEmoji
+ 'left_emoji' => $id1,
+ 'right_emoji' => $id2,
]);
}
+
}
diff --git a/symfony.lock b/symfony.lock
index 7c52ef7..70aa0b4 100644
--- a/symfony.lock
+++ b/symfony.lock
@@ -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": {
diff --git a/templates/combat/index.html.twig b/templates/combat/index.html.twig
index 052843a..680d356 100644
--- a/templates/combat/index.html.twig
+++ b/templates/combat/index.html.twig
@@ -4,22 +4,22 @@