<commit_before><?php
namespace DrdPlus\Exceptionalities\Properties;

use DrdPlus\Exceptionalities\Fates\ExceptionalityFate;
use DrdPlus\Exceptionalities\Templates\Integer1To6;
use DrdPlus\Person\ProfessionLevels\ProfessionLevel;
use DrdPlus\Properties\Base\Agility;
use DrdPlus\Properties\Base\BaseProperty;
use DrdPlus\Properties\Base\BasePropertyFactory;
use DrdPlus\Properties\Base\Charisma;
use DrdPlus\Properties\Base\Intelligence;
use DrdPlus\Properties\Base\Knack;
use DrdPlus\Properties\Base\Strength;
use DrdPlus\Properties\Base\Will;
use Granam\Strict\Object\StrictObject;

class ExceptionalityPropertiesFactory extends StrictObject
{

    /**
     * @param ExceptionalityFate $fate
     * @param ProfessionLevel $professionLevel
     * @param int $strengthRollValue
     * @param int $agilityRollValue
     * @param int $knackRollValue
     * @param int $willRollValue
     * @param int $intelligenceRollValue
     * @param int $charismaRollValue
     * @param BasePropertyFactory $basePropertyFactory
     * @return FortuneProperties
     */
    public function createFortuneProperties(
        ExceptionalityFate $fate,
        ProfessionLevel $professionLevel,
        $strengthRollValue,
        $agilityRollValue,
        $knackRollValue,
        $willRollValue,
        $intelligenceRollValue,
        $charismaRollValue,
        BasePropertyFactory $basePropertyFactory
    )
    {
        $strengthRoll = new Integer1To6($strengthRollValue);
        $strength = $this->createFortuneProperty(
            $professionLevel, $fate, $strengthRoll, Strength::STRENGTH, $basePropertyFactory
        );
        $agilityRoll = new Integer1To6($agilityRollValue);
        $agility = $this->createFortuneProperty(
            $professionLevel, $fate, $agilityRoll, Agility::AGILITY, $basePropertyFactory
        );
        $knackRoll = new Integer1To6($knackRollValue);
        $knack = $this->createFortuneProperty(
            $professionLevel, $fate, $knackRoll, Knack::KNACK, $basePropertyFactory
        );
        $willRoll = new Integer1To6($willRollValue);
        $will = $this->createFortuneProperty(
            $professionLevel, $fate, $willRoll, Will::WILL, $basePropertyFactory
        );
        $intelligenceRoll = new Integer1To6($intelligenceRollValue);
        $intelligence = $this->createFortuneProperty(
            $professionLevel, $fate, $intelligenceRoll, Intelligence::INTELLIGENCE, $basePropertyFactory
        );
        $charismaRoll = new Integer1To6($charismaRollValue);
        $charisma = $this->createFortuneProperty(
            $professionLevel, $fate, $charismaRoll, Charisma::CHARISMA, $basePropertyFactory
        );

        return new FortuneProperties(
            $strength,
            $strengthRoll,
            $agility,
            $agilityRoll,
            $knack,
            $knackRoll,
            $will,
            $willRoll,
            $intelligence,
            $intelligenceRoll,
            $charisma,
            $charismaRoll
        );
    }

    private function createFortuneProperty(
        ProfessionLevel $profession,
        ExceptionalityFate $fate,
        Integer1To6 $roll,
        $propertyCode,
        BasePropertyFactory $basePropertyFactory
    )
    {
        if ($profession->isPrimaryProperty($propertyCode)) {
            $value = $fate->getPrimaryPropertyBonusOnFortune($roll);
        } else {
            $value = $fate->getSecondaryPropertyBonusOnFortune($roll);
        }

        $property = $basePropertyFactory->createProperty($value, $propertyCode);

        return $property;
    }

