/**
  * Gets the Reaction object(s) this product can be produced from.
  *
  * @return \iveeCore\Reaction[] with Reaction objects(s)
  */
 public function getReactions()
 {
     $ret = [];
     foreach ($this->productOfReactionIds as $reactionId) {
         $ret[$reactionId] = Type::getById($reactionId);
     }
     return $ret;
 }
Example #2
0
 public function __construct($data)
 {
     if (is_array($data)) {
         $this->id = $data['gym_id'];
         $this->name = $data['gym_name'];
         $this->city = $data['gym_city'];
         $type = Type::getById(intval($data['gym_type']));
         $this->type = $type->serialize();
         $badge = Badge::getById(intval($data['gym_badge']));
         $this->badge = $badge->serialize();
     }
 }
Example #3
0
 public function __construct($data)
 {
     if (is_array($data)) {
         $this->id = $data['pokemon_id'];
         $this->name = $data['pokemon_name'];
         $type1 = Type::getById(intval($data['pokemon_type1']));
         $this->type = $type1->serialize();
         $type2 = $data['pokemon_type2'];
         if ($type2 !== null) {
             $type2 = Type::getById($type2);
             $this->type2 = $type2->serialize();
         } else {
             $this->type2 = null;
         }
         $this->hp = intval($data['pokemon_hp']);
         $this->speed = intval($data['pokemon_speed']);
         $this->attack = intval($data['pokemon_attack']);
         $this->specialAttack = intval($data['pokemon_special_attack']);
         $this->defense = intval($data['pokemon_defense']);
         $this->specialDefense = intval($data['pokemon_special_defense']);
         if ($data['pokemon_before'] != null) {
             $this->previousEvolution = $data['pokemon_before'];
         } else {
             $this->previousEvolution = null;
         }
         if (intval($data['pokemon_before_evo_level']) != null) {
             $this->previousEvolutionLevel = intval($data['pokemon_before_evo_level']);
         } else {
             $this->previousEvolutionLevel = null;
         }
         if ($data['pokemon_after'] != null) {
             $this->nextEvolution = $data['pokemon_after'];
         } else {
             $this->nextEvolution = null;
         }
         if (intval($data['pokemon_after_evo_level']) != null) {
             $this->nextEvolutionLevel = intval($data['pokemon_after_evo_level']);
         } else {
             $this->nextEvolutionLevel = null;
         }
         if (array_key_exists('pokemon_level', $data)) {
             if (intval($data['pokemon_level']) != null) {
                 $this->level = intval($data['pokemon_level']);
             } else {
                 $this->level = null;
             }
         } else {
             $this->level = null;
         }
     }
 }
Example #4
0
 /**
  * Returns a ManufactureProcessData object with cascaded InventionProcessData object.
  *
  * @param \iveeCore\IndustryModifier $iMod the object with all the necessary industry modifying entities
  * @param int $relicId the ID of the Relic to be used for invention
  * @param int $decryptorId the decryptor the be used, if any
  * @param int $manuRecursionDepth defines if and how deep used materials should be manufactured recursively
  * @param int $reactionRecursionDepth defines if and how deep used materials should be gained through reaction
  * recursively
  *
  * @return \iveeCore\InventionProcessData
  * @throws \iveeCore\Exceptions\NotInventableException if a wrong relicId is given
  * @throws \iveeCore\Exceptions\WrongTypeException if decryptorId isn't a decryptor or if relicId isn't a Relic
  */
 public function inventManufacture(IndustryModifier $iMod, $relicId, $decryptorId = null, $manuRecursionDepth = 1, $reactionRecursionDepth = 0)
 {
     if (!in_array($relicId, $this->inventedFrom)) {
         self::throwException('NotInventableException', "Can't use Relic ID=" . (int) $relicId . " to invent this T3Blueprint");
     }
     $relic = Type::getById($relicId);
     if (!$relic instanceof Relic) {
         self::throwException('WrongTypeException', 'Given object is not instance of Relic');
     }
     return $relic->inventManufacture($iMod, $this->getId(), $decryptorId, $manuRecursionDepth, $reactionRecursionDepth);
 }
Example #5
0
 /**
  * Returns an Manufacturable object representing the item produced by this Blueprint.
  *
  * @return \iveeCore\Manufacturable
  */
 public function getProduct()
 {
     return Type::getById($this->getProductId());
 }
 /**
  * Returns an array with the inventable blueprint instances.
  *
  * @return \iveeCore\InventableBlueprint[]
  */
 public function getInventableBlueprints()
 {
     $ret = [];
     foreach ($this->getInventableBlueprintIds() as $bpId) {
         $ret[$bpId] = Type::getById($bpId);
     }
     return $ret;
 }
 /**
  * Returns blueprint object that can manufacture this item.
  *
  * @return \iveeCore\Blueprint
  */
 public function getBlueprint()
 {
     return Type::getById($this->producedFromBlueprintId);
 }
Example #8
0
 /**
  * Prints data about this process.
  *
  * @param \iveeCore\IndustryModifier $buyContext for buying context
  * @param \iveeCore\IndustryModifier $sellContext for selling context, optional. If not given, $buyContext will be
  * used.
  *
  * @return void
  */
 public function printData(IndustryModifier $buyContext, IndustryModifier $sellContext = null)
 {
     $utilClass = Config::getIveeClassName('Util');
     echo "Total slot time: " . $utilClass::secondsToReadable($this->getTotalTime()) . PHP_EOL;
     //iterate over materials
     foreach ($this->getTotalMaterialMap()->getMaterials() as $typeId => $amount) {
         echo $amount . 'x ' . Type::getById($typeId)->getName() . PHP_EOL;
     }
     echo "Material cost: " . $utilClass::quantitiesToReadable($this->getTotalMaterialBuyCost($buyContext)) . "ISK" . PHP_EOL;
     echo "Slot cost: " . $utilClass::quantitiesToReadable($this->getTotalProcessCost()) . "ISK" . PHP_EOL;
     echo "Total cost: " . $utilClass::quantitiesToReadable($this->getTotalCost($buyContext)) . "ISK" . PHP_EOL;
     echo "Total profit: " . $utilClass::quantitiesToReadable($this->getTotalProfit($buyContext, $sellContext)) . "ISK" . PHP_EOL;
 }
Example #9
0
 /**
  * Computes and adds the material requirements for a process to a ProcessData object.
  * 
  * 
  * @param IndustryModifier $iMod the object that holds all the information about skills, implants, system industry
  * indices, teams, tax and assemblyLines
  * @param ProcessData $pdata to which materials shall be added
  * @param int $activityId of the activity
  * @param float $materialFactor the IndustryModifier and Blueprint ME level dependant ME bonus factor
  * @param float $numPortions the number of portions being built or researched. Note that passing a fraction will
  * make the method not use the rounding for the resulting required amounts.
  * @param bool $recursive defines if used materials should be manufactured recursively
  * 
  * @return void
  */
 protected function addActivityMaterials(IndustryModifier $iMod, ProcessData $pdata, $activityId, $materialFactor, $numPortions, $recursive)
 {
     foreach ($this->getMaterialsForActivity($activityId) as $matID => $matData) {
         //if consume flag is set to 0, add to needed mats with quantity 0
         if (isset($matData['c']) and $matData['c'] == 0) {
             $pdata->addMaterial($matID, 0);
             continue;
         }
         $mat = Type::getById($matID);
         //calculate total quantity needed, applying all modifiers
         //if number of portions is a fraction, don't ceil() amounts
         if (fmod($numPortions, 1.0) > 0.0) {
             $totalNeeded = $matData['q'] * $materialFactor * $numPortions;
         } else {
             $totalNeeded = ceil($matData['q'] * $materialFactor * $numPortions);
         }
         //at least one unit of material is required per portion
         if ($totalNeeded < $numPortions) {
             $totalNeeded = $numPortions;
         }
         //if using recursive building and material is manufacturable, recurse!
         if ($recursive and $mat instanceof Manufacturable) {
             $pdata->addSubProcessData($mat->getBlueprint()->manufacture($iMod, $totalNeeded));
         } else {
             $pdata->addMaterial($matID, $totalNeeded);
         }
     }
 }
