@@ -10,6 +10,10 @@ module Mankala {
10
10
export var NoScore = 31 ;
11
11
export var NoMove = - 1 ;
12
12
13
+ const bodyId = "body" ;
14
+ const humanScoreId = "humanScore" ;
15
+ const computerScoreId = "computerScore"
16
+
13
17
export interface IPositionList extends Base . IList {
14
18
data : Position ;
15
19
push ( pos : Position ) ;
@@ -32,10 +36,8 @@ module Mankala {
32
36
export function testBrowser ( ) {
33
37
var game = new Game ( ) ;
34
38
game . interactive ( ) ;
35
- var bod = document . getElementById ( "bod" ) ;
36
- bod . onresize = function ( ) {
37
- game . resize ( ) ;
38
- }
39
+ var body = < HTMLBodyElement > document . getElementById ( bodyId ) ;
40
+ body . onresize = ( ) => { game . resize ( ) ; } ;
39
41
}
40
42
41
43
export class Game {
@@ -49,12 +51,12 @@ module Mankala {
49
51
50
52
private features = new Features ( ) ;
51
53
private nextSeedCounts : number [ ] = new Array < number > ( 14 ) ;
52
- private bod : Element ;
54
+ private body : Element ;
53
55
private boardElm : Element = null ;
54
56
55
57
public resize ( ) {
56
58
if ( this . boardElm != null ) {
57
- this . bod . removeChild ( this . boardElm ) ;
59
+ this . body . removeChild ( this . boardElm ) ;
58
60
}
59
61
this . showMove ( ) ;
60
62
}
@@ -79,7 +81,7 @@ module Mankala {
79
81
if ( ! this . step ( ) ) {
80
82
this . finish ( ) ;
81
83
}
82
- this . bod . removeChild ( this . boardElm ) ;
84
+ this . body . removeChild ( this . boardElm ) ;
83
85
this . showMove ( ) ;
84
86
} , 1000 ) ;
85
87
}
@@ -96,15 +98,15 @@ module Mankala {
96
98
97
99
private auto ( ) {
98
100
// initialize
99
- this . bod = document . getElementById ( "bod" ) ;
101
+ this . body = document . getElementById ( bodyId ) ;
100
102
this . showMove ( ) ;
101
103
// run with timeout
102
104
this . setStep ( ) ;
103
105
}
104
106
105
107
private showMove ( ) : void {
106
- var hsc = document . getElementById ( "humscore" ) ;
107
- var csc = document . getElementById ( "compscore" ) ;
108
+ var hsc = document . getElementById ( humanScoreId ) ;
109
+ var csc = document . getElementById ( computerScoreId ) ;
108
110
109
111
var g = this ;
110
112
if ( ! this . isInteractive ) {
@@ -116,7 +118,7 @@ module Mankala {
116
118
( ( this . position . turn == 0 ) ? " <-Turn" : "" ) ;
117
119
csc . innerText = this . position . seedCounts [ storeHouses [ 1 ] ] +
118
120
( ( this . position . turn == 1 ) ? " <-Turn" : "" ) ;
119
- this . bod . appendChild ( this . boardElm ) ;
121
+ this . body . appendChild ( this . boardElm ) ;
120
122
}
121
123
122
124
public humanMove ( seed : number ) {
@@ -125,7 +127,7 @@ module Mankala {
125
127
this . position = new DisplayPosition ( this . nextSeedCounts . slice ( 0 ) , NoMove ,
126
128
this . features . turnContinues ? this . position . turn : 1 - this . position . turn ) ;
127
129
this . position . config = this . prevConfig ;
128
- this . bod . removeChild ( this . boardElm ) ;
130
+ this . body . removeChild ( this . boardElm ) ;
129
131
this . showMove ( ) ;
130
132
if ( this . position . turn == 1 ) {
131
133
this . setStep ( ) ;
@@ -135,7 +137,7 @@ module Mankala {
135
137
136
138
public interactive ( ) {
137
139
this . isInteractive = true ;
138
- this . bod = document . getElementById ( "bod" ) ;
140
+ this . body = document . getElementById ( bodyId ) ;
139
141
this . showMove ( ) ;
140
142
}
141
143
0 commit comments