-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathterraria-seed.html
More file actions
795 lines (722 loc) · 30.2 KB
/
terraria-seed.html
File metadata and controls
795 lines (722 loc) · 30.2 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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>泰拉瑞亚 1.4.5 种子生成器</title>
<style>
:root {
--bg-color: #1e1e24;
--panel-bg: #2b2b36;
--text-color: #e0e0e0;
--accent-color: #5d9cec;
--accent-hover: #4a89dc;
--border-color: #444;
--success-color: #8cc152;
--special-zenith: #967adc;
--disabled-color: #666;
--seed-color: #88c0d0;
}
body {
font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
background-color: var(--bg-color);
color: var(--text-color);
margin: 0;
padding: 20px;
display: flex;
justify-content: center;
min-height: 100vh;
}
.container {
display: flex;
gap: 20px;
max-width: 1200px;
width: 100%;
flex-wrap: wrap;
}
/* 左侧面板 */
.left-panel {
flex: 2;
background-color: var(--panel-bg);
padding: 20px;
border-radius: 12px;
box-shadow: 0 4px 15px rgba(0,0,0,0.3);
display: flex;
flex-direction: column;
gap: 20px;
min-width: 320px;
}
/* 右侧面板 */
.right-panel {
flex: 1;
background-color: var(--panel-bg);
padding: 20px;
border-radius: 12px;
box-shadow: 0 4px 15px rgba(0,0,0,0.3);
display: flex;
flex-direction: column;
gap: 15px;
min-width: 300px;
position: sticky;
top: 20px;
height: fit-content;
}
h2, h3 {
margin-top: 0;
border-bottom: 2px solid var(--border-color);
padding-bottom: 10px;
margin-bottom: 15px;
color: var(--accent-color);
}
/* 按钮组样式 */
.control-group {
margin-bottom: 5px;
}
.control-label {
display: block;
margin-bottom: 8px;
font-weight: bold;
font-size: 0.95em;
color: #ccc;
}
.btn-group {
display: flex;
gap: 10px;
flex-wrap: wrap;
}
.btn-radio {
display: none;
}
.btn-radio + label {
background-color: #3a3a45;
padding: 8px 16px;
border-radius: 6px;
cursor: pointer;
border: 1px solid var(--border-color);
transition: all 0.2s;
user-select: none;
}
.btn-radio:checked + label {
background-color: var(--accent-color);
color: white;
border-color: var(--accent-color);
font-weight: bold;
}
/* 特殊标志 Grid */
.flags-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
gap: 10px;
}
.flag-item {
display: flex;
align-items: center;
background: #333;
padding: 8px;
border-radius: 4px;
font-size: 0.9em;
}
.flag-item input {
margin-right: 8px;
cursor: pointer;
}
.flag-zenith {
/* grid-column: span 2; */
border: 1px solid var(--special-zenith);
background: rgba(150, 122, 220, 0.1);
}
.flag-zenith label {
color: var(--special-zenith);
font-weight: bold;
}
.flag-item.disabled {
opacity: 0.4;
pointer-events: none;
}
/* 彩蛋列表 */
.eggs-list {
max-height: 400px;
overflow-y: auto;
border: 1px solid var(--border-color);
border-radius: 6px;
padding: 10px;
background: rgba(0,0,0,0.2);
display: grid;
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
gap: 8px;
}
.egg-item {
display: flex;
align-items: flex-start;
font-size: 0.85em;
padding: 5px;
}
.egg-item:hover {
background-color: rgba(255,255,255,0.05);
}
.egg-item input {
margin-top: 3px;
margin-right: 8px;
}
.egg-undisclosed {
color: var(--disabled-color);
font-style: italic;
text-decoration: line-through;
pointer-events: none;
}
.seed-code {
font-size: 0.8em;
color: var(--seed-color);
}
/* 随机种子输入 */
.seed-input-group {
display: flex;
gap: 10px;
}
input[type="number"] {
flex: 1;
padding: 10px;
background: #333;
border: 1px solid var(--border-color);
color: white;
border-radius: 6px;
font-size: 1em;
}
/* 底部按钮 */
.action-buttons {
display: flex;
gap: 15px;
margin-top: 10px;
padding-top: 15px;
border-top: 1px solid var(--border-color);
}
.btn {
padding: 12px 20px;
border: none;
border-radius: 6px;
cursor: pointer;
font-weight: bold;
transition: filter 0.2s;
flex: 1;
}
.btn:hover { filter: brightness(1.1); }
.btn-primary { background-color: var(--success-color); color: white; flex: 2; font-size: 1.1em;}
.btn-secondary { background-color: #555; color: white; }
.btn-accent { background-color: var(--accent-color); color: white; }
/* 右侧结果区 */
textarea {
width: 100%;
height: 120px;
background: #111;
color: #8cc152;
border: 1px solid var(--border-color);
border-radius: 6px;
padding: 10px;
font-family: 'Consolas', monospace;
font-size: 1.1em;
resize: vertical;
box-sizing: border-box;
}
/* #copy-btn {
border: none;
padding: 10px;
border-radius: 6px;
cursor: pointer;
font-weight: bold;
width: 100%;
} */
#copy-btn:active, #parse-btn:active {
transform: translateY(2px);
}
.format-desc {
font-size: 0.85em;
color: #aaa;
line-height: 1.5;
background: rgba(0,0,0,0.2);
padding: 10px;
border-radius: 6px;
}
.format-desc code {
background: rgba(255,255,255,0.1);
padding: 2px 4px;
border-radius: 3px;
color: #e0e0e0;
}
/* 滚动条美化 */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #222; }
::-webkit-scrollbar-thumb { background: #555; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #777; }
@media (max-width: 768px) {
.container { flex-direction: column; }
.right-panel { position: static; }
}
</style>
</head>
<body>
<div class="container">
<!-- 左侧控制区 -->
<div class="left-panel">
<h2>Terraria 1.4.5 种子生成器</h2>
<!-- 大小 -->
<div class="control-group">
<span class="control-label">世界大小</span>
<div class="btn-group">
<input type="radio" name="size" id="size1" value="1" class="btn-radio">
<label for="size1">小 (1)</label>
<input type="radio" name="size" id="size2" value="2" class="btn-radio" checked>
<label for="size2">中 (2)</label>
<input type="radio" name="size" id="size3" value="3" class="btn-radio">
<label for="size3">大 (3)</label>
</div>
</div>
<!-- 难度 -->
<div class="control-group">
<span class="control-label">游戏难度</span>
<div class="btn-group">
<input type="radio" name="diff" id="diff1" value="1" class="btn-radio">
<label for="diff1">普通 (1)</label>
<input type="radio" name="diff" id="diff2" value="2" class="btn-radio">
<label for="diff2">专家 (2)</label>
<input type="radio" name="diff" id="diff3" value="3" class="btn-radio" checked>
<label for="diff3">大师 (3)</label>
<input type="radio" name="diff" id="diff4" value="4" class="btn-radio">
<label for="diff4">旅途 (4)</label>
</div>
</div>
<!-- 邪恶 -->
<div class="control-group">
<span class="control-label">邪恶生物群落</span>
<div class="btn-group">
<input type="radio" name="evil" id="evil1" value="1" class="btn-radio">
<!-- <label for="evil1" style="color:#a485dd">腐化 (1)</label> -->
<label for="evil1">腐化 (1)</label>
<input type="radio" name="evil" id="evil2" value="2" class="btn-radio">
<!-- <label for="evil2" style="color:#ff6b6b">猩红 (2)</label> -->
<label for="evil2">猩红 (2)</label>
</div>
</div>
<!-- 特殊标志 -->
<div class="control-group">
<span class="control-label">特殊标志</span>
<div class="flags-grid">
<div class="flag-item">
<input type="checkbox" id="flag0" onchange="handleFlag0()">
<label for="flag0">普通世界 (0)</label>
</div>
<div class="flag-item sub-flag">
<input type="checkbox" id="flag1" value="1" class="flag-check">
<label for="flag1">一醉方休 (1)
<div class="seed-code">05162020</div>
</label>
</div>
<div class="flag-item sub-flag">
<input type="checkbox" id="flag2" value="2" class="flag-check">
<label for="flag2">蜜蜂之惧 (2)
<div class="seed-code">not the bees</div>
</label>
</div>
<div class="flag-item sub-flag">
<input type="checkbox" id="flag4" value="4" class="flag-check">
<label for="flag4">勇者之境 (4)
<div class="seed-code">for the worthy</div>
</label>
</div>
<div class="flag-item sub-flag">
<input type="checkbox" id="flag8" value="8" class="flag-check">
<label for="flag8">十年庆典 (8)
<div class="seed-code">celebrationmk10</div>
</label>
</div>
<div class="flag-item sub-flag">
<input type="checkbox" id="flag16" value="16" class="flag-check">
<label for="flag16">永恒领域 (16)
<div class="seed-code">the constant</div>
</label>
</div>
<div class="flag-item sub-flag">
<input type="checkbox" id="flag32" value="32" class="flag-check">
<label for="flag32">颠倒世界 (32)
<div class="seed-code">don't dig up</div>
</label>
</div>
<div class="flag-item sub-flag">
<input type="checkbox" id="flag64" value="64" class="flag-check">
<label for="flag64">没有机关 (64)
<div class="seed-code">no traps</div>
</label>
</div>
<div class="flag-item flag-zenith">
<input type="checkbox" id="flag255" value="255" onchange="handleZenith(this)">
<label for="flag255">天顶世界 (255)
<div class="seed-code">get fixed boi</div>
</label>
</div>
<div class="flag-item">
<input type="checkbox" id="flag256" value="256" class="flag-check-indep">
<label for="flag256">天空之岛 (256)
<div class="seed-code">sky block</div>
</label>
</div>
</div>
</div>
<!-- 彩蛋种子 -->
<div class="control-group">
<span class="control-label">彩蛋种子</span>
<div class="eggs-list" id="eggsList">
<!-- JS 动态生成 -->
</div>
</div>
<!-- 随机数 -->
<div class="control-group">
<span class="control-label">随机种子数 (0 - 2147483647)</span>
<div class="seed-input-group">
<input type="number" id="randomNumber" placeholder="留空自动生成" min="0" max="2147483647">
</div>
</div>
<!-- 按钮区 -->
<div class="action-buttons">
<button class="btn btn-secondary" onclick="resetForm()">重置</button>
<button class="btn btn-accent" onclick="randomizeAll()">随机全部</button>
<button class="btn btn-primary" onclick="generateSeed()">生成种子</button>
</div>
</div>
<!-- 右侧结果区 -->
<div class="right-panel">
<h3>种子</h3>
<textarea id="resultOutput" placeholder="点击生成按钮获取种子,或粘贴已有种子进行解析"></textarea>
<div class="action-buttons" style="margin-top: 5px; padding-top: 5px; border-top: none;">
<button id="copy-btn" class="btn btn-primary" onclick="copyResult()">复制种子</button>
<button id="parse-btn" class="btn btn-accent" onclick="parseSeedHandler(resultOutput.value)">解析种子</button>
</div>
<div class="format-desc">
<strong>如有帮助点个 Star ⭐️ 支持一下吧!</strong>
<iframe style="margin-left: 2px; margin-bottom:-5px;" frameborder="0" scrolling="0" width="81px" height="20px" src="https://ghbtns.com/github-btn.html?user=mojimoon&repo=MojiApps&type=star&count=true" ></iframe> <br>
Made with ❤️ by <a href="https://github.com/mojimoon" target="_blank" style="color: var(--accent-color); text-decoration: underline;">mojimoon</a>
</div>
<div class="format-desc">
<strong>种子结构说明:</strong><br>
<code>大小.难度.邪恶.特殊标志.彩蛋|彩蛋...|随机数</code>
<br><br>
<ul>
<li><strong>大小:</strong>1=小, 2=中, 3=大</li>
<li><strong>难度:</strong>1=普通, 2=专家, 3=大师, 4=旅途</li>
<li><strong>邪恶:</strong>1=腐化, 2=猩红</li>
<li><strong>标志:</strong>按位累加值。普通世界 (0) 与其他标志互斥;天顶世界 (255) 包含从 1 到 64 的所有选项;天空之岛 (256) 独立存在。</li>
<li><strong>彩蛋:</strong>多个彩蛋用竖线 <code>|</code> 分隔。</li>
<li><strong>随机数:</strong>留空则自动生成一个 0 到 2147483647 之间的整数。</li>
</ul>
</div>
<div class="format-desc">
<strong>示例种子:</strong> <code>2.3.2.9.planetoids|i am error|01312026</code> <br>
表示:中等大小,大师难度,猩红邪恶,标志值 9(一醉方休 1 + 十年庆典 8),包含彩蛋小小星球和错误世界,随机数 1312026。
<br><br>
<strong>参考 Wiki:</strong> <a href="https://terraria.wiki.gg/zh/wiki/%E7%89%B9%E6%AE%8A%E4%B8%96%E7%95%8C%E7%A7%8D%E5%AD%90" target="_blank" style="color: var(--accent-color); text-decoration: underline;">特殊世界种子</a>、<a href="https://terraria.wiki.gg/zh/wiki/%E7%A7%98%E5%AF%86%E4%B8%96%E7%95%8C%E7%A7%8D%E5%AD%90" target="_blank" style="color: var(--accent-color); text-decoration: underline;">秘密世界种子</a>
<br>
部分彩蛋种子(如 arachnophobia 和 more traps please)在总共有至少 4 个彩蛋时效果会变化或反转。
</div>
</div>
</div>
<script>
// 彩蛋数据
const eggs = [
{ name: "灰色世界", code: "monochrome" },
{ name: "反色世界", code: "negative infinity" },
{ name: "回声世界 (隐形)", code: "invisible plane" },
{ name: "夜明世界 (全亮)", code: "xray vision" },
{ name: "无地表", code: "mole people" },
{ name: "更多生命树", code: "save the rainforest" },
{ name: "更多漂浮岛", code: "the carebears movie" },
{ name: "错误世界", code: "i am error" },
{ name: "活死人之夜 (血月墓地开局)", code: "night of the living dead" },
{ name: "地表为太空", code: "such great heights" },
{ name: "降雨一整年", code: "bring a towel" },
{ name: "更大废弃房屋", code: "abandoned manors" },
{ name: "随机出生点", code: "how did i get here" },
{ name: "添加传送机", code: "beam me up" },
{ name: "困难模式开局", code: "too easy" },
{ name: "无感染", code: "fish mox" },
{ name: "地表为神圣", code: "does that sparkle" },
{ name: "世界被感染", code: "purify this" },
{ name: "地表为蘑菇", code: "toadstool" },
{ name: "地表为沙漠", code: "sandy britches" },
{ name: "到处都是臭臭", code: "truck stop" },
{ name: "无蜘蛛洞", code: "arachnophobia" },
{ name: "更多陷阱 (实际上没有)", code: "more traps please" },
{ name: "彩虹物件", code: "rainbow road" },
{ name: "挖更多洞", code: "jagged rocks" },
{ name: "圆形地块 (小行星)", code: "planetoids" },
{ name: "额外液体 (水上乐园)", code: "waterpark" },
{ name: "宝箱传送枪", code: "we dont even test for that" },
{ name: "世界被冻结 (凛冬将至)", code: "winter is coming" },
{ name: "万圣节生成 (南瓜季)", code: "pumpkin season" },
{ name: "无尽万圣节", code: "hocus pocus" },
{ name: "无尽圣诞节", code: "jingle all the way" },
{ name: "吸血鬼症", code: "what a horrible night to have a curse" },
{ name: "团队出生点 (大逃杀)", code: "royale with cheese" },
{ name: "双重地牢", code: "double daring dangers" }
];
// 初始化页面
window.onload = function() {
renderEggs();
// 默认随机选一个邪恶,避免 undefined
if(!document.querySelector('input[name="evil"]:checked')){
document.getElementById(`evil${Math.random() > 0.5 ? 1 : 2}`).checked = true;
}
};
// 渲染彩蛋列表
function renderEggs() {
const container = document.getElementById('eggsList');
container.innerHTML = '';
eggs.forEach((egg, index) => {
const div = document.createElement('div');
// const isDisabled = egg.code === "";
// div.className = `egg-item ${isDisabled ? 'egg-undisclosed' : ''}`;
div.className = 'egg-item';
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.id = `egg_${index}`;
checkbox.value = egg.code;
// checkbox.disabled = isDisabled;
const label = document.createElement('label');
label.htmlFor = `egg_${index}`;
label.innerText = egg.name;
const codeDiv = document.createElement('div');
codeDiv.className = 'seed-code';
// codeDiv.innerText = isDisabled ? "" : egg.code;
codeDiv.innerText = egg.code;
label.appendChild(codeDiv);
div.appendChild(checkbox);
div.appendChild(label);
container.appendChild(div);
});
}
// 处理特殊标志逻辑
function handleFlag0() {
const flag0 = document.getElementById('flag0');
if (flag0.checked) {
// 取消其他所有 flag
document.querySelectorAll('.flag-check, #flag255, .flag-check-indep').forEach(el => {
el.checked = false;
el.disabled = false;
el.parentElement.classList.remove('disabled');
});
// 恢复 1-64 的可点击状态 (如果被 zenith 禁用了)
document.querySelectorAll('.sub-flag').forEach(div => div.classList.remove('disabled'));
}
}
// 监听其他 flag 点击,自动取消 flag0
document.addEventListener('change', function(e) {
if (e.target.matches('.flag-check, #flag255, .flag-check-indep') && e.target.checked) {
document.getElementById('flag0').checked = false;
}
});
function handleZenith(checkbox) {
const subFlags = document.querySelectorAll('.sub-flag input');
if (checkbox.checked) {
subFlags.forEach(input => {
input.checked = true; // 视觉上选中或者保持不选中?Prompt说"包含所有选项",但通常生成器会自动勾选或禁用。
// 逻辑:禁用对应选项。
input.checked = false; // 先清空手动选择,避免重复计算逻辑混淆,虽然最终值是直接取255
input.disabled = true;
input.parentElement.classList.add('disabled');
});
document.getElementById('flag0').checked = false;
} else {
subFlags.forEach(input => {
input.disabled = false;
input.parentElement.classList.remove('disabled');
});
}
}
// 随机全部
function randomizeAll() {
// 大小:随机 1-3
// document.getElementById(`size${Math.floor(Math.random() * 3) + 1}`).checked = true;
// 难度:随机 1-4
// document.getElementById(`diff${Math.floor(Math.random() * 4) + 1}`).checked = true;
// 邪恶:随机 1-2
document.getElementById(`evil${Math.floor(Math.random() * 2) + 1}`).checked = true;
// 随机种子数
document.getElementById('randomNumber').value = Math.floor(Math.random() * 2147483647);
// 标志:随机逻辑比较复杂,简单随机几个
// 重置标志
resetFlagsUI();
// 15% 概率天顶
if (Math.random() < 0.15) {
document.getElementById('flag255').checked = true;
handleZenith(document.getElementById('flag255'));
} else {
// 随机勾选 1-64 中的几个
const simpleFlags = [1, 2, 4, 8, 16, 32, 64];
simpleFlags.forEach(val => {
if (Math.random() < 0.2) { // 20% 概率选中每个
document.getElementById(`flag${val}`).checked = true;
}
});
}
// 12.5% 概率天空岛
if (Math.random() < 0.125) document.getElementById('flag256').checked = true;
// 彩蛋:随机选 0-4 个
// const eggBoxes = document.querySelectorAll('.eggs-list input:not(:disabled)');
const eggBoxes = document.querySelectorAll('.eggs-list input');
eggBoxes.forEach(box => box.checked = false);
const count = Math.floor(Math.random() * 5); // 0 to 4
for(let i=0; i<count; i++) {
const randIdx = Math.floor(Math.random() * eggBoxes.length);
eggBoxes[randIdx].checked = true;
}
generateSeed();
}
function parseSeed(seed) {
const parts = seed.split('.');
if (parts.length != 5) {
return false;
}
let [size, diff, evil, flagValue, contentString] = parts;
size = parseInt(size);
document.getElementById(`size${size}`).checked = true;
diff = parseInt(diff);
document.getElementById(`diff${diff}`).checked = true;
evil = parseInt(evil);
document.getElementById(`evil${evil}`).checked = true;
flagValue = parseInt(flagValue);
if (flagValue == 0) {
document.getElementById('flag0').checked = true;
} else {
if (flagValue >= 256) {
document.getElementById('flag256').checked = true;
flagValue -= 256;
}
if (flagValue == 255) {
document.getElementById('flag255').checked = true;
handleZenith(document.getElementById('flag255'));
} else {
const flagChecks = [64, 32, 16, 8, 4, 2, 1];
flagChecks.forEach(val => {
if (flagValue >= val) {
document.getElementById(`flag${val}`).checked = true;
flagValue -= val;
}
});
}
}
const contentParts = contentString.split('|');
if (contentParts.length > 1) {
const randomNum = contentParts.pop();
document.getElementById('randomNumber').value = randomNum;
// 其余为彩蛋
const selectedEggs = contentParts;
document.querySelectorAll('.eggs-list input').forEach(el => {
if (selectedEggs.includes(el.value)) {
el.checked = true;
} else {
el.checked = false;
}
});
} else {
document.getElementById('randomNumber').value = contentParts[0];
document.querySelectorAll('.eggs-list input').forEach(el => el.checked = false);
}
return true;
}
function parseSeedHandler(seed) {
let success = parseSeed(seed);
if (!success) {
alert("无效的种子格式!请确保为正确的结构:大小.难度.邪恶.标志.彩蛋|彩蛋...|随机数");
} else {
const originalText = document.querySelector('#parse-btn').innerText;
document.querySelector('#parse-btn').innerText = "解析成功!";
setTimeout(() => {
document.querySelector('#parse-btn').innerText = originalText;
}, 1500);
}
}
function resetFlagsUI() {
document.getElementById('flag0').checked = false;
document.getElementById('flag255').checked = false;
document.getElementById('flag256').checked = false;
document.querySelectorAll('.sub-flag input').forEach(el => {
el.checked = false;
el.disabled = false;
el.parentElement.classList.remove('disabled');
});
}
function resetForm() {
document.getElementById('size2').checked = true;
document.getElementById('diff3').checked = true;
// 邪恶随机
document.getElementById(`evil${Math.floor(Math.random() * 2) + 1}`).checked = true;
resetFlagsUI();
document.querySelectorAll('.eggs-list input').forEach(el => el.checked = false);
document.getElementById('randomNumber').value = '';
document.getElementById('resultOutput').value = '';
}
// 核心生成逻辑
function generateSeed() {
// 1. 获取基础参数
const size = document.querySelector('input[name="size"]:checked').value;
const diff = document.querySelector('input[name="diff"]:checked').value;
const evil = document.querySelector('input[name="evil"]:checked').value;
// 2. 计算 Flag
let flagValue = 0;
if (document.getElementById('flag0').checked) {
flagValue = 0;
} else {
// 检查 255
if (document.getElementById('flag255').checked) {
flagValue += 255;
} else {
// 累加 1-64
document.querySelectorAll('.sub-flag input:checked').forEach(el => {
flagValue += parseInt(el.value);
});
}
// 检查 256 (独立)
if (document.getElementById('flag256').checked) {
flagValue += 256;
}
}
// 3. 获取彩蛋
const selectedEggs = [];
document.querySelectorAll('.eggs-list input:checked').forEach(el => {
selectedEggs.push(el.value);
});
// 4. 获取随机数
let randomNum = document.getElementById('randomNumber').value;
if (!randomNum) {
randomNum = Math.floor(Math.random() * 2147483647);
document.getElementById('randomNumber').value = randomNum; // 回填
}
// 5. 拼接
// 格式: 大小.难度.邪恶.标志.彩蛋|彩蛋|随机数
// 示例:2.3.2.9.planetoids|waterpark|01312026
// 结构解读: [Header].[Flags].[ContentString]
// Header = size.diff.evil
// Flags = number
// ContentString = egg1|egg2|randomNumber
let contentString = "";
if (selectedEggs.length > 0) {
contentString = selectedEggs.join('|') + '|' + randomNum;
} else {
contentString = randomNum;
}
const finalSeed = `${size}.${diff}.${evil}.${flagValue}.${contentString}`;
document.getElementById('resultOutput').value = finalSeed;
}
function copyResult() {
const copyText = document.getElementById("resultOutput");
if (!copyText.value) generateSeed();
copyText.select();
copyText.setSelectionRange(0, 99999);
navigator.clipboard.writeText(copyText.value).then(() => {
const originalText = document.querySelector('#copy-btn').innerText;
document.querySelector('#copy-btn').innerText = "复制成功!";
setTimeout(() => {
document.querySelector('#copy-btn').innerText = originalText;
}, 1500);
});
}
</script>
</body>
</html>