    public function createChosenProperties(
        ExceptionalityFate $fate,
        ProfessionLevel $professionLevel,
        Strength $chosenStrength,
        Agility $chosenAgility,
        Knack $chosenKnack,
        Will $chosenWill,
        Intelligence $chosenIntelligence,
        Charisma $chosenCharisma
    )
    {
        $this->checkChosenProperties(
            $chosenStrength,
            $chosenAgility,
            $chosenKnack,
            $chosenWill,<commit_msg>Inner variable renamed to reflect its content<commit_after><?php
namespace DrdPlus\Exceptionalities\Properties;

use DrdPlus\Exceptionalities\Fates\ExceptionalityFate;
use DrdPlus\Exceptionalities\Templates\Integer1To6;
use DrdPlus\Person\ProfessionLevels\ProfessionLevel;
use DrdPlus\Properties\Base\Agility;
use DrdPlus\Properties\Base\BaseProperty;
use DrdPlus\Properties\Base\BasePropertyFactory;
use DrdPlus\Properties\Base\Charisma;
use DrdPlus\Properties\Base\Intelligence;
use DrdPlus\Properties\Base\Knack;
use DrdPlus\Properties\Base\Strength;
use DrdPlus\Properties\Base\Will;
use Granam\Strict\Object\StrictObject;

class ExceptionalityPropertiesFactory extends StrictObject
{

    /**
     * @param ExceptionalityFate $fate
     * @param ProfessionLevel $professionLevel
     * @param int $strengthRollValue
     * @param int $agilityRollValue
     * @param int $knackRollValue
     * @param int $willRollValue
     * @param int $intelligenceRollValue
     * @param int $charismaRollValue
     * @param BasePropertyFactory $basePropertyFactory
     * @return FortuneProperties
     */
    public function createFortuneProperties(
        ExceptionalityFate $fate,
        ProfessionLevel $professionLevel,
        $strengthRollValue,
        $agilityRollValue,
        $knackRollValue,
        $willRollValue,
        $intelligenceRollValue,
        $charismaRollValue,
        BasePropertyFactory $basePropertyFactory
    )
    {
        $strengthRoll = new Integer1To6($strengthRollValue);
        $strength = $this->createFortuneProperty(
            $professionLevel, $fate, $strengthRoll, Strength::STRENGTH, $basePropertyFactory
        );
        $agilityRoll = new Integer1To6($agilityRollValue);
        $agility = $this->createFortuneProperty(
            $professionLevel, $fate, $agilityRoll, Agility::AGILITY, $basePropertyFactory
        );
        $knackRoll = new Integer1To6($knackRollValue);
        $knack = $this->createFortuneProperty(
            $professionLevel, $fate, $knackRoll, Knack::KNACK, $basePropertyFactory
        );
        $willRoll = new Integer1To6($willRollValue);
        $will = $this->createFortuneProperty(
            $professionLevel, $fate, $willRoll, Will::WILL, $basePropertyFactory
        );
        $intelligenceRoll = new Integer1To6($intelligenceRollValue);
        $intelligence = $this->createFortuneProperty(
            $professionLevel, $fate, $intelligenceRoll, Intelligence::INTELLIGENCE, $basePropertyFactory
        );
        $charismaRoll = new Integer1To6($charismaRollValue);
        $charisma = $this->createFortuneProperty(
            $professionLevel, $fate, $charismaRoll, Charisma::CHARISMA, $basePropertyFactory
        );

        return new FortuneProperties(
            $strength,
            $strengthRoll,
            $agility,
            $agilityRoll,
            $knack,
            $knackRoll,
            $will,
            $willRoll,
            $intelligence,
            $intelligenceRoll,
            $charisma,
            $charismaRoll
        );
    }

    private function createFortuneProperty(
        ProfessionLevel $professionLevel,
        ExceptionalityFate $fate,
        Integer1To6 $roll,
        $propertyCode,
        BasePropertyFactory $basePropertyFactory
    )
    {
        if ($professionLevel->isPrimaryProperty($propertyCode)) {
            $value = $fate->getPrimaryPropertyBonusOnFortune($roll);
        } else {
            $value = $fate->getSecondaryPropertyBonusOnFortune($roll);
        }

        $property = $basePropertyFactory->createProperty($value, $propertyCode);

        return $property;
    }

    public function createChosenProperties(
        ExceptionalityFate $fate,
        ProfessionLevel $professionLevel,
        Strength $chosenStrength,
        Agility $chosenAgility,
        Knack $chosenKnack,
        Will $chosenWill,
        Intelligence $chosenIntelligence,
        Charisma $chosenCharisma
    )
    {
        $this->checkChosenProperties(
            $chosenStrength,
            $chosenAgility,
            $chosenKnack,
            $chosenWill,
{'fraction_non_alphanumeric': 0.08999755441428223, 'fraction_numerical': 0.003912937148447053, 'mean_word_length': 2.781322237632917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6203973', 'n_tokens_mistral': 2381, 'n_tokens_neox': 2270, 'n_words': 401}