mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-16 06:06:11 +01:00
checkpoint
This commit is contained in:
1 parent
c2714c4d6b
commit
a75c47865b
9 files changed
+70
-61
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { isTankCompatible } from "@blitzkit/core";
|
||||
import {
|
||||
ConsumableTankCategoryFilterCategory,
|
||||
GunDefinition,
|
||||
TankDefinition,
|
||||
TankInclusivityFilter,
|
||||
@@ -13,54 +13,3 @@ export function useTankCompatibility(tank: TankDefinition, gun: GunDefinition) {
|
||||
return isTankCompatible(tank, gun, include, exclude);
|
||||
};
|
||||
}
|
||||
|
||||
export function isTankCompatible(
|
||||
tank: TankDefinition,
|
||||
gun: GunDefinition,
|
||||
include?: TankInclusivityFilter[],
|
||||
exclude?: TankInclusivityFilter[],
|
||||
) {
|
||||
const included = include?.every((rule) => {
|
||||
switch (rule.filter_type!.$case) {
|
||||
case "tiers":
|
||||
return (
|
||||
rule.filter_type!.value.min <= tank.tier &&
|
||||
tank.tier <= rule.filter_type!.value.max
|
||||
);
|
||||
|
||||
case "ids":
|
||||
return rule.filter_type!.value.ids.includes(tank.id);
|
||||
|
||||
case "nations":
|
||||
return rule.filter_type!.value.nations.includes(tank.nation);
|
||||
|
||||
case "categories":
|
||||
throw new SyntaxError("Category filtering found in include rule");
|
||||
}
|
||||
});
|
||||
const excluded = exclude?.some((rule) => {
|
||||
switch (rule.filter_type!.$case) {
|
||||
case "tiers":
|
||||
return (
|
||||
rule.filter_type!.value.min <= tank.tier &&
|
||||
tank.tier <= rule.filter_type!.value.max
|
||||
);
|
||||
|
||||
case "ids":
|
||||
return rule.filter_type!.value.ids.includes(tank.id);
|
||||
|
||||
case "nations":
|
||||
return rule.filter_type!.value.nations.includes(tank.nation);
|
||||
|
||||
case "categories":
|
||||
return rule.filter_type!.value.categories.some((category) => {
|
||||
switch (category) {
|
||||
case ConsumableTankCategoryFilterCategory.CONSUMABLE_TANK_CATEGORY_FILTER_CATEGORY_CLIP:
|
||||
return gun.gun_type!.$case !== "regular";
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return include !== undefined && include?.length > 0 && included && !excluded;
|
||||
}
|
||||
Reference in new issue
Block a user