示例#1
0
 /**
  * Get the blueprint as array.
  *
  * @return array
  */
 public function getAsArray()
 {
     $upgradeWeaponModificator = $this->getUpgradeWeaponModificator();
     return array('id' => $this->getBlueprintId(), 'name' => $this->getName(), 'item' => $this->getItem(), 'itemType' => $this->getItemType(), 'damageType' => $this->getDamageType(), 'materials' => $this->getMaterialsString(), 'techniques' => $this->getTechniquesString(), 'materialWeaponModificator' => $this->getMaterialWeaponModificator(), 'upgradeHitPoints' => $this->getUpgradeHitPoints(), 'upgradeBreakFactor' => $this->getUpgradeBreakFactor(), 'upgradeInitiative' => $this->getUpgradeInitiative(), 'upgradeWeaponModificator' => \Helper\WeaponModificator::format($upgradeWeaponModificator[0]), 'bonusRangedFightValue' => $this->getBonusRangedFightValue(), 'reducePhysicalStrengthRequirement' => $this->getReducePhysicalStrengthRequirement());
 }
示例#2
0
    /**
     * Create a new material asset from the given array.
     * array(
     *     'percentage' => array(
     *         0 => 50,
     *         1 => 50,
     *     ),
     *     'timeFactor' => array(
     *         0 => 1,
     *         1 => 1,
     *     ),
     *     'priceFactor' => array(
     *         0 => 2,
     *         0 => 1.5,
     *     ),
     *     'priceWeight' => array(),
     *     'currency' => array(
     *         0 => 'S',
     *         1 => 'D',
     *     ),
     *     'proof' => array(
     *         0 => 0,
     *         1 => -1,
     *     ),
     *     'breakFactor' => array(
     *         0 => 1,
     *         1 => -1,
     *     ),
     *     'hitPoints' => array(
     *         0 => 0,
     *         1 => 1,
     *     ),
     *     'armor' => array(
     *         0 => 0,
     *         1 => 0,
     *     ),
     *     'weaponModificator' => array(
     *         0 => '0/0',
     *         1 => '-1/0',
     *     ),
     * )
     *
     * @param array $data
     *
     * @return boolean
     */
    public static function create($data)
    {
        if (!$data['materialId'] && !$data['percentage'] && !$data['timeFactor'] && (!$data['priceFactor'] || $data['priceWeight'])) {
            return false;
        }
        $weaponModificators = array();
        if (!empty($data['weaponModificator'])) {
            $weaponModificators = \Helper\WeaponModificator::getWeaponModificatorArray($data['weaponModificator']);
        }
        if (!empty($data['priceWeight'])) {
            $moneyHelper = new \Helper\Money();
            $data['priceWeight'] = $moneyHelper->exchange($data['priceWeight'], $data['currency']);
        }
        $sql = '
			INSERT INTO materialAssets
			SET materialId = ' . \sqlval($data['materialId']) . ',
				percentage = ' . \sqlval($data['percentage']) . ',
				timeFactor = ' . \sqlval($data['timeFactor']) . ',
				priceFactor = ' . \sqlval($data['priceFactor']) . ',
				priceWeight = ' . \sqlval($data['priceWeight']) . ',
				proof = ' . \sqlval($data['proof']) . ',
				breakFactor = ' . \sqlval($data['breakFactor']) . ',
				hitPoints = ' . \sqlval($data['hitPoints']) . ',
				armor = ' . \sqlval($data['armor']) . ',
				weaponModificator = ' . \sqlval(json_encode($weaponModificators)) . '
		';
        query($sql);
        return true;
    }
示例#3
0
 /**
  * Get the weapon modificator string, i.e. 0/-1
  *
  * @return string
  */
 public function getWeaponModificatorFormatted()
 {
     $weaponModificator = $this->getWeaponModificator();
     return \Helper\WeaponModificator::format($weaponModificator[0]);
 }