getUserLands($userId); } catch (\Exception $e) { Log::error('获取用户土地失败', [ 'user_id' => $userId, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString() ]); return collect(); } } public static function getUserLand(int $userId,int $landId) { // 根据用户id,和土地id获取土地信息 } /** * 获取用户指定位置的土地 * * @param int $userId * @param int $position * @return LandInfoDto|null */ public static function getUserLandByPosition(int $userId, int $position): ?LandInfoDto { try { $landLogic = new LandLogic(); return $landLogic->getUserLandByPosition($userId, $position); } catch (\Exception $e) { Log::error('获取用户指定位置土地失败', [ 'user_id' => $userId, 'position' => $position, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString() ]); return null; } } /** * 升级土地 * * @param int $userId * @param int $landId * @param int $targetType * @param array $materials 消耗的材料 * @return bool */ public static function upgradeLand(int $userId, int $landId, int $targetType, array $materials): bool { try { $landLogic = new LandLogic(); return $landLogic->upgradeLand($userId, $landId, $targetType, $materials); } catch (\Exception $e) { Log::error('升级土地失败', [ 'user_id' => $userId, 'land_id' => $landId, 'target_type' => $targetType, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString() ]); return false; } } /** * 获取可用的升级路径 * * @param int $userId * @param int $landId * @return array */ public static function getAvailableUpgradePaths(int $userId, int $landId): array { try { $landLogic = new LandLogic(); return $landLogic->getAvailableUpgradePaths($userId, $landId); } catch (\Exception $e) { Log::error('获取可用升级路径失败', [ 'user_id' => $userId, 'land_id' => $landId, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString() ]); return []; } } }