-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.js
More file actions
4857 lines (4095 loc) · 183 KB
/
Copy pathgame.js
File metadata and controls
4857 lines (4095 loc) · 183 KB
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
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
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==================== 游戏状态管理 ====================
const GameState = {
// 玩家信息
playerName: '', // 玩家名字
gameTitle: '模拟器模拟器', // 游戏标题(可能被彩蛋修改)
// 基础资源
inventory: 1000000,
money: 5000,
reputation: 50,
day: 1,
totalSold: 0,
// 成本系统
costPrice: 1.5, // 模拟器成本价(每个)
// 无尽模式
endlessMode: false,
contractSigned: false, // 是否与生产基地签约
contractDay: 0, // 签约天数
nextDeliveryDay: 0, // 下次送达天数
stockoutDays: 0, // 缺货天数累计
todayPurchase: 0, // 今日已购买数量
// 销售相关
currentPrice: 3,
promotions: {
bogo: false, // 买一送一
discount: false, // 限时折扣
bundle: false // 捆绑销售
},
// 营销效果
activeMarketing: [],
// 店铺
ownedShops: [],
// 赛事
completedEvents: [],
// 天气
weather: 'sunny',
// 特殊状态
specialEffects: {
qualityLabel: false, // 优质模拟器标签
newRecipe: false, // 新菜品解锁
competitorDebuff: 0 // 竞争对手打压剩余天数
},
// 今日销售数据(改为支持多次销售)
todaySales: {
session1: { quantity: 0, revenue: 0, hasSold: false },
session2: { quantity: 0, revenue: 0, hasSold: false },
currentSession: 0 // 当前是第几次销售(0=未开始, 1=第一次, 2=第二次)
},
// 销售倒计时
salesTimer: {
isWaiting: false,
timeLeft: 0,
timerId: null
},
// 游戏状态
isGameOver: false,
gameWon: false,
// 兑换码系统
codeRedeemed: false, // 是否已兑换过代码
// 升级系统
restaurantLevel: 0, // 0=普通, 1=餐馆, 2=工厂, 3=实验室
canUpgradeToRestaurant: false, // 是否可以升级为餐馆(售卖15天后)
cannedProduction: {
enabled: false, // 是否启用产品包生产
dailyInput: 1000, // 每日投入模拟器数量
simulatorsPerCan: 1, // 每个产品包的模拟器数量(0.1-10)
pricePerCan: 5 // 每个产品包售价
},
// 实验室系统
labProduction: {
enabled: false, // 是否启用实验室
experimentAmount: 1000, // 每次实验投入模拟器数(1000-100000,步长1000)
cultureAmount: 1000, // 批量复制数量(1000-100000,步长1000)
experimentLevel: 0, // 实验等级(影响销量提升)
lastCultureDay: 0 // 上次使用批量复制的天数
},
// 研发点系统
techPoints: 0, // 研发点总数
researchUpgrades: [], // 已购买的升级 ID 列表
// 模拟器神学院系统
academy: {
unlocked: false, // 是否已解锁研究院
divinePoints: 0, // 信仰点数量
sacrificeAmount: 10000, // 每次供奉模拟器数量(10000-1000000,步长10000)
salesBonus: 0 // 永久销量加成
},
// 股票市场系统
stockMarket: {
unlocked: false, // 是否已解锁股票市场
totalAssets: 0, // 股票总资产
todayProfit: 0, // 今日收益
holdings: {}, // 持股信息 {companyId: quantity}
selectedStock: null // 当前选中的股票ID
},
// 自定义比赛系统
customEvent: null // 当前进行中的自定义比赛
};
// ==================== 配置常量 ====================
const CONFIG = {
MAX_DAYS: 90,
TARGET_SALES: 1000000,
INITIAL_INVENTORY: 1000000,
INITIAL_MONEY: 5000,
INITIAL_REPUTATION: 50,
// 无尽模式配置
CONTRACT_DELIVERY: 100000, // 每7天送达模拟器数量
CONTRACT_INTERVAL: 7, // 合约周期(天)
CONTRACT_COST: 50000, // 签约费用
WHOLESALE_PRICE: 10, // 无尽模式批发价/个
WHOLESALE_MAX_DAILY: 100000, // 每天最多购买数量
STOCKOUT_LIMIT: 2, // 连续缺货天数上限
BANKRUPTCY_LIMIT: -100000, // 资金链断裂阈值
// 升级系统配置
RESTAURANT_UPGRADE_COST: 1000000, // 升级为餐馆的费用
RESTAURANT_UPGRADE_DAY: 15, // 售卖15天后可升级
RESTAURANT_COST_PRICE: 10, // 餐馆成本价
RESTAURANT_MAX_PRICE: 100, // 餐馆最高定价
FACTORY_UPGRADE_COST: 10000000, // 升级为工厂的费用
CANNED_MIN_CABBAGES: 0.1, // 产品包最少模拟器数量
CANNED_MAX_CABBAGES: 10, // 产品包最多模拟器数量
// 实验室配置
LAB_UPGRADE_COST: 100000000, // 升级为实验室的费用(1亿,原10亿)
LAB_EXPERIMENT_MAX: 100000, // 实验投入模拟器上限
LAB_EXPERIMENT_STEP: 1000, // 实验滑块步长
LAB_CULTURE_MAX: 100000, // 批量复制上限
LAB_CULTURE_STEP: 1000, // 批量复制滑块步长
// 价格配置
MIN_PRICE: 2,
MAX_PRICE: 15,
BASE_PRICE: 3,
COST_PRICE: 1.5, // 成本价
SALES_SESSIONS_PER_DAY: 2, // 每天销售次数
SALES_WAIT_TIME: 5, // 销售等待时间(秒)
// 营销配置(所有加成缩减到原来的10%)
MARKETING_OPTIONS: {
// 基础营销(立即可用)
flyer: { cost: 200, salesBonus: 0.015, reputationBonus: 0, duration: 3, name: '传单派发', unlockDay: 0, icon: '📄' },
social: { cost: 500, salesBonus: 0.03, reputationBonus: 0.5, duration: 5, name: '社交媒体', unlockDay: 0, icon: '📱' },
radio: { cost: 1000, salesBonus: 0.05, reputationBonus: 1, duration: 7, name: '本地电台', unlockDay: 0, icon: '📻' },
tv: { cost: 3000, salesBonus: 0.1, reputationBonus: 2, duration: 10, name: '电视广告', unlockDay: 0, icon: '📺' },
// 高级营销(每5天解锁1个)
newspaper: { cost: 1500, salesBonus: 0.06, reputationBonus: 1.5, duration: 8, name: '报纸广告', unlockDay: 5, icon: '📰' },
billboard: { cost: 2500, salesBonus: 0.08, reputationBonus: 1.2, duration: 12, name: '户外广告牌', unlockDay: 10, icon: '🪧' },
influencer: { cost: 4000, salesBonus: 0.12, reputationBonus: 3, duration: 6, name: '网红带货', unlockDay: 15, icon: '⭐' },
livestream: { cost: 5000, salesBonus: 0.15, reputationBonus: 2.5, duration: 5, name: '直播带货', unlockDay: 20, icon: '🎥' },
festival: { cost: 8000, salesBonus: 0.2, reputationBonus: 5, duration: 15, name: '模拟器文化节', unlockDay: 25, icon: '🎉' },
celebrity: { cost: 15000, salesBonus: 0.25, reputationBonus: 8, duration: 20, name: '明星代言', unlockDay: 30, icon: '🌟' },
documentary: { cost: 25000, salesBonus: 0.3, reputationBonus: 10, duration: 30, name: '纪录片拍摄', unlockDay: 35, icon: '🎬' },
international: { cost: 50000, salesBonus: 0.4, reputationBonus: 15, duration: 45, name: '国际推广', unlockDay: 40, icon: '🌍' }
},
// 店铺配置
SHOPS: [
{ id: 'stall', name: '路边摊', icon: '🏪', unlockAt: 5000, cost: 1000, dailyCost: 50, salesBonus: 0.30, baseSales: 100 },
{ id: 'market', name: '农贸市场摊位', icon: '🏬', unlockAt: 15000, cost: 3000, dailyCost: 150, salesBonus: 0.60, baseSales: 200, wholesaleBonus: 0.10 },
{ id: 'community', name: '社区小店', icon: '🏠', unlockAt: 30000, cost: 8000, dailyCost: 300, salesBonus: 1.0, baseSales: 300 },
{ id: 'supermarket', name: '连锁超市专柜', icon: '🛒', unlockAt: 60000, cost: 15000, dailyCost: 500, salesBonus: 1.50, baseSales: 500 },
{ id: 'online', name: '线上商城', icon: '💻', unlockAt: 80000, cost: 10000, dailyCost: 200, salesBonus: 0.80, baseSales: 250, weatherImmune: true }
],
// 赛事配置
EVENTS: {
15: { type: 'quality', name: '品质大赛', icon: '🏆', cost: 800 },
30: { type: 'cooking', name: '创意设计大赛', icon: '👨🍳', cost: 1200 },
45: { type: 'quality', name: '品质大赛', icon: '🏆', cost: 800 },
60: { type: 'cooking', name: '创意设计大赛', icon: '👨🍳', cost: 1200 },
75: { type: 'championship', name: '半决赛', icon: '🥈', cost: 2000 },
90: { type: 'final', name: '总决赛', icon: '👑', cost: 0 }
},
// 天气配置
WEATHER: {
sunny: { name: '晴天', icon: '☀️', salesMultiplier: 1.0 },
cloudy: { name: '多云', icon: '⛅', salesMultiplier: 0.9 },
rainy: { name: '雨天', icon: '🌧️', salesMultiplier: 0.7 },
stormy: { name: '暴雨', icon: '⛈️', salesMultiplier: 0.4 },
snowy: { name: '雪天', icon: '❄️', salesMultiplier: 0.6 }
},
// 客户类型配置
CUSTOMERS: {
normal: { probability: 0.60, icon: '👤', name: '普通顾客', minDemand: 1, maxDemand: 5 },
restaurant: { probability: 0.20, icon: '🍽️', name: '餐厅老板', minDemand: 50, maxDemand: 200 },
wholesaler: { probability: 0.10, icon: '🚚', name: '批发商', minDemand: 500, maxDemand: 2000 },
blogger: { probability: 0.05, icon: '📸', name: '美食博主', minDemand: 10, maxDemand: 30 },
competitor: { probability: 0.05, icon: '😈', name: '竞争对手', minDemand: 0, maxDemand: 0 }
},
// 股票市场配置
STOCK_COMPANIES: [
{ id: 'oi_restart', name: 'OI 重开模拟器', icon: '🔄', basePrice: 100, price: 100, history: [], changePercent: 0, link: 'https://www.luogu.com.cn/article/9d4wr427' },
{ id: 'oi_coach', name: 'OI 教练模拟器', icon: '👨🏫', basePrice: 150, price: 150, history: [], changePercent: 0, link: 'https://www.luogu.com.cn/article/1s9wdoal' },
{ id: 'oi_association', name: 'OI 协会模拟器', icon: '🏛️', basePrice: 200, price: 200, history: [], changePercent: 0, link: 'https://www.luogu.com.cn/article/w9cahexa' },
{ id: 'oj_operation', name: 'OJ 运维模拟器', icon: '⚙️', basePrice: 180, price: 180, history: [], changePercent: 0, link: 'https://www.luogu.com.cn/article/dcqcee1r' },
{ id: 'whk_teacher', name: 'whk 班主任模拟器', icon: '👔', basePrice: 250, price: 250, history: [], changePercent: 0, link: 'https://www.luogu.com.cn/article/44li54py' },
{ id: 'bj8z', name: '北京八中模拟器', icon: '🏫', basePrice: 300, price: 300, history: [], changePercent: 0, link: 'https://www.luogu.com.cn/article/7xmewwtx' }
],
STOCK_UNLOCK_COST: 100000, // 解锁股票市场费用(10万)
STOCK_LIMIT_UP: 0.10, // 涨停幅度 10%
STOCK_LIMIT_DOWN: -0.10, // 跌停幅度 -10%
// 研究升级配置 (35项)
RESEARCH_UPGRADES: [
// 第 1-10 项:销量加成类
{ id: 'sales_boost_1', name: '营销技巧 I', description: '销量 +5%', cost: 1, effect: { type: 'sales_multiplier', value: 0.05 } },
{ id: 'sales_boost_2', name: '营销技巧 II', description: '销量 +8%', cost: 3, effect: { type: 'sales_multiplier', value: 0.08 } },
{ id: 'sales_boost_3', name: '营销技巧 III', description: '销量 +12%', cost: 6, effect: { type: 'sales_multiplier', value: 0.12 } },
{ id: 'sales_boost_4', name: '品牌效应 I', description: '销量 +15%', cost: 10, effect: { type: 'sales_multiplier', value: 0.15 } },
{ id: 'sales_boost_5', name: '品牌效应 II', description: '销量 +20%', cost: 15, effect: { type: 'sales_multiplier', value: 0.20 } },
{ id: 'sales_boost_6', name: '客户忠诚 I', description: '销量 +25%', cost: 22, effect: { type: 'sales_multiplier', value: 0.25 } },
{ id: 'sales_boost_7', name: '客户忠诚 II', description: '销量 +30%', cost: 30, effect: { type: 'sales_multiplier', value: 0.30 } },
{ id: 'sales_boost_8', name: '市场扩张 I', description: '销量 +35%', cost: 40, effect: { type: 'sales_multiplier', value: 0.35 } },
{ id: 'sales_boost_9', name: '市场扩张 II', description: '销量 +40%', cost: 50, effect: { type: 'sales_multiplier', value: 0.40 } },
{ id: 'sales_boost_10', name: '全球知名', description: '销量 +50%', cost: 65, effect: { type: 'sales_multiplier', value: 0.50 } },
// 第 11-18 项:模拟器获取翻倍类
{ id: 'weekly_simulator_1', name: '农业补贴 I', description: '每周免费模拟器 ×1.5', cost: 5, effect: { type: 'weekly_simulator_multiplier', value: 1.5 } },
{ id: 'weekly_simulator_2', name: '农业补贴 II', description: '每周免费模拟器 ×2', cost: 12, effect: { type: 'weekly_simulator_multiplier', value: 2.0 } },
{ id: 'weekly_simulator_3', name: '农场合作 I', description: '每周免费模拟器 ×2.5', cost: 20, effect: { type: 'weekly_simulator_multiplier', value: 2.5 } },
{ id: 'weekly_simulator_4', name: '农场合作 II', description: '每周免费模拟器 ×3', cost: 30, effect: { type: 'weekly_simulator_multiplier', value: 3.0 } },
{ id: 'weekly_simulator_5', name: '算法优化 I', description: '每周免费模拟器 ×4', cost: 45, effect: { type: 'weekly_simulator_multiplier', value: 4.0 } },
{ id: 'weekly_simulator_6', name: '算法优化 II', description: '每周免费模拟器 ×5', cost: 60, effect: { type: 'weekly_simulator_multiplier', value: 5.0 } },
{ id: 'weekly_simulator_7', name: '层级架构', description: '每周免费模拟器 ×6', cost: 80, effect: { type: 'weekly_simulator_multiplier', value: 6.0 } },
{ id: 'weekly_simulator_8', name: '云端部署', description: '每周免费模拟器 ×8', cost: 100, effect: { type: 'weekly_simulator_multiplier', value: 8.0 } },
// 第 19-26 项:实验室效率类
{ id: 'lab_efficiency_1', name: '实验加速 I', description: '技术研究成本 -10%', cost: 8, effect: { type: 'experiment_cost_reduction', value: 0.10 } },
{ id: 'lab_efficiency_2', name: '实验加速 II', description: '技术研究成本 -20%', cost: 18, effect: { type: 'experiment_cost_reduction', value: 0.20 } },
{ id: 'lab_efficiency_3', name: '批量复制 I', description: '批量复制冷却时间 -2 天', cost: 25, effect: { type: 'culture_cooldown_reduction', value: 2 } },
{ id: 'lab_efficiency_4', name: '批量复制 II', description: '批量复制冷却时间 -4 天', cost: 40, effect: { type: 'culture_cooldown_reduction', value: 4 } },
{ id: 'lab_efficiency_5', name: '复制技术 I', description: '批量复制产量 +50%', cost: 55, effect: { type: 'culture_yield_bonus', value: 0.50 } },
{ id: 'lab_efficiency_6', name: '复制技术 II', description: '批量复制产量 +100%', cost: 75, effect: { type: 'culture_yield_bonus', value: 1.0 } },
{ id: 'lab_efficiency_7', name: '自动化实验', description: '实验等级获取 ×2', cost: 90, effect: { type: 'experiment_level_multiplier', value: 2.0 } },
{ id: 'lab_efficiency_8', name: '量子计算', description: '所有实验室效果 +25%', cost: 110, effect: { type: 'lab_global_bonus', value: 0.25 } },
// 第 27-35 项:其他效果类
{ id: 'passive_sales_1', name: '自动售货 I', description: '被动销售频率 +20%', cost: 15, effect: { type: 'passive_sales_frequency', value: 0.20 } },
{ id: 'passive_sales_2', name: '自动售货 II', description: '被动销售频率 +40%', cost: 35, effect: { type: 'passive_sales_frequency', value: 0.40 } },
{ id: 'marketing_boost_1', name: '广告优化 I', description: '营销效果 +15%', cost: 20, effect: { type: 'marketing_effectiveness', value: 0.15 } },
{ id: 'marketing_boost_2', name: '广告优化 II', description: '营销效果 +30%', cost: 45, effect: { type: 'marketing_effectiveness', value: 0.30 } },
{ id: 'price_premium_1', name: '奢侈品定位', description: '可定价上限 +¥20', cost: 50, effect: { type: 'max_price_increase', value: 20 } },
{ id: 'reputation_boost', name: '声誉加速器', description: '声誉获取 +50%', cost: 60, effect: { type: 'reputation_gain', value: 0.50 } },
{ id: 'cost_reduction', name: '供应链优化', description: '成本价 -¥2', cost: 70, effect: { type: 'cost_price_reduction', value: 2 } },
{ id: 'shop_bonus', name: '连锁经营', description: '店铺收益 +30%', cost: 85, effect: { type: 'shop_revenue_bonus', value: 0.30 } },
{ id: 'ultimate_tech', name: '终极科技', description: '所有效果 +10%', cost: 120, effect: { type: 'global_bonus', value: 0.10 } }
],
// 神学院配置
ACADEMY_UNLOCK_COST: 10000000000, // 神学院解锁费用(100亿)
ACADEMY_SACRIFICE_MIN: 10000, // 最小供奉数量
ACADEMY_SACRIFICE_MAX: 1000000, // 最大供奉数量
ACADEMY_SACRIFICE_STEP: 10000, // 供奉步长
// 无尽模式赛事配置(每75天一个周期)
ENDLESS_EVENTS: [
{ day: 105, type: 'quality', name: '品质大赛', icon: '🏆', cost: 800 },
{ day: 120, type: 'cooking', name: '创意设计大赛', icon: '👨🍳', cost: 1200 },
{ day: 135, type: 'quality', name: '品质大赛', icon: '🏆', cost: 800 },
{ day: 150, type: 'cooking', name: '创意设计大赛', icon: '👨🍳', cost: 1200 },
{ day: 165, type: 'championship', name: '半决赛', icon: '🥈', cost: 2000 },
{ day: 180, type: 'final', name: '总决赛', icon: '👑', cost: 0 }
]
};
// ==================== 工具函数 ====================
function formatNumber(num) {
return num.toLocaleString('zh-CN');
}
function formatMoney(amount) {
return '¥' + formatNumber(amount);
}
function randomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function randomFloat(min, max) {
return Math.random() * (max - min) + min;
}
function clamp(value, min, max) {
return Math.min(Math.max(value, min), max);
}
// ==================== 日志系统 ====================
function addLog(message, type = 'neutral') {
const logEntries = document.getElementById('log-entries');
const entry = document.createElement('div');
entry.className = `log-entry ${type}`;
entry.textContent = `第${GameState.day}天: ${message}`;
logEntries.insertBefore(entry, logEntries.firstChild);
// 只保留最近10条日志
while (logEntries.children.length > 10) {
logEntries.removeChild(logEntries.lastChild);
}
}
// ==================== UI更新函数 ====================
function updateUI() {
// 更新头部信息
document.getElementById('current-day').textContent = GameState.day;
document.getElementById('sold-count').textContent = formatNumber(GameState.totalSold);
// 更新无尽模式显示
const daysLimit = document.getElementById('days-limit');
const endlessBadge = document.getElementById('endless-badge');
if (GameState.endlessMode) {
daysLimit.textContent = '';
endlessBadge.style.display = 'inline';
} else {
daysLimit.textContent = '/ 90';
endlessBadge.style.display = 'none';
}
// 更新进度条
const progressPercent = GameState.endlessMode ? 100 : (GameState.totalSold / CONFIG.TARGET_SALES) * 100;
const progressBar = document.getElementById('sales-progress');
progressBar.style.width = `${progressPercent}%`;
// 根据完成度改变进度条颜色
progressBar.classList.remove('low', 'medium', 'high');
if (progressPercent < 33) {
progressBar.classList.add('low');
} else if (progressPercent < 66) {
progressBar.classList.add('medium');
} else {
progressBar.classList.add('high');
}
// 更新状态面板
document.getElementById('inventory').textContent = formatNumber(GameState.inventory);
document.getElementById('money').textContent = formatMoney(GameState.money);
document.getElementById('cost-price').textContent = formatMoney(GameState.costPrice) + '/个';
// 更新成本价显示(定价区域)
const costPriceDisplay = document.getElementById('cost-price-display');
if (costPriceDisplay) {
costPriceDisplay.textContent = GameState.costPrice;
}
document.getElementById('reputation').textContent = `${GameState.reputation}/100`;
// 更新声誉条
document.getElementById('reputation-fill').style.width = `${GameState.reputation}%`;
// 库存警告
const inventoryEl = document.getElementById('inventory');
inventoryEl.classList.remove('warning', 'error');
if (GameState.inventory < 10000) {
inventoryEl.classList.add('error');
} else if (GameState.inventory < 30000) {
inventoryEl.classList.add('warning');
}
// 更新天气
const weatherConfig = CONFIG.WEATHER[GameState.weather];
document.getElementById('weather-icon').textContent = weatherConfig.icon;
document.getElementById('weather').textContent = weatherConfig.name;
// 更新预估销量
updateEstimatedSales();
// 更新活跃效果
updateActiveEffects();
// 更新店铺列表
updateShopsList();
// 更新赛事日历
updateEventCalendar();
// 检查并显示当前赛事
checkCurrentEvent();
// 更新手动赛事区域显示(无尽模式且超过90天)
const hostEventSection = document.getElementById('host-event-section');
if (hostEventSection) {
const shouldShow = GameState.endlessMode && GameState.day > 90;
hostEventSection.style.display = shouldShow ? 'block' : 'none';
}
// 更新无尽模式批发标签
const wholesaleTabBtn = document.getElementById('wholesale-tab-btn');
if (wholesaleTabBtn) {
wholesaleTabBtn.style.display = GameState.endlessMode ? 'block' : 'none';
}
// 更新批发信息
if (GameState.endlessMode) {
const remaining = CONFIG.WHOLESALE_MAX_DAILY - GameState.todayPurchase;
const wholesaleRemaining = document.getElementById('wholesale-remaining');
const wholesaleTodayPurchase = document.getElementById('wholesale-today-purchase');
const stockoutDaysDisplay = document.getElementById('stockout-days-display');
const stockoutLimitDisplay = document.getElementById('stockout-limit-display');
if (wholesaleRemaining) wholesaleRemaining.textContent = formatNumber(Math.max(0, remaining)) + ' 个';
if (wholesaleTodayPurchase) wholesaleTodayPurchase.textContent = formatNumber(GameState.todayPurchase) + ' 个';
if (stockoutDaysDisplay) stockoutDaysDisplay.textContent = GameState.stockoutDays + ' 天';
if (stockoutLimitDisplay) stockoutLimitDisplay.textContent = CONFIG.STOCKOUT_LIMIT + ' 天';
}
// 更新升级系统显示
updateUpgradeSystem();
// 更新赛事倒计时
updateEventCountdown();
// 更新自定义比赛状态显示
updateCustomEventDisplay();
// 更新神学院UI(如果已解锁)
if (GameState.academy && GameState.academy.unlocked) {
updateAcademyUI();
}
// 同步所有文本与真实值
syncAllText();
// 更新营销选项显示
updateMarketingOptions();
// 如果股票市场已解锁,渲染股票市场页面
if (GameState.stockMarket.unlocked) {
renderStockMarket();
}
// 初始化工厂和实验室显示
if (GameState.restaurantLevel >= 2) {
updateCannedPreview();
}
if (GameState.restaurantLevel >= 3) {
updateExperimentAmount(1000);
updateCultureAmount(1000);
}
}
function updateEstimatedSales() {
if (GameState.todaySales.session1.hasSold && GameState.todaySales.session2.hasSold) {
document.getElementById('estimated-sales').textContent = '今日销售已完成';
return;
}
const estimated = calculateEstimatedSales();
const sessionNum = !GameState.todaySales.session1.hasSold ? 1 : 2;
document.getElementById('estimated-sales').textContent = `第${sessionNum}次预估: 约 ${formatNumber(estimated)} 个`;
}
// ==================== 同步所有文本与真实值 ====================
function syncAllText() {
console.log('syncAllText called, restaurantLevel:', GameState.restaurantLevel);
// 更新天数限制显示
const daysLimit = document.getElementById('days-limit');
if (daysLimit) {
if (GameState.endlessMode) {
daysLimit.textContent = '(无尽)';
} else {
daysLimit.textContent = `/ ${CONFIG.MAX_DAYS}`;
}
}
// 更新销售目标显示
const salesTarget = document.getElementById('sales-target');
if (salesTarget) {
salesTarget.textContent = formatNumber(CONFIG.TARGET_SALES);
}
// 更新价格滑块的最大值 - 使用setAttribute确保生效
const priceSlider = document.getElementById('price-slider');
if (priceSlider) {
const maxPrice = GameState.restaurantLevel >= 1 ? CONFIG.RESTAURANT_MAX_PRICE : 15;
const illegalPriceThreshold = Math.floor(maxPrice * 0.99);
// 同时使用setAttribute和property确保生效
priceSlider.setAttribute('max', illegalPriceThreshold.toString());
priceSlider.max = illegalPriceThreshold;
console.log('✅ Price slider updated:');
console.log(' - Target max:', illegalPriceThreshold);
console.log(' - Attribute max:', priceSlider.getAttribute('max'));
console.log(' - Property max:', priceSlider.max);
}
// 更新销售按钮文本
const salesBtn = document.getElementById('start-sales-btn');
if (salesBtn && !GameState.todaySales.session1.hasSold && !GameState.todaySales.session2.hasSold) {
salesBtn.textContent = `开始第${GameState.day}次销售`;
}
// 更新网页标题
document.title = `${GameState.gameTitle} - Simulator Simulator`;
}
function updateUpgradeSystem() {
const upgradeSection = document.getElementById('upgrade-section');
const restaurantUpgrade = document.getElementById('restaurant-upgrade');
const factoryUpgrade = document.getElementById('factory-upgrade');
const labUpgrade = document.getElementById('lab-upgrade');
const academyUnlock = document.getElementById('academy-unlock');
const stockMarketUnlock = document.getElementById('stock-market-unlock');
const cannedSection = document.getElementById('canned-production-section');
const labSection = document.getElementById('lab-production-section');
// 子标签按钮
const factorySubtabBtn = document.getElementById('factory-subtab-btn');
const labSubtabBtn = document.getElementById('lab-subtab-btn');
const researchUpgradesSubtabBtn = document.getElementById('research-upgrades-subtab-btn');
const academySubtabBtn = document.getElementById('academy-subtab-btn');
const stockMarketSubtabBtn = document.getElementById('stock-market-subtab-btn');
// 显示升级区域
if (GameState.endlessMode || GameState.restaurantLevel > 0) {
upgradeSection.style.display = 'block';
// 根据等级显示不同选项
if (GameState.restaurantLevel === 0 && GameState.canUpgradeToRestaurant) {
restaurantUpgrade.style.display = 'block';
factoryUpgrade.style.display = 'none';
labUpgrade.style.display = 'none';
academyUnlock.style.display = 'none';
} else if (GameState.restaurantLevel === 1) {
restaurantUpgrade.style.display = 'none';
factoryUpgrade.style.display = 'block';
labUpgrade.style.display = 'none';
academyUnlock.style.display = 'none';
} else if (GameState.restaurantLevel === 2) {
restaurantUpgrade.style.display = 'none';
factoryUpgrade.style.display = 'none';
labUpgrade.style.display = 'block';
academyUnlock.style.display = 'none';
} else if (GameState.restaurantLevel >= 3) {
restaurantUpgrade.style.display = 'none';
factoryUpgrade.style.display = 'none';
labUpgrade.style.display = 'none';
// 实验室等级>=3时,如果未解锁研究院则显示解锁选项
academyUnlock.style.display = GameState.academy.unlocked ? 'none' : 'block';
// 如果已解锁餐馆,显示股票市场解锁选项
if (stockMarketUnlock) {
stockMarketUnlock.style.display = (GameState.restaurantLevel >= 1 && !GameState.stockMarket.unlocked) ? 'block' : 'none';
}
}
} else {
upgradeSection.style.display = 'none';
}
// 显示/隐藏工厂子标签按钮(餐馆等级>=1时显示)
if (factorySubtabBtn) {
factorySubtabBtn.style.display = GameState.restaurantLevel >= 1 ? 'block' : 'none';
}
// 显示/隐藏实验室子标签按钮(餐馆等级>=2时显示)
if (labSubtabBtn) {
labSubtabBtn.style.display = GameState.restaurantLevel >= 2 ? 'block' : 'none';
}
// 显示/隐藏研究升级子标签按钮(实验室等级>=3时显示)
if (researchUpgradesSubtabBtn) {
researchUpgradesSubtabBtn.style.display = GameState.restaurantLevel >= 3 ? 'block' : 'none';
}
// 显示/隐藏研究院子标签按钮(研究院解锁后显示)
if (academySubtabBtn) {
const shouldShow = GameState.restaurantLevel >= 3 && GameState.academy.unlocked;
academySubtabBtn.style.display = shouldShow ? 'block' : 'none';
}
// 显示/隐藏股票市场子标签按钮(股票市场解锁后显示)
if (stockMarketSubtabBtn) {
stockMarketSubtabBtn.style.display = GameState.stockMarket.unlocked ? 'block' : 'none';
}
// 显示产品包生产控制
if (GameState.cannedProduction.enabled) {
cannedSection.style.display = 'block';
const cannedSlider = document.getElementById('canned-slider');
if (cannedSlider) {
cannedSlider.value = GameState.cannedProduction.simulatorsPerCan;
}
const cannedDisplay = document.getElementById('canned-simulators-display');
if (cannedDisplay) {
cannedDisplay.textContent = GameState.cannedProduction.simulatorsPerCan;
}
const dailyInputSlider = document.getElementById('daily-input-slider');
if (dailyInputSlider) {
dailyInputSlider.value = GameState.cannedProduction.dailyInput;
}
const dailyInputDisplay = document.getElementById('daily-input-display');
if (dailyInputDisplay) {
dailyInputDisplay.textContent = formatNumber(GameState.cannedProduction.dailyInput);
}
// 更新预计收益显示
updateCannedPreview();
} else {
cannedSection.style.display = 'none';
}
// 显示实验室生产控制
if (GameState.labProduction.enabled) {
labSection.style.display = 'block';
const experimentSlider = document.getElementById('experiment-slider');
if (experimentSlider) {
experimentSlider.value = GameState.labProduction.experimentAmount;
}
const experimentDisplay = document.getElementById('experiment-amount-display');
if (experimentDisplay) {
experimentDisplay.textContent = formatNumber(GameState.labProduction.experimentAmount);
}
// 显示实验等级和销量提升
const experimentLevelEl = document.getElementById('experiment-level-display');
if (experimentLevelEl) {
const level = GameState.labProduction.experimentLevel;
const bonus = (level / 1000 * 100).toFixed(1);
experimentLevelEl.textContent = `实验等级: ${formatNumber(level)} (销量+${bonus}%)`;
}
// 更新研发点显示
const techPointsDisplay = document.getElementById('tech-points-display');
if (techPointsDisplay) {
techPointsDisplay.textContent = formatNumber(GameState.techPoints);
}
const upgradeTechPoints = document.getElementById('upgrade-tech-points');
if (upgradeTechPoints) {
upgradeTechPoints.textContent = formatNumber(GameState.techPoints);
}
const cultureSlider = document.getElementById('culture-slider');
if (cultureSlider) {
cultureSlider.value = GameState.labProduction.cultureAmount;
}
const cultureDisplay = document.getElementById('culture-amount-display');
if (cultureDisplay) {
cultureDisplay.textContent = formatNumber(GameState.labProduction.cultureAmount);
}
// 更新批量复制预计消耗和冷却状态
updateCultureAmount(GameState.labProduction.cultureAmount);
// 显示冷却状态
const cultureCooldownEl = document.getElementById('culture-cooldown-display');
if (cultureCooldownEl) {
const lastDay = GameState.labProduction.lastCultureDay;
// 获取升级效果
const bonuses = getUpgradeBonuses();
const cooldownReduction = bonuses.cultureCooldownReduction;
const actualCooldown = Math.max(1, 10 - cooldownReduction);
if (lastDay > 0) {
const daysSince = GameState.day - lastDay;
if (daysSince < actualCooldown) {
const remaining = actualCooldown - daysSince;
cultureCooldownEl.textContent = `🕒 冷却中: 还需 ${remaining} 天 (第${lastDay + actualCooldown}天可用)`;
cultureCooldownEl.style.color = 'var(--error)';
} else {
cultureCooldownEl.textContent = '✅ 已就绪: 可以使用';
cultureCooldownEl.style.color = 'var(--success)';
}
} else {
cultureCooldownEl.textContent = '✅ 未使用过: 可以立即使用';
cultureCooldownEl.style.color = 'var(--success)';
}
}
} else {
labSection.style.display = 'none';
}
// 更新价格滑块最大值(设置为最高定价的99%作为违法上限)
const priceSlider = document.getElementById('price-slider');
if (priceSlider) {
const maxPrice = GameState.restaurantLevel >= 1 ? CONFIG.RESTAURANT_MAX_PRICE : 15;
const illegalPriceThreshold = Math.floor(maxPrice * 0.99);
priceSlider.max = illegalPriceThreshold;
}
}
// ==================== 更新营销选项显示 ====================
function updateMarketingOptions() {
const marketingGrid = document.getElementById('marketing-grid');
if (!marketingGrid) return;
marketingGrid.innerHTML = '';
Object.entries(CONFIG.MARKETING_OPTIONS).forEach(([type, config]) => {
// 检查是否已解锁
const isUnlocked = GameState.day >= config.unlockDay;
const item = document.createElement('div');
item.className = 'marketing-item';
item.dataset.type = type;
if (!isUnlocked) {
item.classList.add('locked');
item.innerHTML = `
<div class="marketing-icon">🔒</div>
<h3>${config.name}</h3>
<p class="cost">第 ${config.unlockDay} 天解锁</p>
<p class="effect">敬请期待</p>
<button class="btn btn-secondary buy-ad-btn" disabled>未解锁</button>
`;
} else {
// 检查是否已有相同类型的广告
const existingEffect = GameState.activeMarketing.find(effect => effect.type === type);
item.innerHTML = `
<div class="marketing-icon">${config.icon}</div>
<h3>${config.name}</h3>
<p class="cost">成本: ¥${config.cost.toLocaleString()}</p>
<p class="effect">销量+${(config.salesBonus * 100).toFixed(0)}%, ${config.reputationBonus > 0 ? '声誉+' + config.reputationBonus + ', ' : ''}持续${config.duration}天</p>
<button class="btn btn-secondary buy-ad-btn" ${existingEffect ? 'disabled' : ''}>
${existingEffect ? `已购买 (剩余${existingEffect.daysLeft}天)` : '购买'}
</button>
`;
}
marketingGrid.appendChild(item);
});
// 重新绑定购买按钮事件
document.querySelectorAll('.buy-ad-btn').forEach(btn => {
if (!btn.disabled) {
btn.addEventListener('click', (e) => {
const itemType = e.target.closest('.marketing-item').dataset.type;
buyMarketing(itemType);
});
}
});
}
function updateActiveEffects() {
const effectsList = document.getElementById('effects-list');
effectsList.innerHTML = '';
// 无尽模式标识
if (GameState.endlessMode) {
const div = document.createElement('div');
div.className = 'effect-item';
div.textContent = '🌟 无尽模式中';
div.style.color = 'var(--secondary)';
div.style.fontWeight = 'bold';
effectsList.appendChild(div);
}
// 合约状态
if (GameState.contractSigned) {
const div = document.createElement('div');
div.className = 'effect-item';
div.textContent = `📋 生产基地合约 (下次送达: 第${GameState.nextDeliveryDay}天)`;
effectsList.appendChild(div);
}
// 显示营销效果
GameState.activeMarketing.forEach(effect => {
const config = CONFIG.MARKETING_OPTIONS[effect.type];
if (config) {
const div = document.createElement('div');
div.className = 'effect-item';
div.textContent = `${config.name} (剩余${effect.daysLeft}天)`;
effectsList.appendChild(div);
}
});
// 显示特殊效果
if (GameState.specialEffects.qualityLabel) {
const div = document.createElement('div');
div.className = 'effect-item';
div.textContent = '✨ 优质模拟器标签 (+¥1/个)';
effectsList.appendChild(div);
}
if (GameState.specialEffects.newRecipe) {
const div = document.createElement('div');
div.className = 'effect-item';
div.textContent = '🍲 新菜品解锁 (销量+20%)';
effectsList.appendChild(div);
}
if (GameState.specialEffects.competitorDebuff > 0) {
const div = document.createElement('div');
div.className = 'effect-item';
div.textContent = `⚠️ 竞争对手打压 (剩余${GameState.specialEffects.competitorDebuff}天)`;
effectsList.appendChild(div);
}
}
function updateShopsList() {
const shopsList = document.getElementById('shops-list');
shopsList.innerHTML = '';
CONFIG.SHOPS.forEach(shop => {
const isOwned = GameState.ownedShops.includes(shop.id);
const isUnlocked = GameState.totalSold >= shop.unlockAt;
const shopItem = document.createElement('div');
shopItem.className = `shop-item ${!isUnlocked ? 'shop-locked' : ''}`;
let html = `
<div class="shop-info">
<h3>${shop.icon} ${shop.name}</h3>
<p>解锁条件: 已售 ${formatNumber(shop.unlockAt)} 个</p>
<p>开店成本: ${formatMoney(shop.cost)} | 日运营成本: ${formatMoney(shop.dailyCost)}</p>
<p>效果: 销量+${(shop.salesBonus * 100).toFixed(0)}%</p>
`;
if (shop.wholesaleBonus) {
html += `<p>额外: 批发商概率+${(shop.wholesaleBonus * 100).toFixed(0)}%</p>`;
}
if (shop.weatherImmune) {
html += `<p>特性: 不受天气影响</p>`;
}
html += `</div><div class="shop-actions">`;
if (isOwned) {
html += `<span class="shop-owned">✓ 已拥有</span>`;
} else if (isUnlocked) {
html += `<button class="btn btn-secondary" onclick="buyShop('${shop.id}')">开店 (${formatMoney(shop.cost)})</button>`;
} else {
html += `<button class="btn" disabled>未解锁</button>`;
}
html += `</div>`;
shopItem.innerHTML = html;
shopsList.appendChild(shopItem);
});
}
function updateEventCalendar() {
Object.keys(CONFIG.EVENTS).forEach(day => {
const statusEl = document.getElementById(`event-${day}`);
if (!statusEl) return;
if (GameState.completedEvents.includes(parseInt(day))) {
statusEl.textContent = '已完成';
statusEl.className = 'status completed';
} else if (parseInt(day) === GameState.day) {
statusEl.textContent = '进行中';
statusEl.className = 'status active';
} else if (parseInt(day) < GameState.day) {
statusEl.textContent = '已错过';
statusEl.className = 'status';
} else {
statusEl.textContent = '待进行';
statusEl.className = 'status';
}
});
}
// ==================== 核心计算引擎 ====================
function calculatePriceCoefficient(price) {
if (price <= 2) return 2.0; // 超低价
if (price <= 4) return 1.5; // 低价
if (price === 3) return 1.0; // 正常价格(3元)
if (price <= 7) return 0.8; // 偏高
if (price <= 10) return 0.5; // 高价
if (price <= 15) return 0.3; // 超高价
return 0.1; // 天价(会被抓)
}
function calculateReputationCoefficient() {
return 0.5 + (GameState.reputation / 100);
}
function calculateWeatherCoefficient() {
return CONFIG.WEATHER[GameState.weather].salesMultiplier;
}
function calculateMarketingCoefficient() {
// 相同的广告营销不能叠加,只取最高值
const marketingTypes = {};
GameState.activeMarketing.forEach(effect => {
const config = CONFIG.MARKETING_OPTIONS[effect.type];
if (config) {
if (!marketingTypes[effect.type] || config.salesBonus > marketingTypes[effect.type]) {
marketingTypes[effect.type] = config.salesBonus;
}
}
});
let bonus = 0;
Object.values(marketingTypes).forEach(salesBonus => {
bonus += salesBonus;
});
return 1 + bonus;
}
function calculateShopBonus() {
let bonus = 0;
GameState.ownedShops.forEach(shopId => {
const shop = CONFIG.SHOPS.find(s => s.id === shopId);
if (shop) {
bonus += shop.salesBonus;
}
});
return 1 + bonus;
}
function calculatePromotionEffect(price) {
let finalPrice = price;
let salesMultiplier = 1;
if (GameState.promotions.bogo) {
salesMultiplier *= 2; // 销量翻倍
}
if (GameState.promotions.discount) {
finalPrice *= 0.8; // 降价20%
salesMultiplier *= 1.6; // 销量+60%
}
if (GameState.promotions.bundle) {
finalPrice += 2; // 单价+¥2
salesMultiplier *= 1.4; // 销量+40%
}
return { price: finalPrice, multiplier: salesMultiplier };
}
function calculateEstimatedSales() {
const priceCoeff = calculatePriceCoefficient(GameState.currentPrice);
const repCoeff = calculateReputationCoefficient();
const weatherCoeff = calculateWeatherCoefficient();
const marketingCoeff = calculateMarketingCoefficient();
const shopBonus = calculateShopBonus();
let promoEffect = calculatePromotionEffect(GameState.currentPrice);
let baseSales = 1000 * priceCoeff * repCoeff * weatherCoeff * marketingCoeff * shopBonus * promoEffect.multiplier;
// 技术研究加成: g = a + (a * b / 1000 * 100%)
// 其中 a = baseSales(初始购买量), b = experimentLevel(实验等级)
if (GameState.labProduction.experimentLevel > 0) {
const experimentBonus = baseSales * (GameState.labProduction.experimentLevel / 1000);
baseSales += experimentBonus;
}
// 研究升级加成:销量乘数
const bonuses = getUpgradeBonuses();
if (bonuses.salesMultiplier > 0) {
const upgradeBonus = baseSales * bonuses.salesMultiplier;
baseSales += upgradeBonus;
}
// 全局加成
if (bonuses.globalBonus > 0) {
const globalBonus = baseSales * bonuses.globalBonus;
baseSales += globalBonus;
}
// 神学院销量加成(永久)
if (GameState.academy && GameState.academy.salesBonus > 0) {
const academyBonus = baseSales * GameState.academy.salesBonus;
baseSales += academyBonus;
}
// 特殊效果加成
if (GameState.specialEffects.newRecipe) {
baseSales *= 1.2;
}
// 竞争对手打压
if (GameState.specialEffects.competitorDebuff > 0) {
baseSales *= 0.7;
}
// 劣质模拟器效果(销量-10%)
if (GameState.specialEffects.inferiorSimulator > 0) {
baseSales *= 0.9;