diff --git a/migrations/2026/01/Version20260117222218.php b/migrations/2026/01/Version20260117222218.php new file mode 100644 index 00000000..b942f167 --- /dev/null +++ b/migrations/2026/01/Version20260117222218.php @@ -0,0 +1,54 @@ +. + */ + +namespace DoctrineMigrations; + +use Doctrine\DBAL\Schema\Schema; +use Doctrine\Migrations\AbstractMigration; + +/** + * Auto-generated Migration: Please modify to your needs! + */ +final class Version20260117222218 extends AbstractMigration +{ + public function getDescription(): string + { + return ''; + } + + public function up(Schema $schema): void + { + $this->addSql(<<. + */ + +namespace App\Controller\Item; + +use App\Entity\Inventory; +use App\Exceptions\PSPInvalidOperationException; +use App\Functions\DateFunctions; +use App\Service\Clock; +use App\Service\InventoryService; +use App\Service\IRandom; +use App\Service\ResponseService; +use App\Service\TransactionService; +use App\Service\UserAccessor; +use Doctrine\ORM\EntityManagerInterface; +use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\Routing\Attribute\Route; +use Symfony\Component\Security\Http\Attribute\IsGranted; + +#[Route("/item/illGottenGrains")] +class IllGottenGrainsController +{ + #[Route("/{inventory}/rummage", methods: ["POST"])] + #[IsGranted("IS_AUTHENTICATED_FULLY")] + public function consume( + Inventory $inventory, + ResponseService $responseService, + UserAccessor $userAccessor, + EntityManagerInterface $em, + Clock $clock, + IRandom $rng, + TransactionService $transactionService, + InventoryService $inventoryService + ): JsonResponse + { + $user = $userAccessor->getUserOrThrow(); + + ItemControllerHelpers::validateInventory($user, $inventory, 'illGottenGrains/#/rummage'); + + if(DateFunctions::isCornMoon($clock->now)) + return $responseService->itemActionSuccess('It seems the magic of the Corn Moon is preventing this morally-questionable item from being used!'); + + $location = $inventory->getLocation(); + $lockedToOwner = $inventory->getLockedToOwner(); + + $em->remove($inventory); + + $moneys = $rng->rngNextInt(4, 8); + + $transactionService->getMoney($user, $moneys, 'Found in some Ill-gotten Grains.'); + + $inventoryService->receiveItem('Wheat', $user, $user, $user->getName() . ' got this from some Ill-gotten Grains.', $location, $lockedToOwner); + + $em->flush(); + + $responseService->addFlashMessage('You rummage through the Ill-gotten Grains, finding some Wheat and ' . $moneys . '~~m~~.'); + + return $responseService->itemActionSuccess(null, [ 'itemDeleted' => true ]); + } +} diff --git a/src/Service/PetActivity/SpecialLocations/ChocolateMansion.php b/src/Service/PetActivity/SpecialLocations/ChocolateMansion.php index 8d4f711c..cf2af55b 100644 --- a/src/Service/PetActivity/SpecialLocations/ChocolateMansion.php +++ b/src/Service/PetActivity/SpecialLocations/ChocolateMansion.php @@ -210,7 +210,7 @@ private function exploreCellar(ComputedPetSkills $petWithSkills): PetActivityLog $expStats = [ PetSkillEnum::Stealth ]; $item = ItemRepository::findOneByName($this->em, $this->rng->rngNextFromArray([ - 'Blood Wine', 'Chocolate Wine', + 'Blood Wine', 'Chocolate Wine', 'Ill-gotten Grains' ])); $loot[] = $item; @@ -229,7 +229,7 @@ private function exploreCellar(ComputedPetSkills $petWithSkills): PetActivityLog $expStats = [ PetSkillEnum::Stealth ]; $item = ItemRepository::findOneByName($this->em, $this->rng->rngNextFromArray([ - 'Blood Wine', 'Chocolate Wine', + 'Blood Wine', 'Chocolate Wine', 'Ill-gotten Grains', ])); $loot[] = $item; @@ -247,7 +247,7 @@ private function exploreCellar(ComputedPetSkills $petWithSkills): PetActivityLog $expStats = [ ]; $item = ItemRepository::findOneByName($this->em, $this->rng->rngNextFromArray([ - 'Blood Wine', 'Chocolate Wine', + 'Blood Wine', 'Chocolate Wine', 'Ill-gotten Grains', ])); $loot[] = $item; @@ -261,7 +261,7 @@ private function exploreCellar(ComputedPetSkills $petWithSkills): PetActivityLog $expAmount = 3; $expStats = [ PetSkillEnum::Brawl ]; - $loot[] = 'Chocolate Wine'; + $loot[] = $this->rng->rngNextFromArray([ 'Chocolate Wine', 'Ill-gotten Grains' ]); $tags[] = 'Fighting'; if($roll >= 25) diff --git a/src/Service/PetActivity/SpecialLocations/MagicBeanstalkService.php b/src/Service/PetActivity/SpecialLocations/MagicBeanstalkService.php index 583b5ded..743f7d93 100644 --- a/src/Service/PetActivity/SpecialLocations/MagicBeanstalkService.php +++ b/src/Service/PetActivity/SpecialLocations/MagicBeanstalkService.php @@ -25,14 +25,11 @@ use App\Enum\PetSkillEnum; use App\Functions\AdventureMath; use App\Functions\ArrayFunctions; -use App\Functions\DateFunctions; use App\Functions\NumberFunctions; use App\Functions\PetActivityLogFactory; use App\Functions\PetActivityLogTagHelpers; use App\Functions\PetBadgeHelpers; use App\Model\ComputedPetSkills; -use App\Model\PetChanges; -use App\Service\Clock; use App\Service\InventoryService; use App\Service\IRandom; use App\Service\PetActivity\IPetActivity; @@ -45,8 +42,7 @@ public function __construct( private readonly InventoryService $inventoryService, private readonly PetExperienceService $petExperienceService, private readonly IRandom $rng, - private readonly EntityManagerInterface $em, - private readonly Clock $clock + private readonly EntityManagerInterface $em ) { } @@ -531,10 +527,8 @@ private function foundGiantCastle(ComputedPetSkills $petWithSkills): PetActivity if($this->rng->rngSkillRoll($petWithSkills->getStealth()->getTotal() + $petWithSkills->getDexterity()->getTotal()) >= 20) { - $wheatFlourOrCorn = DateFunctions::isCornMoon($this->clock->now) ? 'Corn' : 'Wheat Flour'; - $possibleLoot = [ - $wheatFlourOrCorn, + 'Ill-gotten Grains', 'Gold Bar', 'Linens and Things', 'Pamplemousse', @@ -542,7 +536,7 @@ private function foundGiantCastle(ComputedPetSkills $petWithSkills): PetActivity 'Slice of Bread', 'Stereotypical Bone', 'Puddin\' Rec\'pes', - 'Gold Harp' + 'Gold Harp', ]; $loot = [