<!DOCTYPE html>
<html>
<head>
	<title>等级属性查看器</title>
	<meta charset="utf-8">
	<style>
		body {
			font-family: Arial, sans-serif;
			background-color: #f2f2f2;
		}
		h1 {
			text-align: center;
			color: #333;
			margin-top: 50px;
		}
		form {
			margin: 50px auto;
			width: 400px;
			padding: 20px;
			background-color: #fff;
			border-radius: 5px;
			box-shadow: 0 0 10px rgba(0,0,0,0.2);
		}
		label {
			display: block;
			margin-bottom: 10px;
			font-weight: bold;
		}
		input[type="number"] {
			padding: 5px;
			font-size: 16px;
			border-radius: 3px;
			border: 1px solid #ccc;
			width: 100%;
			box-sizing: border-box;
			margin-bottom: 20px;
		}
		button {
			background-color: #4CAF50;
			color: #fff;
			border: none;
			border-radius: 3px;
			padding: 10px 20px;
			font-size: 16px;
			cursor: pointer;
		}
		button:hover {
			background-color: #3e8e41;
		}
		.result {
			margin: 50px auto;
			width: 400px;
			padding: 20px;
			background-color: #fff;
			border-radius: 5px;
			box-shadow: 0 0 10px rgba(0,0,0,0.2);
			display: none;
		}
		.result h2 {
			text-align: center;
			color: #333;
			margin-top: 0;
		}
		.result p {
			margin: 10px 0;
		}
		.result label {
			font-weight: normal;
		}
		.exchange {
			margin-top: 20px;
			text-align: center;
		}
		.exchange button {
			margin: 0 10px;
		}
	</style>
</head>
<body>
	<h1>等级属性查看器</h1>
	<form>
		<label for="level">请输入等级:</label>
		<input type="number" id="level" name="level" min="1" max="10000" required>
		<button type="submit">查询</button>
	</form>
	<div class="result">
		<h2>等级属性</h2>
		<p><label for="attribute">分配属性:</label><span id="attribute"></span></p>
		<div class="exchange">
			<button id="willpower">兑换15点意志</button>
			<button id="grit">兑换10点骨气</button>
		</div>
	</div>
	<script>
		document.querySelector('form').addEventListener('submit', function(event) {
			event.preventDefault();
			var level = parseInt(document.getElementById('level').value);
			var attribute;
			if (level <= 1000) {
				attribute = level * 2;
			} else {
				attribute = 2000 + (level - 1000) * 2;
			}
			document.getElementById('attribute').textContent = attribute + '点';
			document.querySelector('.result').style.display = 'block';
		});
<pre><code>	document.getElementById('willpower').addEventListener('click', function() {
		var attribute = parseInt(document.getElementById('attribute').textContent);
		if (attribute &gt;= 15) {
			attribute -= 15;
			document.getElementById('attribute').textContent = attribute + '点';
			alert('兑换成功,获得15点意志');
		} else {
			alert('分配属性不足15点,无法兑换');
		}
	});

	document.getElementById('grit').addEventListener('click', function() {
		var attribute = parseInt(document.getElementById('attribute').textContent);
		if (attribute &gt;= 10) {
			attribute -= 10;
			document.getElementById('attribute').textContent = attribute + '点';
			alert('兑换成功,获得10点骨气');
		} else {
			alert('分配属性不足10点,无法兑换');
		}
	});
&lt;/script&gt;
</code></pre>
</body>
</html>

原文地址: https://www.cveoy.top/t/topic/bEMO 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录