<commit_before>import React, { Component } from 'react';
import { Col, Row, Modal, Button} from 'react-bootstrap';
import {connect} from 'react-redux'
import {updateDiceNum, calculateMoney} from '../firebaseFunctions'

class ChooseDiceNumModal extends Component {
  constructor(){
    super()
    this.rollDice = this.rollDice.bind(this)
    this.handleButtonClick = this.handleButtonClick.bind(this)
  }

  //function that will generate a new dice value
  rollDice (diceNum){
    let newDiceNum;
    if (diceNum === 1) {
      newDiceNum = Math.ceil(Math.random() * (6));
    }
    if (diceNum === 2){
      newDiceNum = Math.ceil(Math.random() * (12));
    }
    return newDiceNum;
  }

  handleButtonClick(num){
    let turn = this.props.game.turn
    let players = this.props.game.players
    let user = this.props.user.name
    const playersObj = Object.keys(players)

    let currentPlayer;
    playersObj.forEach(player => {
      if (players[player].name === user) {
        currentPlayer = player
      }
    })

    this.props.closeModal()
    let diceVal = this.rollDice(num)
    updateDiceNum(diceVal)
    .then(()=>calculateMoney(currentPlayer, this.props.game))
    .catch(console.error)
  }

  render() {
    return (
      <div id="dice-modal" style={{height: 200}}>
        <Modal
          show={true}
          container={this}
          aria-labelledby="contained-modal-title"
        >
          <Modal.Header>
            <Modal.Title id="contained-modal-title">Would you like to roll 1 die or 2 dice?</Modal.Title>
          </Modal.Header>
          <Modal.Body>
             <Button onClick={() => {
                this.handleButtonClick(1)
              }}>1</Button>
              <Button onClick={() => {<commit_msg>fixedRollTwoDice<commit_after>import React, { Component } from 'react';
import { Col, Row, Modal, Button} from 'react-bootstrap';
import {connect} from 'react-redux'
import {updateDiceNum, calculateMoney} from '../firebaseFunctions'

class ChooseDiceNumModal extends Component {
  constructor(){
    super()
    this.rollDice = this.rollDice.bind(this)
    this.handleButtonClick = this.handleButtonClick.bind(this)
  }

  //function that will generate a new dice value
  rollDice (diceNum){
    let newDiceNum;
    if (diceNum === 1) {
      newDiceNum = Math.ceil(Math.random() * (6));
    }
    if (diceNum === 2){
      newDiceNum = Math.ceil(Math.random() * (12));
    }
    return newDiceNum;
  }

  handleButtonClick(num){
    let turn = this.props.game.turn
    let players = this.props.game.players
    let user = this.props.user.name
    const playersObj = Object.keys(players)

    let currentPlayer;
    playersObj.forEach(player => {
      if (players[player].name === user) {
        currentPlayer = player
      }
    })

    this.props.closeModal()
    let diceVal = this.rollDice(num)
    updateDiceNum(diceVal)
  }

  render() {
    return (
      <div id="dice-modal" style={{height: 200}}>
        <Modal
          show={true}
          container={this}
          aria-labelledby="contained-modal-title"
        >
          <Modal.Header>
            <Modal.Title id="contained-modal-title">Would you like to roll 1 die or 2 dice?</Modal.Title>
          </Modal.Header>
          <Modal.Body>
             <Button onClick={() => {
                this.handleButtonClick(1)
              }}>1</Button>
              <Button onClick={() => {
{'fraction_non_alphanumeric': 0.13450807635829662, 'fraction_numerical': 0.007048458149779736, 'mean_word_length': 2.4790602655771194, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 28, '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': '6014667', 'n_tokens_mistral': 1088, 'n_tokens_neox': 1058, 'n_words': 229}