mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
Refactor ControlledCreaturesDealCombatDamagePlayerTriggeredAbility. (#5163)
It now triggers once for each player damaged. Fixes https://github.com/magefree/mage/issues/5162
This commit is contained in:
parent
14520097a5
commit
e5c1dfc4b7
5 changed files with 160 additions and 64 deletions
|
|
@ -1,20 +1,18 @@
|
|||
|
||||
package mage.cards.n;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.ControlledCreaturesDealCombatDamagePlayerTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.TapAllTargetPlayerControlsEffect;
|
||||
import mage.abilities.effects.common.UntapAllEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterControlledLandPermanent;
|
||||
import mage.filter.common.FilterLandPermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -26,7 +24,11 @@ public final class NaturesWill extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}{G}");
|
||||
|
||||
// Whenever one or more creatures you control deal combat damage to a player, tap all lands that player controls and untap all lands you control.
|
||||
this.addAbility(new ControlledCreaturesDealCombatDamagePlayerTriggeredAbility(new NaturesWillEffect()));
|
||||
Effect tapAllEffect = new TapAllTargetPlayerControlsEffect(new FilterLandPermanent());
|
||||
tapAllEffect.setText("tap all lands that player controls");
|
||||
Ability ability = new ControlledCreaturesDealCombatDamagePlayerTriggeredAbility(Zone.BATTLEFIELD, tapAllEffect, true);
|
||||
ability.addEffect(new UntapAllEffect(new FilterControlledLandPermanent()));
|
||||
addAbility(ability);
|
||||
}
|
||||
|
||||
public NaturesWill(final NaturesWill card) {
|
||||
|
|
@ -38,37 +40,3 @@ public final class NaturesWill extends CardImpl {
|
|||
return new NaturesWill(this);
|
||||
}
|
||||
}
|
||||
|
||||
class NaturesWillEffect extends OneShotEffect {
|
||||
|
||||
public NaturesWillEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "tap all lands that player controls and untap all lands you control";
|
||||
}
|
||||
|
||||
public NaturesWillEffect(final NaturesWillEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NaturesWillEffect copy() {
|
||||
return new NaturesWillEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Set<UUID> damagedPlayers = (HashSet<UUID>) this.getValue("damagedPlayers");
|
||||
if (damagedPlayers != null) {
|
||||
List<Permanent> lands = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_LAND, source.getControllerId(), source.getSourceId(), game);
|
||||
for (Permanent land : lands) {
|
||||
if (damagedPlayers.contains(land.getControllerId())) {
|
||||
land.tap(game);
|
||||
} else if (land.isControlledBy(source.getControllerId())) {
|
||||
land.untap(game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,14 @@
|
|||
package mage.cards.s;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
|
||||
import mage.abilities.common.ControlledCreaturesDealCombatDamagePlayerTriggeredAbility;
|
||||
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
|
||||
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.abilities.effects.common.TransformSourceEffect;
|
||||
import mage.abilities.keyword.TransformAbility;
|
||||
|
|
@ -17,6 +21,7 @@ import mage.constants.ComparisonType;
|
|||
import mage.constants.SuperType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.token.TreasureToken;
|
||||
|
||||
/**
|
||||
|
|
@ -45,6 +50,8 @@ public final class StormTheVault extends CardImpl {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public StormTheVault(final StormTheVault card) {
|
||||
super(card);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue