<commit_before>import $ from 'jquery';

const Row = {

  rows: {},

  pieces(rowId, color, columnId) {
    if (!this.rows[rowId]) {
      this.rows[rowId] = [];
      this.rows[rowId].push(color, columnId);
    } else {
      this.rows[rowId].push(color, columnId);
    }
    console.log(this.rows);
  }
}

export default Row;<commit_msg>finished up the last bits of winning by row<commit_after>import $ from 'jquery';

const Row = {

  rows: {},

  pieces(rowId, color, columnId) {
    if (!this.rows[rowId]) {
      this.rows[rowId] = [];
      this.rows[rowId].push([color, columnId]);
    } else {
      this.rows[rowId].push([color, columnId]);
    }
    this.checkRows();
  },

  checkRows() {
    let potentialWinners = [];
    for(let row in this.rows) {
      if (this.rows[row].length >= 4) {
        potentialWinners.push(this.rows[row]);
        this.checkForWin(potentialWinners);
      }
    }
  },

  checkForWin(rowSpecs) {
    let matches = [];
    let rows = rowSpecs[0];
    for(let i = 0; i < rows.length; i++) {
      if (rows[i + 1] && rows[i][0] === rows[i + 1][0]) {
        if (parseInt(rows[i][1]) + 1 == rows[i + 1][1]) {
           matches.push(rows[i][0]);
        }
      }
    }
    if (matches.length >= 3) {
      let winner = matches[0].toUpperCase();
      alert(`${winner} has won the game!`);
      location.reload();
    }
  }

}

export default Row;
{'fraction_non_alphanumeric': 0.1829971181556196, 'fraction_numerical': 0.010086455331412104, 'mean_word_length': 2.455223880597015, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, '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': '4059996', 'n_tokens_mistral': 509, 'n_tokens_neox': 495, 'n_words': 97}