source:
trunk/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js
Last change on this file was 846, checked in by , 14 years ago | |
---|---|
File size: 3.5 KB |
Line | |
---|---|
1 | function winner(board) |
2 | { |
3 | for (var i=0; i<3; ++i) { |
4 | if (board.children[i].state != "" |
5 | && board.children[i].state == board.children[i+3].state |
6 | && board.children[i].state == board.children[i+6].state) |
7 | return true |
8 | |
9 | if (board.children[i*3].state != "" |
10 | && board.children[i*3].state == board.children[i*3+1].state |
11 | && board.children[i*3].state == board.children[i*3+2].state) |
12 | return true |
13 | } |
14 | |
15 | if (board.children[0].state != "" |