Business logic of a Tic Tac Toe game.
npm install tic-tac-toe-engineThis is a package that is meant to expose a Redux Store and a set of Actions that together facilitate the business logic of a Tic Tac Toe app.
This package was written using the SAM pattern to facilitate unidirectional data flow(a.k.a the reactive loop of an application).
npm install --save tic-tac-toe-engine
`Usage
`
//ES6
import createEngine from 'tic-tac-toe-engine';
//CommonJS
const createEngine = require('tic-tac-toe-engine');const api = createEngine("");//Can optionally pass a Redux Enhancer as the second argument which will be used when creating the Redux Store
const { store, actions } = api;
``|Ignore|Reducer|Default Value|Summary|
|:---|:---|:---|:---|
| |grid|{ cells: [], cellSets: [], sets: [], finished: false, winner: false, movesTaken: 0, initialized: false, size: 3}|Represents all aspects of a Tic Tac Toe gameboard(a.k.a grid). You need not concern yourself with 'cellSets' and 'sets', since these arrays are for computing if there is a winner or not. 'cells' and 'size' will be the most important for rendering the GUI. 'cells' is simply an array of strings which are either 'X', 'O', or '' which indicate if a player has marked the cell in the grid. 'size' indicates how big the square grid is(i.e. 3 means 3x3 which is 9 cells).|
| |gameType|""(i.e. empty string)|Should be either '', 'Local Game', 'Host Game', 'Join Game'. Represents what Game Type was selected for the Tic Tac Toe game.|
| |gameStatus|"Please select a game mode!"|A string that indicates what the player should do next or the current status of the game.|
| |player|""(i.e. empty string)|A string for the 'Host Game' or 'Join Game' game types that indicates whether the player is 'X' or 'O'.|
| |session|""(i.e. empty string)|A string for an online cross browser game that indicates what game session the player is in.|
| |showJoinSessionForm|false|A boolean for an online cross browser game that indicates if the JoinSessionForm should be displayed.|
|✅|submittedSession|""(i.e. empty string)|A string representing a submitted session.|
|✅|move|-1|An integer representing a cell in the grid that was clicked.|
|✅|turn|""(i.e. empty string)|A string indicating which player's turn it is.|
|✅|turnSwitch|false|A boolean indicating that the turn should be switched.|
|✅|quit|false|A boolean indicating that the current game type should be exited.|
|✅|restart|false|A boolean indicating that the current game type should be restarted.|
| |done|false|A boolean indicating that the current game is finished. Useful for determining when to show the calls to action for quiting or restarting the game.|
- markGridAction(cellIndex): Expects cellIndex to be an integer between 0 and the length of the grid.cells array. See 'grid' property mentioned above for the 'store'.
- setGameTypeAction(gameType): Expects a string to be 'Local Game', 'Host Game', 'Join Game'. See 'gameType' property mentioned above for the 'store'.
- initiateQuitAction():
- initiateRestartAction():
- submitSessionAction(session): Expects a string that correponds to that of a another user who is hosting a Game.
- intent-types.js : exports object exposing strings that describe the different intent types
- intents.js : exports an object exposing all the intent functions that can be be used to present object consisting of a type and a payload to the model
- reducer-defaults.js: exports an object exposing the default values for the reducers(a.k.a Model properties)
- reducer-factory.js: exports createAssignmentReducers which given a set of reducer configs will return an object of reducers
- reducers.js: exports an object exposing the "combined" reducers that should be used to create a Redux Store