|
@@ -10,6 +10,7 @@ use App\Module\GameItems\Services\ItemService;
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
use UCore\Dto\Res;
|
|
use UCore\Dto\Res;
|
|
|
|
|
+use UCore\Helper\Logger;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 宠物自动技能处理逻辑
|
|
* 宠物自动技能处理逻辑
|
|
@@ -45,7 +46,7 @@ class PetAutoSkillLogic
|
|
|
$harvestableLands = LandService::getHarvestableLands($userId);
|
|
$harvestableLands = LandService::getHarvestableLands($userId);
|
|
|
|
|
|
|
|
$harvestCount = 0;
|
|
$harvestCount = 0;
|
|
|
- $autoClearedCount = 0;
|
|
|
|
|
|
|
+
|
|
|
$harvestResults = [];
|
|
$harvestResults = [];
|
|
|
|
|
|
|
|
if (!$harvestableLands->isEmpty()) {
|
|
if (!$harvestableLands->isEmpty()) {
|
|
@@ -81,7 +82,7 @@ class PetAutoSkillLogic
|
|
|
// 记录统计信息
|
|
// 记录统计信息
|
|
|
$this->recordSkillStatistics($activeSkill, 'auto_harvest', [
|
|
$this->recordSkillStatistics($activeSkill, 'auto_harvest', [
|
|
|
'harvest_count' => $harvestCount,
|
|
'harvest_count' => $harvestCount,
|
|
|
- 'auto_cleared_count' => $autoClearedCount,
|
|
|
|
|
|
|
+
|
|
|
'total_lands_checked' => $harvestableLands->count(),
|
|
'total_lands_checked' => $harvestableLands->count(),
|
|
|
'harvest_results' => $harvestResults
|
|
'harvest_results' => $harvestResults
|
|
|
]);
|
|
]);
|
|
@@ -91,8 +92,6 @@ class PetAutoSkillLogic
|
|
|
'pet_id' => $pet->id,
|
|
'pet_id' => $pet->id,
|
|
|
'user_id' => $userId,
|
|
'user_id' => $userId,
|
|
|
'harvest_count' => $harvestCount,
|
|
'harvest_count' => $harvestCount,
|
|
|
- 'auto_cleared_count' => $autoClearedCount,
|
|
|
|
|
-
|
|
|
|
|
'total_lands' => $harvestableLands->count()
|
|
'total_lands' => $harvestableLands->count()
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
@@ -834,13 +833,15 @@ class PetAutoSkillLogic
|
|
|
->first();
|
|
->first();
|
|
|
|
|
|
|
|
if (!$land) {
|
|
if (!$land) {
|
|
|
|
|
+ Logger::warning('自动清理枯萎作物失败', [
|
|
|
|
|
+ 'user_id' => $userId,
|
|
|
|
|
+ 'land_id' => $landId,
|
|
|
|
|
+ 'error' => '土地不存在'
|
|
|
|
|
+ ]);
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 检查土地状态是否为枯萎状态
|
|
|
|
|
- if ($land->status !== \App\Module\Farm\Enums\LAND_STATUS::WITHERED->value) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
// 获取土地上的作物
|
|
// 获取土地上的作物
|
|
|
$crop = \App\Module\Farm\Models\FarmCrop::where('land_id', $landId)->first();
|
|
$crop = \App\Module\Farm\Models\FarmCrop::where('land_id', $landId)->first();
|
|
@@ -854,6 +855,11 @@ class PetAutoSkillLogic
|
|
|
// 检查作物是否为枯萎状态
|
|
// 检查作物是否为枯萎状态
|
|
|
$cropStageValue = is_object($crop->growth_stage) ? $crop->growth_stage->value : $crop->growth_stage;
|
|
$cropStageValue = is_object($crop->growth_stage) ? $crop->growth_stage->value : $crop->growth_stage;
|
|
|
if ($cropStageValue !== \App\Module\Farm\Enums\GROWTH_STAGE::WITHERED->value) {
|
|
if ($cropStageValue !== \App\Module\Farm\Enums\GROWTH_STAGE::WITHERED->value) {
|
|
|
|
|
+ Logger::warning('自动清理枯萎作物失败', [
|
|
|
|
|
+ 'user_id' => $userId,
|
|
|
|
|
+ 'land_id' => $landId,
|
|
|
|
|
+ 'error' => '作物不是枯萎状态'
|
|
|
|
|
+ ]);
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -868,6 +874,13 @@ class PetAutoSkillLogic
|
|
|
]);
|
|
]);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
+ else {
|
|
|
|
|
+ Logger::warning('自动清理枯萎作物失败', [
|
|
|
|
|
+ 'user_id' => $userId,
|
|
|
|
|
+ 'land_id' => $landId,
|
|
|
|
|
+ 'error' => '铲除作物失败'
|
|
|
|
|
+ ]);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|