Example #10
0
});
$app->get('/trainers/:id/badges', function ($id) use($app) {
    $trainer = Trainer::getById($id);
    sendResponse($trainer->getBadges());
});
$app->get('/gyms', function () use($app) {
    sendResponse(Gym::getAll());
});
$app->get('/gyms/:id', function ($id) use($app) {
    $gym = Gym::getById($id);
    sendResponse($gym->serialize());
});
$app->get('/gyms/:id/leader', function ($id) use($app) {
    $gym = Gym::getById($id);
    sendResponse($gym->getLeader()->serialize());
});
$app->get('/types', function () use($app) {
    sendResponse(Type::getAll());
});
$app->get('/types/:id', function ($id) use($app) {
    $type = Type::getById($id);
    sendResponse($type->serialize());
});
$app->get('/badges', function () use($app) {
    sendResponse(Badge::getAll());
});
$app->get('/badges/:id', function ($id) use($app) {
    $badge = Badge::getById($id);
    sendResponse($badge->serialize());
});
$app->run();
 /**
  * Prints data about this process.
  *
  * @param \iveeCore\IndustryModifier $buyContext for buying context
  * @param \iveeCore\IndustryModifier $sellContext for selling context, optional. If not given, $buyContext ist used.
  *
  * @return void
  */
 public function printData(IndustryModifier $buyContext, IndustryModifier $sellContext = null)
 {
     $utilClass = Config::getIveeClassName('Util');
     echo "Total Slot Time: " . $utilClass::secondsToReadable($this->getTotalTime()) . PHP_EOL;
     echo "Total Materials for " . $this->producesQuantity . "x " . Type::getById($this->producesTypeId)->getName() . ":" . PHP_EOL;
     //iterate over materials
     foreach ($this->getTotalMaterialMap()->getMaterials() as $typeId => $amount) {
         echo $amount . 'x ' . Type::getById($typeId)->getName() . PHP_EOL;
     }
     echo "Total Material Cost: " . $utilClass::quantitiesToReadable($this->getTotalMaterialBuyCost($buyContext)) . "ISK" . PHP_EOL;
     echo "Total Slot Cost: " . $utilClass::quantitiesToReadable($this->getTotalProcessCost()) . "ISK" . PHP_EOL;
     echo "Total Cost: " . $utilClass::quantitiesToReadable($this->getTotalCost($buyContext)) . "ISK" . PHP_EOL;
     try {
         echo "Total Profit: " . $utilClass::quantitiesToReadable($this->getTotalProfit($buyContext, $sellContext)) . "ISK" . PHP_EOL;
     } catch (Exceptions\NoPriceDataAvailableException $e) {
         echo "No profit calculation possible due to missing price data for product" . PHP_EOL;
     }
 }
 /**
  * Prints data about this process.
  *
  * @param \iveeCore\IndustryModifier $buyContext for buying context
  * @param \iveeCore\IndustryModifier $sellContext for selling context, optional. If not given, $buyContext ist used.
  *
  * @return void
  */
 public function printData(IndustryModifier $buyContext, IndustryModifier $sellContext = null)
 {
     $utilClass = Config::getIveeClassName('Util');
     echo "Average total success times:" . PHP_EOL;
     print_r($this->getTotalSuccessTimes());
     echo "Average total success materials:" . PHP_EOL;
     foreach ($this->getTotalSuccessMaterialMap()->getMaterials() as $typeId => $amount) {
         echo $amount . 'x ' . Type::getById($typeId)->getName() . PHP_EOL;
     }
     echo "Total average success material cost: " . $utilClass::quantitiesToReadable($this->getTotalSuccessMaterialBuyCost($buyContext)) . "ISK" . PHP_EOL;
     echo "Total average success slot cost: " . $utilClass::quantitiesToReadable($this->getTotalSuccessProcessCost()) . "ISK" . PHP_EOL;
     echo "Total average success cost: " . $utilClass::quantitiesToReadable($this->getTotalSuccessCost($buyContext)) . "ISK" . PHP_EOL;
     echo "Total profit: " . $utilClass::quantitiesToReadable($this->getTotalProfit($buyContext, $sellContext)) . "ISK" . PHP_EOL;
 }
Example #13
0
 /**
  * Produces an ReactionProcessData object detailing a reaction process for a given number of reaction cycles.
  *
  * @param \iveeCore\IndustryModifier $iMod as industry context
  * @param int|float $cycles defines the number of reaction cycles to be calculated. One cycle takes 1h to complete.
  * @param bool $reprocess defines reprocessable reaction outputs should be reprocessed in the process. Applies to
  * alchemy reaction.
  * @param bool $feedback defines if materials occuring in both input and output should be subtracted in the
  * possible numbers, thus showing the effective input/output materials. Applies to alchemy reactions.
  * @param int $recursionDepth defines the maximum number of reaction recursions
  *
  * @return \iveeCore\ReactionProcessData
  */
 public function react(IndustryModifier $iMod, $cycles = 1, $reprocess = true, $feedback = true, $recursionDepth = 0)
 {
     $reactionProcessDataClass = Config::getIveeClassName('ReactionProcessData');
     $materialMapClass = Config::getIveeClassName('MaterialMap');
     //get material input and output maps for one cycle
     $imm = $this->getCycleInputMaterialMap();
     $omm = $this->getCycleOutputMaterialMap();
     //if refine flag set, replace the refinable output materials by their refined materials
     if ($reprocess) {
         $omm->reprocessMaterials($iMod);
     }
     //if feedback flag set, subtract materials occurring in both input and output from each other, respecting
     //quantities. This gives the effective required and resulting materials.
     if ($feedback) {
         $materialMapClass::symmetricDifference($imm, $omm);
     }
     //multiply amounts by cycles as factor
     $imm->multiply($cycles);
     $omm->multiply($cycles);
     $rpd = new $reactionProcessDataClass($this->id, $imm, $omm, $iMod->getSolarSystem()->getId(), $cycles, $this->isAlchemy and $reprocess, $this->isAlchemy and $feedback);
     //if we are doing reaction recursion, replace ReactionProducts in input by their equivalent ReactionProcessData
     if ($recursionDepth > 0) {
         foreach ($imm->getMaterials() as $typeId => $quantity) {
             $mat = Type::getById($typeId);
             if ($mat instanceof ReactionProduct) {
                 $rpd->addSubProcessData($mat->doBestReaction($iMod, $quantity, $recursionDepth - 1));
                 $imm->subtractMaterial($typeId, $quantity);
             }
         }
     }
     return $rpd;
 }
Example #14
0
 /**
  * Returns material sell value, considering specific taxes. The best station (lowest tax) in system will be
  * chosen for that unless another preferred station is set on the IndustryModifier object.
  * Items that are not on the market will be ignored.
  *
  * @param \iveeCore\IndustryModifier $sellContext for market context
  *
  * @return float
  * @throws \iveeCore\Exceptions\PriceDataTooOldException if $maxPriceDataAge is exceeded by any of the materials
  */
 public function getMaterialSellValue(IndustryModifier $sellContext)
 {
     $sum = 0;
     foreach ($this->getMaterials() as $typeId => $amount) {
         $type = Type::getById($typeId);
         if (!$type->onMarket()) {
             continue;
         }
         if ($amount > 0) {
             $sum += $type->getMarketPrices($sellContext->getSolarSystem()->getRegionId(), $sellContext->getMaxPriceDataAge())->getSellPrice($sellContext->getMaxPriceDataAge()) * $amount * $sellContext->getSellTaxFactor();
         }
     }
     return $sum;
 }