<commit_before>import { cloneDeep, sample } from 'lodash';
import SuperBoard from './SuperBoard.js';
import { emptySuperBoard, O, X } from './constants.js';
import { superWinner, winner } from './matrix_functions.js';
import React from 'react/addons';
import { RouteHandler } from 'react-router';

function getFocused(superBoard, lastMove) {
  if (
    !lastMove ||
    winner(superBoard[lastMove.rowIndex][lastMove.columnIndex])
  ) {
    return null;
  }
  return {
    superRowIndex: lastMove.rowIndex,
    superColumnIndex: lastMove.columnIndex,
  };
}

export default React.createClass({
  getInitialState() {
    return {
      activePlayer: sample([X, O]),
      game: emptySuperBoard(),
      lastMove: null,
    };
  },

  handleMove(superRowIndex, superColumnIndex, rowIndex, columnIndex) {
    this.state.game[superRowIndex][superColumnIndex][rowIndex][columnIndex] = this.state.activePlayer;
    this.setState({
      activePlayer: this.state.activePlayer === X ? O : X,
      game: this.state.game,
      lastMove: {superRowIndex, superColumnIndex, rowIndex, columnIndex},
    });
  },

  render() {
    if (superWinner(this.state.game)) {
      return (
        <h1>
          OMG
          {' '}
          <strong>{this.state.activePlayer === X ? O : X}</strong>
          {' '}
          WINS!
        </h1>
      );
    }
    return (
      <div>
        <p>Active player: {this.state.activePlayer}</p>
        <SuperBoard
          focused={getFocused(this.state.game, this.state.lastMove)}
          onMove={this.handleMove}
          superBoard={this.state.game}
        />
      </div>
    );
  },
});

<commit_msg>adding in firebase<commit_after>import { cloneDeep, sample } from 'lodash';
import SuperBoard from './SuperBoard.js';
import { emptySuperBoard, O, X } from './constants.js';
import { superWinner, winner } from './matrix_functions.js';
import React from 'react/addons';
import { RouteHandler } from 'react-router';

function getFocused(superBoard, lastMove) {
  if (
    !lastMove ||
    winner(superBoard[lastMove.rowIndex][lastMove.columnIndex])
  ) {
    return null;
  }
  return {
    superRowIndex: lastMove.rowIndex,
    superColumnIndex: lastMove.columnIndex,
  };
}

export default React.createClass({
  mixins: [ReactFireMixin],

  getInitialState() {
    return {
      activePlayer: sample([X, O]),
      game: emptySuperBoard(),
      lastMove: null,
    };
  },

  componentWillMount: function() {
    this.bindAsObject(new Firebase('https://sttt.firebaseio.com/game'), 'fireGame');
  },

  componentWillMount: function() {
    this.unbind('fireGame');
  },

  handleMove(superRowIndex, superColumnIndex, rowIndex, columnIndex) {
    this.state.game[superRowIndex][superColumnIndex][rowIndex][columnIndex] = this.state.activePlayer;
    this.setState({
      activePlayer: this.state.activePlayer === X ? O : X,
      game: this.state.game,
      lastMove: {superRowIndex, superColumnIndex, rowIndex, columnIndex},
    });
  },

  render() {
    if (superWinner(this.state.game)) {
      return (
        <h1>
          OMG
          {' '}
          <strong>{this.state.activePlayer === X ? O : X}</strong>
          {' '}
          WINS!
        </h1>
      );
    }
    return (
      <div>
        <p>Active player: {this.state.fireGame.activePlayer}</p>
        <SuperBoard
          focused={getFocused(this.state.game, this.state.lastMove)}
          onMove={this.handleMove}
          superBoard={this.state.game}
        />
      </div>
    );
  },
});


{'fraction_non_alphanumeric': 0.144118484762176, 'fraction_numerical': 0.0011392765593847907, 'mean_word_length': 2.744136460554371, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5542640', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1106, 'n_words': 202}