-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrush.js
41 lines (29 loc) · 1.05 KB
/
crush.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// this code should calculate the position of the candies and 'crush' those that meet the matching criteria.
matcher = function(row){
for (var i = 0; i < this.length; i++) {
console.log(i + " " + this[i].color.valueOf());
if (i<this.length-1 && this[i].color.valueOf() === this[i+1].color.valueOf()) {
this[i].match = true;
}
};
}
// test = function(){
// for (var i = 0; i < nie.length; i++) {
// console.log(i + " " + nie[i].color.valueOf());
// if (nie[i+1]<nie.length && nie[i].color.valueOf() === nie[i+1].color.valueOf()) {
// nie[i].match = true;
// }
// };
// }
// var n = makeRow();
// var nie = [pink, pink, green, green, green, blue, yellow, pink, pink];
// test = function(){
// for (var i = 0; i < nie.length; i++) {
// console.log(i + " " + nie[i].color.valueOf());
// if (nie[i+1]<nie.length && nie[i].color.valueOf() === nie[i+1].color.valueOf()) {
// nie[i].match = true;
// }
// };
// }
var n = makeRow();
var nie = [pink, pink, green, green, green, blue, yellow, pink, pink];