feat: enable gamemode exclusive

This commit is contained in:
TrèsAbhi committed 2026-01-02 11:32:27 -06:00
1 parent ee5461a297
commit 9df5efa422
2 files changed
+170 -183

No files matched your search

@@ -11,56 +11,47 @@ export function checkConsumableProvisionInclusivity(
tank: TankDefinition, tank: TankDefinition,
gun: GunDefinition gun: GunDefinition
) { ) {
const included = const included = consumableProvision.include?.every((rule) => {
!consumableProvision.game_mode_exclusive && switch (rule.filter_type!.$case) {
consumableProvision.include?.every((rule) => { case "tiers":
switch (rule.filter_type!.$case) { return (
case "tiers": rule.filter_type!.value.min <= tank.tier &&
return ( tank.tier <= rule.filter_type!.value.max
rule.filter_type!.value.min <= tank.tier && );
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.exclude?.some((rule) => {
consumableProvision.game_mode_exclusive || switch (rule.filter_type!.$case) {
consumableProvision.exclude?.some((rule) => { case "tiers":
switch (rule.filter_type!.$case) { return (
case "tiers": rule.filter_type!.value.min <= tank.tier &&
return ( tank.tier <= rule.filter_type!.value.max
rule.filter_type!.value.min <= tank.tier && );
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";
} }
}); });
} }
}); });
return ( return consumableProvision.include?.length > 0 && included && !excluded;
!consumableProvision.game_mode_exclusive &&
consumableProvision.include?.length > 0 &&
included &&
!excluded
);
} }
+134 -138
View File
@@ -1557,87 +1557,85 @@ export async function definitions() {
const includeRaw = consumable.vehicleFilter?.include.vehicle; const includeRaw = consumable.vehicleFilter?.include.vehicle;
const excludeRaw = consumable.vehicleFilter?.exclude?.vehicle; const excludeRaw = consumable.vehicleFilter?.exclude?.vehicle;
if (!entry.game_mode_exclusive) { if (includeRaw) {
if (includeRaw) { entry.include = [];
entry.include = [];
if ("minLevel" in includeRaw) { if ("minLevel" in includeRaw) {
entry.include.push({ entry.include.push({
filter_type: { filter_type: {
$case: "tiers", $case: "tiers",
value: { value: {
min: includeRaw.minLevel, min: includeRaw.minLevel,
max: includeRaw.maxLevel, max: includeRaw.maxLevel,
},
}, },
}); },
} else if ("name" in includeRaw) { });
entry.include.push({ } else if ("name" in includeRaw) {
filter_type: { entry.include.push({
$case: "ids", filter_type: {
value: { $case: "ids",
ids: includeRaw.name.split(/ +/).map((key) => { value: {
return tankStringIdMap[key]; ids: includeRaw.name.split(/ +/).map((key) => {
}), return tankStringIdMap[key];
}, }),
}, },
}); },
} else throw new SyntaxError("Unhandled include type"); });
} else throw new SyntaxError("Unhandled include type");
if (consumable.vehicleFilter?.include.nations) { if (consumable.vehicleFilter?.include.nations) {
entry.include.push({ entry.include.push({
filter_type: { filter_type: {
$case: "nations", $case: "nations",
value: { value: {
nations: consumable.vehicleFilter.include.nations.split(" "), nations: consumable.vehicleFilter.include.nations.split(" "),
},
}, },
}); },
} });
} }
}
if (excludeRaw) { if (excludeRaw) {
entry.exclude = []; entry.exclude = [];
if ("name" in excludeRaw) { if ("name" in excludeRaw) {
entry.exclude!.push({ entry.exclude!.push({
filter_type: { filter_type: {
$case: "ids", $case: "ids",
value: { value: {
ids: excludeRaw.name.split(/ +/).map((key) => { ids: excludeRaw.name.split(/ +/).map((key) => {
return tankStringIdMap[key]; return tankStringIdMap[key];
}), }),
},
}, },
}); },
} else if ("extendedTags" in excludeRaw) { });
entry.exclude!.push({ } else if ("extendedTags" in excludeRaw) {
filter_type: { entry.exclude!.push({
$case: "categories", filter_type: {
value: { $case: "categories",
categories: excludeRaw.extendedTags value: {
.split(" ") categories: excludeRaw.extendedTags
.map( .split(" ")
(item) => .map(
blitzTankFilterDefinitionCategoryToBlitzkit[ (item) =>
item as BlitzTankFilterDefinitionCategory blitzTankFilterDefinitionCategoryToBlitzkit[
] item as BlitzTankFilterDefinitionCategory
), ]
}, ),
}, },
}); },
} else throw new SyntaxError("Unhandled exclude type"); });
} else throw new SyntaxError("Unhandled exclude type");
if (consumable.vehicleFilter?.exclude?.nations) { if (consumable.vehicleFilter?.exclude?.nations) {
entry.exclude!.push({ entry.exclude!.push({
filter_type: { filter_type: {
$case: "nations", $case: "nations",
value: { value: {
nations: consumable.vehicleFilter.exclude.nations.split(" "), nations: consumable.vehicleFilter.exclude.nations.split(" "),
},
}, },
}); },
} });
} }
} }
}); });
@@ -1657,87 +1655,85 @@ export async function definitions() {
const includeRaw = provision.vehicleFilter?.include.vehicle; const includeRaw = provision.vehicleFilter?.include.vehicle;
const excludeRaw = provision.vehicleFilter?.exclude?.vehicle; const excludeRaw = provision.vehicleFilter?.exclude?.vehicle;
if (!entry.game_mode_exclusive) { if (includeRaw) {
if (includeRaw) { entry.include = [];
entry.include = [];
if ("minLevel" in includeRaw) { if ("minLevel" in includeRaw) {
entry.include.push({ entry.include.push({
filter_type: { filter_type: {
$case: "tiers", $case: "tiers",
value: { value: {
min: includeRaw.minLevel, min: includeRaw.minLevel,
max: includeRaw.maxLevel, max: includeRaw.maxLevel,
},
}, },
}); },
} else if ("name" in includeRaw) { });
entry.include.push({ } else if ("name" in includeRaw) {
filter_type: { entry.include.push({
$case: "ids", filter_type: {
value: { $case: "ids",
ids: includeRaw.name.split(/ +/).map((key) => { value: {
return tankStringIdMap[key]; ids: includeRaw.name.split(/ +/).map((key) => {
}), return tankStringIdMap[key];
}, }),
}, },
}); },
} else throw new SyntaxError("Unhandled include type"); });
} else throw new SyntaxError("Unhandled include type");
if (provision.vehicleFilter?.include.nations) { if (provision.vehicleFilter?.include.nations) {
entry.include.push({ entry.include.push({
filter_type: { filter_type: {
$case: "nations", $case: "nations",
value: { value: {
nations: provision.vehicleFilter.include.nations.split(" "), nations: provision.vehicleFilter.include.nations.split(" "),
},
}, },
}); },
} });
} }
}
if (excludeRaw) { if (excludeRaw) {
entry.exclude = []; entry.exclude = [];
if ("name" in excludeRaw) { if ("name" in excludeRaw) {
entry.exclude!.push({ entry.exclude!.push({
filter_type: { filter_type: {
$case: "ids", $case: "ids",
value: { value: {
ids: excludeRaw.name ids: excludeRaw.name
.split(/ +/) .split(/ +/)
.map((key) => tankStringIdMap[key]), .map((key) => tankStringIdMap[key]),
},
}, },
}); },
} else if ("extendedTags" in excludeRaw) { });
entry.exclude!.push({ } else if ("extendedTags" in excludeRaw) {
filter_type: { entry.exclude!.push({
$case: "categories", filter_type: {
value: { $case: "categories",
categories: excludeRaw.extendedTags value: {
.split(" ") categories: excludeRaw.extendedTags
.map( .split(" ")
(item) => .map(
blitzTankFilterDefinitionCategoryToBlitzkit[ (item) =>
item as BlitzTankFilterDefinitionCategory blitzTankFilterDefinitionCategoryToBlitzkit[
] item as BlitzTankFilterDefinitionCategory
), ]
}, ),
}, },
}); },
} else throw new SyntaxError("Unhandled exclude type"); });
} else throw new SyntaxError("Unhandled exclude type");
if (provision.vehicleFilter?.exclude?.nations) { if (provision.vehicleFilter?.exclude?.nations) {
entry.exclude!.push({ entry.exclude!.push({
filter_type: { filter_type: {
$case: "nations", $case: "nations",
value: { value: {
nations: provision.vehicleFilter.exclude.nations.split(" "), nations: provision.vehicleFilter.exclude.nations.split(" "),
},
}, },
}); },
} });
} }
} }