🎮ArcadeLab

🗡️地牢寻宝V2

by TurboFalcon96
187 lines6.0 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>🗡️地牢寻宝V2</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:16px;font-size:26px;}
        .text-box{
            background:#16213e;
            padding:20px;
            border-radius:12px;
            margin-bottom:16px;
            line-height:1.6;
        }
        .status{
            font-size:19px;
            margin-bottom:16px;
            background:#0f3460;
            padding:10px;
            border-radius:10px;
        }
        .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>🗡️地牢寻宝V2</h2>
    <div class="text-box" id="text"></div>
    <div class="status">
        ❤️生命:<span id="hp">5</span> &nbsp;&nbsp;
        💰金币:<span id="gold">0</span> &nbsp;&nbsp;
        🧪药水:<span id="potion">1</span>
    </div>
    <div id="buttons"></div>

<script>
let hp = 5;
let gold = 0;
let potion = 1;
const textEl = document.getElementById("text");
const hpEl = document.getElementById("hp");
const goldEl = document.getElementById("gold");
const potEl = document.getElementById("potion");
const btnBox = document.getElementById("buttons");

function refreshUI(){
    hpEl.innerText=hp;
    goldEl.innerText=gold;
    potEl.innerText=potion;
}

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;gold=0;potion=1;
    refreshUI();
    show("你站在地牢入口。三条道路摆在眼前。",[
        {name:"①左边昏暗石头通道",action:()=>{
            if(Math.random()>0.4){
                hp--;refreshUI();
                if(hp<=0){lose();return;}
                show("⚠️踩到尖刺陷阱!-1生命。",[
                    {name:"往前走",action:hall}
                ])
            }else{
                gold +=3;refreshUI();
                show("✅安全通过!捡到3枚金币!",[
                    {name:"前往大厅",action:hall}
                ])
            }
        }},
        {name:"②幽蓝发光大门",action:()=>{
            show("门缓缓打开,一只骷髅冲出来!",[
                {name:"⚔️战斗",action:()=>{
                    if(Math.random()>0.5){
                        gold +=8;refreshUI();
                        show("🎉打赢骷髅!获得8金币!",[{name:"去大厅",action:hall}]);
                    }else{
                        hp-=2;refreshUI();
                        if(hp<=0){lose();return;}
                        show("😫被砍了一刀!-2生命!",[{name:"去大厅",action:hall}]);
                    }
                }},
                {name:"🏃逃跑",action:()=>{
                    show("你赶紧跑回入口!",[{name:"回到起点",action:start}]);
                }}
            ])
        }},
        {name:"③堆满木箱的小路",action:()=>{
            gold +=6;refreshUI();
            show("💰撬开箱子,拿到6枚金币!",[
                {name:"去大厅",action:hall}
            ])
        }}
    ])
}

function hall(){
    refreshUI();
    show("📍地牢大厅!前方有一间小店,还有一条幽深走廊。",[
        {name:"🏪进商店",action:()=>{
            show("老板:药水5金币1瓶,可以回血!",[
                {name:"🧪买药水(5金)",action:()=>{
                    if(gold>=5){
                        gold -=5;
                        potion +=1;
                        refreshUI();
                        show("✅买到一瓶药水!",[{name:"返回大厅",action:hall}]);
                    }else{
                        show("❌金币不够!",[{name:"返回大厅",action:hall}]);
                    }
                }},
                {name:"🚪离开商店",action:hall}
            ])
        }},
        {name:"🧪喝一瓶药水",action:()=>{
            if(potion>0){
                potion--;hp+=2;refreshUI();
                show("💚喝下药水,恢复2点生命!",[{name:"继续选择",action:hall}]);
            }else{
                show("😥没有药水了!",[{name:"继续选择",action:hall}]);
            }
        }},
        {name:"🚶走幽深走廊",action:()=>{
            show("走廊尽头是一扇上锁的黄金门!",[
                {name:"🔍寻找钥匙",action:()=>{
                    if(Math.random()>0.35){
                        show("🎉找到了钥匙!",[{name:"打开金门",action:win}]);
                    }else{
                        hp--;refreshUI();
                        if(hp<=0){lose();return;}
                        show("😱惊动巨型老鼠!扣1滴血!",[{name:"继续找钥匙",action:()=>{
                            show("再一次搜寻!",[
                                {name:"继续找",action:()=>{show("终于找到了钥匙!",[{name:"开门",action:win}])}}
                            ])
                        }}])
                    }
                }}
            ])
        }}
    ])
}

function win(){
    refreshUI();
    show("🏆恭喜!打开金门,发现巨大宝藏!你胜利啦!",[
        {name:"🔁再来一局",action:start}
    ])
}

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

Game Source: 🗡️地牢寻宝V2

Creator: TurboFalcon96

Libraries: none

Complexity: moderate (187 lines, 6.0 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: v2-turbofalcon96" to link back to the original. Then publish at arcadelab.ai/publish.