<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8" />
<script src="sample.js"></script>
<script src="jquery.js"></script>
<script src="ex.js"></script>
<script src="svgpaint.js"></script>
<title>野球</title>
</head>
<body onload="sample()">
<p id="memo"></p>
</body>
</html>
var inn,home,out,point;
var base = new Array();
var point_home = new Array();
var point_visit = new Array();
function sample() {
inn = 1;
home = 1;
out = 0;
point = 0;
base[1] = 0;
base[2] = 0;
base[3] = 0;
var timer;
var delay = 100;
var loop = function () {
var sub = new ex();
sub.home = home;
sub.inn = inn;
sub.out = out;
sub.base = base;
sub.point = point;
sub.point_home = point_home;
sub.point_visit = point_visit;
sub.game();
inn = sub.inn;
home = sub.home;
out = sub.out;
base = sub.base;
point = sub.point;
point_home = sub.point_home;
point_visit = sub.point_visit;
strx = "" + inn + "," + home + "," + out;
strx = strx +","+ base[1] + "," + base[2];
$("#memo").html(strx);
clearTimeout(timer);
timer = setTimeout(loop, delay);
}
loop();
}
class ex{
inn:number;
home:number;
out:number;
base:number[]=new Array();
point:number;
point_home:number[]=new Array();
point_visit:number[]=new Array();
game():void{
var h1:number;
h1=this.hit();
if(h1==0)this.out=this.out+1;
if(h1==0)this.play();
if(this.out>2)this.fresh();
}
hit():number{
var n1:number;
var n2:number;
var m1:number;
n1=100*Math.random();
m1=0;
if(n1>50)m1=1;
return m1;
}
fresh():void{
this.out=0;
if(this.home==2)this.point_home[this.inn]=this.point;
if(this.home==1)this.point_visit[this.inn]=this.point;
this.point=0;
this.home=this.home+1;
if(this.home==3)this.inn=this.inn+1;
if(this.home==3)this.home=1;
this.base[1]=0;
this.base[2]=0;
this.base[3]=0;
if(this.inn>9)this.clear_game();
}
clear_game():void{
this.inn=1;
this.home=0;
}
play():void{
if(this.base[3]==1)this.point=this.point+1;
if(this.base[3]==1)this.base[3]=0;
if(this.base[2]==1)this.base[3]=1;
if(this.base[2]==1)this.base[2]=0;
if(this.base[1]==1)this.base[2]=1;
this.base[1]=1;
}
}
最終更新:2015年10月02日 17:31