Skip to content

Commit e55aacf

Browse files
committed
delete 2048game code
some code should be specification
1 parent 65a3c12 commit e55aacf

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

2048game(over)/main.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
this._parent_ele=null;
1313
}
1414
game.prototype.init=function(obj){
15-
if(typeof obj !='object'||obj instanceof Array){throw new('type error');return;}
15+
if(typeof obj !='object'||obj instanceof Array){
16+
throw new TypeError('type error');
17+
}
1618
this._parent_ele=obj.parentChile;
1719
this.arr = obj._arr;
1820
this.printList();
@@ -57,7 +59,6 @@
5759
}
5860
}
5961
return false;
60-
break;
6162
case 'right':
6263
for(var row=0;row<4;row++){
6364
for(var col=2;col>=0;col--){
@@ -69,7 +70,6 @@
6970
}
7071
}
7172
return false;
72-
break;
7373
case 'up':
7474
for(var row=1;row<4;row++){
7575
for(var col=0;col<4;col++){
@@ -81,7 +81,6 @@
8181
}
8282
}
8383
return false;
84-
break;
8584
case 'down':
8685
for(var row=0;row<3;row++){
8786
for(var col=0;col<4;col++){
@@ -93,7 +92,6 @@
9392
}
9493
}
9594
return false;
96-
break;
9795

9896
}
9997
};
@@ -107,23 +105,20 @@
107105
}
108106
}
109107
return this;
110-
break;
111108
case 'right':
112109
if(this.cango(flag)){
113110
for(var row=0;row<4;row++){
114111
this.moveInRow(flag,row);
115112
}
116113
}
117114
return this;
118-
break;
119115
case 'up':
120116
if(this.cango(flag)){
121117
for(var col=0;col<4;col++){
122118
this.moveInCol(flag,col);
123119
}
124120
}
125121
return this;
126-
break;
127122
case 'down':
128123
if(this.cango(flag)){
129124
for(var col=0;col<4;col++){
@@ -132,7 +127,6 @@
132127
}
133128
}
134129
return this;
135-
break;
136130

137131
}
138132

@@ -228,31 +222,27 @@
228222
}
229223
}
230224
return -1;
231-
break;
232225
case 'right':
233226
for(var i =col-1;i>=0;i--){
234227
if(this.arr[row][i]!=0){
235228
return i ;
236229
}
237230
}
238231
return -1;
239-
break;
240232
case 'up':
241233
for(var i=row+1;i<4;i++){
242234
if(this.arr[i][col]!=0){
243235
return i;
244236
}
245237
}
246238
return -1;
247-
break;
248239
case 'down':
249240
for(var i=row-1;i>=0;i--){
250241
if(this.arr[i][col]!=0){
251242
return i;
252243
}
253244
}
254245
return -1;
255-
break;
256246
}
257247
};
258248
game.prototype.printList=function(){

0 commit comments

Comments
 (0)