<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
var base=new Array();
var out,home;
var point_v,point_h;
var x=new Array();
function sample(){
x=["三振","ヒット","ニ塁打","三塁打","ホームラン"];
var timer;
var delay = 100;
point_h=0;
point_v=0;
inn=1;
home="v";
out=0;
base[1]=0;
base[2]=0;
base[3]=0;
var loop = function () {
n1=5*Math.random();
n2=Math.floor(n1);
hit=x[n2];
step(hit);
if(out==3)fresh();
if(inn>9)game();
b="";
if(base[1]==1)b=b+"●";
if(base[1]==0)b=b+"○";
if(base[2]==1)b=b+"●";
if(base[2]==0)b=b+"○";
if(base[3]==1)b=b+"●";
if(base[3]==0)b=b+"○";
str=""+inn+"回表"+"("+out+")"+point_h+"*"+point_v+b;
if(home=="h")str=""+inn+"回裏"+"("+out+")"+point_h+"*"+point_v+b;
$("#memo").html(str);
clearTimeout(timer);
timer = setTimeout(loop, delay);
}
loop();
}
function fresh(){
out=0;
he=home;
if(he=="h")inn=inn+1;
if(he=="h")home="v";
if(he=="v")home="h";
base[1]=0;
base[2]=0;
base[3]=0;
base[3]=0;
}
function game(){
out=0;
home="v";
inn=1;
base[1]=0;
base[2]=0;
base[3]=0;
base[3]=0;
point_h=0;
point_v=0;
}
function step(hit){
if(hit=="三振")out=out+1;
}
function one(){
p=0;
if(base[3]==1)p=1;
if(base[3]==1)base[3]=0;
if(base[2]==1)base[3]=1;
if(base[2]==1)base[2]=0;
if(base[1]==1)base[2]=1;
if(base[1]==1)base[1]=0;
base[1]=1;
if(home=="v")point_v=point_v+p;
if(home=="h")point_h=point_h+p;
}
function two(){
p=0;
if(base[3]==1)p=p+1;
if(base[3]==1)base[3]=0;
if(base[2]==1)p=p+1;
if(base[2]==1)base[2]=0;
if(base[1]==1)base[3]=1;
if(base[1]==1)base[1]=0;
base[2]=1;
if(home=="v")point_v=point_v+p;
if(home=="h")point_h=point_h+p;
}
function three(){
p=0;
if(base[3]==1)p=p+1;
if(base[3]==1)base[3]=0;
if(base[2]==1)p=p+1;
if(base[2]==1)base[2]=0;
if(base[1]==1)p=p+1;
if(base[1]==1)base[1]=0;
base[3]=1;
if(home=="v")point_v=point_v+p;
if(home=="h")point_h=point_h+p;
}
function four(){
p=0;
if(base[3]==1)p=p+1;
if(base[3]==1)base[3]=0;
if(base[2]==1)p=p+1;
if(base[2]==1)base[2]=0;
if(base[1]==1)p=p+1;
if(base[1]==1)base[1]=0;
p=p+1;
if(home=="v")point_v=point_v+p;
if(home=="h")point_h=point_h+p;
}
</script>
最終更新:2018年06月05日 06:39