Turing Mod1 Final Solo Project
What we have here is a simple Tic Tac Toe game:
- Each player in the game is controlled manually by the user
- The top banner displays which player’s turn it is
- Each player can only place their token in an empty square
- If a player attempts to place their token on a square that’s already occupied, it will not work
- It remains that player's turn
- Once a player places their token, it becomes the other player’s turn
- The banner updates to communicate this
- If a player wins (by connecting 3 horizontally, vertically, or diagonally)
- The top banner changes to declare the winner
- The declared winner's total wins updates
- If a draw occurs (all squares are filled, but no win was detected)
- The top banner changes to declare a draw
- Neither player’s win count increases nor decreases
- If either a win or draw occurs
- The game restarts automatically after 3 seconds
- The player who didn’t begin the previous match now is the first player to go in the new match
To clone the repo and run it locally on your own machine:
- Navigate to the repo in your browser: https://github.com/ericahagle/tic-tac-toe
- Clone the repo to the desired location on your machine
cd
into the newtic-tac-toe
directory- Type
open index.html
in your terminal and hit enter to launch the app in your default browser - Have fun!
tic-tac-toe-final.mov
Kickoff Date: Tuesday, September 18, 2023, 11am MT
Due Date: Tuesday, September 26, 2023, 6pm MT
As of Tuesday, September 26, 2023, and the end of this project, I will be in the middle of the sixth (and final) week of FE Mod 1 at Turing School of Software & Design.
- Solidify and demonstrate your understanding of:
- DRY JavaScript
- event delegation to handle similar event listeners
- Understand the difference between the data model and how the data is displayed on the DOM
- Iterate through/filter DOM elements using for loops
- Use your problem solving process to break down large problems, solve things step by step, and trust yourself to not rely on an outside “answer” to a logical challenge
Wins:
- I got it working and looking halfway decent! Honestly, that was a big win to me. It's nothing too fancy, but I think it looks pretty good and functions as expected.
- I was able to implement some refactoring on my own, and then a little more after discussing with Nik what could possibly still be updated. I may not have gotten it perfect, but I was able to get it at least a little cleaner, DRYer, and more pure than it was!
Challenges:
- Honestly? Refactoring. Sheesh. That's probably the hardest part for me. I think it will get easier with time and practice, but right now, it's hard to move past the way I thought of something the first time.
- I struggled a bit with splitting the data model updates and DOM updates. This is another area where I think I could refactor this in the future to be a better app. But right now, I just can't seem to find a better solution than what I already have. I think, if I have time, I might try to redo this during intermission and see if I can do better the second time.
- A GitHub Project was created to manage the flow of this project.
- As a bonus, I've added a button at the bottom of the screen that allows a user to switch between Tic-Tac-Toe (a yellow/red color scheme with ❌ and ⭕️ tokens) and Tic-Tac-Rainbow (a rainbow color scheme with 🦄 and 🌈 tokens).
- The page title is also updated to reflect the change
- Users cannot switch views during a match; once a token is placed, the button is disabled until the board resets
- The function being used to accomplish this is pretty meaty. It could almost certainly be refactored, but for now, I'm just happy that it works!
- As a bonus to the bonus, I've added another aesthetic option called Tic-Tac-HoHoHo (green/white/red color scheme with 🎅🏼 and 👹 tokens).
- The same button cycles through the three options.
- As a bonus to the bonus... bonus, I've added one more aesthetic option (I promise, this is the last one... until I think up more puns) called Tic-Tac-Snow (lightblue/white/blue color scheme with ⛄️ and 🌞 tokens).
- Again, the same button is used to cycle through all 4 options.