-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tic Tac Toe Pull Request #9
base: dfp/master
Are you sure you want to change the base?
Conversation
dezshino
commented
Jan 30, 2016
- Created a Tic Tac Toe game
- If a player claims 2 spots in a row, they win. If the board fills with no wins, its a tie. Alert messages display the status at the end of the game.
- Board automatically clears at the end of each game
- In the future, I would like to add the single player mode versus computer, a score board to keep track of wins for each player, and change the standard alerts to custom-styled messages
|
||
|
||
// playing the game, what happens when you click each space | ||
clickSpace: function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this method is setting up the click handlers, not actually doing the clicking itself. I might recommend re-naming it to clarify this distinction.
var winConditions = this.winConditions; | ||
var board = $(".square"); // == [r1c1,r1c2,r1c3,....] | ||
for (var i = 0; i < winConditions.length; i++){ | ||
if((board[winConditions[i][0]].innerText == board[winConditions[i][1]].innerText) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is where an array that stored the board as you take turns would come in handy. I think you've successfully used just the UI/jQuery elements up until this point, but this conditional would be a lot more simple given an array which stores each players moves
Nice job on this. I think you got away without using an array to store the board data but it could have simplified some of your logic. I like the way you used different methods for each purpose and the winning conditions that were pre-defined. |