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
62 changes: 1 addition & 61 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7116,12 +7116,6 @@ parameters:
count: 2
path: src/Service/PetActivity/GatheringService.php

-
message: '#^Cannot call method setEnchantment\(\) on App\\Entity\\Inventory\|null\.$#'
identifier: method.nonObject
count: 1
path: src/Service/PetActivity/GatheringService.php

-
message: '#^Parameter \#3 \$species of method App\\Service\\PetFactory\:\:createPet\(\) expects App\\Entity\\PetSpecies, App\\Entity\\PetSpecies\|null given\.$#'
identifier: argument.type
Expand All @@ -7140,12 +7134,6 @@ parameters:
count: 1
path: src/Service/PetActivity/GivingTreeGatheringService.php

-
message: '#^Cannot call method getGuild\(\) on App\\Entity\\GuildMembership\|null\.$#'
identifier: method.nonObject
count: 3
path: src/Service/PetActivity/GizubisGardenService.php

-
message: '#^Cannot call method getName\(\) on App\\Entity\\Guild\|null\.$#'
identifier: method.nonObject
Expand All @@ -7158,16 +7146,10 @@ parameters:
count: 1
path: src/Service/PetActivity/GizubisGardenService.php

-
message: '#^Cannot call method increaseReputation\(\) on App\\Entity\\GuildMembership\|null\.$#'
identifier: method.nonObject
count: 1
path: src/Service/PetActivity/GizubisGardenService.php

-
message: '#^Cannot call method getGuild\(\) on App\\Entity\\GuildMembership\|null\.$#'
identifier: method.nonObject
count: 31
count: 2
path: src/Service/PetActivity/GuildService.php

-
Expand All @@ -7188,36 +7170,12 @@ parameters:
count: 1
path: src/Service/PetActivity/GuildService.php

-
message: '#^Cannot call method getRank\(\) on App\\Entity\\GuildMembership\|null\.$#'
identifier: method.nonObject
count: 1
path: src/Service/PetActivity/GuildService.php

-
message: '#^Cannot call method getReputation\(\) on App\\Entity\\GuildMembership\|null\.$#'
identifier: method.nonObject
count: 1
path: src/Service/PetActivity/GuildService.php

-
message: '#^Cannot call method getStarterTool\(\) on App\\Entity\\Guild\|null\.$#'
identifier: method.nonObject
count: 2
path: src/Service/PetActivity/GuildService.php

-
message: '#^Cannot call method getTitle\(\) on App\\Entity\\GuildMembership\|null\.$#'
identifier: method.nonObject
count: 2
path: src/Service/PetActivity/GuildService.php

-
message: '#^Cannot call method increaseReputation\(\) on App\\Entity\\GuildMembership\|null\.$#'
identifier: method.nonObject
count: 9
path: src/Service/PetActivity/GuildService.php

-
message: '#^Method App\\Service\\PetActivity\\GuildService\:\:joinGuild\(\) has parameter \$possibilities with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
Expand Down Expand Up @@ -7326,12 +7284,6 @@ parameters:
count: 4
path: src/Service/PetActivity/PhilosophersStoneService.php

-
message: '#^Cannot call method setEnchantment\(\) on App\\Entity\\Inventory\|null\.$#'
identifier: method.nonObject
count: 1
path: src/Service/PetActivity/PhilosophersStoneService.php

-
message: '#^Cannot call method getName\(\) on App\\Entity\\Pet\|null\.$#'
identifier: method.nonObject
Expand Down Expand Up @@ -7434,12 +7386,6 @@ parameters:
count: 3
path: src/Service/PetActivity/SpecialLocations/BurntForestService.php

-
message: '#^Cannot call method setEnchantment\(\) on App\\Entity\\Inventory\|null\.$#'
identifier: method.nonObject
count: 1
path: src/Service/PetActivity/SpecialLocations/BurntForestService.php

-
message: '#^Left side of && is always true\.$#'
identifier: booleanAnd.leftAlwaysTrue
Expand All @@ -7464,12 +7410,6 @@ parameters:
count: 2
path: src/Service/PetActivity/SpecialLocations/FructalPlaneService.php

