background-color:#eee; width:90px;border: 1px solid black;}
button{border: 1px solid black;}
function gu(monsterHealth,monsterAttack,playerHealth,playerAttack){//生命不息整活不止
var monsterName=["亡灵","血骷髅","炸弹人"];
var monster = monsterName[Math.round(Math.random()*2)];//生命不息整活不止
monsterHealth=Math.ceil(Math.random()*200);
monsterAttack=Math.ceil(Math.random()*30);//生命不息整活不止
playerHealth=Math.ceil(Math.random()*200);//生命不息整活不止
playerAttack=Math.ceil(Math.random()*30);
document.getElementById("monsterName").value=monster;//生命不息整活不止
document.getElementById("monsterHealth").value=monsterHealth;//生命不息整活不止
document.getElementById("monsterAttack").value=monsterAttack;
document.getElementById("playerName").value="GULAO";
document.getElementById("playerHealth").value=playerHealth;
document.getElementById("playerAttack").value=playerAttack;
}
function Attack(){
console.log("fffff");
var monsterHealth=document.getElementById("monsterHealth").value;
var playerAttack=document.getElementById("playerAttack").value;
var playerHealth=document.getElementById("playerHealth").value;
var monsterAttack=document.getElementById("monsterAttack").value;
console.log("monsterAttack:"+monsterAttack);
document.getElementById("monsterHealth").value=monsterHealth-playerAttack;
document.getElementById("playerHealth").value=playerHealth-monsterAttack;
playerHealth=playerHealth-monsterAttack;
monsterHealth=monsterHealth-playerAttack;
if(monsterHealth<=0&&playerHealth<=0){
var result="平局";
document.getElementById("result").value=result;
}else if(monsterHealth<=0){
var result="获胜";
document.getElementById("result").value=result;
}else if(playerHealth<=0){
var result="失败";
document.getElementById("result").value=result;
}
}
「」
血量:
攻击:
「」
血量:
攻击:
重制
攻击