Download index.html from ToIik/farming: direct link, hf CLI and curl.
- Browser
- Download file 42.7 kB
-
https://huggingface.co/spaces/ToIik/farming/resolve/main/index.html
- Command line
-
hf download hf://spaces/ToIik/farming/index.html
-
curl -L -o index.html https://huggingface.co/spaces/ToIik/farming/resolve/main/index.html
42.7 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Farming Simulator 25</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| @keyframes pulse { | |
| 0% { transform: scale(1); } | |
| 50% { transform: scale(1.05); } | |
| 100% { transform: scale(1); } | |
| } | |
| .pulse-animation { | |
| animation: pulse 2s infinite; | |
| } | |
| .field-tile { | |
| transition: all 0.3s ease; | |
| } | |
| .field-tile:hover { | |
| transform: scale(1.05); | |
| box-shadow: 0 0 10px rgba(0,0,0,0.3); | |
| } | |
| .progress-bar { | |
| transition: width 0.5s ease; | |
| } | |
| .vehicle { | |
| transition: all 0.5s ease; | |
| } | |
| .harvest-effect { | |
| position: absolute; | |
| background-color: gold; | |
| border-radius: 50%; | |
| pointer-events: none; | |
| transform: scale(0); | |
| opacity: 0.7; | |
| animation: harvest-animation 1s forwards; | |
| } | |
| @keyframes harvest-animation { | |
| 0% { transform: scale(0); opacity: 0.7; } | |
| 100% { transform: scale(3); opacity: 0; } | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-green-100 font-sans"> | |
| <div class="container mx-auto px-4 py-6"> | |
| <!-- Game Header --> | |
| <header class="flex justify-between items-center mb-6 bg-green-800 text-white p-4 rounded-lg shadow-lg"> | |
| <div class="flex items-center"> | |
| <i class="fas fa-tractor text-3xl mr-3"></i> | |
| <h1 class="text-2xl font-bold">Farming Simulator 25</h1> | |
| </div> | |
| <div class="flex items-center space-x-4"> | |
| <div class="bg-green-700 px-4 py-2 rounded-lg"> | |
| <span class="font-bold">$</span> | |
| <span id="money">50,000</span> | |
| </div> | |
| <div class="bg-green-700 px-4 py-2 rounded-lg"> | |
| <span class="font-bold">Day:</span> | |
| <span id="day">1</span> | |
| </div> | |
| <button id="next-day-btn" class="bg-yellow-600 hover:bg-yellow-700 px-4 py-2 rounded-lg font-bold transition"> | |
| Next Day <i class="fas fa-forward ml-1"></i> | |
| </button> | |
| </div> | |
| </header> | |
| <!-- Main Game Area --> | |
| <div class="flex flex-col lg:flex-row gap-6"> | |
| <!-- Left Panel - Farm Field --> | |
| <div class="flex-1 bg-white p-4 rounded-lg shadow-lg"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h2 class="text-xl font-bold text-green-800">Your Farm</h2> | |
| <div class="flex space-x-2"> | |
| <button id="buy-field-btn" class="bg-blue-600 hover:bg-blue-700 text-white px-3 py-1 rounded text-sm"> | |
| Buy Field ($5,000) | |
| </button> | |
| <button id="sell-field-btn" class="bg-red-600 hover:bg-red-700 text-white px-3 py-1 rounded text-sm"> | |
| Sell Field ($3,000) | |
| </button> | |
| </div> | |
| </div> | |
| <div id="farm-field" class="grid grid-cols-5 gap-2"> | |
| <!-- Field tiles will be generated here --> | |
| </div> | |
| <div class="mt-6 bg-gray-100 p-4 rounded-lg"> | |
| <h3 class="font-bold mb-2">Field Status</h3> | |
| <div id="field-status" class="text-sm"> | |
| Select a field to see details | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Right Panel - Controls --> | |
| <div class="w-full lg:w-80 bg-white p-4 rounded-lg shadow-lg h-fit"> | |
| <div class="mb-6"> | |
| <h2 class="text-xl font-bold text-green-800 mb-4">Equipment</h2> | |
| <div class="grid grid-cols-2 gap-3"> | |
| <div class="bg-gray-100 p-3 rounded-lg cursor-pointer hover:bg-gray-200 transition equipment-btn" data-equipment="tractor"> | |
| <i class="fas fa-tractor text-3xl text-blue-600 mb-1"></i> | |
| <div class="text-sm font-bold">Tractor</div> | |
| <div class="text-xs">$15,000</div> | |
| </div> | |
| <div class="bg-gray-100 p-3 rounded-lg cursor-pointer hover:bg-gray-200 transition equipment-btn" data-equipment="harvester"> | |
| <i class="fas fa-harvest text-3xl text-green-600 mb-1"></i> | |
| <div class="text-sm font-bold">Harvester</div> | |
| <div class="text-xs">$25,000</div> | |
| </div> | |
| <div class="bg-gray-100 p-3 rounded-lg cursor-pointer hover:bg-gray-200 transition equipment-btn" data-equipment="plow"> | |
| <i class="fas fa-tools text-3xl text-yellow-600 mb-1"></i> | |
| <div class="text-sm font-bold">Plow</div> | |
| <div class="text-xs">$5,000</div> | |
| </div> | |
| <div class="bg-gray-100 p-3 rounded-lg cursor-pointer hover:bg-gray-200 transition equipment-btn" data-equipment="seeder"> | |
| <i class="fas fa-seedling text-3xl text-green-700 mb-1"></i> | |
| <div class="text-sm font-bold">Seeder</div> | |
| <div class="text-xs">$8,000</div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="mb-6"> | |
| <h2 class="text-xl font-bold text-green-800 mb-4">Crops</h2> | |
| <div class="grid grid-cols-2 gap-3"> | |
| <div class="bg-gray-100 p-3 rounded-lg cursor-pointer hover:bg-gray-200 transition crop-btn" data-crop="wheat"> | |
| <i class="fas fa-wheat-alt text-3xl text-yellow-500 mb-1"></i> | |
| <div class="text-sm font-bold">Wheat</div> | |
| <div class="text-xs">$200/unit</div> | |
| </div> | |
| <div class="bg-gray-100 p-3 rounded-lg cursor-pointer hover:bg-gray-200 transition crop-btn" data-crop="corn"> | |
| <i class="fas fa-corn text-3xl text-yellow-700 mb-1"></i> | |
| <div class="text-sm font-bold">Corn</div> | |
| <div class="text-xs">$300/unit</div> | |
| </div> | |
| <div class="bg-gray-100 p-3 rounded-lg cursor-pointer hover:bg-gray-200 transition crop-btn" data-crop="soybean"> | |
| <i class="fas fa-leaf text-3xl text-green-600 mb-1"></i> | |
| <div class="text-sm font-bold">Soybean</div> | |
| <div class="text-xs">$250/unit</div> | |
| </div> | |
| <div class="bg-gray-100 p-3 rounded-lg cursor-pointer hover:bg-gray-200 transition crop-btn" data-crop="sunflower"> | |
| <i class="fas fa-sun text-3xl text-yellow-400 mb-1"></i> | |
| <div class="text-sm font-bold">Sunflower</div> | |
| <div class="text-xs">$350/unit</div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="bg-gray-100 p-4 rounded-lg"> | |
| <h3 class="font-bold mb-2">Actions</h3> | |
| <div class="space-y-2"> | |
| <button id="plow-btn" class="w-full bg-yellow-600 hover:bg-yellow-700 text-white py-2 rounded disabled:opacity-50" disabled> | |
| Plow Field | |
| </button> | |
| <button id="plant-btn" class="w-full bg-green-600 hover:bg-green-700 text-white py-2 rounded disabled:opacity-50" disabled> | |
| Plant Crops | |
| </button> | |
| <button id="harvest-btn" class="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 rounded disabled:opacity-50" disabled> | |
| Harvest Crops | |
| </button> | |
| <button id="sell-btn" class="w-full bg-purple-600 hover:bg-purple-700 text-white py-2 rounded disabled:opacity-50" disabled> | |
| Sell Harvest | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Inventory and Stats --> | |
| <div class="mt-6 grid grid-cols-1 md:grid-cols-3 gap-4"> | |
| <div class="bg-white p-4 rounded-lg shadow-lg"> | |
| <h2 class="text-xl font-bold text-green-800 mb-3">Inventory</h2> | |
| <div id="inventory" class="space-y-2"> | |
| <div class="flex justify-between"> | |
| <span>Wheat:</span> | |
| <span id="wheat-inv">0 units</span> | |
| </div> | |
| <div class="flex justify-between"> | |
| <span>Corn:</span> | |
| <span id="corn-inv">0 units</span> | |
| </div> | |
| <div class="flex justify-between"> | |
| <span>Soybean:</span> | |
| <span id="soybean-inv">0 units</span> | |
| </div> | |
| <div class="flex justify-between"> | |
| <span>Sunflower:</span> | |
| <span id="sunflower-inv">0 units</span> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="bg-white p-4 rounded-lg shadow-lg"> | |
| <h2 class="text-xl font-bold text-green-800 mb-3">Equipment Owned</h2> | |
| <div id="equipment-owned" class="space-y-2"> | |
| <div class="flex items-center"> | |
| <i class="fas fa-tractor text-blue-600 mr-2"></i> | |
| <span>Tractor:</span> | |
| <span class="ml-auto font-bold">1</span> | |
| </div> | |
| <div class="flex items-center"> | |
| <i class="fas fa-harvest text-green-600 mr-2"></i> | |
| <span>Harvester:</span> | |
| <span class="ml-auto font-bold">0</span> | |
| </div> | |
| <div class="flex items-center"> | |
| <i class="fas fa-tools text-yellow-600 mr-2"></i> | |
| <span>Plow:</span> | |
| <span class="ml-auto font-bold">0</span> | |
| </div> | |
| <div class="flex items-center"> | |
| <i class="fas fa-seedling text-green-700 mr-2"></i> | |
| <span>Seeder:</span> | |
| <span class="ml-auto font-bold">0</span> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="bg-white p-4 rounded-lg shadow-lg"> | |
| <h2 class="text-xl font-bold text-green-800 mb-3">Stats</h2> | |
| <div class="space-y-2"> | |
| <div class="flex justify-between"> | |
| <span>Fields Owned:</span> | |
| <span id="fields-owned">1</span> | |
| </div> | |
| <div class="flex justify-between"> | |
| <span>Total Harvested:</span> | |
| <span id="total-harvested">0 units</span> | |
| </div> | |
| <div class="flex justify-between"> | |
| <span>Total Sold:</span> | |
| <span id="total-sold">$0</span> | |
| </div> | |
| <div class="flex justify-between"> | |
| <span>Days Played:</span> | |
| <span id="days-played">1</span> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Vehicle Display --> | |
| <div id="vehicle-display" class="mt-6 bg-white p-4 rounded-lg shadow-lg relative" style="height: 120px;"> | |
| <div id="tractor" class="vehicle absolute bottom-4 left-4 hidden"> | |
| <i class="fas fa-tractor text-4xl text-blue-600"></i> | |
| </div> | |
| <div id="harvester" class="vehicle absolute bottom-4 left-20 hidden"> | |
| <i class="fas fa-harvest text-4xl text-green-600"></i> | |
| </div> | |
| <div id="plow" class="vehicle absolute bottom-4 left-36 hidden"> | |
| <i class="fas fa-tools text-4xl text-yellow-600"></i> | |
| </div> | |
| <div id="seeder" class="vehicle absolute bottom-4 left-52 hidden"> | |
| <i class="fas fa-seedling text-4xl text-green-700"></i> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Modals --> | |
| <div id="notification-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50"> | |
| <div class="bg-white p-6 rounded-lg max-w-md w-full"> | |
| <h3 class="text-xl font-bold mb-2" id="notification-title">Notification</h3> | |
| <p id="notification-message">This is a notification message.</p> | |
| <button id="notification-close" class="mt-4 bg-blue-600 text-white px-4 py-2 rounded">OK</button> | |
| </div> | |
| </div> | |
| <script> | |
| // Game State | |
| const gameState = { | |
| money: 50000, | |
| day: 1, | |
| selectedField: null, | |
| selectedEquipment: null, | |
| selectedCrop: null, | |
| fields: [], | |
| inventory: { | |
| wheat: 0, | |
| corn: 0, | |
| soybean: 0, | |
| sunflower: 0 | |
| }, | |
| equipment: { | |
| tractor: 1, | |
| harvester: 0, | |
| plow: 0, | |
| seeder: 0 | |
| }, | |
| stats: { | |
| fieldsOwned: 1, | |
| totalHarvested: 0, | |
| totalSold: 0, | |
| daysPlayed: 1 | |
| }, | |
| prices: { | |
| wheat: 200, | |
| corn: 300, | |
| soybean: 250, | |
| sunflower: 350, | |
| tractor: 15000, | |
| harvester: 25000, | |
| plow: 5000, | |
| seeder: 8000, | |
| field: 5000, | |
| fieldSell: 3000 | |
| } | |
| }; | |
| // DOM Elements | |
| const moneyEl = document.getElementById('money'); | |
| const dayEl = document.getElementById('day'); | |
| const nextDayBtn = document.getElementById('next-day-btn'); | |
| const farmFieldEl = document.getElementById('farm-field'); | |
| const fieldStatusEl = document.getElementById('field-status'); | |
| const buyFieldBtn = document.getElementById('buy-field-btn'); | |
| const sellFieldBtn = document.getElementById('sell-field-btn'); | |
| const plowBtn = document.getElementById('plow-btn'); | |
| const plantBtn = document.getElementById('plant-btn'); | |
| const harvestBtn = document.getElementById('harvest-btn'); | |
| const sellBtn = document.getElementById('sell-btn'); | |
| const equipmentBtns = document.querySelectorAll('.equipment-btn'); | |
| const cropBtns = document.querySelectorAll('.crop-btn'); | |
| const notificationModal = document.getElementById('notification-modal'); | |
| const notificationTitle = document.getElementById('notification-title'); | |
| const notificationMessage = document.getElementById('notification-message'); | |
| const notificationClose = document.getElementById('notification-close'); | |
| const vehicleDisplay = document.getElementById('vehicle-display'); | |
| // Initialize the game | |
| function initGame() { | |
| updateUI(); | |
| createInitialField(); | |
| setupEventListeners(); | |
| } | |
| // Create initial field | |
| function createInitialField() { | |
| gameState.fields.push({ | |
| id: 1, | |
| size: 1, | |
| plowed: false, | |
| planted: null, | |
| growth: 0, | |
| ready: false | |
| }); | |
| renderFields(); | |
| } | |
| // Render all fields | |
| function renderFields() { | |
| farmFieldEl.innerHTML = ''; | |
| gameState.fields.forEach(field => { | |
| const fieldEl = document.createElement('div'); | |
| fieldEl.className = 'field-tile bg-brown-200 h-24 rounded-lg cursor-pointer flex flex-col items-center justify-center relative overflow-hidden'; | |
| // Set field appearance based on state | |
| if (field.ready) { | |
| // Ready to harvest | |
| let bgColor = ''; | |
| if (field.planted === 'wheat') bgColor = 'bg-yellow-300'; | |
| else if (field.planted === 'corn') bgColor = 'bg-yellow-600'; | |
| else if (field.planted === 'soybean') bgColor = 'bg-green-500'; | |
| else if (field.planted === 'sunflower') bgColor = 'bg-yellow-400'; | |
| fieldEl.className = `field-tile ${bgColor} h-24 rounded-lg cursor-pointer flex flex-col items-center justify-center relative overflow-hidden`; | |
| const iconClass = field.planted === 'wheat' ? 'fa-wheat-alt' : | |
| field.planted === 'corn' ? 'fa-corn' : | |
| field.planted === 'soybean' ? 'fa-leaf' : 'fa-sun'; | |
| fieldEl.innerHTML = ` | |
| <i class="fas ${iconClass} text-3xl ${field.planted === 'sunflower' ? 'text-yellow-600' : 'text-white'} mb-1"></i> | |
| <div class="text-xs font-bold">Ready!</div> | |
| <div class="absolute bottom-0 left-0 right-0 bg-green-800 text-white text-center py-1 text-xs"> | |
| Field ${field.id} | |
| </div> | |
| `; | |
| } else if (field.planted) { | |
| // Growing | |
| let bgColor = ''; | |
| if (field.planted === 'wheat') bgColor = 'bg-yellow-100'; | |
| else if (field.planted === 'corn') bgColor = 'bg-yellow-200'; | |
| else if (field.planted === 'soybean') bgColor = 'bg-green-200'; | |
| else if (field.planted === 'sunflower') bgColor = 'bg-yellow-100'; | |
| fieldEl.className = `field-tile ${bgColor} h-24 rounded-lg cursor-pointer flex flex-col items-center justify-center relative overflow-hidden`; | |
| const iconClass = field.planted === 'wheat' ? 'fa-wheat-alt' : | |
| field.planted === 'corn' ? 'fa-corn' : | |
| field.planted === 'soybean' ? 'fa-leaf' : 'fa-sun'; | |
| fieldEl.innerHTML = ` | |
| <i class="fas ${iconClass} text-2xl ${field.planted === 'sunflower' ? 'text-yellow-500' : 'text-green-700'} mb-1"></i> | |
| <div class="w-full px-2"> | |
| <div class="bg-gray-300 h-2 rounded-full overflow-hidden"> | |
| <div class="progress-bar bg-green-600 h-2" style="width: ${field.growth}%"></div> | |
| </div> | |
| </div> | |
| <div class="text-xs mt-1">Growing...</div> | |
| <div class="absolute bottom-0 left-0 right-0 bg-green-800 text-white text-center py-1 text-xs"> | |
| Field ${field.id} | |
| </div> | |
| `; | |
| } else if (field.plowed) { | |
| // Plowed but not planted | |
| fieldEl.className = 'field-tile bg-brown-300 h-24 rounded-lg cursor-pointer flex flex-col items-center justify-center relative overflow-hidden'; | |
| fieldEl.innerHTML = ` | |
| <i class="fas fa-seedling text-3xl text-green-700 mb-1"></i> | |
| <div class="text-xs">Ready to plant</div> | |
| <div class="absolute bottom-0 left-0 right-0 bg-green-800 text-white text-center py-1 text-xs"> | |
| Field ${field.id} | |
| </div> | |
| `; | |
| } else { | |
| // Untouched field | |
| fieldEl.className = 'field-tile bg-brown-400 h-24 rounded-lg cursor-pointer flex flex-col items-center justify-center relative overflow-hidden'; | |
| fieldEl.innerHTML = ` | |
| <i class="fas fa-grass text-3xl text-green-800 mb-1"></i> | |
| <div class="text-xs">Needs plowing</div> | |
| <div class="absolute bottom-0 left-0 right-0 bg-green-800 text-white text-center py-1 text-xs"> | |
| Field ${field.id} | |
| </div> | |
| `; | |
| } | |
| // Highlight selected field | |
| if (gameState.selectedField === field.id) { | |
| fieldEl.classList.add('ring-4', 'ring-yellow-500'); | |
| } | |
| fieldEl.addEventListener('click', () => selectField(field.id)); | |
| farmFieldEl.appendChild(fieldEl); | |
| }); | |
| } | |
| // Select a field | |
| function selectField(fieldId) { | |
| gameState.selectedField = fieldId; | |
| updateFieldStatus(); | |
| renderFields(); | |
| updateActionButtons(); | |
| } | |
| // Update field status display | |
| function updateFieldStatus() { | |
| if (!gameState.selectedField) { | |
| fieldStatusEl.textContent = 'Select a field to see details'; | |
| return; | |
| } | |
| const field = gameState.fields.find(f => f.id === gameState.selectedField); | |
| if (!field) return; | |
| let status = `Field ${field.id} - Size: ${field.size} acre(s)\n`; | |
| if (field.ready) { | |
| status += `Status: Ready to harvest (${field.planted})\n`; | |
| status += `Estimated yield: ${field.size * 10} units`; | |
| } else if (field.planted) { | |
| status += `Status: Growing ${field.planted} (${field.growth}%)\n`; | |
| status += `Time remaining: ${Math.ceil((100 - field.growth) / 10)} days`; | |
| } else if (field.plowed) { | |
| status += 'Status: Plowed and ready for planting'; | |
| } else { | |
| status += 'Status: Needs plowing'; | |
| } | |
| fieldStatusEl.innerHTML = status.split('\n').map(line => `<div>${line}</div>`).join(''); | |
| } | |
| // Update action buttons based on selection | |
| function updateActionButtons() { | |
| const field = gameState.fields.find(f => f.id === gameState.selectedField); | |
| // Reset all buttons | |
| plowBtn.disabled = true; | |
| plantBtn.disabled = true; | |
| harvestBtn.disabled = true; | |
| sellBtn.disabled = true; | |
| if (!gameState.selectedField) return; | |
| // Plow button - enabled if field is not plowed | |
| if (!field.plowed) { | |
| plowBtn.disabled = false; | |
| } | |
| // Plant button - enabled if field is plowed but not planted | |
| if (field.plowed && !field.planted && gameState.selectedCrop) { | |
| plantBtn.disabled = false; | |
| } | |
| // Harvest button - enabled if crop is ready | |
| if (field.ready) { | |
| harvestBtn.disabled = false; | |
| } | |
| // Sell button - enabled if there's anything in inventory | |
| if (Object.values(gameState.inventory).some(amount => amount > 0)) { | |
| sellBtn.disabled = false; | |
| } | |
| } | |
| // Update all UI elements | |
| function updateUI() { | |
| // Money and day | |
| moneyEl.textContent = gameState.money.toLocaleString(); | |
| dayEl.textContent = gameState.day; | |
| // Inventory | |
| document.getElementById('wheat-inv').textContent = `${gameState.inventory.wheat} units`; | |
| document.getElementById('corn-inv').textContent = `${gameState.inventory.corn} units`; | |
| document.getElementById('soybean-inv').textContent = `${gameState.inventory.soybean} units`; | |
| document.getElementById('sunflower-inv').textContent = `${gameState.inventory.sunflower} units`; | |
| // Equipment owned | |
| const equipmentEl = document.getElementById('equipment-owned'); | |
| equipmentEl.innerHTML = ` | |
| <div class="flex items-center"> | |
| <i class="fas fa-tractor text-blue-600 mr-2"></i> | |
| <span>Tractor:</span> | |
| <span class="ml-auto font-bold">${gameState.equipment.tractor}</span> | |
| </div> | |
| <div class="flex items-center"> | |
| <i class="fas fa-harvest text-green-600 mr-2"></i> | |
| <span>Harvester:</span> | |
| <span class="ml-auto font-bold">${gameState.equipment.harvester}</span> | |
| </div> | |
| <div class="flex items-center"> | |
| <i class="fas fa-tools text-yellow-600 mr-2"></i> | |
| <span>Plow:</span> | |
| <span class="ml-auto font-bold">${gameState.equipment.plow}</span> | |
| </div> | |
| <div class="flex items-center"> | |
| <i class="fas fa-seedling text-green-700 mr-2"></i> | |
| <span>Seeder:</span> | |
| <span class="ml-auto font-bold">${gameState.equipment.seeder}</span> | |
| </div> | |
| `; | |
| // Stats | |
| document.getElementById('fields-owned').textContent = gameState.stats.fieldsOwned; | |
| document.getElementById('total-harvested').textContent = `${gameState.stats.totalHarvested} units`; | |
| document.getElementById('total-sold').textContent = `$${gameState.stats.totalSold.toLocaleString()}`; | |
| document.getElementById('days-played').textContent = gameState.stats.daysPlayed; | |
| // Update vehicle display | |
| updateVehicleDisplay(); | |
| } | |
| // Update vehicle display | |
| function updateVehicleDisplay() { | |
| // Hide all vehicles first | |
| document.querySelectorAll('.vehicle').forEach(el => el.classList.add('hidden')); | |
| // Show owned vehicles | |
| if (gameState.equipment.tractor > 0) { | |
| document.getElementById('tractor').classList.remove('hidden'); | |
| } | |
| if (gameState.equipment.harvester > 0) { | |
| document.getElementById('harvester').classList.remove('hidden'); | |
| } | |
| if (gameState.equipment.plow > 0) { | |
| document.getElementById('plow').classList.remove('hidden'); | |
| } | |
| if (gameState.equipment.seeder > 0) { | |
| document.getElementById('seeder').classList.remove('hidden'); | |
| } | |
| // Highlight selected equipment | |
| if (gameState.selectedEquipment) { | |
| const selectedEl = document.getElementById(gameState.selectedEquipment); | |
| if (selectedEl) { | |
| selectedEl.classList.add('pulse-animation'); | |
| } | |
| } | |
| } | |
| // Show notification | |
| function showNotification(title, message) { | |
| notificationTitle.textContent = title; | |
| notificationMessage.textContent = message; | |
| notificationModal.classList.remove('hidden'); | |
| } | |
| // Setup event listeners | |
| function setupEventListeners() { | |
| // Equipment selection | |
| equipmentBtns.forEach(btn => { | |
| btn.addEventListener('click', () => { | |
| const equipment = btn.dataset.equipment; | |
| // Check if player owns this equipment | |
| if (gameState.equipment[equipment] === 0) { | |
| // Try to buy | |
| if (gameState.money >= gameState.prices[equipment]) { | |
| if (confirm(`Buy ${equipment} for $${gameState.prices[equipment].toLocaleString()}?`)) { | |
| gameState.money -= gameState.prices[equipment]; | |
| gameState.equipment[equipment]++; | |
| updateUI(); | |
| showNotification('Purchase Complete', `You bought a ${equipment}!`); | |
| } | |
| } else { | |
| showNotification('Not Enough Money', `You need $${gameState.prices[equipment].toLocaleString()} to buy a ${equipment}.`); | |
| } | |
| } else { | |
| // Select equipment | |
| gameState.selectedEquipment = equipment; | |
| document.querySelectorAll('.equipment-btn').forEach(b => b.classList.remove('bg-gray-300')); | |
| btn.classList.add('bg-gray-300'); | |
| // Remove pulse animation from all vehicles | |
| document.querySelectorAll('.vehicle').forEach(el => el.classList.remove('pulse-animation')); | |
| // Add pulse to selected vehicle | |
| const vehicleEl = document.getElementById(equipment); | |
| if (vehicleEl) { | |
| vehicleEl.classList.add('pulse-animation'); | |
| } | |
| updateActionButtons(); | |
| } | |
| }); | |
| }); | |
| // Crop selection | |
| cropBtns.forEach(btn => { | |
| btn.addEventListener('click', () => { | |
| const crop = btn.dataset.crop; | |
| gameState.selectedCrop = crop; | |
| document.querySelectorAll('.crop-btn').forEach(b => b.classList.remove('bg-gray-300')); | |
| btn.classList.add('bg-gray-300'); | |
| updateActionButtons(); | |
| }); | |
| }); | |
| // Action buttons | |
| plowBtn.addEventListener('click', () => { | |
| if (!gameState.selectedField || !gameState.selectedEquipment) return; | |
| const field = gameState.fields.find(f => f.id === gameState.selectedField); | |
| if (!field || field.plowed) return; | |
| if (gameState.selectedEquipment !== 'plow') { | |
| showNotification('Wrong Equipment', 'You need to select the plow to plow a field.'); | |
| return; | |
| } | |
| // Animate plowing | |
| const fieldEl = document.querySelector(`.field-tile:nth-child(${gameState.fields.findIndex(f => f.id === field.id) + 1})`); | |
| if (fieldEl) { | |
| fieldEl.classList.add('bg-brown-300'); | |
| fieldEl.innerHTML = ` | |
| <i class="fas fa-tools text-3xl text-yellow-600 animate-spin mb-2"></i> | |
| <div class="text-xs">Plowing...</div> | |
| `; | |
| setTimeout(() => { | |
| field.plowed = true; | |
| renderFields(); | |
| updateFieldStatus(); | |
| updateActionButtons(); | |
| showNotification('Field Plowed', `Field ${field.id} has been plowed and is ready for planting.`); | |
| }, 1500); | |
| } | |
| }); | |
| plantBtn.addEventListener('click', () => { | |
| if (!gameState.selectedField || !gameState.selectedCrop || !gameState.selectedEquipment) return; | |
| const field = gameState.fields.find(f => f.id === gameState.selectedField); | |
| if (!field || !field.plowed || field.planted) return; | |
| if (gameState.selectedEquipment !== 'seeder') { | |
| showNotification('Wrong Equipment', 'You need to select the seeder to plant crops.'); | |
| return; | |
| } | |
| // Animate planting | |
| const fieldEl = document.querySelector(`.field-tile:nth-child(${gameState.fields.findIndex(f => f.id === field.id) + 1})`); | |
| if (fieldEl) { | |
| let bgColor = ''; | |
| if (gameState.selectedCrop === 'wheat') bgColor = 'bg-yellow-100'; | |
| else if (gameState.selectedCrop === 'corn') bgColor = 'bg-yellow-200'; | |
| else if (gameState.selectedCrop === 'soybean') bgColor = 'bg-green-200'; | |
| else if (gameState.selectedCrop === 'sunflower') bgColor = 'bg-yellow-100'; | |
| fieldEl.className = `field-tile ${bgColor} h-24 rounded-lg cursor-pointer flex flex-col items-center justify-center relative overflow-hidden`; | |
| fieldEl.innerHTML = ` | |
| <i class="fas fa-seedling text-3xl text-green-700 animate-bounce mb-2"></i> | |
| <div class="text-xs">Planting...</div> | |
| `; | |
| setTimeout(() => { | |
| field.planted = gameState.selectedCrop; | |
| field.growth = 10; // Start at 10% | |
| renderFields(); | |
| updateFieldStatus(); | |
| updateActionButtons(); | |
| showNotification('Crops Planted', `You planted ${gameState.selectedCrop} in field ${field.id}.`); | |
| }, 1500); | |
| } | |
| }); | |
| harvestBtn.addEventListener('click', () => { | |
| if (!gameState.selectedField || !gameState.selectedEquipment) return; | |
| const field = gameState.fields.find(f => f.id === gameState.selectedField); | |
| if (!field || !field.ready) return; | |
| if (gameState.selectedEquipment !== 'harvester') { | |
| showNotification('Wrong Equipment', 'You need to select the harvester to harvest crops.'); | |
| return; | |
| } | |
| // Animate harvesting | |
| const fieldEl = document.querySelector(`.field-tile:nth-child(${gameState.fields.findIndex(f => f.id === field.id) + 1})`); | |
| if (fieldEl) { | |
| // Create harvest effect | |
| for (let i = 0; i < 5; i++) { | |
| setTimeout(() => { | |
| const effect = document.createElement('div'); | |
| effect.className = 'harvest-effect'; | |
| effect.style.width = '20px'; | |
| effect.style.height = '20px'; | |
| effect.style.left = `${Math.random() * 80 + 10}%`; | |
| effect.style.top = `${Math.random() * 80 + 10}%`; | |
| fieldEl.appendChild(effect); | |
| // Remove effect after animation | |
| setTimeout(() => effect.remove(), 1000); | |
| }, i * 300); | |
| } | |
| setTimeout(() => { | |
| // Calculate yield | |
| const yieldAmount = field.size * 10; | |
| gameState.inventory[field.planted] += yieldAmount; | |
| gameState.stats.totalHarvested += yieldAmount; | |
| // Reset field | |
| field.planted = null; | |
| field.ready = false; | |
| field.growth = 0; | |
| field.plowed = false; | |
| renderFields(); | |
| updateUI(); | |
| updateFieldStatus(); | |
| updateActionButtons(); | |
| showNotification('Harvest Complete', `You harvested ${yieldAmount} units of ${field.planted} from field ${field.id}.`); | |
| }, 2000); | |
| } | |
| }); | |
| sellBtn.addEventListener('click', () => { | |
| // Calculate total value | |
| let totalValue = 0; | |
| let soldItems = []; | |
| for (const [crop, amount] of Object.entries(gameState.inventory)) { | |
| if (amount > 0) { | |
| const value = amount * gameState.prices[crop]; | |
| totalValue += value; | |
| soldItems.push(`${amount} ${crop} for $${value.toLocaleString()}`); | |
| gameState.inventory[crop] = 0; | |
| } | |
| } | |
| if (totalValue === 0) { | |
| showNotification('Nothing to Sell', 'Your inventory is empty.'); | |
| return; | |
| } | |
| gameState.money += totalValue; | |
| gameState.stats.totalSold += totalValue; | |
| updateUI(); | |
| updateActionButtons(); | |
| showNotification('Sale Complete', `You sold ${soldItems.join(', ')} for a total of $${totalValue.toLocaleString()}.`); | |
| }); | |
| // Buy/sell field | |
| buyFieldBtn.addEventListener('click', () => { | |
| if (gameState.money >= gameState.prices.field) { | |
| const newFieldId = gameState.fields.length + 1; | |
| gameState.fields.push({ | |
| id: newFieldId, | |
| size: 1, | |
| plowed: false, | |
| planted: null, | |
| growth: 0, | |
| ready: false | |
| }); | |
| gameState.money -= gameState.prices.field; | |
| gameState.stats.fieldsOwned++; | |
| renderFields(); | |
| updateUI(); | |
| showNotification('Field Purchased', `You bought a new field (ID: ${newFieldId}) for $${gameState.prices.field.toLocaleString()}.`); | |
| } else { | |
| showNotification('Not Enough Money', `You need $${gameState.prices.field.toLocaleString()} to buy a new field.`); | |
| } | |
| }); | |
| sellFieldBtn.addEventListener('click', () => { | |
| if (!gameState.selectedField) { | |
| showNotification('No Field Selected', 'Please select a field to sell.'); | |
| return; | |
| } | |
| if (gameState.fields.length <= 1) { | |
| showNotification('Cannot Sell', 'You must keep at least one field.'); | |
| return; | |
| } | |
| const fieldIndex = gameState.fields.findIndex(f => f.id === gameState.selectedField); | |
| if (fieldIndex === -1) return; | |
| const field = gameState.fields[fieldIndex]; | |
| // Check if field has crops | |
| if (field.planted) { | |
| showNotification('Field Has Crops', 'You cannot sell a field with growing crops.'); | |
| return; | |
| } | |
| if (confirm(`Sell field ${field.id} for $${gameState.prices.fieldSell.toLocaleString()}?`)) { | |
| gameState.money += gameState.prices.fieldSell; | |
| gameState.fields.splice(fieldIndex, 1); | |
| gameState.selectedField = null; | |
| gameState.stats.fieldsOwned--; | |
| renderFields(); | |
| updateUI(); | |
| updateFieldStatus(); | |
| showNotification('Field Sold', `You sold field ${field.id} for $${gameState.prices.fieldSell.toLocaleString()}.`); | |
| } | |
| }); | |
| // Next day button | |
| nextDayBtn.addEventListener('click', () => { | |
| gameState.day++; | |
| gameState.stats.daysPlayed++; | |
| // Grow crops | |
| gameState.fields.forEach(field => { | |
| if (field.planted && !field.ready) { | |
| field.growth += 10; | |
| if (field.growth >= 100) { | |
| field.growth = 100; | |
| field.ready = true; | |
| } | |
| } | |
| }); | |
| renderFields(); | |
| updateUI(); | |
| updateFieldStatus(); | |
| showNotification('New Day', `Day ${gameState.day} begins. Your crops have grown.`); | |
| }); | |
| // Notification close | |
| notificationClose.addEventListener('click', () => { | |
| notificationModal.classList.add('hidden'); | |
| }); | |
| } | |
| // Start the game | |
| initGame(); | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=ToIik/farming" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |