diff --git a/README.md b/README.md index 71469e3..2d61236 100755 --- a/README.md +++ b/README.md @@ -1 +1,20 @@ -TicTacToe with Flask, Reactjs, Flux, and Redis \ No newline at end of file +# TicTacToe with Flask, Reactjs, Flux, and Redis + +A simple tic tac toe game built with Flask, with Flux and Reactjs on the frontend, and Redis to maintain the state of the game. + +## Setting it up on your Environment: + +1. Clone the repo, +2. Make sure you have Flask installed +3. In the root directory, run `pip install -r requirements.txt` +4. In the root directory, run `npm install` +5. In the root directory, run `bower install` +6. Start the app by running start.sh: `sh start.sh` + +## Some questions perhaps? + +### Why not just have everything on the client side without Flask or Redis? +A: The server determines the next move for the AI and also maintains the state of the game. This ensures that the player can't cheat their way to a win by modifying anything on the front end. + +### Why Flux? +A: Because it's a nice way to maintain the flow of dynamic data throughout the game. \ No newline at end of file diff --git a/tictactoe/static/scripts/jsx/components/TicTacToe.js b/tictactoe/static/scripts/jsx/components/TicTacToe.js index b7e9984..f744538 100644 --- a/tictactoe/static/scripts/jsx/components/TicTacToe.js +++ b/tictactoe/static/scripts/jsx/components/TicTacToe.js @@ -26,6 +26,7 @@ var TicTacToe = React.createClass({ }, tileClick: function(position, player) { + // Make sure that this only occurs on tiles that aren't occupied, and the game is still in a valid state if (!TicTacToeStore.isOccupied(position) && !TicTacToeStore.getWinner() && TicTacToeStore.getPlayer() == 'x') { TicTacToeActions.playPosition(position); // play position this.setState({tiles: TicTacToeStore.getBoard(), currentPlayer: TicTacToeStore.getPlayer()}); diff --git a/tictactoe/static/scripts/jsx/stores/TicTacToeStore.js b/tictactoe/static/scripts/jsx/stores/TicTacToeStore.js index 254a341..47d2e66 100644 --- a/tictactoe/static/scripts/jsx/stores/TicTacToeStore.js +++ b/tictactoe/static/scripts/jsx/stores/TicTacToeStore.js @@ -1,6 +1,5 @@ var AppDispatcher = require('../dispatcher/AppDispatcher'); var AppConstants = require('../constants/AppConstants') -var TicTacToeApi = require('../utils/TicTacToeApi'); var EventEmitter = require('events').EventEmitter; var assign = require('object-assign'); diff --git a/tictactoe/static/scripts/jsx/utils/TicTacToeApi.js b/tictactoe/static/scripts/jsx/utils/TicTacToeApi.js deleted file mode 100644 index f7765e5..0000000 --- a/tictactoe/static/scripts/jsx/utils/TicTacToeApi.js +++ /dev/null @@ -1,6 +0,0 @@ -var request = require('superagent'); - -var TicTacToeApi = { - -} -module.exports = TicTacToeApi; \ No newline at end of file