original_string: public function getAttackNumberModifierByDistance(
          Distance $targetDistance,
          EncounterRange $currentEncounterRange,
          MaximalRange $currentMaximalRange
      ): int
      {
          if ($targetDistance->getBonus()->getValue() > $currentMaximalRange->getValue()) { // comparing distance bonuses in fact
              throw new DistanceIsOutOfMaximalRange(
                  "Given distance {$targetDistance->getBonus()} ({$targetDistance->getMeters()} meters)"
                  . " is out of maximal range {$currentMaximalRange}"
                  . ' (' . $currentMaximalRange->getInMeters($this->tables) . ' meters)'
              );
          }
          if ($currentEncounterRange->getValue() > $currentMaximalRange->getValue()) {
              throw new EncounterRangeCanNotBeGreaterThanMaximalRange(
                  "Got encounter range {$currentEncounterRange} greater than given maximal range {$currentMaximalRange}"
              );
          }
          $attackNumberModifier = $this->tables->getAttackNumberByContinuousDistanceTable()
              ->getAttackNumberModifierByDistance($targetDistance);
          if ($targetDistance->getBonus()->getValue() > $currentEncounterRange->getValue()) { // comparing distance bonuses in fact
              $attackNumberModifier += $currentEncounterRange->getValue() - $targetDistance->getBonus()->getValue(); // always negative
          }
  
          return $attackNumberModifier;
      }
code: public function getAttackNumberModifierByDistance(
          Distance $targetDistance,
          EncounterRange $currentEncounterRange,
          MaximalRange $currentMaximalRange
      ): int
      {
          if ($targetDistance->getBonus()->getValue() > $currentMaximalRange->getValue()) { // comparing distance bonuses in fact
              throw new DistanceIsOutOfMaximalRange(
                  "Given distance {$targetDistance->getBonus()} ({$targetDistance->getMeters()} meters)"
                  . " is out of maximal range {$currentMaximalRange}"
                  . ' (' . $currentMaximalRange->getInMeters($this->tables) . ' meters)'
              );
          }
          if ($currentEncounterRange->getValue() > $currentMaximalRange->getValue()) {
              throw new EncounterRangeCanNotBeGreaterThanMaximalRange(
                  "Got encounter range {$currentEncounterRange} greater than given maximal range {$currentMaximalRange}"
              );
          }
          $attackNumberModifier = $this->tables->getAttackNumberByContinuousDistanceTable()
              ->getAttackNumberModifierByDistance($targetDistance);
          if ($targetDistance->getBonus()->getValue() > $currentEncounterRange->getValue()) { // comparing distance bonuses in fact
              $attackNumberModifier += $currentEncounterRange->getValue() - $targetDistance->getBonus()->getValue(); // always negative
          }
  
          return $attackNumberModifier;
      }
code_tokens: public function getAttackNumberModifierByDistance ( Distance $ targetDistance , EncounterRange $ currentEncounterRange , MaximalRange $ currentMaximalRange ) : int { if ( $ targetDistance -> getBonus ( ) -> getValue ( ) > $ currentMaximalRange -> getValue ( ) ) { // comparing distance bonuses in fact throw new DistanceIsOutOfMaximalRange ( "Given distance {$targetDistance->getBonus()} ({$targetDistance->getMeters()} meters)" . " is out of maximal range {$currentMaximalRange}" . ' (' . $ currentMaximalRange -> getInMeters ( $ this -> tables ) . ' meters)' ) ; } if ( $ currentEncounterRange -> getValue ( ) > $ currentMaximalRange -> getValue ( ) ) { throw new EncounterRangeCanNotBeGreaterThanMaximalRange ( "Got encounter range {$currentEncounterRange} greater than given maximal range {$currentMaximalRange}" ) ; } $ attackNumberModifier = $ this -> tables -> getAttackNumberByContinuousDistanceTable ( ) -> getAttackNumberModifierByDistance ( $ targetDistance ) ; if ( $ targetDistance -> getBonus ( ) -> getValue ( ) > $ currentEncounterRange -> getValue ( ) ) { // comparing distance bonuses in fact $ attackNumberModifier += $ currentEncounterRange -> getValue ( ) - $ targetDistance -> getBonus ( ) -> getValue ( ) ; // always negative } return $ attackNumberModifier ; }
docstring: Distance modifier can be solved very roughly by a simple table or more precisely with continual values by a
  calculation. This uses that calculation. See PPH page 104 left column.
  
  @param EncounterRange $currentEncounterRange
  @param Distance $targetDistance
  @param MaximalRange $currentMaximalRange
  @return int
  @throws \DrdPlus\Tables\Armaments\Exceptions\DistanceIsOutOfMaximalRange
  @throws \DrdPlus\Tables\Armaments\Exceptions\EncounterRangeCanNotBeGreaterThanMaximalRange
  @throws \DrdPlus\Tables\Combat\Attacks\Exceptions\DistanceOutOfKnownValues
docstring_tokens: Distance modifier can be solved very roughly by a simple table or more precisely with continual values by a calculation . This uses that calculation . See PPH page 104 left column .