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
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
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>中国农场模拟器</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Microsoft YaHei', sans-serif;
        }

        body {
            background-color: #e8f4ea;
            color: #333;
            overflow: hidden;
            height: 100vh;
        }

        /* 游戏容器 */
        .game-container {
            display: flex;
            height: 100vh;
            position: relative;
        }

        /* 侧边栏 - 信息面板 */
        .sidebar {
            width: 250px;
            background-color: #4a6b3a;
            color: white;
            padding: 20px;
            box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
            z-index: 10;
            display: flex;
            flex-direction: column;
        }

        .sidebar-header {
            text-align: center;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        }

        .sidebar-title {
            font-size: 1.5rem;
            margin-bottom: 10px;
        }

        .stats {
            margin-bottom: 30px;
        }

        .stat-item {
            display: flex;
            justify-content: space-between;
            margin-bottom: 8px;
            font-size: 0.9rem;
        }

        .stat-value {
            font-weight: bold;
        }

        /* 工具栏 */
        .toolbar {
            margin-top: auto;
        }

        .tool-btn {
            width: 100%;
            padding: 10px 15px;
            margin-bottom: 10px;
            background-color: #5d8a4c;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            display: flex;
            align-items: center;
            transition: all 0.3s ease;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        }

        .tool-btn i {
            margin-right: 10px;
        }

        .tool-btn:hover {
            background-color: #6e9d5b;
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
        }

        /* 农场区域 */
        .farm-area {
            flex: 1;
            position: relative;
            overflow: hidden;
            background: linear-gradient(to bottom, #a8d8b4, #8fc19e);
        }

        /* 田地 */
        .field {
            position: absolute;
            width: 80px;
            height: 80px;
            background-color: #8b704e;
            border: 2px solid #6a5238;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .field:hover {
            transform: scale(1.05);
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
        }

        .field.planted {
            background-color: #5d8a4c;
        }

        .field.harvest-ready {
            background-color: #d4a017;
            box-shadow: 0 0 15px #f1c40f;
        }

        /* 作物显示 */
        .crop {
            position: absolute;
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 2rem;
        }

        /* 天气效果 */
        .weather {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 5;
        }

        .sun {
            position: absolute;
            top: 50px;
            right: 100px;
            width: 80px;
            height: 80px;
            background-color: #f1c40f;
            border-radius: 50%;
            box-shadow: 0 0 30px #f39c12;
        }

        .cloud {
            position: absolute;
            background-color: rgba(255, 255, 255, 0.8);
            border-radius: 50%;
            filter: blur(5px);
            animation: float 30s linear infinite;
        }

        @keyframes float {
            0% {
                transform: translateX(-100px);
            }
            100% {
                transform: translateX(calc(100vw + 100px));
            }
        }

        .rain {
            position: absolute;
            width: 2px;
            height: 20px;
            background-color: rgba(174, 214, 241, 0.6);
            animation: rain linear infinite;
        }

        @keyframes rain {
            to {
                transform: translateY(100vh);
            }
        }

        /* 动物 */
        .animal {
            position: absolute;
            font-size: 2rem;
            animation: wander 10s linear infinite alternate;
            z-index: 3;
        }

        @keyframes wander {
            0% {
                transform: translateX(0) rotateY(0deg);
            }
            50% {
                transform: translateX(100px) rotateY(0deg);
            }
            51% {
                transform: translateX(100px) rotateY(180deg);
            }
            100% {
                transform: translateX(0) rotateY(180deg);
            }
        }

        /* 模态框 */
        .modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.7);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 100;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
        }

        .modal.active {
            opacity: 1;
            pointer-events: all;
        }

        .modal-content {
            background-color: white;
            padding: 20px;
            border-radius: 10px;
            width: 400px;
            max-width: 90%;
            max-height: 80vh;
            overflow-y: auto;
        }

        .modal-title {
            font-size: 1.5rem;
            margin-bottom: 20px;
            color: #4a6b3a;
            text-align: center;
        }

        .crop-selection {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 15px;
        }

        .crop-option {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 15px;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s ease;
            background-color: #f5f5f5;
        }

        .crop-option:hover {
            background-color: #e0e0e0;
            transform: scale(1.05);
        }

        .crop-icon {
            font-size: 2rem;
            margin-bottom: 10px;
        }

        .crop-name {
            font-weight: bold;
            margin-bottom: 5px;
        }

        .crop-details {
            font-size: 0.8rem;
            color: #666;
            text-align: center;
        }

        /* 通知 */
        .notification {
            position: fixed;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            background-color: rgba(0, 0, 0, 0.8);
            color: white;
            padding: 10px 20px;
            border-radius: 5px;
            opacity: 0;
            transition: opacity 0.3s ease;
            z-index: 100;
        }

        .notification.show {
            opacity: 1;
        }

        /* 季节指示器 */
        .season-indicator {
            position: absolute;
            top: 20px;
            right: 20px;
            background-color: rgba(255, 255, 255, 0.8);
            padding: 10px 15px;
            border-radius: 20px;
            font-weight: bold;
            color: #4a6b3a;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
            z-index: 10;
            display: flex;
            align-items: center;
        }

        .season-icon {
            margin-right: 8px;
            font-size: 1.2rem;
        }

        /* 仓库 */
        .warehouse {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            width: 80%;
            height: 100px;
            background-color: #8b704e;
            border-radius: 10px 10px 0 0;
            bottom: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 2;
            border-top: 5px solid #6a5238;
        }

        .warehouse-door {
            width: 100px;
            height: 80px;
            background-color: #6a5238;
            border-radius: 5px;
            display: flex;
            justify-content: center;
            align-items: center;
            color: white;
            font-size: 1.5rem;
            cursor: pointer;
            transition: transform 0.5s ease;
        }

        .warehouse-door:hover {
            transform: translateY(-5px);
        }

        /* 水塘 */
        .pond {
            position: absolute;
            width: 200px;
            height: 150px;
            background: linear-gradient(to bottom, #3498db, #2980b9);
            border-radius: 50%;
            border: 5px solid #1a5276;
        }
    </style>
</head>
<body>
    <div class="game-container">
        <!-- 侧边栏 -->
        <div class="sidebar">
            <div class="sidebar-header">
                <div class="sidebar-title">中国农场</div>
                <div><span id="day-count">1</span></div>
            </div>

            <div class="stats">
                <div class="stat-item">
                    <span>资金:</span>
                    <span class="stat-value" id="money">¥1000</span>
                </div>
                <div class="stat-item">
                    <span>声望:</span>
                    <span class="stat-value" id="reputation">50</span>
                </div>
                <div class="stat-item">
                    <span>水稻:</span>
                    <span class="stat-value" id="rice-count">0</span>
                </div>
                <div class="stat-item">
                    <span>小麦:</span>
                    <span class="stat-value" id="wheat-count">0</span>
                </div>
                <div class="stat-item">
                    <span>玉米:</span>
                    <span class="stat-value" id="corn-count">0</span>
                </div>
                <div class="stat-item">
                    <span>蔬菜:</span>
                    <span class="stat-value" id="vegetable-count">0</span>
                </div>
            </div>

            <div class="toolbar">
                <button class="tool-btn" id="market-btn">
                    <i class="fas fa-shopping-cart"></i> 市场
                </button>
                <button class="tool-btn" id="inventory-btn">
                    <i class="fas fa-box-open"></i> 仓库
                </button>
                <button class="tool-btn" id="weather-btn">
                    <i class="fas fa-cloud-sun"></i> 看天气
                </button>
                <button class="tool-btn" id="next-day-btn">
                    <i class="fas fa-forward"></i> 下一天
                </button>
            </div>
        </div>

        <!-- 农场区域 -->
        <div class="farm-area">
            <!-- 田地将在这里动态生成 -->
            
            <!-- 天气效果 -->
            <div class="weather">
                <div class="sun"></div>
                <!-- 云和雨将在这里动态生成 -->
            </div>

            <!-- 仓库 -->
            <div class="warehouse">
                <div class="warehouse-door">
                    <i class="fas fa-warehouse"></i>
                </div>
            </div>

            <!-- 水塘 -->
            <div class="pond" style="top: 100px; right: 150px;"></div>
            <div class="pond" style="top: 300px; left: 100px;"></div>

            <!-- 季节指示器 -->
            <div class="season-indicator">
                <i class="fas fa-sun season-icon" id="season-icon"></i>
                <span id="season-text">春季</span>
            </div>
        </div>
    </div>

    <!-- 作物选择模态框 -->
    <div class="modal" id="crop-modal">
        <div class="modal-content">
            <div class="modal-title">选择要种植的作物</div>
            <div class="crop-selection">
                <div class="crop-option" data-crop="rice">
                    <div class="crop-icon">🌾</div>
                    <div class="crop-name">水稻</div>
                    <div class="crop-details">收获: ¥150<br>生长: 3天</div>
                </div>
                <div class="crop-option" data-crop="wheat">
                    <div class="crop-icon">🌾</div>
                    <div class="crop-name">小麦</div>
                    <div class="crop-details">收获: ¥120<br>生长: 2天</div>
                </div>
                <div class="crop-option" data-crop="corn">
                    <div class="crop-icon">🌽</div>
                    <div class="crop-name">玉米</div>
                    <div class="crop-details">收获: ¥180<br>生长: 4天</div>
                </div>
                <div class="crop-option" data-crop="vegetable">
                    <div class="crop-icon">🥬</div>
                    <div class="crop-name">蔬菜</div>
                    <div class="crop-details">收获: ¥200<br>生长: 1天</div>
                </div>
                <div class="crop-option" data-crop="cotton">
                    <div class="crop-icon">🧶</div>
                    <div class="crop-name">棉花</div>
                    <div class="crop-details">收获: ¥250<br>生长: 5天</div>
                </div>
                <div class="crop-option" data-crop="tea">
                    <div class="crop-icon">🍵</div>
                    <div class="crop-name">茶叶</div>
                    <div class="crop-details">收获: ¥300<br>生长: 6天</div>
                </div>
            </div>
        </div>
    </div>

    <!-- 市场模态框 -->
    <div class="modal" id="market-modal">
        <div class="modal-content">
            <div class="modal-title">农产品市场</div>
            <div style="margin-bottom: 20px;">
                <p style="margin-bottom: 10px;">根据季节变化,农产品的价格会有浮动。</p>
                <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px;">
                    <div style="background-color: #f5f5f5; padding: 10px; border-radius: 5px;">
                        <div style="font-weight: bold; margin-bottom: 5px;">当前价格</div>
                        <div>水稻: ¥<span id="rice-price">150</span></div>
                        <div>小麦: ¥<span id="wheat-price">120</span></div>
                        <div>玉米: ¥<span id="corn-price">180</span></div>
                        <div>蔬菜: ¥<span id="vegetable-price">200</span></div>
                    </div>
                    <div style="background-color: #f5f5f5; padding: 10px; border-radius: 5px;">
                        <div style="font-weight: bold; margin-bottom: 5px;">你有</div>
                        <div>水稻: <span id="market-rice-count">0</span></div>
                        <div>小麦: <span id="market-wheat-count">0</span></div>
                        <div>玉米: <span id="market-corn-count">0</span></div>
                        <div>蔬菜: <span id="market-vegetable-count">0</span></div>
                    </div>
                </div>
            </div>
            <div style="text-align: right;">
                <button style="padding: 8px 20px; background-color: #4a6b3a; color: white; border: none; border-radius: 5px; cursor: pointer; margin-right: 10px;" id="sell-all-btn">卖出全部</button>
                <button style="padding: 8px 20px; background-color: #ccc; color: #333; border: none; border-radius: 5px; cursor: pointer;" id="close-market-btn">关闭</button>
            </div>
        </div>
    </div>

    <!-- 通知 -->
    <div class="notification" id="notification"></div>

    <script>
        // 游戏状态
        const gameState = {
            money: 1000,
            reputation: 50,
            inventory: {
                rice: 0,
                wheat: 0,
                corn: 0,
                vegetable: 0
            },
            day: 1,
            season: 'spring',
            weather: 'sunny',
            fields: [],
            selectedField: null,
            prices: {
                rice: 150,
                wheat: 120,
                corn: 180,
                vegetable: 200
            }
        };

        // DOM元素
        const elements = {
            money: document.getElementById('money'),
            reputation: document.getElementById('reputation'),
            'rice-count': document.getElementById('rice-count'),
            'wheat-count': document.getElementById('wheat-count'),
            'corn-count': document.getElementById('corn-count'),
            'vegetable-count': document.getElementById('vegetable-count'),
            'day-count': document.getElementById('day-count'),
            'season-text': document.getElementById('season-text'),
            'season-icon': document.getElementById('season-icon'),
            cropModal: document.getElementById('crop-modal'),
            marketModal: document.getElementById('market-modal'),
            notification: document.getElementById('notification'),
            farmArea: document.querySelector('.farm-area'),
            weatherElement: document.querySelector('.weather')
        };

        // 季节图标映射
        const seasonIcons = {
            spring: 'fas fa-seedling',
            summer: 'fas fa-sun',
            autumn: 'fas fa-leaf',
            winter: 'fas fa-snowflake'
        };

        // 作物信息
        const cropsInfo = {
            rice: { emoji: '🌾', name: '水稻', growthTime: 3, value: 150, color: '#7cb342' },
            wheat: { emoji: '🌾', name: '小麦', growthTime: 2, value: 120, color: '#d4b830' },
            corn: { emoji: '🌽', name: '玉米', growthTime: 4, value: 180, color: '#f9a825' },
            vegetable: { emoji: '🥬', name: '蔬菜', growthTime: 1, value: 200, color: '#66bb6a' },
            cotton: { emoji: '🧶', name: '棉花', growthTime: 5, value: 250, color: '#a5d6a7' },
            tea: { emoji: '🍵', name: '茶叶', growthTime: 6, value: 300, color: '#c8e6c9' }
        };

        // 初始化游戏
        function initGame() {
            createFields();
            updateUI();
            setupEventListeners();
            updateWeather();
        }

        // 创建田地
        function createFields() {
            const farmWidth = elements.farmArea.clientWidth;
            const farmHeight = elements.farmArea.clientHeight;
            
            const cols = Math.floor(farmWidth / 100);
            const rows = Math.floor((farmHeight - 120) / 100);
            
            for (let row = 0; row < rows; row++) {
                for (let col = 0; col < cols; col++) {
                    const field = document.createElement('div');
                    field.className = 'field';
                    field.style.left = `${50 + col * 100}px`;
                    field.style.top = `${50 + row * 100}px`;
                    
                    field.dataset.id = gameState.fields.length;
                    gameState.fields.push({
                        id: gameState.fields.length,
                        planted: false,
                        crop: null,
                        growth: 0,
                        ready: false
                    });
                    
                    field.addEventListener('click', () => handleFieldClick(field.dataset.id));
                    elements.farmArea.appendChild(field);
                }
            }
        }

        // 处理田地点击
        function handleFieldClick(fieldId) {
            const fieldIndex = parseInt(fieldId);
            const field = gameState.fields[fieldIndex];
            
            if (!field.planted) {
                // 如果田地是空的,打开作物选择模态框
                gameState.selectedField = fieldIndex;
                elements.cropModal.classList.add('active');
            } else if (field.ready) {
                // 如果作物已经成熟,收获
                harvestCrop(fieldIndex);
            }
        }

        // 种植作物
        function plantCrop(fieldIndex, cropType) {
            const field = gameState.fields[fieldIndex];
            
            if (field.planted) return;
            
            field.planted = true;
            field.crop = cropType;
            field.growth = 0;
            field.ready = false;
            
            // 更新田地显示
            const fieldElement = document.querySelector(`.field[data-id="${fieldIndex}"]`);
            fieldElement.classList.add('planted');
            fieldElement.innerHTML = `<div class="crop" data-crop="${cropType}">${cropsInfo[cropType].emoji}</div>`;
            
            showNotification(`种植了${cropsInfo[cropType].name}`);
        }

        // 收获作物
        function harvestCrop(fieldIndex) {
            const field = gameState.fields[fieldIndex];
            const cropInfo = cropsInfo[field.crop];
            
            // 更新库存
            gameState.inventory[field.crop]++;
            gameState.money += cropInfo.value;
            
            // 重置田地
            resetField(fieldIndex);
            
            showNotification(`收获了${cropInfo.name},获得¥${cropInfo.value}`);
            updateUI();
        }

        // 重置田地
        function resetField(fieldIndex) {
            const field = gameState.fields[fieldIndex];
            
            field.planted = false;
            field.crop = null;
            field.growth = 0;
            field.ready = false;
            
            // 更新田地显示
            const fieldElement = document.querySelector(`.field[data-id="${fieldIndex}"]`);
            fieldElement.classList.remove('planted', 'harvest-ready');
            fieldElement.innerHTML = '';
        }

        // 更新天气
        function updateWeather() {
            // 清除现有天气效果
            elements.weatherElement.innerHTML = '<div class="sun"></div>';
            
            // 根据季节设置天气
            if (gameState.season === 'spring') {
                if (Math.random() < 0.7) {
                    createClouds(4);
                    if (Math.random() < 0.4) createRain();
                }
            } else if (gameState.season === 'summer') {
                if (Math.random() < 0.5) {
                    createClouds(2);
                }
            } else if (gameState.season === 'autumn') {
                if (Math.random() < 0.6) {
                    createClouds(3);
                }
            } else if (gameState.season === 'winter') {
                if (Math.random() < 0.8) {
                    createClouds(5);
                }
            }
        }

        // 创建云
        function createClouds(count) {
            for (let i = 0; i < count; i++) {
                const cloud = document.createElement('div');
                cloud.className = 'cloud';
                
                // 随机大小
                const width = Math.random() * 120 + 50;
                const height = Math.random() * 60 + 30;
                cloud.style.width = `${width}px`;
                cloud.style.height = `${height}px`;
                
                // 随机位置
                cloud.style.top = `${Math.random() * 50}%`;
                cloud.style.left = `${Math.random() * 100}%`;
                
                // 随机动画延迟和时长
                cloud.style.animationDelay = `${Math.random() * 10}s`;
                cloud.style.animationDuration = `${Math.random() * 30 + 20}s`;
                
                elements.weatherElement.appendChild(cloud);
            }
        }

        // 创建雨
        function createRain() {
            for (let i = 0; i < 50; i++) {
                const rain = document.createElement('div');
                rain.className = 'rain';
                
                // 随机位置和长度
                rain.style.left = `${Math.random() * 100}%`;
                rain.style.height = `${Math.random() * 30 + 20}px`;
                
                // 随机动画延迟和时长
                rain.style.animationDelay = `${Math.random() * 2}s`;
                rain.style.animationDuration = `${Math.random() * 0.5 + 0.5}s`;
                
                elements.weatherElement.appendChild(rain);
            }
        }

        // 进入下一天
        function nextDay() {
            gameState.day++;
            
            // 检查季节变化
            if (gameState.day % 30 === 0) {
                changeSeason();
            }
            
            // 更新天气
            updateWeather();
            
            // 更新作物生长
            updateCrops();
            
            // 更新UI
            updateUI();
            
            showNotification(`第${gameState.day}天开始了`);
        }

        // 更新作物生长
        function updateCrops() {
            gameState.fields.forEach((field, index) => {
                if (field.planted && !field.ready) {
                    field.growth++;
                    
                    const cropInfo = cropsInfo[field.crop];
                    if (field.growth >= cropInfo.growthTime) {
                        field.ready = true;
                        
                        // 更新田地显示为可收获状态
                        const fieldElement = document.querySelector(`.field[data-id="${index}"]`);
                        fieldElement.classList.add('harvest-ready');
                    }
                }
            });
        }

        // 改变季节
        function changeSeason() {
            const seasons = ['spring', 'summer', 'autumn', 'winter'];
            const currentIndex = seasons.indexOf(gameState.season);
            const nextIndex = (currentIndex + 1) % seasons.length;
            gameState.season = seasons[nextIndex];
            
            // 更新价格根据季节
            updatePrices();
            
            showNotification(`季节变换为${getSeasonName(gameState.season)}`);
        }

        // 获取季节名称
        function getSeasonName(season) {
            const names = {
                spring: '春季',
                summer: '夏季',
                autumn: '秋季',
                winter: '冬季'
            };
            return names[season];
        }

        // 根据季节更新价格
        function updatePrices() {
            const season = gameState.season;
            
            if (season === 'spring') {
                gameState.prices.rice = 180;
                gameState.prices.wheat = 140;
                gameState.prices.corn = 160;
                gameState.prices.vegetable = 220;
            } else if (season === 'summer') {
                gameState.prices.rice = 150;
                gameState.prices.wheat = 120;
                gameState.prices.corn = 180;
                gameState.prices.vegetable = 200;
            } else if (season === 'autumn') {
                gameState.prices.rice = 170;
                gameState.prices.wheat = 150;
                gameState.prices.corn = 190;
                gameState.prices.vegetable = 180;
            } else if (season === 'winter') {
                gameState.prices.rice = 200;
                gameState.prices.wheat = 170;
                gameState.prices.corn = 220;
                gameState.prices.vegetable = 250;
            }
        }

        // 卖出全部农产品
        function sellAll() {
            let total = 0;
            
            for (const crop in gameState.inventory) {
                if (gameState.inventory[crop] > 0) {
                    total += gameState.inventory[crop] * gameState.prices[crop];
                    gameState.inventory[crop] = 0;
                }
            }
            
            if (total > 0) {
                gameState.money += total;
                showNotification(`卖出了所有农产品,获得¥${total}`);
                updateUI();
            } else {
                showNotification('没有农产品可以卖出');
            }
            
            // 关闭市场模态框
            elements.marketModal.classList.remove('active');
        }

        // 显示通知
        function showNotification(message) {
            elements.notification.textContent = message;
            elements.notification.classList.add('show');
            
            setTimeout(() => {
                elements.notification.classList.remove('show');
            }, 3000);
        }

        // 更新UI
        function updateUI() {
            elements.money.textContent = ${gameState.money}`;
            elements.reputation.textContent = gameState.reputation;
            elements['rice-count'].textContent = gameState.inventory.rice;
            elements['wheat-count'].textContent = gameState.inventory.wheat;
            elements['corn-count'].textContent = gameState.inventory.corn;
            elements['vegetable-count'].textContent = gameState.inventory.vegetable;
            elements['day-count'].textContent = gameState.day;
            elements['season-text'].textContent = getSeasonName(gameState.season);
            
            // 更新季节图标
            elements['season-icon'].className = '';
            elements['season-icon'].classList.add(...seasonIcons[gameState.season].split(' '));
            
            // 更新市场UI
            if (elements.marketModal.classList.contains('active')) {
                updateMarketUI();
            }
        }

        // 更新市场UI
        function updateMarketUI() {
            document.getElementById('rice-price').textContent = gameState.prices.rice;
            document.getElementById('wheat-price').textContent = gameState.prices.wheat;
            document.getElementById('corn-price').textContent = gameState.prices.corn;
            document.getElementById('vegetable-price').textContent = gameState.prices.vegetable;
            
            document.getElementById('market-rice-count').textContent = gameState.inventory.rice;
            document.getElementById('market-wheat-count').textContent = gameState.inventory.wheat;
            document.getElementById('market-corn-count').textContent = gameState.inventory.corn;
            document.getElementById('market-vegetable-count').textContent = gameState.inventory.vegetable;
        }

        // 设置事件监听器
        function setupEventListeners() {
            // 作物选择模态框
            document.querySelectorAll('.crop-option').forEach(option => {
                option.addEventListener('click', () => {
                    const cropType = option.dataset.crop;
                    plantCrop(gameState.selectedField, cropType);
                    elements.cropModal.classList.remove('active');
                });
            });
            
            // 关闭模态框点击背景
            document.querySelectorAll('.modal').forEach(modal => {
                modal.addEventListener('click', (e) => {
                    if (e.target === modal) {
                        modal.classList.remove('active');
                    }
                });
            });
            
            // 市场按钮
            document.getElementById('market-btn').addEventListener('click', () => {
                elements.marketModal.classList.add('active');
                updateMarketUI();
            });
            
            // 卖出全部按钮
            document.getElementById('sell-all-btn').addEventListener('click', sellAll);
            
            // 关闭市场按钮
            document.getElementById('close-market-btn').addEventListener('click', () => {
                elements.marketModal.classList.remove('active');
            });
            
            // 下一天按钮
            document.getElementById('next-day-btn').addEventListener('click', nextDay);
        }

        // 启动游戏
        initGame();
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: absolute; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">This website has been generated by <a href="https://enzostvs-deepsite.hf.space" style="color: #fff;" target="_blank" >DeepSite</a> <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;"></p></body>
</html>