mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-11 16:26:22 +00:00
Reduce bias towards standard in event selection.
Make allowedEvents override other filters. Ensure set pool filter can't filter out every event.
This commit is contained in:
@@ -175,17 +175,17 @@ public class AdventureEventData implements Serializable {
|
|||||||
private static final Predicate<CardEdition> filterStandard = FModel.getFormats().getStandard().editionLegalPredicate;
|
private static final Predicate<CardEdition> filterStandard = FModel.getFormats().getStandard().editionLegalPredicate;
|
||||||
|
|
||||||
public static Predicate<CardEdition> selectSetPool() {
|
public static Predicate<CardEdition> selectSetPool() {
|
||||||
// Should we negate any of these to avoid overlap?
|
|
||||||
final int rollD100 = MyRandom.getRandom().nextInt(100);
|
final int rollD100 = MyRandom.getRandom().nextInt(100);
|
||||||
Predicate<CardEdition> rolledFilter;
|
Predicate<CardEdition> rolledFilter;
|
||||||
if (rollD100 < 30) {
|
if (rollD100 < 30) {
|
||||||
rolledFilter = filterStandard;
|
rolledFilter = filterStandard;
|
||||||
} else if (rollD100 < 60) {
|
} else if (rollD100 < 60) {
|
||||||
rolledFilter = filterPioneer;
|
// Remove standard from older pools because its representation is already inflated.
|
||||||
|
rolledFilter = filterPioneer.and(filterStandard.negate());
|
||||||
} else if (rollD100 < 80) {
|
} else if (rollD100 < 80) {
|
||||||
rolledFilter = filterModern;
|
rolledFilter = filterModern.and(filterStandard.negate());
|
||||||
} else {
|
} else {
|
||||||
rolledFilter = filterVintage;
|
rolledFilter = filterVintage.and(filterStandard.negate());
|
||||||
}
|
}
|
||||||
return rolledFilter;
|
return rolledFilter;
|
||||||
}
|
}
|
||||||
@@ -195,25 +195,33 @@ public class AdventureEventData implements Serializable {
|
|||||||
private static CardBlock pickWeightedCardBlock() {
|
private static CardBlock pickWeightedCardBlock() {
|
||||||
CardEdition.Collection editions = FModel.getMagicDb().getEditions();
|
CardEdition.Collection editions = FModel.getMagicDb().getEditions();
|
||||||
ConfigData configData = Config.instance().getConfigData();
|
ConfigData configData = Config.instance().getConfigData();
|
||||||
Predicate<CardEdition> filter = CardEdition.Predicates.CAN_MAKE_BOOSTER.and(selectSetPool());
|
Predicate<CardEdition> filter = CardEdition.Predicates.CAN_MAKE_BOOSTER;
|
||||||
|
|
||||||
if(configData.allowedEvents != null) {
|
if(configData.allowedEvents != null) {
|
||||||
Set<String> allowedEvents = Set.of(configData.allowedEvents);
|
Set<String> allowedEvents = Set.of(configData.allowedEvents);
|
||||||
filter = filter.and(q -> allowedEvents.contains(q.getCode()));
|
filter = filter.and(q -> allowedEvents.contains(q.getCode()));
|
||||||
}
|
}
|
||||||
else if(configData.restrictedEvents != null) {
|
else
|
||||||
//Temporary restriction until rewards are more diverse - don't want to award restricted cards so these editions need different rewards added.
|
{
|
||||||
//Also includes sets that use conspiracy or commander drafts.
|
//The whitelist beats all other filters.
|
||||||
Set<String> restrictedEvents = Set.of(configData.restrictedEvents);
|
if(configData.restrictedEvents != null) {
|
||||||
filter = filter.and((q) -> !restrictedEvents.contains(q.getCode()));
|
//Temporary restriction until rewards are more diverse - don't want to award restricted cards so these editions need different rewards added.
|
||||||
}
|
//Also includes sets that use conspiracy or commander drafts.
|
||||||
if (configData.allowedEditions != null) {
|
Set<String> restrictedEvents = Set.of(configData.restrictedEvents);
|
||||||
Set<String> allowed = Set.of(configData.allowedEditions);
|
filter = filter.and((q) -> !restrictedEvents.contains(q.getCode()));
|
||||||
filter = filter.and(q -> allowed.contains(q.getCode()));
|
}
|
||||||
} else if(configData.restrictedEditions != null) {
|
if (configData.allowedEditions != null) {
|
||||||
List<String> restrictedList = Arrays.asList(configData.restrictedEditions);
|
Set<String> allowed = Set.of(configData.allowedEditions);
|
||||||
Set<String> restricted = new HashSet<>(restrictedList); //Would use Set.of but that throws an error if there's any duplicates, and users edit these lists all the time.
|
filter = filter.and(q -> allowed.contains(q.getCode()));
|
||||||
filter = filter.and(q -> !restricted.contains(q.getCode()));
|
} else if(configData.restrictedEditions != null) {
|
||||||
|
List<String> restrictedList = Arrays.asList(configData.restrictedEditions);
|
||||||
|
Set<String> restricted = new HashSet<>(restrictedList); //Would use Set.of but that throws an error if there's any duplicates, and users edit these lists all the time.
|
||||||
|
filter = filter.and(q -> !restricted.contains(q.getCode()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Predicate<CardEdition> setPoolFilter = selectSetPool();
|
||||||
|
if(editions.stream().anyMatch(setPoolFilter))
|
||||||
|
filter = filter.and(setPoolFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<CardEdition> allEditions = new ArrayList<>();
|
List<CardEdition> allEditions = new ArrayList<>();
|
||||||
|
|||||||
Reference in New Issue
Block a user