Skip to content
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

Open
wants to merge 25 commits into
base: dfp/master
Choose a base branch
from
Open

Conversation

dezshino
Copy link

  • 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

@kariabancroft kariabancroft self-assigned this Feb 8, 2016


// playing the game, what happens when you click each space
clickSpace: function() {

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)

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

@kariabancroft
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants