随机edit icon

创建者:
用户vAcdaiVI
Fork(复制)
下载
嵌入
BUG反馈
index.html
style.css
index.js
index.html
            
            <!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;
        }
        .easter-egg {
            color: #9c27b0;
            font-weight: bold;
        }
        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 regulators = ["厂长", "小丑", "鹿头", "杰克", "蜘蛛", "红蝶", "黄衣之主",
                           "宿伞之魂", "摄影师", "疯眼", "梦之女巫", "爱哭鬼", "孽蜥",
                           "红夫人", "26号守卫", "使徒", "小提琴家", "雕刻家", "博士",
                           "破轮", "渔女", "蜡像师", "噩梦", "记录员", "隐士", "守夜人",
                           "歌剧", "愚人金", "时空之影", "跛脚羊", "喧嚣", "杂货商", "厂长",
                           "鹿头", "杰克", "蜘蛛", "红蝶",  "宿伞之魂",  "爱哭鬼",  "孽蜥", "红夫人",
                           "26号守卫", "使徒", "小提琴家", "雕刻家", "博士",
                           "渔女", "蜡像师", "噩梦", "隐士", "守夜人",  "愚人金",];

        // 求生者列表
        const survivors = ["幸运儿", "医生", "律师", "慈善家", "园丁", "魔术师", "冒险家",
                          "佣兵", "空军", "机械师", "前锋", "盲女", "祭司", "调香师",
                          "牛仔", "舞女", "先知", "入殓师", "勘探员", "咒术师", "野人",
                          "大副", "杂技演员", "调酒师", "邮差", "守墓人", "囚徒", "昆虫学者",
                          "画家", "击球手", "玩具商", "心理学家", "病患", "小说家", "小女孩",
                          "哭泣小丑", "教授", "古董商", "作曲家", "记者", "飞行家", "啦啦队员",
                          "木偶师", "火灾调查员", "法罗", "骑士", "气象学家", "弓箭手", "逃脱大师"];

        // 彩蛋模式的多种固定求生者阵容
        const easterEggSurvivorSets = [
            ["医生", "律师", "慈善家", "园丁"],
            ["佣兵", "大副", "守墓人", "记者"],
            ["调香师", "医生", "心理学家", "调酒师"],
            ["机械师", "囚徒", "盲女", "作曲家"],
            ["心理学家", "病患", "小说家", "记者"],
            ["杂技演员", "魔术师", "调香师", "火灾调查员"],
            ["弓箭手", "勘探员", "古董商", "击球手"],
            ["园丁", "医生", "咒术师", "舞女"],
            ["入殓师", "囚徒", "佣兵", "勘探员"],
            ["作曲家", "昆虫学者", "小说家", "记者"],
            ["杂技演员", "野人", "哭泣小丑", "舞女"],
            ["逃脱大师", "大副", "法罗女士", "魔术师"]
        ];

        // 彩蛋模式固定监管者
        const easterEggRegulators = ["厂长", "鹿头", "杰克", "蜘蛛", "红蝶", "黄衣之主",
                           "宿伞之魂", "爱哭鬼", "孽蜥",
                           "红夫人", "26号守卫", "使徒", "小提琴家", "雕刻家", "博士",
                           "渔女", "蜡像师", "噩梦", "隐士", "守夜人","愚人金"];

        // 种子随机数生成器
        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 randomSample(arr, count) {
            const shuffled = [...arr];
            for (let i = shuffled.length - 1; i > 0; i--) {
                const j = Math.floor(rng.random() * (i + 1));
                [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
            }
            return shuffled.slice(0, count);
        }

        // 生成结果(基于每分钟固定种子)
        function generateNewResult() {
            // 重新获取当前分钟的种子(确保跨分钟时更新)
            minuteSeed = getMinuteSeed();
            rng = new SeedRandom(minuteSeed);

            // 生成1-5的随机不重复编号
            const numbers = [1, 2, 3, 4, 5];
            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]];
            }

            // 10%概率触发彩蛋模式
            const isEasterEgg = rng.random() < 0.1;
            const result = [];

            // 生成地图
            result.push(randomChoice(maps));

            if (isEasterEgg) {
                // 彩蛋模式
                result.push(`<span class="easter-egg">🎉 触发彩蛋模式 🎉</span>`);
                const regulator = randomChoice(easterEggRegulators);
                result.push(`${numbers[0]}号 监管者:${regulator}  可任选天赋`);
                const selectedSet = randomChoice(easterEggSurvivorSets);
                selectedSet.forEach((survivor, index) => {
                    const selfRising = rng.random() < 0.6 ? "有自起" : "无自起";
                    result.push(`${numbers[index + 1]}号 求生者:${survivor}  八卦阵  ${selfRising}`);
                });
            } else {
                // 正常模式
                const regulator = randomChoice(regulators);
                let regulatorTalent;
                if (rng.random() < 0.5) {
                    regulatorTalent = "八卦阵";
                } else {
                    const options = ["封窗一刀", "封窗底牌", "封窗张狂", "张狂底牌", "张狂一刀", "底牌一刀"];
                    regulatorTalent = randomChoice(options);
                }
                result.push(`${numbers[0]}号 监管者:${regulator}  ${regulatorTalent}`);

                const selectedSurvivors = randomSample(survivors, 4);
                selectedSurvivors.forEach((survivor, index) => {
                    let survivorTalent;
                    if (rng.random() < 0.5) {
                        survivorTalent = "八卦阵";
                    } else {
                        const options = ["双弹飞轮", "双弹大心脏", "双弹搏命", "飞轮搏命", "飞轮大心脏", "搏命大心脏"];
                        survivorTalent = randomChoice(options);
                    }
                    const selfRising = rng.random() < 0.6 ? "有自起" : "无自起";
                    result.push(`${numbers[index + 1]}号 求生者:${survivor}  ${survivorTalent}  ${selfRising}`);
                });
            }

            // 更新页面显示
            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>

        
编辑器加载中
预览
控制台