pay (supply) {
    var newSupply = this.collectedSupply + supply
    var startPrice = this.priceAt(this.collectedSupply)
    var endPrice = this.priceAt(newSupply)

    var year = this.collectedSupply < this.yearDemand && 
          newSupply > this.yearDemand
    var whole = this.collectedSupply < this.wholeDemand && 
          newSupply > this.wholeDemand
    if (year || whole) {
      var overSupply = (newSupply - this.yearDemand)
      if (newSupply > this.wholeDemand) {
        overSupply = (newSupply - this.wholeDemand)
      }
      var underSupply = supply - overSupply
      var underSupplyPrice = this.priceAt(underSupply + this.collectedSupply)
      return this.priceBetween(startPrice, underSupplyPrice, underSupply) +
        this.priceBetween(underSupplyPrice, endPrice, overSupply)
    }

    return this.priceBetween(startPrice, endPrice, supply)
  }
/**
   * Calculates the amount of money player will get from the given supply. Is based on
   * how much player supplies and how much they have supplied.
   * @param {*} supply amount supplied this week
   */
Calculates the amount of money player will get from the given supply. Is based on
how much player supplies and how much they have supplied.
@param {*} supply amount supplied this week
Calculates the amount of money player will get from the given supply . Is based on how much player supplies and how much they have supplied . @param { * } supply amount supplied this week
pay (supply) {
    var newSupply = this.collectedSupply + supply
    var startPrice = this.priceAt(this.collectedSupply)
    var endPrice = this.priceAt(newSupply)
    var year = this.collectedSupply < this.yearDemand && 
          newSupply > this.yearDemand
    var whole = this.collectedSupply < this.wholeDemand && 
          newSupply > this.wholeDemand
    if (year || whole) {
      var overSupply = (newSupply - this.yearDemand)
      if (newSupply > this.wholeDemand) {
        overSupply = (newSupply - this.wholeDemand)
      }
      var underSupply = supply - overSupply
      var underSupplyPrice = this.priceAt(underSupply + this.collectedSupply)
      return this.priceBetween(startPrice, underSupplyPrice, underSupply) +
        this.priceBetween(underSupplyPrice, endPrice, overSupply)
    }
    return this.priceBetween(startPrice, endPrice, supply)
  }
pay ( supply ) { var newSupply = this . collectedSupply + supply var startPrice = this . priceAt ( this . collectedSupply ) var endPrice = this . priceAt ( newSupply ) var year = this . collectedSupply < this . yearDemand && newSupply > this . yearDemand var whole = this . collectedSupply < this . wholeDemand && newSupply > this . wholeDemand if ( year || whole ) { var overSupply = ( newSupply - this . yearDemand ) if ( newSupply > this . wholeDemand ) { overSupply = ( newSupply - this . wholeDemand ) } var underSupply = supply - overSupply var underSupplyPrice = this . priceAt ( underSupply + this . collectedSupply ) return this . priceBetween ( startPrice , underSupplyPrice , underSupply ) + this . priceBetween ( underSupplyPrice , endPrice , overSupply ) } return this . priceBetween ( startPrice , endPrice , supply ) }
Calculates the amount of money player will get from the given supply.
Calculates the amount of money player will get from the given supply .