Merge de la branche de Cleo

raph_combat
Raphael LACOTE 4 days ago
parent f5fde68b14
commit 9c931cc616

@ -1,50 +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 Version20250603073633 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 emoji (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nom VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, force DOUBLE PRECISION NOT NULL, robustesse DOUBLE PRECISION NOT NULL, intelligence DOUBLE PRECISION NOT NULL, vitesse DOUBLE PRECISION NOT NULL, nb_combat_gagne INTEGER NOT NULL, rarete INTEGER NOT NULL)
SQL);
$this->addSql(<<<'SQL'
CREATE TABLE messenger_messages (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, body CLOB NOT NULL, headers CLOB NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL, available_at DATETIME NOT NULL, delivered_at DATETIME DEFAULT NULL)
SQL);
$this->addSql(<<<'SQL'
CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)
SQL);
$this->addSql(<<<'SQL'
CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)
SQL);
$this->addSql(<<<'SQL'
CREATE INDEX IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)
SQL);
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL'
DROP TABLE emoji
SQL);
$this->addSql(<<<'SQL'
DROP TABLE messenger_messages
SQL);
}
}

@ -0,0 +1,53 @@
<?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 Version20250604225046 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 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, 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, 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'
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);
$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'
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 emoji
SQL);
$this->addSql(<<<'SQL'
DROP TABLE rarity
SQL);
}
}

@ -12,9 +12,6 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use App\Repository\EmojiRepository;
use Doctrine\ORM\EntityManagerInterface;
use App\Repository\EmojiRepository;
use Symfony\Component\HttpFoundation\JsonResponse;
#[Route('/emoji', name: 'emoji')]
class EmojiController extends AbstractController
@ -37,6 +34,17 @@ class EmojiController extends AbstractController
]);
}
#[Route('/addRarity', name: 'addR')]
public function addRarityDebug(EntityManagerInterface $entityManager) {
$rarity = new Rarity();
$rarity->setName('Bip');
$rarity->setDropRate(42);
$entityManager->persist($rarity);
$entityManager->flush();
return new Response();
}
#[Route('/add/{code}', name: 'add')]
public function addEmojiDebug(string $code, EntityManagerInterface $entityManager) {
$emoji = new Emoji();
@ -175,12 +183,9 @@ class EmojiController extends AbstractController
'childId' => $child->getId()
]);
}
}
public function reproduceEmoji(Emoji $emoji1, Emoji $emoji2): Emoji {
return new Emoji();
}
#[Route('/emoji/fight/{idEmoji1}/{idEmoji2}', name: 'fight_emoji')]
#[Route('/fight/{idEmoji1}/{idEmoji2}', name: 'fight_emoji')]
public function fightEmoji(int $idEmoji1, int $idEmoji2, EntityManagerInterface $entityManager, EmojiRepository $emojiRepository): JsonResponse {
$emoji1 = $emojiRepository->find($idEmoji1);
$emoji2 = $emojiRepository->find($idEmoji2);
@ -189,8 +194,8 @@ class EmojiController extends AbstractController
return new JsonResponse(['error' => 'Emoji not found'], 404);
}
$aleatoire = random_int(0,3);
$valEmoji1 = [$emoji1->getForce(),$emoji1->getRobustesse(),$emoji1->getIntelligence(),$emoji1->getVitesse()];
$valEmoji2 = [$emoji2->getForce(),$emoji2->getRobustesse(),$emoji2->getIntelligence(),$emoji2->getVitesse()];
$valEmoji1 = [$emoji1->getStrength(),$emoji1->getToughness(),$emoji1->getIntelligence(),$emoji1->getSpeed()];
$valEmoji2 = [$emoji2->getStrength(),$emoji2->getToughness(),$emoji2->getIntelligence(),$emoji2->getSpeed()];
$difference = $valEmoji1[$aleatoire] - $valEmoji2[$aleatoire];
if($difference > 0){
$emoji1->wonFight();
@ -198,8 +203,8 @@ class EmojiController extends AbstractController
$entityManager->remove($emoji2);
} else {
$emoji2->wonFight();
$entityManager->persist($emoji1);
$entityManager->remove($emoji2);
$entityManager->persist($emoji2);
$entityManager->remove($emoji1);
}
$entityManager->flush();
@ -211,18 +216,18 @@ class EmojiController extends AbstractController
public function testToMove(){
$e = new Emoji();
$e->setNom("ROBERT");
$e->setForce(5);
$e->setName("ROBERT");
$e->setStrength(5);
$e->setIntelligence(2);
$e->setRobustesse(3);
$e->setVitesse(4);
$e->setToughness(3);
$e->setSpeed(4);
$e2 = new Emoji();
$e2->setNom("BIBOP");
$e2->setForce(42);
$e2->setName("BIBOP");
$e2->setStrength(42);
$e2->setIntelligence(1);
$e2->setRobustesse(1);
$e2->setVitesse(1);
$e2->setToughness(1);
$e2->setSpeed(1);
$vic = $this->fightEmoji($e,$e2);
echo $vic->getNom();
echo $vic->getName();
}
}

@ -162,11 +162,11 @@ class Emoji
}
public function wonFight() : self{
$this->nbCombatGagne = $this->nbCombatGagne + 1;
$this->force += 1;
$this->robustesse += 1;
$this->fightsWon = $this->fightsWon + 1;
$this->strength += 1;
$this->toughness += 1;
$this->intelligence += 1;
$this->vitesse += 1;
$this->speed += 1;
return $this;
}
}

Loading…
Cancel
Save