File size: 42,671 Bytes
74bc8be | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 | <!DOCTYPE html>
<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> |