<commit_before>import React from 'react'
import Controls from './Controls'
import UserRangeInputs from './UserRangeInputs'
require('./styles.scss')


class App extends React.Component {
  constructor() {
    super()
    this.state = {
      guess: '',
      showGuess: null,
      hint: null,
      min: 1,
      max: 100,
      generatedNum: null,
      gameWon: false,
      showMinRange: null,
      showMaxRange: null,
    }

    this.handleChange = this.handleChange.bind(this)
    this.handleSubmit = this.handleSubmit.bind(this)
    this.handleClear = this.handleClear.bind(this)
    this.handleReset = this.handleReset.bind(this)
    this.handleMinRange = this.handleMinRange.bind(this)
    this.handleMaxRange = this.handleMaxRange.bind(this)
    this.handleRangeSubmit = this.handleRangeSubmit.bind(this)
  }
  componentDidMount() {
    let { min, max } = this.state
    this.setState({
      generatedNum: this.randomNum(),
      showMinRange: min,
      showMaxRange: max,
     })
  }

  randomNum() {
    return Math.floor(Math.random() * (this.state.max - this.state.min + 1)) + this.state.min
  }

  handleChange(e) {
    let guess = e.target.value

    if (Number.isNaN(+guess)) {
      alert('Sorry, that is not a number')
      guess = ''
    } else if (+guess >= 101 || +guess <= 0) {
      alert('Sorry, you are outside the range')
      guess = ''
    }
    this.setState({guess: guess})
  }

  handleSubmit() {
    const { guess, min, max } = this.state
    this.setState({showGuess: guess, guess: '', hint: this.highOrLow(), gameWon: true}, ()=> {
        if (this.state.hint === 'Winner winner, chicken dinner!') {
          this.setState({
            min: min - 10,
            max: max + 10,
          }, () => {
             this.setState({
               generatedNum: this.randomNum(),
             }, () => {
               this.setState({
                    showMinRange: this.state.min,
                    showMaxRange: this.state.max,
              })
            })
         })
       }
    })
  }

  handleClear() {
    this.setState({ guess: '' })
  }

  handleReset() {
    this.setState({ showGuess: '', guess: '', hint: '', generatedNum: this.randomNum(), gameWon: false})
  }

  handleMinRange(e) {
    let minRange = e.target.value
    this.setState({min: minRange})
  }

  handleMaxRange(e) {
    let maxRange = e.target.value
    this.setState({max: maxRange})
  }

  handleRangeSubmit(minMax) {
    let { min, max } = this.state
    this.setState({
      showMinRange: minMax.min,
      showMaxRange: minMax.max,
      gameWon: true,
      min: +minMax.min,
      max: +minMax.max,
    }, () => {
      this.setState({ generatedNum: this.randomNum() })
    })
  }

  renderGuess() {
    return this.state.showGuess
  }

  renderMinRange() {
    return this.state.showMinRange
  }

  renderMaxRange() {
    return this.state.showMaxRange
  }

  renderHint() {
    return this.state.hint
  }

  buttonDisabled() {
    return !this.state.guess
  }

  resetDisabled() {
    return !this.state.gameWon
  }

  highOrLow() {
    let { guess, generatedNum } = this.state
    if (guess > generatedNum)  {
      return 'Sorry, that guess is too high.  Try a lower number.'
    } else if ( guess < generatedNum) {
      return 'Sorry, that guess is too low.  Try a higher number'
    } else {
      return 'Winner winner, chicken dinner!'
    }
  }

  // win() {
  //   let { min, max } = this.state
  //   if (this.state.hint === 'Winner winner, chicken dinner!') {
  //     this.setState({
  //       min: +10,
  //       max: -10,
  //       gameWon: true,
  //     })
  //   }
  // }
  //
  //
  // win() {
  //   let {guess, generatedNum } = this.state
  //   if (guess === generatedNum) {
  //     this.setState({gameWon: true, min: -10, max: +10})
  //   }
  // }





