<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8" />
<script src="sample.js"></script>
<script src="jquery.js"></script>
<script src="baseball.js"></script>
<title>野球</title>
</head>
<body onload="sample()">
<p id="memo"></p>
</body>
</html>
var point_h, point_v;
function sample() {
var sub = new base();
sub.delta();
point_h = sub.point_h;
point_v = sub.point_v;
$("#memo").html(point_h+","+point_v);
}
class base{
out:number;
base:number[]=new Array();
point:number;
point_h:number;
point_v:number;
delta():void{
this.point_h=0;
this.point_v=0;
var inn:number;
for(inn=1;inn<10;inn++){
this.game();
this.point_v=this.point_v+this.point;
this.game();
this.point_h=this.point_h+this.point;
}
}
game():void{
this.out=0;
this.point=0;
var s:number;
for(s=1;s<4;s++){
this.base[s]=0;
}
while(this.out<3){
this.play();
}
}
play():void{
var h:number;
h=this.hit();
if(h<50)this.out=this.out+1;
if(h>50)this.step();
}
step():void{
if(this.base[3]>50)this.point=this.point+1;
if(this.base[3]>50)this.base[3]=0;
if(this.base[2]>50)this.base[3]=100;
if(this.base[2]>50)this.base[2]=0;
if(this.base[1]>50)this.base[2]=100;
this.base[1]=100;
}
hit():number{
var h:number;
h=0;
if(Math.random()>0.5)h=100;
return h;
}
}
最終更新:2015年07月28日 14:43