protected function I_can_detect_way_of_payment(SkillPoint $skillPoint)
 {
     self::assertSame($skillPoint->getBackgroundSkillPoints() !== null, $skillPoint->isPaidByFirstLevelBackgroundSkillPoints());
     self::assertSame($skillPoint->getFirstPaidOtherSkillPoint() !== null && $skillPoint->getSecondPaidOtherSkillPoint() !== null, $skillPoint->isPaidByOtherSkillPoints());
     self::assertSame(!$skillPoint->isPaidByFirstLevelBackgroundSkillPoints() && !$skillPoint->isPaidByOtherSkillPoints() && $skillPoint->getProfessionNextLevel() !== null, $skillPoint->isPaidByNextLevelPropertyIncrease());
     self::assertSame(1, $skillPoint->isPaidByFirstLevelBackgroundSkillPoints() + $skillPoint->isPaidByNextLevelPropertyIncrease() + $skillPoint->isPaidByOtherSkillPoints());
 }
Exemplo n.º 2
0
 private static function extractPaymentDetails(SkillPoint $skillPoint)
 {
     $propertyPayment = self::getPaymentsSkeleton();
     $type = $skillPoint->getTypeName();
     if ($skillPoint->isPaidByFirstLevelBackgroundSkillPoints()) {
         /**
          * There are limited first level background skill points,
          *
          * @see \DrdPlus\Person\Background\BackgroundSkillPoints
          * and @see \DrdPlus\Person\Background\Heritage
          * check their sum
          */
         $propertyPayment['firstLevel'][$type]['spentFirstLevelSkillPoints'] += $skillPoint->getValue();
         $propertyPayment['firstLevel'][$type]['backgroundSkillPoints'] = $skillPoint->getBackgroundSkillPoints();
         return $propertyPayment;
     } else {
         if ($skillPoint->isPaidByOtherSkillPoints()) {
             $firstPaidOtherSkillPoint = self::extractPaymentDetails($skillPoint->getFirstPaidOtherSkillPoint());
             $secondPaidOtherSkillPoint = self::extractPaymentDetails($skillPoint->getSecondPaidOtherSkillPoint());
             // the other skill points have to be extracted to first level background skills, see upper
             return self::sumPayments([$firstPaidOtherSkillPoint, $secondPaidOtherSkillPoint]);
         } else {
             if ($skillPoint->isPaidByNextLevelPropertyIncrease()) {
                 // for every skill point of this type has to exists level property increase
                 $propertyPayment['nextLevels'][$type]['spentNextLevelsSkillPoints'] += $skillPoint->getValue();
                 $propertyPayment['nextLevels'][$type]['relatedProperties'] = $skillPoint->getRelatedProperties();
                 return $propertyPayment;
             } else {
                 throw new Exceptions\UnknownPaymentForSkillPoint('Unknown payment for skill point ' . get_class($skillPoint));
             }
         }
     }
 }