Skip to content

Commit

Permalink
Minor fix to how auto sell works for auto disenchant
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamKyle committed Dec 18, 2024
1 parent f50a106 commit bef40dd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
21 changes: 15 additions & 6 deletions app/Game/Battle/Services/BattleDrop.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ public function handleMonsterQuestDrop(Character $character, bool $returnItem =
}

/**
* Handles drops for special locations.
*
* @param Character $character
* @return void
* @throws Exception
*/
public function handleSpecialLocationQuestItem(Character $character)
{
Expand Down Expand Up @@ -184,13 +184,20 @@ public function handleSpecialLocationQuestItem(Character $character)
}

/**
* Depending on the map name and the location, we fetch the drop item from the cache.
* @param Character $character
* @param string $gameMapName
* @param Location|null $locationWithEffect
* @return Item|null
*/
protected function getDropFromCache(Character $character, string $gameMapName, ?Location $locationWithEffect = null): ?Item
{
return $this->randomItemDropBuilder->generateItem($this->getMaxLevelBasedOnPlane($character));
}

/**
* @param Character $character
* @return int
*/
protected function getMaxLevelBasedOnPlane(Character $character): int
{
$characterLevel = $character->level;
Expand Down Expand Up @@ -309,10 +316,12 @@ private function autoDisenchantItem(Character $character, Item $item): void
private function handleDisenchantOrAutoSell(Character $character, Item $item): void {
$maxCurrenciesValue = new MaxCurrenciesValue($character->gold_dust, MaxCurrenciesValue::GOLD_DUST);

if ($maxCurrenciesValue->canNotGiveCurrency()) {
$this->shopService->autoSellItem($character, $item);
if ($character->user->auto_sell_item) {
if ($maxCurrenciesValue->canNotGiveCurrency()) {
$this->shopService->autoSellItem($character, $item);

return;
return;
}
}

$this->disenchantService->setUp($character)->disenchantItemWithSkill();
Expand Down
1 change: 0 additions & 1 deletion app/Game/Core/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public function chatSettings(request $request, User $user)

public function autoDisenchantSettings(Request $request, User $user)
{

if (filter_var($request->auto_disenchant, FILTER_VALIDATE_BOOLEAN) === false) {
$request->merge([
'auto_disenchant' => false,
Expand Down
2 changes: 2 additions & 0 deletions app/Game/Skills/Services/DisenchantService.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ public function disenchantItemWithSkill(): void

event(new UpdateCharacterInventoryCountEvent($this->character));

ServerMessageHandler::sendBasicMessage($this->character->user, 'Disenchanted item but got no gold dust as you are capped. Maybe you want to auto sell it (can be enabled in your settings, profile icon -> settings, scroll down to Auto Disenchant)?');

return;
}

Expand Down

0 comments on commit bef40dd

Please sign in to comment.