Example #1
0
 /**
  * Constructor. Use iveeCore\Type::getById() to instantiate Reaction objects.
  *
  * @param int $id of the Reaction object
  *
  * @throws Exception if typeId is not found
  */
 protected function __construct($id)
 {
     //call parent constructor
     parent::__construct($id);
     //get data from SQL
     $row = $this->queryAttributes();
     //set data to object attributes
     $this->setAttributes($row);
     $materialMapClass = Config::getIveeClassName('MaterialMap');
     $this->cycleInputMaterialMap = new $materialMapClass();
     $this->cycleOutputMaterialMap = new $materialMapClass();
     $sdeClass = Config::getIveeClassName('SDE');
     //get reaction materials
     $res = $sdeClass::instance()->query('SELECT itr.input,
         itr.typeID,
         itr.quantity * IFNULL(COALESCE(dta.valueInt, dta.valueFloat), 1) as quantity
         FROM invTypeReactions as itr
         JOIN invTypes as it ON itr.typeID = it.typeID
         LEFT JOIN dgmTypeAttributes as dta ON itr.typeID = dta.typeID
         WHERE it.published = 1
         AND (dta.attributeID = 726 OR dta.attributeID IS NULL)
         AND itr.reactionTypeID = ' . $this->id . ';');
     while ($row = $res->fetch_assoc()) {
         if ($row['input'] == 1) {
             $this->cycleInputMaterialMap->addMaterial($row['typeID'], $row['quantity']);
         } else {
             $this->cycleOutputMaterialMap->addMaterial($row['typeID'], $row['quantity']);
             if (Type::getById($row['typeID'])->isReprocessable()) {
                 $this->isAlchemy = true;
             }
         }
     }
 }
 /**
  * Returns the volume of the process materials, without sub-processes.
  *
  * @return float
  */
 public function getMaterialVolume()
 {
     if (!isset($this->materials)) {
         return 0;
     }
     return $this->materials->getMaterialVolume();
 }
 /**
  * Convenience function for getting the sell value of the input materials.
  *
  * @param \iveeCore\IndustryModifier $iMod for market context
  *
  * @return float
  * @throws \iveeCore\Exceptions\PriceDataTooOldException if $maxPriceDataAge is exceeded by any of the materials
  */
 public function getOutputSellValue(IndustryModifier $iMod)
 {
     return $this->outputMaterials->getMaterialSellValue($iMod);
 }
Example #4
0
 public function testReaction()
 {
     $reactionProduct = Type::getByName('Platinum Technite');
     $this->assertTrue($reactionProduct instanceof ReactionProduct);
     //test correct handling of reaction products that can result from alchemy + refining
     $this->assertTrue($reactionProduct->getReactionIDs() == array(17952, 32831));
     //test handling of alchemy reactions with refining + feedback
     $iMod = IndustryModifier::getBySystemIdForPos(30000119);
     $rpd = Type::getByName('Unrefined Platinum Technite Reaction')->react($iMod, 24 * 30, true, true);
     $inTarget = new MaterialMap();
     $inTarget->addMaterial(16640, 72000);
     $inTarget->addMaterial(16644, 7200);
     $this->assertTrue($rpd->getMaterialMap()->getMaterials() == $inTarget->getMaterials());
     $outTarget = new MaterialMap();
     $outTarget->addMaterial(16662, 14400);
     $this->assertTrue($rpd->getOutputMaterialMap()->getMaterials() == $outTarget->getMaterials());
 }