math/index.html

48 lines
1.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet icon" href="data:" type="image/x-icon" />
<title>陆战棋游戏</title>
<style>
button {
padding: 0.5rem;
color: lightgray;
cursor: pointer;
}
.player1 {
color: black;
}
.player2 {
color: red;
}
</style>
</head>
<body>
<h1>陆战棋游戏</h1>
<h2 id="role"></h2>
<button id="gameButton">玩家1</button>
<script src="/socket.io/socket.io.min.js"></script>
<script>
const client = io();
client.on("role", (name) => {
role.innerText = name;
});
client.on("player", (plaayer) => {
gamepadButton.classList = plaayer;
gamepadButton.classList = plaayer == "player" ? "玩家1" : "玩家2";
});
gamepadButton.onclick = () => {
client.emit("click");
};
</script>
</body>
</html>