This repository contains a completed implementation of the classic Tic-Tac-Toe game using HTML, CSS, and JavaScript. The game logic is organized using factory functions and follows a modular structure.
The project is organized into three main components:
-
Gameboard:
- The gameboard is stored as an Object inside the
Gameboard
module. - The
Gameboard
factory provides methods to access and manipulate the gameboard.
- The gameboard is stored as an Object inside the
-
Player:
- Players are represented by objects created using the
Player
factory function. - Each player has a name and a token ('X' or 'O').
- Players are represented by objects created using the
-
ScreenController:
- The
ScreenController
handles the flow of the game in the script file. - It includes functions to check for winners, ties, and to switch between players.
- The
-
Display/DOM Logic:
- The gameboard array is rendered to the webpage.
- Players can interact with the DOM elements to place marks.
-
Player Interaction:
- Players can add marks by clicking on the board squares.
- Logic prevents players from playing in occupied spots.
-
Interface Cleanup:
- Players can input their names.
- A button allows starting/restarting the game.
- Results are displayed upon game end.
This project was completed as part of the Odin Project.