<commit_before><?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BMButton
 *
 * @author james
 */
class BMButton {
    // properties
    public $recipe;
    public $dieArray;
    // three lists of dice

    // methods
    public function load_from_recipe($recipe) {
        $dieSides = $this->parseRecipeForSides($recipe);
        unset($this->dieArray);
        for ($dieIdx = 0; $dieIdx <= (count($dieSides) - 1); $dieIdx++) {
            $tempBMDie = new BMDie;
            $tempBMDie->mSides = $dieSides[$dieIdx];
            $this->dieArray[] = $tempBMDie;
        }
    }

    private function parseRecipeForSides($recipe) {
        $dieSizeArray = preg_split('/[^[:digit:]]+/', $recipe);

        return $dieSizeArray;
    }

    // create dice

    // load die values
}

?><commit_msg>Added ability to load simple dice with single letter abilities from a recipe, and simple validation of button recipes.<commit_after><?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BMButton
 *
 * @author james
 */
class BMButton {
    // properties
    public $recipe;
    public $dieArray;
    // three lists of dice

    // methods
    public function loadFromRecipe($recipe) {
        $this->validateRecipe($recipe);
        $dieSides = $this->parseRecipeForSides($recipe);
        $dieSkills = $this->parseRecipeForSkills($recipe);
        unset($this->dieArray);

        // set die sides and skills, one die at a time
        for ($dieIdx = 0; $dieIdx <= (count($dieSides) - 1); $dieIdx++) {
            $tempBMDie = new BMDie;
            $tempBMDie->mSides = $dieSides[$dieIdx];
            if (!empty($dieSkills[$dieIdx])) {
                $tempBMDie->mSkills = $dieSkills[$dieIdx];
            }
            $this->dieArray[] = $tempBMDie;
        }
    }

    private function validateRecipe($recipe) {
        $dieArray = preg_split('/[[:space:]]+/', $recipe,
                               NULL, PREG_SPLIT_NO_EMPTY);

        for ($dieIdx = 0; $dieIdx < count($dieArray); $dieIdx++) {
            $dieContainsDigit = preg_match('/[[:digit:]]/', $dieArray[$dieIdx]);
            print($dieContainsDigit);
            if (1 !== $dieContainsDigit) {
                throw new InvalidArgumentException("Invalid button recipe.");
            }
        }
    }

    private function parseRecipeForSides($recipe) {
        $dieSizeArray = preg_split('/[^[:digit:]]+/', $recipe,
                                   NULL, PREG_SPLIT_NO_EMPTY);
        return $dieSizeArray;
    }

    private function parseRecipeForSkills($recipe) {
        $dieSkillArray = preg_split('/[[:digit:][:space:]]+/', $recipe);
        return $dieSkillArray;
    }

    // create dice

    // load die values
}

?>
{'fraction_non_alphanumeric': 0.14200561009817672, 'fraction_numerical': 0.0021037868162692847, 'mean_word_length': 2.2457337883959045, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2064249', 'n_tokens_mistral': 901, 'n_tokens_neox': 872, 'n_words': 201}