mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
fix: some filtering
This commit is contained in:
1 parent
532d677491
commit
a8cdc96382
2 files changed
+36
-12
No files matched your search
@@ -4,54 +4,54 @@ import {
|
|||||||
GunDefinition,
|
GunDefinition,
|
||||||
Provision,
|
Provision,
|
||||||
TankDefinition,
|
TankDefinition,
|
||||||
} from '../protos';
|
} from "../protos";
|
||||||
|
|
||||||
export function checkConsumableProvisionInclusivity(
|
export function checkConsumableProvisionInclusivity(
|
||||||
consumableProvision: Consumable | Provision,
|
consumableProvision: Consumable | Provision,
|
||||||
tank: TankDefinition,
|
tank: TankDefinition,
|
||||||
gun: GunDefinition,
|
gun: GunDefinition
|
||||||
) {
|
) {
|
||||||
const included =
|
const included =
|
||||||
!consumableProvision.game_mode_exclusive &&
|
!consumableProvision.game_mode_exclusive &&
|
||||||
consumableProvision.include?.every((rule) => {
|
consumableProvision.include?.every((rule) => {
|
||||||
switch (rule.filter_type!.$case) {
|
switch (rule.filter_type!.$case) {
|
||||||
case 'tiers':
|
case "tiers":
|
||||||
return (
|
return (
|
||||||
rule.filter_type!.value.min <= tank.tier &&
|
rule.filter_type!.value.min <= tank.tier &&
|
||||||
tank.tier <= rule.filter_type!.value.max
|
tank.tier <= rule.filter_type!.value.max
|
||||||
);
|
);
|
||||||
|
|
||||||
case 'ids':
|
case "ids":
|
||||||
return rule.filter_type!.value.ids.includes(tank.id);
|
return rule.filter_type!.value.ids.includes(tank.id);
|
||||||
|
|
||||||
case 'nations':
|
case "nations":
|
||||||
return rule.filter_type!.value.nations.includes(tank.nation);
|
return rule.filter_type!.value.nations.includes(tank.nation);
|
||||||
|
|
||||||
case 'categories':
|
case "categories":
|
||||||
throw new SyntaxError('Category filtering found in include rule');
|
throw new SyntaxError("Category filtering found in include rule");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const excluded =
|
const excluded =
|
||||||
consumableProvision.game_mode_exclusive ||
|
consumableProvision.game_mode_exclusive ||
|
||||||
consumableProvision.exclude?.some((rule) => {
|
consumableProvision.exclude?.some((rule) => {
|
||||||
switch (rule.filter_type!.$case) {
|
switch (rule.filter_type!.$case) {
|
||||||
case 'tiers':
|
case "tiers":
|
||||||
return (
|
return (
|
||||||
rule.filter_type!.value.min <= tank.tier &&
|
rule.filter_type!.value.min <= tank.tier &&
|
||||||
tank.tier <= rule.filter_type!.value.max
|
tank.tier <= rule.filter_type!.value.max
|
||||||
);
|
);
|
||||||
|
|
||||||
case 'ids':
|
case "ids":
|
||||||
return rule.filter_type!.value.ids.includes(tank.id);
|
return rule.filter_type!.value.ids.includes(tank.id);
|
||||||
|
|
||||||
case 'nations':
|
case "nations":
|
||||||
return rule.filter_type!.value.nations.includes(tank.nation);
|
return rule.filter_type!.value.nations.includes(tank.nation);
|
||||||
|
|
||||||
case 'categories':
|
case "categories":
|
||||||
return rule.filter_type!.value.categories.some((category) => {
|
return rule.filter_type!.value.categories.some((category) => {
|
||||||
switch (category) {
|
switch (category) {
|
||||||
case ConsumableTankCategoryFilterCategory.CLIP:
|
case ConsumableTankCategoryFilterCategory.CLIP:
|
||||||
return gun.gun_type!.$case !== 'regular';
|
return gun.gun_type!.$case !== "regular";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,30 @@ export async function filterTank(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)) &&
|
||||||
|
(filters.abilities.length === 0 ||
|
||||||
|
filters.abilities.every((ability) =>
|
||||||
|
tank.turrets.some((turret) =>
|
||||||
|
turret.guns.some((gun) =>
|
||||||
|
checkConsumableProvisionInclusivity(
|
||||||
|
consumableDefinitions.consumables[ability],
|
||||||
|
tank,
|
||||||
|
gun
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)) &&
|
||||||
|
(filters.powers.length === 0 ||
|
||||||
|
filters.powers.every((power) =>
|
||||||
|
tank.turrets.some((turret) =>
|
||||||
|
turret.guns.some((gun) =>
|
||||||
|
checkConsumableProvisionInclusivity(
|
||||||
|
provisionDefinitions.provisions[power],
|
||||||
|
tank,
|
||||||
|
gun
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user