mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
useCompatibility
This commit is contained in:
1 parent
33bb8ead3c
commit
750bdd236a
7 files changed
+59
-38
No files matched your search
@@ -1,57 +0,0 @@
|
||||
import {
|
||||
Consumable,
|
||||
ConsumableTankCategoryFilterCategory,
|
||||
GunDefinition,
|
||||
Provision,
|
||||
TankDefinition,
|
||||
} from "@blitzkit/protos";
|
||||
|
||||
export function checkConsumableProvisionInclusivity(
|
||||
consumableProvision: Consumable | Provision,
|
||||
tank: TankDefinition,
|
||||
gun: GunDefinition,
|
||||
) {
|
||||
const included = consumableProvision.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 = consumableProvision.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 consumableProvision.include?.length > 0 && included && !excluded;
|
||||
}
|
||||
Reference in new issue
Block a user