<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>炸金花发牌器</title>
</head>
<body style="padding:20px;font-size:22px;">
<button onclick="deal()" style="padding:10px;font-size:20px;">发3张牌</button>
<div id="cardBox" style="margin-top:20px;"></div>
<script>
// 52张扑克牌
const allCards = [
"A♠","2♠","3♠","4♠","5♠","6♠","7♠","8♠","9♠","10♠","J♠","Q♠","K♠",
"A♥","2♥","3♥","4♥","5♥","6♥","7♥","8♥","9♥","10♥","J♥","Q♥","K♥",
"A♣","2♣","3♣","4♣","5♣","6♣","7♣","8♣","9♣","10♣","J♣","Q♣","K♣",
"A♦","2♦","3♦","4♦","5♦","6♦","7♦","8♦","9♦","10♦","J♦","Q♦","K♦"
];

function deal(){
    let temp = [...allCards];
    let hand = [];
    for(let i=0;i<3;i++){
        let r = Math.floor(Math.random() * temp.length);
        hand.push(temp[r]);
        temp.splice(r,1);
    }
    document.getElementById("cardBox").innerText = hand.join("  ");
}
</script>
</body>
</html>
