Ejemplo n.º 1
0
 /**
  * @test
  */
 public function I_can_get_round_half()
 {
     $number = 5;
     $this->assertSame(3, SumAndRound::half($number));
     $number = 4.99;
     $this->assertSame(2, SumAndRound::half($number));
 }
 public function provideDistanceAndExpectedModifier()
 {
     $testValues = [];
     $distanceTable = new DistanceTable();
     for ($distanceBonus = 1; $distanceBonus < 100; $distanceBonus++) {
         $distanceInMeters = (new DistanceBonus($distanceBonus, $distanceTable))->getDistance()->getMeters();
         $attackNumberModifier = -(SumAndRound::half($distanceBonus) - 9);
         // PPH page 104 left column
         $testValues[] = [$distanceInMeters, $attackNumberModifier];
     }
     return $testValues;
 }
Ejemplo n.º 3
0
 /**
  * @param RangedWeaponCode $rangedWeaponCode
  * @param Speed $speed
  * @return int
  * @throws CanNotUseWeaponBecauseOfMissingStrength
  */
 private function getEncounterRangeBonusBySpeed(RangedWeaponCode $rangedWeaponCode, Speed $speed)
 {
     if (!$rangedWeaponCode->isThrowingWeapon()) {
         return 0;
     }
     return SumAndRound::half($speed->getValue());
 }
 /**
  * Despite rules this library deducts half of size from defense number, instead of adding to attack number,
  * because it is more practical from numbers-point-of-view
  * PPH page 104 right column top
  *
  * @param DefenseNumber $defense
  * @param Size $size
  */
 public function __construct(DefenseNumber $defense, Size $size)
 {
     /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
     parent::__construct($defense->getValue() - SumAndRound::half($size->getValue()));
 }
 protected function calculateValue($firstPropertyValue, $secondPropertyValue, $charismaValue)
 {
     return SumAndRound::average($firstPropertyValue, $secondPropertyValue) + SumAndRound::half($charismaValue);
 }
 /**
  * @param IntegerInterface $firstProperty
  * @param IntegerInterface $secondProperty
  * @param Charisma $charisma
  */
 protected function __construct(IntegerInterface $firstProperty, IntegerInterface $secondProperty, Charisma $charisma)
 {
     /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
     parent::__construct(SumAndRound::average($firstProperty->getValue(), $secondProperty->getValue()) + SumAndRound::half($charisma->getValue()));
 }
 /**
  * @param Speed $speed
  */
 public function __construct(Speed $speed)
 {
     /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
     parent::__construct(SumAndRound::half($speed->getValue()));
 }
Ejemplo n.º 8
0
 /**
  * Affects activities using strength, agility or knack, see PPH page 113, right column, bottom.
  * @param Strength $strength
  * @param Weight $cargoWeight
  * @return int negative number or zero
  * @throws \DrdPlus\Tables\Measurements\Partials\Exceptions\BonusRequiresInteger
  */
 public function getMalusFromLoad(Strength $strength, Weight $cargoWeight)
 {
     $requiredStrength = $cargoWeight->getBonus()->getValue();
     $missingStrength = $requiredStrength - $strength->getValue();
     $malus = -SumAndRound::half($missingStrength);
     // see PPH page 113, right column
     if ($malus > 0) {
         return 0;
     }
     return $malus;
 }