Fix AutoChecker inventory rules

Count every inventory block towards exactly one Schematic.Limited rule:
filled blocks towards a rule whose Content allows all their items, empty
blocks towards a rule without Content (unlimited if there is none). Each
rule's Amount now caps how many blocks it covers, instead of taking the
highest Amount of all rules for that block type.

Inventory blocks whose items fit no rule are now checked and reported,
items from different rules in one block are reported as mixed, and the
auto-fix trims or removes them accordingly.

Remove the hardcoded wargearseason26 wind charge handling and its 2048
limit, wind charges are configured via Limited rules now.

Log a warning for Limited rules that match no blocks, e.g. a misspelled
'Materials' key.

Fixes #458, #481, #502
This commit is contained in:
2026-10-15 17:53:06 +02:00
parent 2b42f0d13c
commit d727982ce0
7 changed files with 123 additions and 83 deletions
@@ -19,6 +19,7 @@
package de.steamwar.sql;
import de.steamwar.sql.internal.SQLConfig;
import lombok.ToString;
import java.io.File;
@@ -250,6 +251,11 @@ public final class GameModeConfig<M, W> {
Times = new TimesConfig(loader.with("Times"));
// Arena would be here to be in config order but needs Schematic.Size and EnterStages loaded afterwards
Schematic = new SchematicConfig<>(loader.with("Schematic"));
for (int i = 0; i < Schematic.Limited.size(); i++) {
if (Schematic.Limited.get(i).Materials.isEmpty()) {
SQLConfig.impl.getLogger().warning(file.getName() + ": Schematic.Limited[" + i + "] matches no blocks, check its 'Materials' entry");
}
}
GameName = loader.getString("GameName", defaultGameName.apply(file));
ActiveMonths = loader.getIntList("ActiveMonths");
TeamChatPrefix = loader.getString("TeamChatPrefix", "+");
@@ -703,7 +709,10 @@ public final class GameModeConfig<M, W> {
public final double MaxDesignBlastResistance;
/**
* List of limited block materials
* List of limited block materials<br/>
* Every inventory block is counted towards exactly one rule: a filled block towards a rule whose
* {@link BlockRule#Content} allows all of its items, an empty block towards a rule without
* {@link BlockRule#Content}. Empty inventory blocks without such a rule are unlimited.
*
* @implSpec {@link SQLWrapper#getInventoryMaterials)} are all disallowed by default to have any content but are unlimited in number.
* @implSpec Any Block that has more Blast Resistance than {@link #MaxBlastResistance} will be defaulted to 0.
@@ -759,18 +768,13 @@ public final class GameModeConfig<M, W> {
}
public boolean isInventory(M material) {
return Limited.stream()
.filter(rule -> rule.Materials.contains(material))
.anyMatch(rule -> rule.Content.loaded);
return SQLWrapper.impl.getInventoryMaterials().contains(material) || Limited.stream().anyMatch(rule -> rule.Content.loaded && rule.Materials.contains(material));
}
public Integer getItemAmount(M material, M item) {
public List<BlockRule<M>> getRules(M material) {
return Limited.stream()
.filter(rule -> rule.Materials.contains(material))
.filter(rule -> rule.Content.Items.contains(item))
.mapToInt(rule -> rule.Content.Amount)
.max()
.orElse(0);
.collect(Collectors.toList());
}
@ToString
@@ -46,7 +46,7 @@ public interface SQLWrapper<M> {
}
/**
* Every inventory material - the {@code all} group usable in {@code GameModeConfig}'s
* Every inventory material - the {@code inventory} group usable in {@code GameModeConfig}'s
* {@code Limited}. Expected to be a superset of {@link #getStorageMaterials()}.
*/
default Set<M> getInventoryMaterials() {