Chef update (#11189)
* Sort recipes based on total ingredient count Fix the recipe sort function so that recipes with more ingredients are matched first. This fixes vegetable pizzas and allows more complex recipes in the future. * Chef update * Pet linter
This commit is contained in:
@@ -35,5 +35,21 @@ namespace Content.Shared.Kitchen
|
||||
|
||||
public IReadOnlyDictionary<string, FixedPoint2> IngredientsReagents => _ingsReagents;
|
||||
public IReadOnlyDictionary<string, FixedPoint2> IngredientsSolids => _ingsSolids;
|
||||
|
||||
/// <summary>
|
||||
/// Count the number of ingredients in a recipe for sorting the recipe list.
|
||||
/// This makes sure that where ingredient lists overlap, the more complex
|
||||
/// recipe is picked first.
|
||||
/// </summary>
|
||||
public FixedPoint2 IngredientCount()
|
||||
{
|
||||
FixedPoint2 n = 0;
|
||||
n += _ingsReagents.Count; // number of distinct reagents
|
||||
foreach (FixedPoint2 i in _ingsSolids.Values) // sum the number of solid ingredients
|
||||
{
|
||||
n += i;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,9 @@ namespace Content.Shared.Kitchen
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -x.IngredientsReagents.Count.CompareTo(y.IngredientsReagents.Count);
|
||||
var nx = x.IngredientCount();
|
||||
var ny = y.IngredientCount();
|
||||
return -nx.CompareTo(ny);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user