Skip to content

Commit

Permalink
Merge pull request #21 from dazorni/show-previous-turn
Browse files Browse the repository at this point in the history
Show the previous turn to the user
  • Loading branch information
dazorni committed May 28, 2016
2 parents 0c9c492 + df3d717 commit 7ebe285
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 12 deletions.
5 changes: 5 additions & 0 deletions app/component/game-cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class GameCell extends React.Component {
playerClass = '-ptwo';
}

if (this.props.isLastTurn) {
playerClass = playerClass + ' game-cell-last-turn';
}

className = className + ' game-cell-marked game-cell-marked' + playerClass;
}

Expand All @@ -31,6 +35,7 @@ class GameCell extends React.Component {
}

GameCell.propTypes = {
isLastTurn: React.PropTypes.bool.isRequired,
position: React.PropTypes.any.isRequired,
onTurn: React.PropTypes.func.isRequired
}
Expand Down
1 change: 1 addition & 0 deletions app/component/game-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class GameField extends React.Component {
field={this.props.field}
onTurn={this.props.onTurn}
marked={cell.marked}
isLastTurn={cell.isLastTurn}
isStartingPlayer={cell.isStartingPlayer} />
});
}
Expand Down
15 changes: 12 additions & 3 deletions app/component/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Game extends React.Component {
const cells = [];

for (let inc = 0; inc <= 8; inc++) {
cells.push({position: this._getPosition(field, inc), marked: false, isStartingPlayer: false});
cells.push({position: this._getPosition(field, inc), marked: false, isStartingPlayer: false, isLastTurn: false});
}

fields.push({ position: field, won: false, player: null, cells: cells, next: false})
Expand Down Expand Up @@ -200,11 +200,20 @@ class Game extends React.Component {
const fields = this.state.fields;

fields.map(field => {
field.cells.map(cell => {
cell.isLastTurn = false;

return cell;
});

if (field.position == turn.Field) {
field.cells.map(cell => {
cell.isLastTurn = false;

if (cell.position == turn.Position) {
cell.marked = true
cell.isStartingPlayer = this.state.startingPlayer == username
cell.marked = true;
cell.isStartingPlayer = this.state.startingPlayer == username;
cell.isLastTurn = true;
}

return cell
Expand Down
5 changes: 5 additions & 0 deletions app/style/elements/_game.scss
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,10 @@
}
}
}

&.game-cell-last-turn {
z-index: 1;
transform: scale(1.1, 1.1);
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"build:css:watch": "./node_modules/.bin/onchange app/style/**/* -- npm run build:css",
"build:js": "./node_modules/.bin/webpack -d",
"build:js:watch": "./node_modules/.bin/webpack -d --watch",
"build:js:prod": "./node_modules/.bin/webpack -p",
"build:js:prod": "./node_modules/.bin/webpack --progress -p",
"build:fonts": "mkdir build/public/fonts && cp -R node_modules/font-awesome/fonts/* build/public/fonts",
"build:views": "cp app/views/* build/public",
"build:views:watch": "./node_modules/.bin/onchange app/views/**/* -- npm run build:views",
Expand Down
11 changes: 3 additions & 8 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,16 @@ var config = {
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.EnvironmentPlugin(["NODE_ENV"]),
new webpack.EnvironmentPlugin(["NODE_ENV"]),
],
module : {
loaders : [
{
test : /.+.js$/,
include : APP_DIR,
loader : 'babel'
},
{
test: /bootstrap\/js\//,
loader: 'imports?jQuery=jquery'
}
],

}
],
preLoaders: [
{
test: /\.js?$/,
Expand Down

0 comments on commit 7ebe285

Please sign in to comment.