🎮ArcadeLab

🗡️地牢寻宝

by TurboFalcon96
137 lines4.2 KB
▶ Play
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>🗡️地牢寻宝</title>
    <style>
        *{margin:0;padding:0;box-sizing:border-box;font-family:system-ui, sans-serif;}
        html{
            background:#1a1a2e !important;
        }
        body{
            background:#1a1a2e !important;
            color:#fff;
            padding:30px 20px;
            min-height:100vh;
            font-size:18px;
        }
        h2{text-align:center;margin-bottom:24px;font-size:26px;}
        .text-box{
            background:#16213e;
            padding:20px;
            border-radius:12px;
            margin-bottom:20px;
            line-height:1.6;
        }
        .hp-info{
            font-size:20px;
            margin-bottom:20px;
        }
        .btn{
            width:100%;
            padding:16px;
            margin:10px 0;
            font-size:17px;
            background:#0f3460;
            color:white;
            border:none;
            border-radius:12px;
        }
        .btn:active{
            background:#e94560;
        }
    </style>
</head>
<body>
    <h2>🗡️地牢寻宝</h2>
    <div class="text-box" id="text"></div>
    <div class="hp-info">❤️生命:<span id="hp">5</span></div>
    <div id="buttons"></div>

<script>
let hp = 5;
const textEl = document.getElementById("text");
const hpEl = document.getElementById("hp");
const btnBox = document.getElementById("buttons");

function show(txt,opts){
    textEl.innerText = txt;
    btnBox.innerHTML = "";
    opts.forEach(opt=>{
        let b = document.createElement("button");
        b.className="btn";
        b.innerText=opt.name;
        b.onclick = opt.action;
        btnBox.appendChild(b);
    })
}

function lose(){
    show("💀你的生命值归零,冒险失败!",[{name:"🔄重新开始",action:start}]);
}
function start(){
    hp=5;hpEl.innerText=hp;
    show("黑漆漆的地牢入口,三条道路摆在眼前。",[
        {name:"①左边昏暗石头通道",action:()=>{
            if(Math.random()>0.4){
                hp--;hpEl.innerText=hp;
                if(hp<=0){lose();return;}
                show("⚠️踩到尖刺陷阱!-1生命,继续向前。",[
                    {name:"往前走",action:room2}
                ])
            }else{
                show("✅安全通过,来到了一个大厅!",[
                    {name:"进入大厅",action:room2}
                ])
            }
        }},
        {name:"②中间飘着蓝光的大门",action:()=>{
            show("幽蓝大门缓缓打开,一只幽灵飘了出来!",[
                {name:"⚔️战斗",action:()=>{
                    hp-=2;hpEl.innerText=hp;
                    if(hp<=0){lose();return;}
                    show("奋力击退幽灵!但是受到了伤害。",[{name:"继续前进",action:room2}])
                }},
                {name:"🏃逃跑",action:()=>{
                    show("你飞快后退,回到入口。",[{name:"返回起点",action:start}])
                }}
            ])
        }},
        {name:"③右边堆满旧木箱的小路",action:()=>{
            show("撬开木箱,找到了一袋金币!💰",[
                {name:"拿上金币往前走",action:room2}
            ])
        }}
    ])
}

function room2(){
    show("来到地牢中央大厅,前方有一道上锁的黄金门。",[
        {name:"🔍四处寻找钥匙",action:()=>{
            if(Math.random()>0.3){
                show("🎉找到了生锈的钥匙!",[{name:"打开金门",action:win}])
            }else{
                hp--;hpEl.innerText=hp;
                if(hp<=0){lose();return;}
                show("😱惊动了老鼠群!扣1滴血,再找找!",[{name:"继续搜寻",action:room2}])
            }
        }},
        {name:"🚪尝试强行撞门",action:()=>{
            hp-=2;hpEl.innerText=hp;
            if(hp<=0){lose();return;}
            show("门纹丝不动,自己撞疼了!",[{name:"再做选择",action:room2}])
        }}
    ])
}

function win(){
    show("🏆恭喜!打开大门,找到了巨大宝藏!游戏通关!",[
        {name:"🔁再来一局",action:start}
    ])
}

start();
</script>
</body>
</html>

Game Source: 🗡️地牢寻宝

Creator: TurboFalcon96

Libraries: none

Complexity: moderate (137 lines, 4.2 KB)

The full source code is displayed above on this page.

Remix Instructions

To remix this game, copy the source code above and modify it. Add a ARCADELAB header at the top with "remix_of: game-turbofalcon96" to link back to the original. Then publish at arcadelab.ai/publish.