Updated Baki's Curse damage processing
*/
package mage.cards.b;
+import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
@@ -35,11 +36,10 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
-import mage.filter.FilterPermanent;
-import mage.filter.predicate.mageobject.CardTypePredicate;
-import mage.filter.predicate.mageobject.SubtypePredicate;
+import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
+import mage.players.Player;
/**
*
@@ -62,8 +62,9 @@ public class BakisCurse extends CardImpl {
public BakisCurse copy() {
return new BakisCurse(this);
}
+}
- private static class BakisCurseEffect extends OneShotEffect {
+class BakisCurseEffect extends OneShotEffect {
public BakisCurseEffect() {
super(Outcome.Detriment);
@@ -75,27 +76,23 @@ public class BakisCurse extends CardImpl {
}
@Override
- public boolean apply(Game game, Ability source) {
+ public BakisCurseEffect copy() {
+ return new BakisCurseEffect(this);
+ }
- FilterPermanent filterEnchantments = new FilterPermanent();
- filterEnchantments.add(new CardTypePredicate(CardType.ENCHANTMENT));
- filterEnchantments.add(new SubtypePredicate(SubType.AURA));
- for (Permanent auraEnchantment : game.getBattlefield().getActivePermanents(filterEnchantments, source.getControllerId(), source.getSourceId(), game)) {
- if (auraEnchantment.getAttachedTo() != null) {
- Permanent attachedToCreature = game.getPermanent(auraEnchantment.getAttachedTo());
- if (attachedToCreature != null && attachedToCreature.isCreature()) {
- attachedToCreature.damage(2, source.getId(), game, false, true);
- game.informPlayers("2 damage assigned to " + attachedToCreature.getName() + " from Baki's Curse due to " + auraEnchantment.getName());
+ @Override
+ public boolean apply(Game game, Ability source) {
+ for (Permanent creature : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), source.getSourceId(), game)) {
+ int count = 0;
+ List<UUID> attachments = creature.getAttachments();
+ for (UUID attachmentId : attachments) {
+ Permanent attached = game.getPermanent(attachmentId);
+ if (attached != null && attached.getSubtype(game).contains(SubType.AURA)) {
+ count++;
}
}
+ creature.damage(count * 2, source.getId(), game, false, true);
}
return true;
}
-
- @Override
- public BakisCurseEffect copy() {
- return new BakisCurseEffect(this);
- }
-
- }
}