  render() {
    return (
      <div>
          <h1>Number Guesser in React</h1>
          <h2>Your last guess was...</h2>
        <ul className='rendered-guess'>
          <li className='shown-guess'>{this.renderGuess()}</li>
          <li>{this.renderHint()}</li>
        </ul>
        <Controls
          buttonDisabled={this.buttonDisabled()}
          resetDisabled={this.resetDisabled()}
          highOrLow={this.highOrLow()}
          guess={this.state.guess}
          handleChange={this.handleChange}
          handleSubmit={this.handleSubmit}
          handleClear={this.handleClear}
          handleReset={this.handleReset}/>
        <UserRangeInputs
          handleMinRange={this.handleMinRange}
          handleMaxRange={this.handleMaxRange}
          handleRangeSubmit={this.handleRangeSubmit}/>
            <li className='range'>
              <span className='min'>Min:  {this.renderMinRange()}</span>
              <span>Max:  {this.renderMaxRange()}</span>
            </li><commit_msg>outsideRange functionality<commit_after>import React from 'react'
import Controls from './Controls'
import UserRangeInputs from './UserRangeInputs'
require('./styles.scss')


class App extends React.Component {
  constructor() {
    super()
    this.state = {
      guess: '',
      showGuess: null,
      hint: null,
      min: 1,
      max: 100,
      generatedNum: null,
      gameWon: false,
      showMinRange: null,
      showMaxRange: null,
    }

    this.handleChange = this.handleChange.bind(this)
    this.handleSubmit = this.handleSubmit.bind(this)
    this.handleClear = this.handleClear.bind(this)
    this.handleReset = this.handleReset.bind(this)
    this.handleMinRange = this.handleMinRange.bind(this)
    this.handleMaxRange = this.handleMaxRange.bind(this)
    this.handleRangeSubmit = this.handleRangeSubmit.bind(this)
  }
  componentDidMount() {
    let { min, max } = this.state
    this.setState({
      generatedNum: this.randomNum(),
      showMinRange: min,
      showMaxRange: max,
     })
  }

  randomNum() {
    return Math.floor(Math.random() * (this.state.max - this.state.min + 1)) + this.state.min
  }

  handleChange(e) {
    let guess = e.target.value
    if (Number.isNaN(+guess)) {
      alert('Sorry, that is not a number')
      guess = ''
    }
    this.setState({guess: +guess})
  }

  outsideRange() {
    let { guess } = this.state
    if (+guess > this.state.max || +guess < this.state.min) {
      alert('Sorry, you are outside the range')
      guess = ''
    }
  }

  handleSubmit() {
    this.outsideRange()
    const { guess, min, max } = this.state
    this.setState({
      showGuess: guess,
      guess: '',
      hint: this.highOrLow(),
      gameWon: true}, () => {
        if (this.state.hint === 'Winner winner, chicken dinner!') {
          this.setState({
            min: min - 10,
            max: max + 10,
          }, () => {
             this.setState({
               generatedNum: this.randomNum(),
             }, () => {
               this.setState({
                    showMinRange: this.state.min,
                    showMaxRange: this.state.max,
              })
            })
         })
       }
    })
  }

  handleClear() {
    this.setState({ guess: '' })
  }

  handleReset() {
    this.setState({ showGuess: '', guess: '', hint: '', generatedNum: this.randomNum(), gameWon: false})
  }

  handleMinRange(e) {
    let minRange = e.target.value
    this.setState({min: minRange})
  }

  handleMaxRange(e) {
    let maxRange = e.target.value
    this.setState({max: maxRange})
  }

  handleRangeSubmit(minMax) {
    let { min, max } = this.state
    this.setState({
      showMinRange: minMax.min,
      showMaxRange: minMax.max,
      gameWon: true,
      min: +minMax.min,
      max: +minMax.max,
    }, () => {
      this.setState({ generatedNum: this.randomNum() })
    })
  }

  renderGuess() {
    return this.state.showGuess
  }

  renderMinRange() {
    return this.state.showMinRange
  }

  renderMaxRange() {
    return this.state.showMaxRange
  }

  renderHint() {
    return this.state.hint
  }

  buttonDisabled() {
    return !this.state.guess
  }

  resetDisabled() {
    return !this.state.gameWon
  }

  highOrLow() {
    let { guess, generatedNum } = this.state
    if (guess > generatedNum)  {
      return 'Sorry, that guess is too high.  Try a lower number.'
    } else if ( guess < generatedNum) {
      return 'Sorry, that guess is too low.  Try a higher number'
    } else {
      return 'Winner winner, chicken dinner!'
    }
  }

  render() {
    return (
      <div>
          <h1>Number Guesser in React</h1>
          <h2>Your last guess was...</h2>
        <ul className='rendered-guess'>
          <li className='shown-guess'>{this.renderGuess()}</li>
          <li>{this.renderHint()}</li>
        </ul>
        <Controls
          buttonDisabled={this.buttonDisabled()}
          resetDisabled={this.resetDisabled()}
          highOrLow={this.highOrLow()}
          guess={this.state.guess}
          handleChange={this.handleChange}
          handleSubmit={this.handleSubmit}
          handleClear={this.handleClear}
          handleReset={this.handleReset}/>
        <UserRangeInputs
          handleMinRange={this.handleMinRange}
          handleMaxRange={this.handleMaxRange}
          handleRangeSubmit={this.handleRangeSubmit}/>
            <li className='range'>
              <span className='min'>Min:  {this.renderMinRange()}</span>
              <span>Max:  {this.renderMaxRange()}</span>
            </li>
{'fraction_non_alphanumeric': 0.1421542410953043, 'fraction_numerical': 0.004064605840196812, 'mean_word_length': 2.135479543930248, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 53, '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': '3972198', 'n_tokens_mistral': 2988, 'n_tokens_neox': 2957, 'n_words': 579}