Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. checkRecipe: function (recipe) {
  2.                 var i, j, item,
  3.                         usedGids = [],
  4.                         matchList = [];
  5.  
  6.                 for (i = 0; i < recipe.Ingredients.length; i += 1) {
  7.                         var optimalItem;
  8.                         for (j = 0; j < this.validIngredients.length; j += 1) {
  9.                                 if (usedGids.indexOf(this.validIngredients[j].gid) === -1 &&
  10.                                                 (this.validIngredients[j].classid === recipe.Ingredients[i] || (recipe.Ingredients[i] === "pgem" &&
  11.                                                 this.gemList.indexOf(this.validIngredients[j].classid) > -1))
  12.                                                 ) {
  13.                                         item = me.getItem(this.validIngredients[j].classid, -1, this.validIngredients[j].gid);
  14.  
  15.                                         if (item && this.validItem(item, recipe)) { // 26.11.2012. check if the item actually belongs to the given recipe
  16.                                                 if(item.location === 3 || !optimalItem) {
  17.                                                         optimalItem = item;
  18.                                                 }
  19.                                                 break;
  20.                                         }
  21.                                 }
  22.                         }
  23.                         if(!optimalItem) {
  24.                                 // don't repeat the same item
  25.                                 usedGids.push(optimalItem.gid);
  26.                                 // push the item into the match list
  27.                                 matchList.push(copyUnit(optimalItem));
  28.                         }
  29.  
  30.                         // no new items in the match list = not enough ingredients
  31.                         if (matchList.length !== i + 1) {
  32.                                 return false;
  33.                         }
  34.                 }
  35.  
  36.                 // return the match list. these items go to cube
  37.                 return matchList;
  38.         },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement