<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>游戏角色生成器</title>
<!-- QQ预览元标签 -->
<meta property="og:title" content="随机(首飞版)生成器" />
<meta property="og:description" content="每分钟更新的固定角色组合,同一分钟内所有人看到相同结果" />
<meta property="og:image" content="https://picsum.photos/400/300?random=1" />
<style>
body {
font-family: 'Arial', sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #f0f0f0;
}
.container {
background-color: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
h1 {
color: #333;
text-align: center;
margin-bottom: 30px;
}
.update-info {
text-align: center;
color: #666;
margin-bottom: 20px;
font-size: 0.9em;
}
.countdown {
color: #e74c3c;
font-weight: bold;
}
.result {
font-size: 1.2em;
line-height: 1.8;
margin: 20px 0;
padding: 20px;
background-color: #f9f9f9;
border-radius: 5px;
min-height: 180px;
}
.result p {
margin: 8px 0;
padding: 5px;
border-bottom: 1px solid #eee;
}
.result p:last-child {
border-bottom: none;
}
button {
display: block;
margin: 20px auto;
padding: 12px 24px;
font-size: 1em;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
transition: all 0.3s;
}
button:hover {
background-color: #45a049;
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
button:active {
transform: translateY(0);
}
</style>
</head>
<body>
<div class="container">
<h1>每分钟角色生成器</h1>
<div class="update-info">
当前分钟配置 - 每分钟自动更新,<span class="countdown" id="countdown">60</span>秒后刷新
</div>
<div class="result" id="result"></div>
<button onclick="generateNewResult()">重新生成(本分钟内结果不变)</button>
</div>
<script>
// 地图列表
const maps = ["里奥的回忆", "湖景村", "月亮河公园", "永眠镇"];
// 求生者列表
const survivors1 = ["幸运儿", "慈善家", "园丁",
"空军", "前锋",
"牛仔", "勘探员", "咒术师", "野人",
"击球手", "小说家",
"古董商", "弓箭手"];
const survivors2 = ["医生", "魔术师",
"祭司", "调香师",
"舞女", "先知", "入殓师",
"调酒师", "邮差", "昆虫学者",
"画家", "玩具商", "小女孩",
"哭泣小丑", "教授", "飞行家", "啦啦队员",
"火灾调查员", "气象学家", "逃脱大师"];
// 种子随机数生成器
function SeedRandom(seed) {
this.seed = seed % 2147483647;
if (this.seed <= 0) this.seed += 2147483646;
}
// 生成0-1之间的伪随机数
SeedRandom.prototype.random = function() {
return (this.seed = this.seed * 16807 % 2147483647) / 2147483647;
};
// 获取基于当前分钟的固定种子(每分钟更新一次)
function getMinuteSeed() {
const date = new Date();
// 生成格式为YYYYMMDDHHMM的字符串(年+月+日+时+分)
const dateStr = `${date.getFullYear()}` +
`${(date.getMonth() + 1).toString().padStart(2, '0')}` +
`${date.getDate().toString().padStart(2, '0')}` +
`${date.getHours().toString().padStart(2, '0')}` +
`${date.getMinutes().toString().padStart(2, '0')}`;
// 转换为数字种子
return parseInt(dateStr, 10);
}
// 倒计时功能 - 显示距离下一次更新的秒数
function startCountdown() {
const countdownEl = document.getElementById('countdown');
setInterval(() => {
const now = new Date();
// 计算当前分钟剩余的秒数(60 - 当前秒数)
const secondsLeft = 60 - now.getSeconds();
countdownEl.textContent = secondsLeft;
// 每分钟0秒时自动刷新结果
if (secondsLeft === 59) {
generateNewResult();
}
}, 1000);
}
// 基于当前分钟的固定种子
let minuteSeed = getMinuteSeed();
let rng = new SeedRandom(minuteSeed);
// 基于种子的随机选择
function randomChoice(arr) {
const index = Math.floor(rng.random() * arr.length);
return arr[index];
}
// 生成结果(基于每分钟固定种子)
function generateNewResult() {
// 重新获取当前分钟的种子(确保跨分钟时更新)
minuteSeed = getMinuteSeed();
rng = new SeedRandom(minuteSeed);
// 生成1-8的随机不重复编号
const numbers = [1, 2, 3, 4, 5, 6, 7, 8];
for (let i = numbers.length - 1; i > 0; i--) {
const j = Math.floor(rng.random() * (i + 1));
[numbers[i], numbers[j]] = [numbers[j], numbers[i]];
}
const result = [];
// 生成地图
result.push(randomChoice(maps));
// 生成8个求生者(70%概率从survivors1选择,不重复)
const selectedSurvivors = [];
// 复制原始数组用于选择(避免修改原数组)
const availableS1 = [...survivors1];
const availableS2 = [...survivors2];
// 需要选择8个求生者
while (selectedSurvivors.length < 8) {
// 70%概率选择survivors1,30%选择survivors2
if (rng.random() < 0.7 && availableS1.length > 0) {
// 从survivors1选择
const index = Math.floor(rng.random() * availableS1.length);
selectedSurvivors.push(availableS1[index]);
availableS1.splice(index, 1); // 移除已选元素
} else if (availableS2.length > 0) {
// 从survivors2选择
const index = Math.floor(rng.random() * availableS2.length);
selectedSurvivors.push(availableS2[index]);
availableS2.splice(index, 1); // 移除已选元素
} else {
// 如果目标类别已选完,从剩余可用的类别中选择
const remaining = availableS1.concat(availableS2);
if (remaining.length === 0) break; // 防止意外情况
const index = Math.floor(rng.random() * remaining.length);
selectedSurvivors.push(remaining[index]);
// 从对应的可用数组中移除
if (availableS1.includes(remaining[index])) {
availableS1.splice(availableS1.indexOf(remaining[index]), 1);
} else {
availableS2.splice(availableS2.indexOf(remaining[index]), 1);
}
}
}
// 拼接结果
selectedSurvivors.forEach((survivor, index) => {
result.push(`${numbers[index]}号 求生者:${survivor}`);
});
// 更新页面显示
const resultElement = document.getElementById('result');
resultElement.innerHTML = result.map(line => `<p>${line}</p>`).join('');
resultElement.style.opacity = "0";
setTimeout(() => {
resultElement.style.transition = "opacity 0.5s";
resultElement.style.opacity = "1";
}, 50);
}
// 页面加载时初始化
window.onload = () => {
generateNewResult();
startCountdown(); // 启动倒计时
};
</script>
</body>
</html>
index.html
style.css
index.js
index.html