微件:CharacterAttributes:修订间差异
无编辑摘要 标签:已被回退 |
无编辑摘要 标签:手工回退 |
||
第1行: | 第1行: | ||
<includeonly> | <includeonly> | ||
<div> | <div> | ||
<label for="levelSlider"> | <label for="levelSlider">角色等级: <span id="currentLevel">1</span></label> | ||
<input type="range" id="levelSlider" min="1" max="100" value="1"> | <input type="range" id="levelSlider" min="1" max="100" value="1"> | ||
</div> | </div> | ||
第12行: | 第12行: | ||
<script> | <script> | ||
document.addEventListener('DOMContentLoaded', function() { | document.addEventListener('DOMContentLoaded', function() { | ||
const | const data = { | ||
"levels": { | |||
"1": {"health": 100, "attack": 10, "defense": 5}, | |||
"2": {"health": 120, "attack": 12, "defense": 6}, | |||
"3": {"health": 140, "attack": 14, "defense": 7}, | |||
"100": {"health": 1000, "attack": 100, "defense": 50} | |||
} | |||
}; | |||
const levelSlider = document.getElementById('levelSlider'); | |||
const | const currentLevel = document.getElementById('currentLevel'); | ||
const health = document.getElementById('health'); | |||
const attack = document.getElementById('attack'); | |||
const defense = document.getElementById('defense'); | |||
levelSlider.addEventListener('input', function() { | |||
const level = levelSlider.value; | |||
currentLevel.textContent = level; | |||
const attributes = data.levels[level]; | |||
if (attributes) { | |||
health.textContent = attributes.health; | |||
attack.textContent = attributes.attack; | |||
defense.textContent = attributes.defense; | |||
} | |||
}); | |||
}); | }); | ||
</script> | </script> | ||
</includeonly> | </includeonly> |