small complexity rewrite

This commit is contained in:
Ingmar Goudt 2019-07-11 15:44:46 +02:00
parent d9ace1b66f
commit b704618f32
2 changed files with 8 additions and 15 deletions

View file

@ -35,14 +35,10 @@ public enum GetKickerXValue implements DynamicValue {
// search that kicker used X value
KickerAbility kickerAbility = (KickerAbility) ability;
boolean haveVarCost = false;
for (OptionalAdditionalCost cost : kickerAbility.getKickerCosts()) {
List<VariableCost> varCosts = ((OptionalAdditionalCostImpl) cost).getVariableCosts();
if (!varCosts.isEmpty()) {
haveVarCost = true;
break;
}
}
boolean haveVarCost = kickerAbility.getKickerCosts()
.stream()
.anyMatch(varCost -> !((OptionalAdditionalCostImpl) varCost).getVariableCosts().isEmpty());
if (haveVarCost) {
int kickedCount = ((KickerAbility) ability).getKickedCounter(game, source);

View file

@ -3049,13 +3049,10 @@ public abstract class PlayerImpl implements Player, Serializable {
protected boolean canLandPlayAlternateSourceCostsAbility(Card sourceObject, ManaOptions available, Ability
ability, Game game) {
if (!(sourceObject instanceof Permanent)) {
Ability sourceAbility = null;
for (Ability landAbility : sourceObject.getAbilities()) {
if (landAbility.getAbilityType() == AbilityType.PLAY_LAND) {
sourceAbility = landAbility;
break;
}
}
Ability sourceAbility = sourceObject.getAbilities().stream()
.filter(landAbility -> landAbility.getAbilityType() == AbilityType.PLAY_LAND)
.findFirst().orElse(null);
if (sourceAbility != null && ((AlternativeSourceCosts) ability).isAvailable(sourceAbility, game)) {
if (ability.getCosts().canPay(ability, sourceObject.getId(), this.getId(), game)) {
ManaCostsImpl manaCosts = new ManaCostsImpl();