<commit_before>import React, { PropTypes } from 'react';
import classnames           from 'classnames';
import { selectShip }       from '../../actions/game';

const shipConfigurations = [
  { name: 'Aircraft carrier', size: 5 },
  { name: 'Battleship', size: 4 },
  { name: 'Cruiser', size: 3 },
  { name: 'Destroyer', size: 2 },
  { name: 'Submarine', size: 1 },
];

export default class ShipSelector extends React.Component {
  _renderAvailableShips() {
    const { dispatch, selectedShip, game } = this.props;

    const ships = shipConfigurations.map((ship, i) => {
      const handleClick = (e) => {
        e.preventDefault();

        if (game.my_board.ready) return false;

        dispatch(selectShip(ship));
      };

      const classes = classnames({
        active: ship.name == selectedShip.name,
      });

      const orientation = ship.name == selectedShip.name ? selectedShip.orientation : '';

      return (
        <li
          className={classes}
          key={i}
          onClick={handleClick}>{ship.name} {orientation}</li>
      );
    });

    return (
      <ul>{ships}</ul>
    );
  }

  render() {
    return (<commit_msg>Take available ships from the game board<commit_after>import React, { PropTypes } from 'react';
import classnames           from 'classnames';
import { selectShip }       from '../../actions/game';

const shipConfigurations = [
  { name: 'Aircraft carrier', size: 5 },
  { name: 'Battleship', size: 4 },
  { name: 'Cruiser', size: 3 },
  { name: 'Destroyer', size: 2 },
  { name: 'Submarine', size: 1 },
];

export default class ShipSelector extends React.Component {
  _renderAvailableShips() {
    const { dispatch, selectedShip, game } = this.props;

    const ships = game.my_board.ships.map((ship, i) => {
      const config = shipConfigurations.find((item) => item.size === ship.size);

      const handleClick = (e) => {
        e.preventDefault();

        if (game.my_board.ready) return false;

        dispatch(selectShip(config));
      };

      const classes = classnames({
        active: config.name == selectedShip.name,
      });

      const orientation = config.name == selectedShip.name ? selectedShip.orientation : '';

      return (
        <li
          className={classes}
          key={i}
          onClick={handleClick}>{config.name} {orientation}</li>
      );
    });

    return (
      <ul>{ships}</ul>
    );
  }

  render() {
    return (
{'fraction_non_alphanumeric': 0.14991762767710048, 'fraction_numerical': 0.004118616144975288, 'mean_word_length': 2.525399129172714, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 16, 'https://': 0, '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': '7651614', 'n_tokens_mistral': 732, 'n_tokens_neox': 719, 'n_words': 175}