52 lines
1.1 KiB
HTML
52 lines
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh">
|
|
|
|
<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="shortcut 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', (player) => {
|
|
gameButton.classList = player
|
|
gameButton.innerText = player == 'player1' ? '玩家1' : '玩家2'
|
|
})
|
|
|
|
gameButton.onclick = () => {
|
|
client.emit('click')
|
|
}
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|