Giter Club home page Giter Club logo

tic-tac-toe's Introduction

tic-tac-toe

Turing Mod1 Final Solo Project

Abstract:

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

Installation Instructions:

To clone the repo and run it locally on your own machine:

  1. Navigate to the repo in your browser: https://github.com/ericahagle/tic-tac-toe
  2. Clone the repo to the desired location on your machine
  3. cd into the new tic-tac-toe directory
  4. Type open index.html in your terminal and hit enter to launch the app in your default browser
  5. Have fun!

Preview of App:

tic-tac-toe-final.mov

Context:

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.

Contributors:

Erica Hagle

Learning Goals:

  • 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 + Challenges:

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.

Additional Notes:

  • 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.

tic-tac-toe's People

Contributors

ericahagle avatar

Stargazers

 avatar

Watchers

NikSeif avatar  avatar

tic-tac-toe's Issues

Add README

Add README to repo.
Include boilerplate and fill out items that make sense for the beginning of the project (contributors, timeline, etc).

Extension: Tic Tac Rainbow

Add a button to the bottom of the game board.

  • This button should allow the user to switch between aesthetic views (Tic-Tac-Toe and Tic-Tac-Rainbow).
  • The game should function exactly as usual, just with different colors and tokens.
  • The button should be disabled during matches, so the user can't change views again until the board resets.

Tic-Tac-Toe: yellow/red sidebars with ❌ and ⭕️ tokens
Tic-Tac-Rainbow: rainbow sidebars with 🦄 and 🌈 tokens

Create Players

As a user, I want to exist as a player in the game.

Create a function that creates the objects that store each players’ informations - properties should include: id (ex: 'one'), token (ex: '⭐️'), wins (ex: 0)

This should also add the players to the game.

Extension: Tic Tac Whoa

Maybeeeeeeee update the game to be called "Tic Tac Whoa" and style it to use as tokens pictures of Keanu Reeves as Ted Theodore Logan (in place of the X) and Neo (in place of the O). Because I'm a dork and that sounds funny to me. 😂

Extension: Tic-Tac-Snow

Adds another aesthetic change to the button for a Winter (Snowman vs The Sun) themed game.

Uses ⛄️ and 🌞 tokens, and lightblue/white/blue gradient sidebars.

Image

Detect Wins

As a user, I want to see when my match results in a win.

  • A player can win by connecting 3 horizontally, vertically, or diagonally.
  • The top banner changes to declare the winner

Note: Requires creation of a function that checks the game board data for win conditions

Image

Players' Moves

As a user, I want to see my icon appear on the board where I click to place it.

  • User can only place their token in an empty square
  • Attempting to place their token on a square that’s already occupied will not work, and it remains their turn

Image

Refactor/Cleanup

Look through codebase and refactor for:

  • anything that can be DRYed up or refactored for efficiency
  • any remaining console logs or unnecessary comments
  • any formatting errors

Extension: Tic-Tac-HoHoHo

Adds another aesthetic change to the button for a Christmas (Santa vs Krampus) themed game.

Uses 🎅🏼 and 👹 tokens, and green/white/red gradient sidebars.

Image

Players' Turns

As a user, I want to see when it is my turn.

The top displays which player’s turn it is

  • Once a user places their token, it becomes the other player’s turn
  • The banner updates to show that it is the other player's turn

Note: Requires creation of a function that keeps track of which player’s turn it currently is

Image
Image

Basic Layout

As a user, I want to see a tic tac toe game.

Plan out the HTML layout (colors and icons do not need to match, but overall layout should closely match the demo video / screenshot). Should include:

  • main center container
    • player's turn placeholder
    • game board grid container
      • game board
  • left and right sidebars
    • player 1 container
      • icon placeholder
      • wins placeholder
    • player 2 container
      • icon placeholder
      • wins placeholder

Image

Reset Game Board for New Game

As a user, I want to see the game board reset for a new match after a match is completed.

Automatically reset the game board to allow for a new game to be played after the previous game ends

  • The game restarts after a brief pause, (long enough that the draw/win message can be read before resetting)
  • The player who didn’t begin the previous game now is the first player to go in the new game

Notes:

  • Requires creation of a function that resets the game board’s data to begin a new game
  • A timeout is used after a completed game to reset the board.

Image

Update Wins

As a user, I want to see my overall wins total update when I win a match.

Will need to create functionality to update the scores after detecting a win (or not, if draw).

  • The DOM updates to display how many wins the player has in total

Note: Requires creation of a function called increaseWins - increases the count of a player’s wins (should work for either player)

Image
Image

BUG: Token not updating after matches

Steps to repro:

  1. Win a match
  2. Wait 5 seconds for board to reset
  3. Place a token

Expected:
The token placed should correspond with the player's turn, as specified in the "It's ___'s turn" banner.

Actual:
The token placed does not correspond with the player's turn, as specified in the "It's ___'s turn" banner.

Add Tickets for User Stories

Read through spec and add user story tickets for each feature to add to the application.
These tickets should be split up into manageable chunks.

Note: There is ALWAYS the option to split the tickets further later, if one turns out to be too big.

Detect Draws

As a user, I want to see if my match resulted in a draw.

  • A draw can occur, in which case:
    • The top banner declares a draw
    • Neither player’s win count increases or decreases

Note: Requires creation of a function that detects when a game is a draw (no one has won)

Image

Setup Project

Setup github project for the repo.
Add board, labels, milestones, etc.

Final CSS Styling

As a user, I want to see a beautifully styled tic tac toe game.

  • Refactor CSS styling to make the game more more visually appealing
  • Should resemble the comps, but can have additional personalized styling

Image
Image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.