Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- checkRecipe: function (recipe) {
- var i, j, item,
- usedGids = [],
- matchList = [];
- for (i = 0; i < recipe.Ingredients.length; i += 1) {
- var optimalItem;
- for (j = 0; j < this.validIngredients.length; j += 1) {
- if (usedGids.indexOf(this.validIngredients[j].gid) === -1 &&
- (this.validIngredients[j].classid === recipe.Ingredients[i] || (recipe.Ingredients[i] === "pgem" &&
- this.gemList.indexOf(this.validIngredients[j].classid) > -1))
- ) {
- item = me.getItem(this.validIngredients[j].classid, -1, this.validIngredients[j].gid);
- if (item && this.validItem(item, recipe)) { // 26.11.2012. check if the item actually belongs to the given recipe
- if(item.location === 3 || !optimalItem) {
- optimalItem = item;
- }
- break;
- }
- }
- }
- if(!optimalItem) {
- // don't repeat the same item
- usedGids.push(optimalItem.gid);
- // push the item into the match list
- matchList.push(copyUnit(optimalItem));
- }
- // no new items in the match list = not enough ingredients
- if (matchList.length !== i + 1) {
- return false;
- }
- }
- // return the match list. these items go to cube
- return matchList;
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement