/**
  * Gets the best compatible Team for the activity and Type. 
  * Bonuses are ranked as material bonus > time bonus > cost bonus
  * 
  * @param int $activityID the ID of the activity to get Team for
  * @param Type $type It's always the final output item that needs to be given. This means that for manufacturing, 
  * its the Blueprint product; for copying its the Blueprint itself; for invention it is the product of the 
  * invented blueprint.
  *
  * @return Team|null
  */
 public function getBestTeamForActivity($activityID, Type $type)
 {
     $bestTeam = null;
     $bestModifier = null;
     try {
         //get available teams for the wanted activity
         $teams = $this->getTeamsForActivity($activityID);
     } catch (Exceptions\ActivityIdNotFoundException $e) {
         return null;
     }
     foreach ($teams as $candidateTeam) {
         //skip teams incompatible with output groupID
         if (!$candidateTeam->isGroupIDCompatible($type->getGroupID())) {
             continue;
         } elseif (is_null($bestTeam)) {
             $bestTeam = $candidateTeam;
             $bestModifier = $candidateTeam->getModifiersForGroupID($type->getGroupID());
         } else {
             $candidateModifier = $candidateTeam->getModifiersForGroupID($type->getGroupID());
             //Modifiers are ranked with priority order for material, time then cost modifiers (lower is better!)
             if ($bestModifier['m'] < $candidateModifier['m']) {
                 continue;
             } elseif ($bestModifier['m'] > $candidateModifier['m']) {
                 $bestTeam = $candidateTeam;
                 $bestModifier = $candidateModifier;
             } elseif ($bestModifier['t'] < $candidateModifier['t']) {
                 continue;
             } elseif ($bestModifier['t'] > $candidateModifier['t']) {
                 $bestTeam = $candidateTeam;
                 $bestModifier = $candidateModifier;
             } elseif ($bestModifier['c'] < $candidateModifier['c']) {
                 continue;
             } elseif ($bestModifier['c'] > $candidateModifier['c']) {
                 $bestTeam = $candidateTeam;
                 $bestModifier = $candidateModifier;
             }
         }
     }
     return $bestTeam;
 }
Example #2
0
 /**
  * Checks if the Team gives bonus to given Type
  * 
  * @param \iveeCore\Type $type to be checked
  * 
  * @return bool
  */
 public function isTypeCompatible(Type $type)
 {
     return $this->isGroupIDCompatible($type->getGroupID());
 }
Example #3
0
 /**
  * Checks if a Type is compatible with the AssemblyLine. The passed Type should be the final product of the process. 
  * This means that for manufacturing, its the Blueprint product; for copying its the Blueprint itself; for invention 
  * it is the product of the invented blueprint.
  * 
  * @param Type $type the item to be checked
  * 
  * @return bool
  */
 public function isTypeCompatible(Type $type)
 {
     //the type is compatible if its groupID or categoryID is listet in the modifiers array
     return isset($this->groupModifiers[$type->getGroupID()]) or isset($this->categoryModifiers[$type->getCategoryID()]);
 }