-
message: '#^Cannot call method setEnchantment\(\) on App\\Entity\\Inventory\|null\.$#'
identifier: method.nonObject
count: 1
path: src/Service/PetActivity/SpecialLocations/FructalPlaneService.php

-
message: '#^Offset ''message'' might not exist on array\{stat\: ''brawl''\|''crafts''\|''music'', value\: int, message\: non\-falsy\-string\}\|null\.$#'
identifier: offsetAccess.notFound
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/Inventory/RemoveBonusController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use App\Entity\Inventory;
use App\Exceptions\PSPNotFoundException;
use App\Functions\InventoryHelpers;
use App\Service\ResponseService;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
Expand All @@ -37,7 +38,7 @@ public function removeBonus(
if($inventory->getOwner()->getId() !== $user->getId())
throw new PSPNotFoundException('That item does not belong to you.');

$inventory->setEnchantment(null);
InventoryHelpers::removeEnchantment($em, $inventory);

$em->flush();

Expand Down
12 changes: 12 additions & 0 deletions src/Functions/InventoryHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@

class InventoryHelpers
{
/**
* Removes an enchantment (bonus) from an inventory item.
*/
public static function removeEnchantment(EntityManagerInterface $em, Inventory $inventory): void
{
if(!$inventory->getEnchantmentData())
return;

$em->remove($inventory->getEnchantmentData());
$inventory->setEnchantment(null);
}

public static function findOneToConsume(EntityManagerInterface $em, User $owner, string $itemName): ?Inventory
{
return $em->getRepository(Inventory::class)->createQueryBuilder('i')
Expand Down
4 changes: 3 additions & 1 deletion src/Service/MarketService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use App\Enum\LocationEnum;
use App\Enum\UnlockableFeatureEnum;
use App\Enum\UserStat;
use App\Functions\InventoryHelpers;
use App\Functions\InventoryModifierFunctions;
use App\Functions\MarketListingRepository;
use App\Functions\UserQuestRepository;
Expand Down Expand Up @@ -106,9 +107,10 @@ public function transferItemToPlayer(Inventory $item, User $newOwner, int $locat
$this->userStatsRepository->incrementStat($item->getOwner(), UserStat::ItemsSoldInMarket, 1);
$this->userStatsRepository->incrementStat($newOwner, UserStat::ItemsBoughtInMarket, 1);

InventoryHelpers::removeEnchantment($this->em, $item);

$item
->setSpice(null)
->setEnchantment(null)
->changeOwner($newOwner, $newItemComment, $this->em)
->setLocation($location)
;
Expand Down
2 changes: 1 addition & 1 deletion src/Service/PetActivity/GatheringService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ private function foundOldSettlement(ComputedPetSkills $petWithSkills): PetActivi
{
$item = $this->inventoryService->petCollectsItem($itemName, $pet, $pet->getName() . ' found this in a ruined settlement deep in the island\'s Micro-jungle.', $activityLog);

if($itemName === 'No Right Turns')
if($item && $itemName === 'No Right Turns')
$item->setEnchantment(EnchantmentRepository::findOneByName($this->em, 'Thorn-covered'));
}

Expand Down
3 changes: 2 additions & 1 deletion src/Service/PetActivity/GizubisGardenService.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public function adventure(ComputedPetSkills $petWithSkills): PetActivityLog
private function doRandomSeedlingadventure(ComputedPetSkills $petWithSkills): PetActivityLog
{
$pet = $petWithSkills->getPet();
$member = $pet->getGuildMembership();
$member = $pet->getGuildMembership()
?? throw new \RuntimeException('Pet is not in a guild?!');

switch($this->rng->rngNextInt(1, 3))
{
Expand Down
32 changes: 20 additions & 12 deletions src/Service/PetActivity/GuildService.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function doGuildActivity(ComputedPetSkills $petWithSkills): ?PetActivityL

$activityLog = $this->pickGuildActivity($petWithSkills);

if($activityLog !== null)
if($activityLog)
{
$activityLog
->setChanges($changes->compare($petWithSkills->getPet()))
Expand All @@ -136,9 +136,7 @@ private function pickGuildActivity(ComputedPetSkills $petWithSkills): ?PetActivi
$pet = $petWithSkills->getPet();

if($pet->getGuildMembership()->getLevel() === 0)
{
return $this->doGuildIntroductions($pet);
}

return match ($pet->getGuildMembership()->getGuild()->getName())
{
Expand All @@ -157,7 +155,9 @@ private function pickGuildActivity(ComputedPetSkills $petWithSkills): ?PetActivi

private function doGuildIntroductions(Pet $pet): PetActivityLog
{
$member = $pet->getGuildMembership();
$member = $pet->getGuildMembership()
?? throw new \RuntimeException('Pet is not in a guild?!');

$collectStarterTool = false;

switch($member->getReputation())
Expand Down Expand Up @@ -190,7 +190,8 @@ private function doGuildIntroductions(Pet $pet): PetActivityLog

private function doTimesArrowMission(Pet $pet): PetActivityLog
{
$member = $pet->getGuildMembership();
$member = $pet->getGuildMembership()
?? throw new \RuntimeException('Pet is not in a guild?!');

$message = $this->rng->rngNextFromArray([
'%pet:' . $pet->getId() . '.name% ' . $this->rng->rngNextFromArray([ 'picked up a book from', 'returned a book to' ]). ' the Library of Fire for one of their ' . $member->getGuild()->getName() . ' seniors.',
Expand All @@ -210,7 +211,8 @@ private function doTimesArrowMission(Pet $pet): PetActivityLog

private function doLightAndShadowMission(Pet $pet): PetActivityLog
{
$member = $pet->getGuildMembership();
$member = $pet->getGuildMembership()
?? throw new \RuntimeException('Pet is not in a guild?!');

$message = $this->rng->rngNextFromArray([
$pet->getName() . ' ' . $this->rng->rngNextFromArray([ 'picked up a book from', 'returned a book to' ]). ' the Library of Fire for one of their ' . $member->getGuild()->getName() . ' seniors.',
Expand All @@ -230,7 +232,8 @@ private function doLightAndShadowMission(Pet $pet): PetActivityLog

private function doTapestriesMission(Pet $pet): PetActivityLog
{
$member = $pet->getGuildMembership();
$member = $pet->getGuildMembership()
?? throw new \RuntimeException('Pet is not in a guild?!');

$message = $this->rng->rngNextFromArray([
$pet->getName() . ' ' . $this->rng->rngNextFromArray([ 'picked up a book from', 'returned a book to' ]). ' the Library of Fire for one of their ' . $member->getGuild()->getName() . ' seniors.',
Expand All @@ -250,7 +253,8 @@ private function doTapestriesMission(Pet $pet): PetActivityLog

private function doInnerSanctumMission(Pet $pet): PetActivityLog
{
$member = $pet->getGuildMembership();
$member = $pet->getGuildMembership()
?? throw new \RuntimeException('Pet is not in a guild?!');

if($this->rng->rngNextInt(1, 3) === 1)
{
Expand Down Expand Up @@ -310,7 +314,8 @@ private function doInnerSanctumMission(Pet $pet): PetActivityLog

private function doDwarfcraftMission(Pet $pet): PetActivityLog
{
$member = $pet->getGuildMembership();
$member = $pet->getGuildMembership()
?? throw new \RuntimeException('Pet is not in a guild?!');

$message = $this->rng->rngNextFromArray([
$pet->getName() . ' picked up some Liquid-hot Magma for one of their ' . $member->getGuild()->getName() . ' seniors.',
Expand All @@ -330,7 +335,8 @@ private function doDwarfcraftMission(Pet $pet): PetActivityLog

private function doHighImpactMission(Pet $pet): ?PetActivityLog
{
$member = $pet->getGuildMembership();
$member = $pet->getGuildMembership()
?? throw new \RuntimeException('Pet is not in a guild?!');

// High Impact members do other cool stuff, high up a magic bean stalks, and deep undersea
if($member->getTitle() >= 3)
Expand All @@ -354,7 +360,8 @@ private function doHighImpactMission(Pet $pet): ?PetActivityLog

private function doTheUniverseForgetsMission(Pet $pet): PetActivityLog
{
$member = $pet->getGuildMembership();
$member = $pet->getGuildMembership()
?? throw new \RuntimeException('Pet is not in a guild?!');

$message = $this->rng->rngNextFromArray([
$pet->getName() . ' ' . $this->rng->rngNextFromArray([ 'picked up a book from', 'returned a book to' ]). ' the Library of Fire for one of their ' . $member->getGuild()->getName() . ' seniors.',
Expand All @@ -374,7 +381,8 @@ private function doTheUniverseForgetsMission(Pet $pet): PetActivityLog

private function doCorrespondenceMission(Pet $pet): ?PetActivityLog
{
$member = $pet->getGuildMembership();
$member = $pet->getGuildMembership()
?? throw new \RuntimeException('Pet is not in a guild?!');

// there are delivery messages that Correspondence members can do, during normal pet activities
if($this->rng->rngNextInt(0, 2) < $member->getTitle())
Expand Down
4 changes: 3 additions & 1 deletion src/Service/PetActivity/PhilosophersStoneService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use App\Enum\PetSkillEnum;
use App\Functions\ActivityHelpers;
use App\Functions\EquipmentFunctions;
use App\Functions\InventoryHelpers;
use App\Functions\ItemRepository;
use App\Functions\MeritRepository;
use App\Functions\PetActivityLogFactory;
Expand Down Expand Up @@ -393,7 +394,8 @@ public function seekMerkabaOfAir(ComputedPetSkills $petWithSkills): ?PetActivity

PetBadgeHelpers::awardBadge($this->em, $pet, PetBadgeEnum::FoundMerkabaOfAir, $activityLog);

$pet->getTool()->setEnchantment(null);
if($pet->getTool())
InventoryHelpers::removeEnchantment($this->em, $pet->getTool());

$pet->addMerit(MeritRepository::findOneByName($this->em, MeritEnum::LIGHTNING_REINS));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use App\Enum\StatusEffectEnum;
use App\Functions\ActivityHelpers;
use App\Functions\EnchantmentRepository;
use App\Functions\InventoryHelpers;
use App\Functions\NumberFunctions;
use App\Functions\PetActivityLogFactory;
use App\Functions\PetActivityLogTagHelpers;
Expand Down Expand Up @@ -461,7 +462,8 @@ private function breakToolBonus(Pet $pet): PetActivityLog

$this->petExperienceService->spendTime($pet, $this->rng->rngNextInt(30, 45), PetActivityStatEnum::OTHER, true);

$pet->getTool()->setEnchantment(null);
if($pet->getTool())
InventoryHelpers::removeEnchantment($this->em, $pet->getTool());

return $activityLog;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use App\Enum\PetSkillEnum;
use App\Functions\ActivityHelpers;
use App\Functions\ArrayFunctions;
use App\Functions\InventoryHelpers;
use App\Functions\PetActivityLogFactory;
use App\Functions\PetActivityLogTagHelpers;
use App\Functions\PetBadgeHelpers;
Expand Down Expand Up @@ -107,7 +108,8 @@ public function adventure(ComputedPetSkills $petWithSkills): PetActivityLog
$this->petExperienceService->gainExp($pet, count($loot), [ PetSkillEnum::Arcana ], $activityLog);
$this->petExperienceService->spendTime($pet, 2, PetActivityStatEnum::UMBRA, true);

$pet->getTool()->setEnchantment(null);
if($pet->getTool())
InventoryHelpers::removeEnchantment($this->em, $pet->getTool());

PetBadgeHelpers::awardBadge($this->em, $pet, PetBadgeEnum::VisitedTheFructalPlane, $activityLog);

Expand Down
Loading