|
|
@@ -33,7 +33,7 @@ class LandLogic
|
|
|
$lands = FarmLand::where('user_id', $userId)
|
|
|
->orderBy('position')
|
|
|
->get();
|
|
|
-
|
|
|
+// dd($lands);
|
|
|
return $lands->map(function ($land) {
|
|
|
return LandInfoDto::fromModel($land);
|
|
|
});
|
|
|
@@ -283,7 +283,7 @@ class LandLogic
|
|
|
* @param int $landId
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function getAvailableUpgradePaths(int $userId, int $landId): array
|
|
|
+ public function getAvailableUpgradePaths(int $userId, int $landId ,$to_type =null): array
|
|
|
{
|
|
|
try {
|
|
|
// 获取土地信息
|
|
|
@@ -299,6 +299,9 @@ class LandLogic
|
|
|
$currentType = $land->land_type;
|
|
|
|
|
|
// 获取用户房屋等级
|
|
|
+ /**
|
|
|
+ * @var FarmUser $farmUser
|
|
|
+ */
|
|
|
$farmUser = FarmUser::where('user_id', $userId)->first();
|
|
|
|
|
|
if (!$farmUser) {
|
|
|
@@ -317,12 +320,14 @@ class LandLogic
|
|
|
return $path->toType->unlock_house_level <= $houseLevel;
|
|
|
});
|
|
|
|
|
|
+
|
|
|
// 检查特殊土地数量限制
|
|
|
$specialLandCount = FarmLand::where('user_id', $userId)
|
|
|
->whereIn('land_type', [LAND_TYPE::GOLD->value, LAND_TYPE::BLUE->value, LAND_TYPE::PURPLE->value])
|
|
|
->count();
|
|
|
|
|
|
$houseConfig = $farmUser->houseConfig;
|
|
|
+
|
|
|
$specialLandLimit = $houseConfig->special_land_limit;
|
|
|
|
|
|
// 如果特殊土地已达上限,过滤掉特殊土地升级路径
|
|
|
@@ -333,7 +338,7 @@ class LandLogic
|
|
|
}
|
|
|
|
|
|
// 格式化返回结果
|
|
|
- return $availablePaths->map(function ($path) use ($userId) {
|
|
|
+ return $availablePaths->map(function ( FarmLandUpgradeConfig $path) use ($userId) {
|
|
|
// 获取升级所需材料
|
|
|
$materials = $path->getUpgradeMaterials();
|
|
|
|