// Simulated garage data - this would be replaced with actual game data let garageData = { vehicles: [ { id: 1, name: "Offroad Vehicle", category: "Land", type: "Transport", status: "available", fuel: 100, damage: 0, maintenance: 95, lastUsed: "2025-04-10T15:30:00", image: "placeholder.jpg" }, { id: 2, name: "Transport Helicopter", category: "Air", type: "Transport", status: "in-use", fuel: 75, damage: 15, maintenance: 80, lastUsed: "2025-04-12T09:15:00", image: "placeholder.jpg" }, { id: 3, name: "Patrol Boat", category: "Sea", type: "Patrol", status: "maintenance", fuel: 50, damage: 35, maintenance: 45, lastUsed: "2025-04-11T18:45:00", image: "placeholder.jpg" }, { id: 4, name: "Armed SUV", category: "Land", type: "Combat", status: "available", fuel: 90, damage: 5, maintenance: 88, lastUsed: "2025-04-12T11:20:00", image: "placeholder.jpg" } ] }; // Initialize the garage interface function initializeGarage() { updateStats(); setupCategoryFilters(); displayVehicles(); } // Update garage statistics function updateStats() { const totalVehicles = garageData.vehicles.length; const inMaintenance = garageData.vehicles.filter(v => v.status === 'maintenance').length; document.getElementById('vehicleCount').textContent = totalVehicles; document.getElementById('maintenanceCount').textContent = inMaintenance; } // Set up category filters function setupCategoryFilters() { const categories = ['All', ...new Set(garageData.vehicles.map(v => v.category))]; const filtersContainer = document.getElementById('categoryFilters'); categories.forEach(category => { const button = document.createElement('button'); button.className = 'filter-btn' + (category === 'All' ? ' active' : ''); button.textContent = category; button.addEventListener('click', () => filterVehicles(category)); filtersContainer.appendChild(button); }); } // Filter vehicles by category function filterVehicles(category) { // Update active filter button document.querySelectorAll('.filter-btn').forEach(btn => { btn.classList.toggle('active', btn.textContent === category); }); // Filter and display vehicles const filteredVehicles = category === 'All' ? garageData.vehicles : garageData.vehicles.filter(v => v.category === category); displayVehicles(filteredVehicles); } // Display vehicles in the grid function displayVehicles(vehicles = garageData.vehicles) { const grid = document.getElementById('vehiclesGrid'); grid.innerHTML = ''; vehicles.forEach(vehicle => { const card = document.createElement('div'); card.className = 'vehicle-card'; const statusText = { 'available': 'Available', 'in-use': 'In Use', 'maintenance': 'Maintenance' }[vehicle.status]; card.innerHTML = `