var x = new Array();
var fight,def;
function sample(){
for(s=1;s<11;s++){
x[s]=s;
}
fight = select_f();
def = select_d();
if(def>0)game();
paint();
}
function paint(){
var str;
str="<table>";
for(s=1;s<11;s++){
str=str+"<tr><td>"+s+"</td>";
str=str+"<td>"+x[s]+"</td>";
}
str=str+"</table>"
$("#memo").html(str);
}
function game(){
z = 0;
if (Math.random() > 0.5) z = 100;
x1=x[fight];
x2=x[def];
if (z > 50) x[fight] = x2;
if (z > 50) x[def] = x1;
}
function select_d(){
var y = new Array();
f1=x[fight];
sx = 0;
for (s = 1; s < 11;s++ ){
h=0;
if(x[s]==f1)h=100;
if(h<50)sx=sx+1;
if(h<50)y[sx]=s;
}
n1=sx * Math.random();
n2 = Math.floor(n1) + 1;
if(n2>0)n2 = x[n2];
return n2;
}
function select_f(){
n1 = 10*Math.random();
n2 = Math.floor(n1)+1;
return n2;
}
最終更新:2015年06月01日 14:22