mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 05:22:02 -08:00
replaced various instances of instanceof lambda functions with
This commit is contained in:
parent
26ef55c1bc
commit
26ae7b7281
21 changed files with 37 additions and 46 deletions
|
|
@ -18,7 +18,7 @@ public enum BuybackCondition implements Condition {
|
|||
Card card = game.getCard(source.getSourceId());
|
||||
if (card != null) {
|
||||
return card.getAbilities(game).stream()
|
||||
.filter(a -> a instanceof BuybackAbility)
|
||||
.filter(BuybackAbility.class::isInstance)
|
||||
.anyMatch(a -> ((BuybackAbility) a).isBuybackActivated(game));
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public enum DashedCondition implements Condition {
|
|||
Card card = game.getCard(source.getSourceId());
|
||||
if (card != null) {
|
||||
return card.getAbilities(game).stream()
|
||||
.filter(a -> a instanceof DashAbility)
|
||||
.filter(DashAbility.class::isInstance)
|
||||
.anyMatch(d -> ((DashAbility) d).isActivated(source, game));
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public enum EvokedCondition implements Condition {
|
|||
Card card = game.getCard(source.getSourceId());
|
||||
if (card != null) {
|
||||
return card.getAbilities(game).stream()
|
||||
.filter(ab -> ab instanceof EvokeAbility)
|
||||
.filter(EvokeAbility.class::isInstance)
|
||||
.anyMatch(evoke -> ((EvokeAbility) evoke).isActivated(source, game));
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter
|
|||
if (alternativeCostsToCheck.canPay(ability, ability, ability.getControllerId(), game)
|
||||
&& player.chooseUse(Outcome.Benefit, costChoiceText, this, game)) {
|
||||
if (ability instanceof SpellAbility) {
|
||||
ability.getManaCostsToPay().removeIf(manaCost -> manaCost instanceof VariableCost);
|
||||
ability.getManaCostsToPay().removeIf(VariableCost.class::isInstance);
|
||||
CardUtil.reduceCost((SpellAbility) ability, ability.getManaCosts());
|
||||
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -418,7 +418,7 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
|||
// extraPredicates from some filters is player related, you don't need it here
|
||||
List<Predicate> list = new ArrayList<>();
|
||||
Predicates.collectAllComponents(filter.getPredicates(), list);
|
||||
if (list.stream().anyMatch(p -> p instanceof SubType.SubTypePredicate)) {
|
||||
if (list.stream().anyMatch(SubType.SubTypePredicate.class::isInstance)) {
|
||||
this.addDependedToType(DependencyType.AddingCreatureType);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ class CipherStoreEffect extends OneShotEffect {
|
|||
Card copyCard = game.copyCard(cipherCard, source, controller.getId());
|
||||
SpellAbility ability = copyCard.getSpellAbility();
|
||||
// remove the cipher effect from the copy
|
||||
ability.getEffects().removeIf(effect -> effect instanceof CipherEffect);
|
||||
ability.getEffects().removeIf(CipherEffect.class::isInstance);
|
||||
controller.cast(ability, game, true, new ApprovingObject(source, game));
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class CastAsThoughItHadFlashAllEffect extends AsThoughEffectImpl {
|
|||
if (card != null) {
|
||||
//Allow lands with morph to be played at instant speed
|
||||
if (card.isLand(game)) {
|
||||
boolean morphAbility = card.getAbilities().stream().anyMatch(ability -> ability instanceof MorphAbility);
|
||||
boolean morphAbility = card.getAbilities().stream().anyMatch(MorphAbility.class::isInstance);
|
||||
if (morphAbility) {
|
||||
Card cardCopy = card.copy();
|
||||
cardCopy.removeAllCardTypes(game);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class FlankingAbility extends TriggeredAbilityImpl {
|
|||
Permanent permanent = game.getPermanent(event.getSourceId());
|
||||
if (permanent != null) {
|
||||
boolean hasFlankingAbility
|
||||
= permanent.getAbilities().stream().anyMatch(ability -> ability instanceof FlankingAbility);
|
||||
= permanent.getAbilities().stream().anyMatch(FlankingAbility.class::isInstance);
|
||||
|
||||
if (!hasFlankingAbility) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public class FilterCard extends FilterObject<Card> {
|
|||
// card filter can't contain controller predicate (only permanents on battlefield have controller)
|
||||
List<Predicate> list = new ArrayList<>();
|
||||
Predicates.collectAllComponents(predicate, list);
|
||||
if (list.stream().anyMatch(p -> p instanceof TargetController.ControllerPredicate)) {
|
||||
if (list.stream().anyMatch(TargetController.ControllerPredicate.class::isInstance)) {
|
||||
throw new IllegalArgumentException("Card filter doesn't support controller predicate");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3706,7 +3706,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
ManaOptions manaFull = availableMana.copy();
|
||||
if (ability instanceof SpellAbility) {
|
||||
for (AlternateManaPaymentAbility altAbility : CardUtil.getAbilities(object, game).stream()
|
||||
.filter(a -> a instanceof AlternateManaPaymentAbility)
|
||||
.filter(AlternateManaPaymentAbility.class::isInstance)
|
||||
.map(a -> (AlternateManaPaymentAbility) a)
|
||||
.collect(Collectors.toList())) {
|
||||
ManaOptions manaSpecial = altAbility.getManaOptions(ability, game, ability.getManaCostsToPay());
|
||||
|
|
@ -3739,7 +3739,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
if (ability instanceof AlternativeSourceCosts && object != null && !(object instanceof Permanent)) {
|
||||
ActivatedAbility playAbility = null;
|
||||
if (object.isLand(game)) {
|
||||
playAbility = (PlayLandAbility) CardUtil.getAbilities(object, game).stream().filter(a -> a instanceof PlayLandAbility).findFirst().orElse(null);
|
||||
playAbility = (PlayLandAbility) CardUtil.getAbilities(object, game).stream().filter(PlayLandAbility.class::isInstance).findFirst().orElse(null);
|
||||
} else if (object instanceof Card) {
|
||||
playAbility = ((Card) object).getSpellAbility();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue