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());
 }
 private function checkPaidFirstLevelSkillPoint(SkillPoint $paidSkillPoint)
 {
     if (!$paidSkillPoint->isPaidByFirstLevelBackgroundSkillPoints()) {
         $message = 'Skill point to-pay-with has to origin from first level background skills.';
         if ($paidSkillPoint->isPaidByNextLevelPropertyIncrease()) {
             $message .= ' Next level skill point is not allowed to trade.';
         }
         if ($paidSkillPoint->isPaidByOtherSkillPoints()) {
             $message .= ' There is no sense to trade first level skill point multiple times.';
         }
         throw new Exceptions\ProhibitedOriginOfPaidBySkillPoint($message);
     }
     if ($paidSkillPoint->getTypeName() === $this->getTypeName()) {
         throw new Exceptions\NonSensePaymentBySameType("There is no sense to pay for skill point by another one of the very same type ({$this->getTypeName()})." . ' Got paid skill point from level ' . $paidSkillPoint->getProfessionLevel()->getLevelRank() . ' of profession ' . $paidSkillPoint->getProfessionLevel()->getProfession()->getValue() . '.');
     }
 }
예제 #3
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));
             }
         }
     }
 }