Skip to content

Commit

Permalink
fix(refine): refine should be sorted by result name, not its id
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Apr 19, 2023
1 parent 7dd6358 commit a83c155
Showing 1 changed file with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class RefiningPageDisplayComponent implements OnInit, OnChanges, OnDestro
public itemOutputs: Record<string, IGameItem> = {};
public resourceOutputs: Record<string, IGameResource> = {};
public rarityOutputs: Record<string, string> = {};
public outputIdToName: Record<string, string> = {};

public summedResources: Record<string, number> = {};

Expand All @@ -87,6 +88,8 @@ export class RefiningPageDisplayComponent implements OnInit, OnChanges, OnDestro
ngOnInit() {
this.allStarredRecipes = this.starredRecipes || {};

this.setIngredients();
this.setResults();
this.setVisibleRecipes();
this.setRefiningWorkerHash();
this.setTotalResources();
Expand Down Expand Up @@ -169,15 +172,13 @@ export class RefiningPageDisplayComponent implements OnInit, OnChanges, OnDestro
this.setType('resources');
}

this.setIngredients();
this.setCanCrafts();
this.setResults();
}

setIngredients() {
this.ingredients = {};

[...this.resourceRecipes, ...this.itemRecipes].forEach((recipe) => {
this.locationData.forEach((recipe) => {
this.ingredients[recipe.result] = Object.keys(recipe.ingredients || {})
.filter(x => this.contentService.isResource(x))
.map((name) => ({ name, amount: recipe.ingredients[name] }));
Expand All @@ -202,15 +203,21 @@ export class RefiningPageDisplayComponent implements OnInit, OnChanges, OnDestro
this.resourceOutputs = {};
this.rarityOutputs = {};

this.itemRecipes.forEach((recipe) => {
this.itemOutputs[recipe.result] = this.contentService.getItemByName(recipe.result) as IGameItem;
this.rarityOutputs[recipe.result] = this.itemOutputs[recipe.result].rarity;
});
this.locationData
.filter((recipe: IGameRecipe) => this.contentService.isItem(recipe.result))
.forEach((recipe: IGameRecipe) => {
this.itemOutputs[recipe.result] = this.contentService.getItemByName(recipe.result) as IGameItem;
this.rarityOutputs[recipe.result] = this.itemOutputs[recipe.result].rarity;
this.outputIdToName[recipe.result] = this.itemOutputs[recipe.result].name;
});

this.resourceRecipes.forEach((recipe) => {
this.resourceOutputs[recipe.result] = this.contentService.getResourceByName(recipe.result) as IGameResource;
this.rarityOutputs[recipe.result] = this.resourceOutputs[recipe.result].rarity;
});
this.locationData
.filter((recipe: IGameRecipe) => this.contentService.isResource(recipe.result))
.forEach((recipe: IGameRecipe) => {
this.resourceOutputs[recipe.result] = this.contentService.getResourceByName(recipe.result) as IGameResource;
this.rarityOutputs[recipe.result] = this.resourceOutputs[recipe.result].rarity;
this.outputIdToName[recipe.result] = this.resourceOutputs[recipe.result].name;
});
}

setRefiningWorkerHash() {
Expand Down Expand Up @@ -349,7 +356,7 @@ export class RefiningPageDisplayComponent implements OnInit, OnChanges, OnDestro
return sortBy(validRecipes, [
(recipe) => !this.allStarredRecipes[recipe.result],
(recipe) => !this.canCraftRecipe(recipe),
(recipe) => recipe.result
(recipe) => this.outputIdToName[recipe.result]
]);
}

Expand Down

0 comments on commit a83c155

Please sign in to comment.