アットウィキロゴ

jig

var x = new Array();
var namex = new Array();
var fight,def;
function sample(){
 
var timer;
var delay = 100;
 
 faststep();
 
for(s=1;s<11;s++){
x[s]=s;    
}
 
var loop = function(){
 
fight = select_f();
def = select_d();
 
if(def>0)game();
 
 
paint();
 
clearTimeout(timer);
timer = setTimeout(loop,delay);
}
 
loop();
 
}
 
function paint(){
 
var str;
 
str="<table>";
for(s=1;s<11;s++){
str=str+"<tr><td>"+namex[s]+"</td>";
sx = x[s];
str=str+"<td>"+namex[sx]+"</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 = y[n2];
 
return n2;
}
 
function faststep(){
 
    namex[1] = "山守";
    namex[2] = "広能";
    namex[3] = "武田";
    namex[4] = "江田";
     namex[5] = "松永";
    namex[6] = "打本";
    namex[7] = "大友";
    namex[8] = "岡島";
    namex[9] = "早川";
    namex[10] = "槙原";
 
number=10;    
 
}
 
 
function select_f(){
 
    n1 = 10*Math.random();
    n2 = Math.floor(n1)+1;
    return n2;
}
 
最終更新:2015年06月01日 14:32