mirror of
https://github.com/Kornstalx/5etools-mirror-2.github.io.git
synced 2025-10-28 20:45:35 -05:00
v1.199.1
This commit is contained in:
@@ -25,6 +25,13 @@ class PageFilterRecipes extends PageFilter {
|
||||
itemSortFn: SortUtil.ascSortLower,
|
||||
});
|
||||
this._servesFilter = new RangeFilter({header: "Serves", min: 1, max: 1});
|
||||
this._timeFilterTotal = new RangeFilter({header: "Total", min: 10, max: 60, displayFn: time => Parser.getMinutesToFull(time, {isShort: true}), displayFnTooltip: Parser.getMinutesToFull});
|
||||
this._timeFilterPreparation = new RangeFilter({header: "Preparation", min: 10, max: 60, displayFn: time => Parser.getMinutesToFull(time, {isShort: true}), displayFnTooltip: Parser.getMinutesToFull});
|
||||
this._timeFilterCooking = new RangeFilter({header: "Cooking", min: 10, max: 60, displayFn: time => Parser.getMinutesToFull(time, {isShort: true}), displayFnTooltip: Parser.getMinutesToFull});
|
||||
this._timeFilter = new MultiFilter({
|
||||
header: "Time",
|
||||
filters: [this._timeFilterTotal, this._timeFilterPreparation, this._timeFilterCooking],
|
||||
});
|
||||
this._dietFilter = new Filter({
|
||||
header: "Diet",
|
||||
displayFn: PageFilterRecipes._dietToFull,
|
||||
@@ -48,11 +55,52 @@ class PageFilterRecipes extends PageFilter {
|
||||
if (SourceUtil.isLegacySourceWotc(it.source)) it._fMisc.push("Legacy");
|
||||
if (it.miscTags) it._fMisc.push(...it.miscTags);
|
||||
it._fServes = (it.serves?.min != null && it.serves?.max != null) ? [it.serves.min, it.serves.max] : (it.serves?.exact ?? null);
|
||||
const totalTime = it.time?.total ?? this._mutateForFilters_getTotalTime(it.time);
|
||||
it._fTimeTotal = totalTime != null ? this._mutateForFilters_getFilterTime(totalTime) : null;
|
||||
it._fTimePreparation = it.time?.preparation ? this._mutateForFilters_getFilterTime(it.time.preparation) : null;
|
||||
it._fTimeCooking = it.time?.cooking ? this._mutateForFilters_getFilterTime(it.time.cooking) : null;
|
||||
it._fDiet = it.diet ? PageFilterRecipes._DIET_TO_FULL[it.diet] || it.diet : null;
|
||||
if (it.hasFluff || it.fluff?.entries) it._fMisc.push("Has Info");
|
||||
if (it.hasFluffImages || it.fluff?.images) it._fMisc.push("Has Images");
|
||||
}
|
||||
|
||||
static _ONE_DAY_MINS = 24 * 60;
|
||||
|
||||
static _mutateForFilters_getTotalTime (time) {
|
||||
if (time == null) return null;
|
||||
|
||||
let min = 0; let max = 0;
|
||||
|
||||
Object.values(time)
|
||||
.forEach(val => {
|
||||
if (val.min != null && val.max != null) {
|
||||
min += val.min;
|
||||
max += val.max;
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof val === "number") {
|
||||
min += val;
|
||||
max += val;
|
||||
}
|
||||
});
|
||||
|
||||
if (!min && !max) return null;
|
||||
|
||||
// Heuristic -- if calculated total time is longer than a day, we probably don't want to display it
|
||||
// e.g. when including long "fermentation" time
|
||||
if (min >= this._ONE_DAY_MINS || max >= this._ONE_DAY_MINS) return null;
|
||||
|
||||
if (min === max) return min;
|
||||
return {min, max};
|
||||
}
|
||||
|
||||
static _mutateForFilters_getFilterTime (val) {
|
||||
if (val.min != null && val.max != null) return [val.min, val.max];
|
||||
if (typeof val === "number") return val;
|
||||
return null;
|
||||
}
|
||||
|
||||
addToFilters (it, isExcluded) {
|
||||
if (isExcluded) return;
|
||||
|
||||
@@ -60,6 +108,9 @@ class PageFilterRecipes extends PageFilter {
|
||||
this._typeFilter.addItem(it.type);
|
||||
this._dishTypeFilter.addItem(it.dishTypes);
|
||||
this._servesFilter.addItem(it._fServes);
|
||||
this._timeFilterTotal.addItem(it._fTimeTotal);
|
||||
this._timeFilterPreparation.addItem(it._fTimePreparation);
|
||||
this._timeFilterCooking.addItem(it._fTimeCooking);
|
||||
this._dietFilter.addItem(it._fDiet);
|
||||
this._allergensFilter.addItem(it.allergenGroups);
|
||||
this._miscFilter.addItem(it._fMisc);
|
||||
@@ -71,6 +122,7 @@ class PageFilterRecipes extends PageFilter {
|
||||
this._typeFilter,
|
||||
this._dishTypeFilter,
|
||||
this._servesFilter,
|
||||
this._timeFilter,
|
||||
this._dietFilter,
|
||||
this._allergensFilter,
|
||||
this._miscFilter,
|
||||
@@ -84,6 +136,11 @@ class PageFilterRecipes extends PageFilter {
|
||||
it.type,
|
||||
it.dishTypes,
|
||||
it._fServes,
|
||||
[
|
||||
it._fTimeTotal,
|
||||
it._fTimePreparation,
|
||||
it._fTimeCooking,
|
||||
],
|
||||
it._fDiet,
|
||||
it.allergenGroups,
|
||||
it._fMisc,
|
||||
|
||||
Reference in New Issue
Block a user