根据角色的攻击速度,有需要用速度带走的生命值。问题:console.log(currentChartherHealth) 显示角色的起始生命值时生命值没有被带走
let curentChartherHealth
let curentRandHealth
let timerId = setInterval(()=> {
curentChartherHealth = character.health - rand.damage-character.armor
console.log(curentChartherHealth)
},character.atackSpeed)
let timerId2 = setInterval(()=>{
curentRandHealth = rand.health - (character.damage-rand.armor)
},rand.atackSpeed)
if(curentChartherHealth<=0){
alert(`${rand.name} Win!`)
clearInterval(timerId)
} else if(curentRandHealth<=0){
alert(`${character.name} Win!`)
clearInterval(timerId)
}
}