7
<p id="show"></p><button id='xzbtn' onclick="xunzhao(this)">寻找</button>
<div id="zdsysdis" style='display:None'>
<div>井中月:<div id="jzy"></div>
<button onclick="zdgog('gj')">攻击</button><button onclick="zdgog('fy')">防御</button><button onclick="zdgog('jn')">技能</button><button onclick="zdgog('wp')">物品</button><button onclick="zdgog('tp')">逃跑</button>
<div><div id="drdis"></div></div>
<div id="wpdis"></div><br>
<div id="jndis"></div></div>
<script>
var nt=0,siv=0,xzzf=[".","..","..."]
var jingzhongyue={name:'井中月',type:"ziji",lv:5,maxhp:200,maxxp:200,hp:200,xp:200,gjl:12,fyl:3}
var jingzy=newobj(jingzhongyue)
var wupin={caoyao:{name:'草药',en:'cy',n:5,hp:200},lingsan:{name:'灵散',en:'ls',n:3,xp:200}};
var jineng={tbq:{name:'通臂拳',en:'tbq',xp:35,gjl:53},bgz:{name:'八卦掌',en:'bgz',xp:56,gjl:82}}
var direns=[{name:'野猪',type:"diren",lv:2,hp:60,xp:200,gjl:35,fyl:2},{name:'狼',type:"diren",lv:5,hp:57,xp:200,gjl:28,fyl:5},{name:'蛇',type:"diren",lv:6,hp:93,xp:200,gjl:47,fyl:8}]
var prvdr=newobj(direns[1])
function xunzhao(){xzbtn.style.display="None";prvdr=newobj(direns[Math.floor(Math.random()*direns.length)]);prvdr.action=function(){jingzy.hp-=prvdr.gjl-jingzy.fyl};siv=setInterval("gog()",200)}
function gog(){
if(nt>7){nt=0;clearInterval(siv);zdsysdis.style.display="";updatedis()
}else if(nt<3){
show.innerHTML=nt+"寻找中"+xzzf[nt]}else if(nt>=3&&nt<8){
show.innerHTML=nt+""+prvdr.name}
nt++}
function zdgog(n){
var rsu=0
switch(n){
case 'gj':jingzy.action=function(){prvdr.hp-=jingzy.gjl-prvdr.fyl};break;
case 'fy':alert(2);break;
case 'jn':alert(3);break;
}rsu=hurteach(jingzy,prvdr);losewindo(rsu);updatedis()}
function hurteach(c,d){var a=0,b=0;if(c.lv>d.lv){a=c;b=d}else if(c.lv<d.lv){a=d;b=c}else{if(c.type=="ziji"){a=d;b=c}else{a=c;b=d}}
a.action();/*b.hp-=a.gjl-b.fyl*/;if(b.hp<=0){b.hp=0;return b/*alert(b.name)*/}else{b.action()/*a.hp-=b.gjl-a.fyl*/;if(a.hp<=0){a.hp=0;return a/*alert(a.name)*/}}
return 0}
function updatedis(){jzy.innerHTML="等级:"+jingzy.lv+' 生命:'+jingzy.hp+' 体力:'+jingzy.xp;drdis.innerHTML=prvdr.name+":<br>"+"等级:"+prvdr.lv+' 生命:'+prvdr.hp};function udbtn(emt,wp){emt.innerHTML=wp.name+'×'+wp.n}
function newobj(o){var a={};for(b in o){a[b]=o[b]};a.action=function(){alert(a.name)};return a}
function gameover(){xzbtn.style.display='';zdsysdis.style.display='None';jingzy=newobj(jingzhongyue)}
function gamecontinue(){zdsysdis.style.display='None';xunzhao()}
wpjnset();function wpjnset(){
for(let a in wupin){let emt = document.createElement('button');emt.innerHTML=wupin[a]['name']+"×"+wupin[a]['n'];emt.onclick=function(){var wp=wupin[a];switch(wp.en){case 'cy':jingzy.action=function(){if(wp.n>0){wp.n-=1;jingzy.hp+=200}else{alert(wp.n)};if(jingzy.hp>jingzy.maxhp){jingzy.hp=jingzy.maxhp}};break;case 'ls':jingzy.action=function(){if(wp.n>0){wp.n-=1;jingzy.xp+=200}else{alert(wp.n+'没有了')};if(jingzy.xp>jingzy.maxxp){jingzy.xp=jingzy.maxxp}};break;};losewindo(hurteach(jingzy,prvdr));updatedis();udbtn(this,wp);};wpdis.append(emt)}
for(let a in jineng){let emt = document.createElement('button');emt.innerHTML=jineng[a]['name'];jndis.append(emt);emt.onclick=function(){var jn=jineng[a];switch(jn.en){case 'tbq':jingzy.action=function(){ if(jingzy.xp>=jn.xp){prvdr.hp-=jn.gjl-prvdr.fyl;jingzy.xp-=jn.xp }else{alert('xp不足')} };break;case 'bgz':jingzy.action=function(){ if(jingzy.xp>=jn.xp){prvdr.hp-=jn.gjl-prvdr.fyl;jingzy.xp-=jn.xp }else{alert('xp不足')} };break;};losewindo(hurteach(jingzy,prvdr));updatedis(); }}
}
function losewindo(rsu){if(rsu!=0){if(rsu.type=="ziji"){gameover();/*alert('输')*/}else{gamecontinue();/*alert('赢')*/}}}
</script>
6
<p id="show"></p><button id='xzbtn' onclick="xunzhao(this)">寻找</button>
<div id="zdsysdis" style='display:None'>
<div>井中月:<div id="jzy"></div>
<button onclick="zdgog('gj')">攻击</button><button onclick="zdgog('fy')">防御</button><button onclick="zdgog('jn')">技能</button><button onclick="zdgog('wp')">物品</button><button onclick="zdgog('tp')">逃跑</button>
<div><div id="drdis"></div></div>
<div id="wpdis"></div></div>
<script>
var nt=0,siv=0,xzzf=[".","..","..."]
var jingzhongyue={name:'井中月',type:"ziji",lv:5,maxhp:200,maxxp:200,hp:200,xp:200,gjl:12,fyl:3}
var jingzy=newobj(jingzhongyue)
var wupin={caoyao:{name:'草药',en:'cy',n:5,hp:200},lingsan:{name:'灵散',en:'ls',n:3,xp:200}};wpset()
var yezhu={name:'野猪',type:"diren",lv:2,hp:60,xp:200,gjl:35,fyl:2}
var lang={name:'狼',type:"diren",lv:5,hp:57,xp:200,gjl:28,fyl:5}
var she={name:'蛇',type:"diren",lv:6,hp:93,xp:200,gjl:47,fyl:8}
var direns=[yezhu,lang,she]
var prvdr=newobj(direns[1])
function xunzhao(){xzbtn.style.display="None";prvdr=newobj(direns[Math.floor(Math.random()*direns.length)]);prvdr.action=function(){jingzy.hp-=prvdr.gjl-jingzy.fyl};siv=setInterval("gog()",200)}
function gog(){
if(nt>7){nt=0;clearInterval(siv);zdsysdis.style.display="";updatedis()
}else if(nt<3){
show.innerHTML=nt+"寻找中"+xzzf[nt]}else if(nt>=3&&nt<8){
show.innerHTML=nt+""+prvdr.name}
nt++}
function zdgog(n){
var rsu=0
switch(n){
case 'gj':jingzy.action=function(){prvdr.hp-=jingzy.gjl-prvdr.fyl}
//if(rsu!=0){if(rsu.type=="ziji"){gameover();/*alert('输')*/}else{gamecontinue();/*alert('赢')*/}};
break;
case 'fy':alert(2);break;
case 'jn':alert(3);break;
}rsu=hurteach(jingzy,prvdr);losewindo(rsu);updatedis()}
function hurteach(c,d){var a=0,b=0;if(c.lv>d.lv){a=c;b=d}else if(c.lv<d.lv){a=d;b=c}else{if(c.type=="ziji"){a=d;b=c}else{a=c;b=d}}
a.action();/*b.hp-=a.gjl-b.fyl*/;if(b.hp<=0){b.hp=0;return b/*alert(b.name)*/}else{b.action()/*a.hp-=b.gjl-a.fyl*/;if(a.hp<=0){a.hp=0;return a/*alert(a.name)*/}}
return 0}
function updatedis(){jzy.innerHTML="等级:"+jingzy.lv+' 生命:'+jingzy.hp;drdis.innerHTML=prvdr.name+":<br>"+"等级:"+prvdr.lv+' 生命:'+prvdr.hp};function udbtn(emt,wp){emt.innerHTML=wp.name+'×'+wp.n}
function newobj(o){var a={};for(b in o){a[b]=o[b]};a.action=function(){alert(a.name)};return a}
function gameover(){xzbtn.style.display='';zdsysdis.style.display='None';jingzy=newobj(jingzhongyue)}
function gamecontinue(){zdsysdis.style.display='None';xunzhao()}
function wpset(){for(let a in wupin){let emt = document.createElement('button');emt.innerHTML=wupin[a]['name']+"×"+wupin[a]['n'];emt.onclick=function(){var wp=wupin[a];switch(wp.en){case 'cy':jingzy.action=function(){if(wp.n>0){wp.n-=1;jingzy.hp+=200}else{alert(wp.n)};if(jingzy.hp>jingzy.maxhp){jingzy.hp=jingzy.maxhp}};break;case 'ls':if(wp.n>0){wp.n-=1;jingzy.xp+=200}else{alert(wp.n+'没有了')};if(jingzy.xp>jingzy.maxxp){jingzy.xp=jingzy.maxxp};break;};losewindo(hurteach(jingzy,prvdr));updatedis();udbtn(this,wp);};wpdis.append(emt)}}
function losewindo(rsu){if(rsu!=0){if(rsu.type=="ziji"){gameover();/*alert('输')*/}else{gamecontinue();/*alert('赢')*/}}}
</script>
5
<p id="show"></p><button id='xzbtn' onclick="xunzhao(this)">寻找</button>
<div id="zdsysdis" style='display:None'>
<div>井中月:<div id="jzy"></div>
<button onclick="zdgog('gj')">攻击</button><button onclick="zdgog('fy')">防御</button><button onclick="zdgog('jn')">技能</button><button onclick="zdgog('wp')">物品</button><button onclick="zdgog('tp')">逃跑</button>
<div><div id="drdis"></div></div>
<div id="wpdis"></div></div>
<script>
var nt=0,siv=0,xzzf=[".","..","..."]
var jingzhongyue={name:'井中月',type:"ziji",lv:5,maxhp:200,maxxp:200,hp:200,xp:200,gjl:12,fyl:3}
var jingzy=newobj(jingzhongyue)
var wupin={caoyao:{name:'草药',en:'cy',n:5,hp:200},lingsan:{name:'灵散',en:'ls',n:3,xp:200}};wpset()
var yezhu={name:'野猪',type:"diren",lv:2,hp:60,xp:200,gjl:35,fyl:2}
var lang={name:'狼',type:"diren",lv:5,hp:57,xp:200,gjl:28,fyl:5}
var she={name:'蛇',type:"diren",lv:6,hp:93,xp:200,gjl:47,fyl:8}
var direns=[yezhu,lang,she]
var prvdr=newobj(direns[1])
function xunzhao(){xzbtn.style.display="None";prvdr=newobj(direns[Math.floor(Math.random()*direns.length)]);siv=setInterval("gog()",200)}
function gog(){
if(nt>7){nt=0;clearInterval(siv);zdsysdis.style.display="";updatedis()
}else if(nt<3){
show.innerHTML=nt+"寻找中"+xzzf[nt]}else if(nt>=3&&nt<8){
show.innerHTML=nt+""+prvdr.name}
nt++}
function zdgog(n){prvdr.action=function(){jingzy.hp-=prvdr.gjl-jingzy.fyl}
var rsu=0
switch(n){
case 'gj':jingzy.action=function(){prvdr.hp-=jingzy.gjl-prvdr.fyl}
//if(rsu!=0){if(rsu.type=="ziji"){gameover();/*alert('输')*/}else{gamecontinue();/*alert('赢')*/}};
break;
case 'fy':alert(2);break;
case 'jn':alert(3);break;
}rsu=hurteach(jingzy,prvdr);losewindo(rsu);updatedis()}
function hurteach(c,d){var a=0,b=0;if(c.lv>d.lv){a=c;b=d}else if(c.lv<d.lv){a=d;b=c}else{if(c.type=="ziji"){a=d;b=c}else{a=c;b=d}}
a.action();/*b.hp-=a.gjl-b.fyl*/;if(b.hp<=0){b.hp=0;return b/*alert(b.name)*/}else{b.action()/*a.hp-=b.gjl-a.fyl*/;if(a.hp<=0){a.hp=0;return a/*alert(a.name)*/}}
return 0}
function updatedis(){jzy.innerHTML="等级:"+jingzy.lv+' 生命:'+jingzy.hp;drdis.innerHTML=prvdr.name+":<br>"+"等级:"+prvdr.lv+' 生命:'+prvdr.hp};function udbtn(emt,wp){emt.innerHTML=wp.name+'×'+wp.n}
function newobj(o){var a={};for(b in o){a[b]=o[b]};a.action=function(){alert(a.name)};return a}
function gameover(){xzbtn.style.display='';zdsysdis.style.display='None';jingzy=newobj(jingzhongyue)}
function gamecontinue(){zdsysdis.style.display='None';xunzhao()}
function wpset(){for(let a in wupin){let emt = document.createElement('button');emt.innerHTML=wupin[a]['name']+"×"+wupin[a]['n'];emt.onclick=function(){var wp=wupin[a];switch(wp.en){case 'cy':if(wp.n>0){wp.n-=1;jingzy.hp+=200}else{alert(wp.n)};if(jingzy.hp>jingzy.maxhp){jingzy.hp=jingzy.maxhp};break;case 'ls':if(wp.n>0){wp.n-=1;jingzy.xp+=200}else{alert(wp.n+'没有了')};if(jingzy.xp>jingzy.maxxp){jingzy.xp=jingzy.maxxp};break;};losewindo(hurteach(jingzy,prvdr));updatedis();udbtn(this,wp);};wpdis.append(emt)}}
function losewindo(rsu){if(rsu!=0){if(rsu.type=="ziji"){gameover();/*alert('输')*/}else{gamecontinue();/*alert('赢')*/}}}
</script>
4
<p id="show"></p><button id='xzbtn' onclick="xunzhao(this)">寻找</button>
<div id="zdsysdis" style='display:None'>
<div>井中月:<div id="jzy"></div>
<button onclick="zdgog('gj')">攻击</button><button onclick="zdgog('fy')">防御</button><button onclick="zdgog('jn')">技能</button><button onclick="zdgog('wp')">物品</button><button onclick="zdgog('tp')">逃跑</button>
<div><div id="drdis"></div></div>
<div id="wpdis"></div></div>
<script>
var nt=0,siv=0,xzzf=[".","..","..."]
var jingzhongyue={name:'井中月',type:"ziji",lv:5,maxhp:200,maxxp:200,hp:200,xp:200,gjl:12,fyl:3}
var jingzy=newobj(jingzhongyue)
var wupin={caoyao:{name:'草药',en:'cy',n:5,hp:200},lingsan:{name:'灵散',en:'ls',n:3,xp:200}};wpset()
var yezhu={name:'野猪',type:"diren",lv:2,hp:60,xp:200,gjl:35,fyl:2}
var lang={name:'狼',type:"diren",lv:5,hp:57,xp:200,gjl:28,fyl:5}
var she={name:'蛇',type:"diren",lv:6,hp:93,xp:200,gjl:47,fyl:8}
var direns=[yezhu,lang,she]
var prvdr=newobj(direns[1])
function xunzhao(){xzbtn.style.display="None";prvdr=newobj(direns[Math.floor(Math.random()*direns.length)]);siv=setInterval("gog()",200)}
function gog(){
if(nt>7){nt=0;clearInterval(siv);zdsysdis.style.display="";updatedis()
}else if(nt<3){
show.innerHTML=nt+"寻找中"+xzzf[nt]}else if(nt>=3&&nt<8){
show.innerHTML=nt+""+prvdr.name}
nt++}
function zdgog(n){
switch(n){
case 'gj':var rsu=hurteach(jingzy,prvdr);if(rsu!=0){if(rsu.type=="ziji"){gameover();/*alert('输')*/}else{gamecontinue();/*alert('赢')*/}};break;
case 'fy':alert(2);break;
case 'jn':alert(3);break;
}updatedis()}
function hurteach(c,d){var a=0,b=0;if(c.lv>d.lv){a=c;b=d}else if(c.lv<d.lv){a=d;b=c}else{if(c.type=="ziji"){a=d;b=c}else{a=c;b=d}}
b.hp-=a.gjl-b.fyl;if(b.hp<=0){b.hp=0;return b/*alert(b.name)*/}else{a.hp-=b.gjl-a.fyl;if(a.hp<=0){a.hp=0;return a/*alert(a.name)*/}}
return 0}
function updatedis(){jzy.innerHTML="等级:"+jingzy.lv+' 生命:'+jingzy.hp;drdis.innerHTML=prvdr.name+":<br>"+"等级:"+prvdr.lv+' 生命:'+prvdr.hp};function udbtn(emt,wp){emt.innerHTML=wp.name+'×'+wp.n}
function newobj(o){var a={};for(b in o){a[b]=o[b]};return a}
function gameover(){xzbtn.style.display='';zdsysdis.style.display='None';jingzy=newobj(jingzhongyue)}
function gamecontinue(){zdsysdis.style.display='None';xunzhao()}
function wpset(){for(let a in wupin){let emt = document.createElement('button');emt.innerHTML=wupin[a]['name']+"×"+wupin[a]['n'];emt.onclick=function(){var wp=wupin[a];switch(wp.en){case 'cy':if(wp.n>0){wp.n-=1;jingzy.hp+=200}else{alert(wp.n)};if(jingzy.hp>jingzy.maxhp){jingzy.hp=jingzy.maxhp};break;case 'ls':if(wp.n>0){wp.n-=1;jingzy.xp+=200}else{alert(wp.n+'没有了')};if(jingzy.xp>jingzy.maxxp){jingzy.xp=jingzy.maxxp};break;} updatedis();udbtn(this,wp);};wpdis.append(emt)}}
</script>
界面2
<style>
.center{display:block;border:2px solid blue;position:absolute;width:240;left:50%;top:50%;transform:translate(-50%,-50%);}
.mygame{border:1px solid red}
.topinfo{border:1px solid red;height:20px;}
.midcharacter{border:1px solid red;height:220px;}
.midcharacter .left,.right{position:relative;box-sizing:border-box;float:left;width:50%;height:100%;border:1px solid green}
.midcharacter .right{}
.midcharacter .chars{border:1px solid gray;display:inline-block;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%) }
.midcharacter .chars div{border:1px solid pink;width:40px;height:40px;}
.btncontrol{border:1px solid red;height:80px;}
.btncontrol .optn{border:1px solid blue;height:100%;}
.btncontrol .charinfo{position:relative;}
.btncontrol .charinfo .char{/*display:inline-block;*/float:left;box-sizing:border-box;padding:5px;border:1px solid orange;width:80}
.btncontrol .charinfo .img{border:1px solid green;height:30px;width:30px;}
.btncontrol .charinfo .hp,.xp{height:5px;background:linear-gradient(to right,blue 10%,gray 0%);border:0.5px solid red;}
.btncontrol .charinfo .xp{background:linear-gradient(to right,blue 30%,gray 0%);}
.btncontrol .charinfo .num{font-size:10px}
.btncontrol{}
</style>
<div class="mygame">
<div class="topinfo">顶部信息栏</div>
<div class="midcharacter">
<div class="left"><div class='chars'><div>1</div><div>2</div><div>3</div></div></div>
<div class="right"><div class='chars'><div>1</div><div>2</div><div>3</div></div></div>
</div>
<div class="btncontrol">
<div class="optn charinfo">
<div class='center'>
<div class='char'>
<div class='img'>1</div>
<div class='num'>159/200</div><div class='hp'></div>
<div class='num'>159/200</div><div class='xp'></div></div>
<div class='char'>
<div class='img'>2</div>
<div class='num'>159/200</div><div class='hp'></div>
<div class='num'>89/200</div><div class='xp'></div></div>
<div class='char'>
<div class='img'>3</div>
<div class='num'>159/200</div><div class='hp'></div>
<div class='num'>159/200</div><div class='xp'></div></div>
</div></div>
<div class="optn skill">技能</div> <div class="optn material">物品</div></div></div>
<script>
mygame=document.getElementsByClassName('mygame')[0]
mygame.topinfo=document.getElementsByClassName('topinfo')[0]
mygame.midcharacter=document.getElementsByClassName('midcharacter')[0]
mygame.btncontrol=document.getElementsByClassName('btncontrol')[0]
</script>
界面1
<style>
.mygame{border:1px solid red}
.topinfo{border:1px solid red;height:20px;}
.midcharacter{border:1px solid red;height:220px;}
.midcharacter .left,.right{position:relative;box-sizing:border-box;float:left;width:50%;height:100%;border:1px solid green}
.midcharacter .right{}
.midcharacter .chars{border:1px solid gray;display:inline-block;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%) }
.midcharacter .chars div{border:1px solid pink;width:40px;height:40px;}
.btncontrol{border:1px solid red;height:60px;}
.btncontrol .optn{border:1px solid blue;height:100%;}
.btncontrol .charinfo .char{display:inline-block;border:1px solid orange;}
.btncontrol .charinfo .hp,.xp{height:10px;background:linear-gradient(to right,blue 10%,gray 0%);border:1px solid red;}
.btncontrol{}
</style>
<div class="mygame">
<div class="topinfo">顶部信息栏</div>
<div class="midcharacter">
<div class="left"><div class='chars'><div>1</div><div>2</div><div>3</div></div></div>
<div class="right"><div class='chars'><div>1</div><div>2</div><div>3</div></div></div>
</div>
<div class="btncontrol">
<div class="optn charinfo">
<div class='char'>
<div class='img'>井中月img</div>
<div class='hp'></div>
<div class='xp'></div>
</div>
<div class='char'>王亦风</div>
<div class='char'>周芷若</div>
</div>
<div class="optn skill">技能</div>
<div class="optn material">物品</div>
</div>
</div>
<script>
mygame=document.getElementsByClassName('mygame')[0]
mygame.topinfo=document.getElementsByClassName('topinfo')[0]
mygame.midcharacter=document.getElementsByClassName('midcharacter')[0]
mygame.btncontrol=document.getElementsByClassName('btncontrol')[0]
</script>
3
<p id="show"></p>
<button id='xzbtn' onclick="xunzhao(this)">寻找</button>
<div id="zdsysdis" style='display:None'>
<div>井中月:<div id="jzy"></div>
<button onclick="zdgog('gj')">攻击</button><button onclick="zdgog('fy')">防御</button><button onclick="zdgog('jn')">技能</button><button onclick="zdgog('wp')">物品</button><button onclick="zdgog('tp')">逃跑</button>
<div><div id="drdis"></div></div>
<div id="wpdis"></div>
</div>
<script>
var nt=0,siv=0,xzzf=[".","..","..."]
var jingzy={name:'井中月',type:"ziji",lv:5,hp:200,xp:200,gjl:12,fyl:3}
var wupin={caoyao:{name:'草药',en:'cy',n:5,hp:200},lingsan:{name:'灵散',en:'ls',n:3,xp:200}}
wpset()
var yezhu={name:'野猪',type:"diren",lv:2,hp:60,xp:200,gjl:35,fyl:8}
var lang={name:'狼',type:"diren",lv:5,hp:57,xp:200,gjl:28,fyl:3}
var she={name:'蛇',type:"diren",lv:6,hp:93,xp:200,gjl:12,fyl:3}
var direns=[yezhu,lang,she]
var prvdr=newdiren(direns[1])
function xunzhao(){xzbtn.style.display="None";prvdr=newdiren(direns[Math.floor(Math.random()*direns.length)]);siv=setInterval("gog()",200)}
function gog(){
if(nt>7){nt=0;clearInterval(siv);zdsysdis.style.display="";updatedis()
}else if(nt<3){
show.innerHTML=nt+"寻找中"+xzzf[nt]}else if(nt>=3&&nt<8){
show.innerHTML=nt+""+prvdr.name}
nt++}
function zdgog(n){
switch(n){
case 'gj':var rsu=hurteach(jingzy,prvdr);if(rsu!=0){if(rsu.type=="ziji"){gameover();/*alert('输')*/}else{gamecontinue();/*alert('赢')*/}};break;
case 'fy':alert(2);break;
case 'jn':alert(3);break;
}
updatedis()}
function hurteach(c,d){var a=0,b=0;if(c.lv>d.lv){a=c;b=d}else if(c.lv<d.lv){a=d;b=c}else{if(c.type=="ziji"){a=d;b=c}else{a=c;b=d}}
b.hp-=a.gjl-b.fyl;if(b.hp<=0){b.hp=0;return b/*alert(b.name)*/}else{a.hp-=b.gjl-a.fyl;if(a.hp<=0){a.hp=0;return a/*alert(a.name)*/}}
return 0
}
function updatedis(){jzy.innerHTML=jingzy.hp;drdis.innerHTML=prvdr.name+":"+prvdr.hp}
function newdiren(o){var a={};for(b in o){a[b]=o[b]};return a}
function gameover(){xzbtn.style.display='';zdsysdis.style.display='None';jingzy.hp=200}
function gamecontinue(){zdsysdis.style.display='None';xunzhao()}
function wpset(){for(let a in wupin){let emt = document.createElement('button');emt.innerHTML=wupin[a]['name'];emt.onclick=function(){var wp=wupin[a];switch(wp.en){case 'cy':jingzy.hp+=200;break;case 'ls':jingzy.xp+=200;break;} updatedis();};wpdis.append(emt)}}
</script>
2
<p id="show"></p>
<button onclick="xunzhao(this)">寻找</button>
<div id="zdsysdis" style='display:None'>
<div>井中月:<div id="jzy"></div>
<button onclick="zdgog('gj')">攻击</button><button onclick="zdgog('fy')">防御</button><button onclick="zdgog('jn')">技能</button><button onclick="zdgog('wp')">物品</button><button onclick="zdgog('tp')">逃跑</button>
<div><div id="drdis"></div></div>
</div>
<script>
var nt=0,siv=0,xzzf=[".","..","..."]
var jingzy={name:'井中月',type:"ziji",lv:5,hp:200,xp:200,gjl:12,fyl:3}
var yezhu={name:'野猪',type:"diren",lv:2,hp:60,xp:200,gjl:35,fyl:8}
var lang={name:'狼',type:"diren",lv:5,hp:57,xp:200,gjl:28,fyl:3}
var she={name:'蛇',type:"diren",lv:6,hp:93,xp:200,gjl:12,fyl:3}
var direns=[yezhu,lang,she]
var prvdr=newdiren(direns[1])
function xunzhao(emt){emt.style.display="None";prvdr=newdiren(direns[Math.floor(Math.random()*direns.length)]);siv=setInterval("gog()",200)}
function gog(){
if(nt>7){clearInterval(siv);zdsysdis.style.display="";updatedis()
}else if(nt<3){
show.innerHTML=nt+"寻找中"+xzzf[nt]}else if(nt>=3&&nt<8){
show.innerHTML=nt+""+prvdr.name}
nt++}
function zdgog(n){
switch(n){
case 'gj':var rsu=hurteach(jingzy,prvdr);if(rsu!=0){if(rsu.type=="ziji"){alert('输')}else{alert('赢')}};break;
case 'fy':alert(2);break;
case 'jn':alert(3);break;
}
updatedis()}
function hurteach(c,d){var a=0,b=0;if(c.lv>d.lv){a=c;b=d}else if(c.lv<d.lv){a=d;b=c}else{if(c.type=="ziji"){a=d;b=c}else{a=c;b=d}}
b.hp-=a.gjl-b.fyl;if(b.hp<=0){b.hp=0;return b/*alert(b.name)*/}else{a.hp-=b.gjl-a.fyl;if(a.hp<=0){a.hp=0;return a/*alert(a.name)*/}}
return 0
}
function updatedis(){jzy.innerHTML=jingzy.hp;drdis.innerHTML=prvdr.name+":"+prvdr.hp}
function newdiren(o){var a={};for(b in o){a[b]=o[b]};return a}
//alert(newdiren(yezhu).hp)
</script>
1
<html><head></head><body>
<div id="jzyshow"></div>
<button onclick="gog('gj')">攻</button>
<button onclick="gog('fy')">防</button>
<button onclick="gog('jn')">技</button>
<button onclick="gog('wp')">物</button>
<button onclick="gog('tp')">逃</button>
<div id="yzshow"></div>
<div><span class='' onclick='gog("cy")'>草药</span></div>
<script>
var jingzy={xueliang:200,tili:200,gongjili:12,fangyuli:5}
var beibao={caoyao:3,lingsan:2}
var yezhu={xueliang:65,gongjili:47,fangyuli:3}
var lang={xueliang:50,gongjili:52,fangyuli:8}
var she={xueliang:100,gongjili:76,fangyuli:12}
var ani=[yezhu,lang,she]
var prvani=ani[1]
function gog(n){
switch(n){
case "gj":
prvani.xueliang-=jingzy.gongjili-prvani.fangyuli;
break;
case 'fy':break;
case 'cy':
if(beibao.caoyao>0){jingzy.xueliang+=200;beibao.caoyao-=1}
break;
}
jingzy.xueliang-=prvani.gongjili-jingzy.fangyuli;
if(jingzy.xueliang<=0){jingzy.xueliang=0;alert("输")}
if(prvani.xueliang<=0){prvani.xueliang=0;alert("赢")}
disupdate()}
disupdate()
function disupdate(n){
jzyshow.innerHTML="血量:"+jingzy.xueliang+" 体力:"+jingzy.tili
yzshow.innerHTML="血量:"+prvani.xueliang
}
function anynum(anum,bnum){
var arr=[]
for(let a=anum;anum<bnum;anum++){arr.push(anum)}
for(let a=0;a<arr.length;a++){
var rn=Math.floor(Math.random()*arr.length)
var temp=arr[a]
arr[a]=arr[rn]
arr[rn]=temp
}
alert(arr)
}
anynum(0,3)
</script></body></html>
基本
<html>
<head>
</head>
<body>
<div id="jzyshow"></div>
<button onclick="gog('gj')">攻</button>
<button onclick="gog('fy')">防</button>
<button onclick="gog('jn')">技</button>
<button onclick="gog('wp')">物</button>
<button onclick="gog('tp')">逃</button>
<div id="yzshow"></div>
<div>
<span class='' onclick='gog("cy")'>草药</span>
</div>
<script>
var jingzy={xueliang:200,tili:200,gongjili:12,fangyuli:5}
var yezhu={xueliang:65,gongjili:47,fangyuli:3}
function gog(n){
switch(n){
case "gj":
yezhu.xueliang-=jingzy.gongjili-yezhu.fangyuli;
break;
case 'fy':break;
case 'cy':
jingzy.xueliang+=200;
break;
}
jingzy.xueliang-=yezhu.gongjili-jingzy.fangyuli;
if(jingzy.xueliang<=0){
jingzy.xueliang=0;alert("输")
}
disupdate()
}
function disupdate(n){
jzyshow.innerHTML="血量:"+jingzy.xueliang+" 体力:"+jingzy.tili
yzshow.innerHTML="血量:"+yezhu.xueliang
}
</script>
</body>
</html>