Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# IDEs
/.idea
/.vscode
/.vs

# local config
/.claude/settings.local.json
CLAUDE.local.md

###> symfony/framework-bundle ###
/.env.local
Expand Down
47 changes: 47 additions & 0 deletions migrations/2026/01/Version20260108025052.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);

/**
* This file is part of the Poppy Seed Pets API.
*
* The Poppy Seed Pets API is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* The Poppy Seed Pets API is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with The Poppy Seed Pets API. If not, see <https://www.gnu.org/licenses/>.
*/

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20260108025052 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('CREATE TABLE inventory_enchantment (hue INT NOT NULL, inventory_id INT NOT NULL, enchantment_id INT NOT NULL, INDEX IDX_AF133F98F3927CF3 (enchantment_id), PRIMARY KEY (inventory_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci`');
$this->addSql('ALTER TABLE inventory_enchantment ADD CONSTRAINT FK_AF133F989EEA759 FOREIGN KEY (inventory_id) REFERENCES inventory (id)');
$this->addSql('ALTER TABLE inventory_enchantment ADD CONSTRAINT FK_AF133F98F3927CF3 FOREIGN KEY (enchantment_id) REFERENCES enchantment (id)');

// Migrate existing enchantment data to the new bridge table
$this->addSql('INSERT INTO inventory_enchantment (inventory_id, enchantment_id, hue) SELECT id, enchantment_id, 0 FROM inventory WHERE enchantment_id IS NOT NULL');

$this->addSql('ALTER TABLE inventory DROP FOREIGN KEY `FK_B12D4A36F3927CF3`');
$this->addSql('DROP INDEX IDX_B12D4A36F3927CF3 ON inventory');
$this->addSql('ALTER TABLE inventory DROP enchantment_id');
}

public function down(Schema $schema): void
{
}
}
3 changes: 2 additions & 1 deletion src/Controller/Hattier/ApplyAuraController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function applyAura(

$petId = $request->request->getInt('pet');
$auraId = $request->request->getInt('aura');
$hue = $request->request->getInt('hue', 0) % 360;

if($petId <= 0 || $auraId <= 0)
throw new PSPInvalidOperationException('A pet and style must be selected.');
Expand Down Expand Up @@ -85,7 +86,7 @@ public function applyAura(
else
$transactionService->spendRecyclingPoints($user, 100, 'Bought the ' . $unlockedAura->getAura()->getAura()->getName() . ' style from the Hattier.', [ 'Hattier' ]);

$pet->getHat()->setEnchantment($unlockedAura->getAura());
$pet->getHat()->setEnchantment($unlockedAura->getAura(), $hue);

PetBadgeHelpers::awardBadgeAndLog($em, $pet, PetBadgeEnum::TriedOnANewStyle, null);

Expand Down
32 changes: 26 additions & 6 deletions src/Entity/Inventory.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ class Inventory
#[ORM\OneToOne(targetEntity: LunchboxItem::class, mappedBy: 'inventoryItem', cascade: ['remove'])]
private ?LunchboxItem $lunchboxItem = null;

#[ORM\ManyToOne(targetEntity: Enchantment::class)]
#[Groups(["myInventory", "itemEncyclopedia", "marketItem", "fireplaceFuel", "greenhouseFertilizer", "myPet", "fireplaceMantle", "dragonTreasure", "userPublicProfile", "petPublicProfile", "hollowEarth", "petGroupDetails"])]
private ?Enchantment $enchantment = null;
#[ORM\OneToOne(targetEntity: InventoryEnchantment::class, mappedBy: 'inventory', cascade: ['persist', 'remove'])]
private ?InventoryEnchantment $enchantmentData = null;

#[ORM\ManyToOne(targetEntity: Spice::class)]
#[Groups(["myInventory", "itemEncyclopedia", "marketItem", "fireplaceFuel", "greenhouseFertilizer", "myPet", "fireplaceMantle", "dragonTreasure"])]
Expand Down Expand Up @@ -323,20 +322,41 @@ public function setLunchboxItem(LunchboxItem $lunchboxItem): self
return $this;
}

#[Groups(["myInventory", "itemEncyclopedia", "marketItem", "fireplaceFuel", "greenhouseFertilizer", "myPet", "fireplaceMantle", "dragonTreasure", "userPublicProfile", "petPublicProfile", "hollowEarth", "petGroupDetails"])]
public function getEnchantment(): ?Enchantment
{
return $this->enchantment;
return $this->enchantmentData?->getEnchantment();
}

public function setEnchantment(?Enchantment $enchantment): self
public function setEnchantment(?Enchantment $enchantment, int $hue = 0): self
{
$this->enchantment = $enchantment;
if ($enchantment === null) {
$this->enchantmentData = null;
} else {
if ($this->enchantmentData === null) {
$this->enchantmentData = new InventoryEnchantment($this, $enchantment, $hue);
} else {
$this->enchantmentData->setEnchantment($enchantment);
$this->enchantmentData->setHue($hue);
}
}

$this->fullItemName = InventoryModifierFunctions::getNameWithModifiers($this);

return $this;
}

public function getEnchantmentData(): ?InventoryEnchantment
{
return $this->enchantmentData;
}

#[Groups(["myInventory", "itemEncyclopedia", "marketItem", "fireplaceFuel", "greenhouseFertilizer", "myPet", "fireplaceMantle", "dragonTreasure", "userPublicProfile", "petPublicProfile", "hollowEarth", "petGroupDetails"])]
public function getEnchantmentHue(): ?int
{
return $this->enchantmentData?->getHue();
}

public function providesLight(): bool
{
return
Expand Down
86 changes: 86 additions & 0 deletions src/Entity/InventoryEnchantment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
declare(strict_types=1);

/**
* This file is part of the Poppy Seed Pets API.
*
* The Poppy Seed Pets API is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* The Poppy Seed Pets API is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with The Poppy Seed Pets API. If not, see <https://www.gnu.org/licenses/>.
*/

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Table(
name: 'inventory_enchantment',
uniqueConstraints: [
new ORM\UniqueConstraint(name: 'inventory_unique', columns: ['inventory_id']),
]
)]
class InventoryEnchantment
{
#[ORM\Id]
#[ORM\OneToOne(targetEntity: Inventory::class, inversedBy: 'enchantmentData')]
#[ORM\JoinColumn(nullable: false)]
private Inventory $inventory;

#[ORM\ManyToOne(targetEntity: Enchantment::class)]
#[ORM\JoinColumn(nullable: false)]
private Enchantment $enchantment;

#[ORM\Column(type: 'integer')]
private int $hue = 0;

public function __construct(Inventory $inventory, Enchantment $enchantment, int $hue = 0)
{
$this->inventory = $inventory;
$this->enchantment = $enchantment;
$this->hue = $hue;
}

public function getInventory(): Inventory
{
return $this->inventory;
}

public function setInventory(Inventory $inventory): self
{
$this->inventory = $inventory;

return $this;
}

public function getEnchantment(): Enchantment
{
return $this->enchantment;
}

public function setEnchantment(Enchantment $enchantment): self
{
$this->enchantment = $enchantment;

return $this;
}

public function getHue(): int
{
return $this->hue;
}

public function setHue(int $hue): self
{
if($hue < 0)
$hue = 360 - abs($hue);
else if($hue >= 360)
$hue = $hue % 360;

$this->hue = $hue;

return $this;
}
}
Loading