Added new filters for picking allies in a given region, or the fellowship's current region. Altered blueprint ally home definition to support multiple home sites.
This commit is contained in:
@@ -6,14 +6,18 @@ import com.gempukku.lotro.cards.build.FieldProcessor;
|
|||||||
import com.gempukku.lotro.cards.build.InvalidCardDefinitionException;
|
import com.gempukku.lotro.cards.build.InvalidCardDefinitionException;
|
||||||
import com.gempukku.lotro.common.SitesBlock;
|
import com.gempukku.lotro.common.SitesBlock;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class AllyHomeFieldProcessor implements FieldProcessor {
|
public class AllyHomeFieldProcessor implements FieldProcessor {
|
||||||
@Override
|
@Override
|
||||||
public void processField(String key, Object value, BuiltLotroCardBlueprint blueprint, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
public void processField(String key, Object value, BuiltLotroCardBlueprint blueprint, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
||||||
final String allyHome = FieldUtils.getString(value, "allyHome");
|
final String allyHome = FieldUtils.getString(value, "allyHome");
|
||||||
final String[] allyHomeSplit = allyHome.split(",", 2);
|
final String[] allyHomeSplit = allyHome.split(",", 4);
|
||||||
SitesBlock sitesBlock = Enum.valueOf(SitesBlock.class, allyHomeSplit[0].toUpperCase().replace(' ', '_'));
|
SitesBlock sitesBlock = Enum.valueOf(SitesBlock.class, allyHomeSplit[0].toUpperCase().replace(' ', '_'));
|
||||||
final int number = Integer.parseInt(allyHomeSplit[1]);
|
|
||||||
|
|
||||||
blueprint.setAllyHomeSites(sitesBlock, new int[]{number});
|
String[] sites = Arrays.copyOfRange(allyHomeSplit, 1, allyHomeSplit.length);
|
||||||
|
int[] numbers = Arrays.stream(sites).mapToInt(Integer::parseInt).toArray();
|
||||||
|
|
||||||
|
blueprint.setAllyHomeSites(sitesBlock, numbers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,6 +199,17 @@ public class FilterFactory {
|
|||||||
int number = Integer.parseInt(parameterSplit[1]);
|
int number = Integer.parseInt(parameterSplit[1]);
|
||||||
return (actionContext) -> Filters.isAllyHome(number, sitesBlock);
|
return (actionContext) -> Filters.isAllyHome(number, sitesBlock);
|
||||||
});
|
});
|
||||||
|
parameterFilters.put("allyInRegion",
|
||||||
|
(parameter, environment) -> {
|
||||||
|
final String[] parameterSplit = parameter.split(",");
|
||||||
|
final SitesBlock sitesBlock = Enum.valueOf(SitesBlock.class, parameterSplit[0].toUpperCase().replace('_', ' '));
|
||||||
|
int number = Integer.parseInt(parameterSplit[1]);
|
||||||
|
return (actionContext) -> Filters.isAllyInRegion(number, sitesBlock);
|
||||||
|
});
|
||||||
|
parameterFilters.put("allyInCurrentRegion",
|
||||||
|
(parameter, environment) -> {
|
||||||
|
return (actionContext) -> Filters.isAllyInCurrentRegion();
|
||||||
|
});
|
||||||
parameterFilters.put("siteBlock",
|
parameterFilters.put("siteBlock",
|
||||||
(parameter, environment) -> {
|
(parameter, environment) -> {
|
||||||
final SitesBlock sitesBlock = Enum.valueOf(SitesBlock.class, parameter.toUpperCase().replace(' ', '_'));
|
final SitesBlock sitesBlock = Enum.valueOf(SitesBlock.class, parameter.toUpperCase().replace(' ', '_'));
|
||||||
|
|||||||
@@ -665,6 +665,28 @@ public class Filters {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Filter isAllyInRegion(final int regionNumber, final SitesBlock siteBlock) {
|
||||||
|
return Filters.and(
|
||||||
|
CardType.ALLY,
|
||||||
|
new Filter() {
|
||||||
|
@Override
|
||||||
|
public boolean accepts(LotroGame game, PhysicalCard physicalCard) {
|
||||||
|
return RuleUtils.isAllyInRegion(physicalCard, regionNumber, siteBlock);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Filter isAllyInCurrentRegion() {
|
||||||
|
return Filters.and(
|
||||||
|
CardType.ALLY,
|
||||||
|
new Filter() {
|
||||||
|
@Override
|
||||||
|
public boolean accepts(LotroGame game, PhysicalCard physicalCard) {
|
||||||
|
return RuleUtils.isAllyInRegion(physicalCard, GameUtils.getRegion(game), game.getGameState().getCurrentSiteBlock());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static final Filter allyAtHome = Filters.and(
|
public static final Filter allyAtHome = Filters.and(
|
||||||
CardType.ALLY,
|
CardType.ALLY,
|
||||||
new Filter() {
|
new Filter() {
|
||||||
@@ -709,6 +731,8 @@ public class Filters {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static Filter siteNumber(final int siteNumber) {
|
public static Filter siteNumber(final int siteNumber) {
|
||||||
return siteNumberBetweenInclusive(siteNumber, siteNumber);
|
return siteNumberBetweenInclusive(siteNumber, siteNumber);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ import com.gempukku.lotro.game.LotroCardBlueprint;
|
|||||||
import com.gempukku.lotro.game.PhysicalCard;
|
import com.gempukku.lotro.game.PhysicalCard;
|
||||||
import com.gempukku.lotro.game.state.LotroGame;
|
import com.gempukku.lotro.game.state.LotroGame;
|
||||||
import com.gempukku.lotro.game.state.Skirmish;
|
import com.gempukku.lotro.game.state.Skirmish;
|
||||||
|
import com.gempukku.lotro.logic.GameUtils;
|
||||||
import com.gempukku.lotro.logic.modifiers.evaluator.Evaluator;
|
import com.gempukku.lotro.logic.modifiers.evaluator.Evaluator;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -186,4 +188,18 @@ public class RuleUtils {
|
|||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isAllyInRegion(PhysicalCard ally, int regionNumber, SitesBlock siteBlock) {
|
||||||
|
final SitesBlock allySiteBlock = ally.getBlueprint().getAllyHomeSiteBlock();
|
||||||
|
final int[] allyHomeSites = ally.getBlueprint().getAllyHomeSiteNumbers();
|
||||||
|
if (allySiteBlock != siteBlock)
|
||||||
|
return false;
|
||||||
|
// for (int number : allyHomeSites)
|
||||||
|
// if (regionNumber == GameUtils.getRegion(number))
|
||||||
|
// return true;
|
||||||
|
// return false;
|
||||||
|
|
||||||
|
return Arrays.stream(ally.getBlueprint().getAllyHomeSiteNumbers()).anyMatch(x -> regionNumber == GameUtils.getRegion(x));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user