mirror of
https://github.com/magefree/mage.git
synced 2026-01-23 19:59:54 -08:00
* Reworked Cho-Manno's Blessing protection handling.
This commit is contained in:
parent
2ca8595789
commit
630b2c32d7
4 changed files with 153 additions and 80 deletions
|
|
@ -28,26 +28,18 @@
|
|||
package mage.sets.mercadianmasques;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||
import mage.abilities.effects.common.ChooseColorEffect;
|
||||
import mage.abilities.effects.keyword.ProtectionChosenColorAttachedEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.abilities.keyword.FlashAbility;
|
||||
import mage.abilities.keyword.ProtectionAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.choices.ChoiceColor;
|
||||
import mage.constants.AttachmentType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.constants.Zone;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
|
|
@ -64,17 +56,19 @@ public class ChoMannosBlessing extends CardImpl {
|
|||
|
||||
// Flash
|
||||
this.addAbility(FlashAbility.getInstance());
|
||||
|
||||
|
||||
// Enchant creature
|
||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||
this.getSpellAbility().addTarget(auraTarget);
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Protect));
|
||||
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
||||
|
||||
|
||||
// As Cho-Manno's Blessing enters the battlefield, choose a color.
|
||||
this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect(Outcome.Benefit)));
|
||||
|
||||
// Enchanted creature has protection from the chosen color. This effect doesn't remove Cho-Manno's Blessing.
|
||||
this.addAbility(new AsEntersBattlefieldAbility(new ChoMannosBlessingEffect()));
|
||||
}
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ProtectionChosenColorAttachedEffect(true)));
|
||||
}
|
||||
|
||||
public ChoMannosBlessing(final ChoMannosBlessing card) {
|
||||
super(card);
|
||||
|
|
@ -85,38 +79,3 @@ public class ChoMannosBlessing extends CardImpl {
|
|||
return new ChoMannosBlessing(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ChoMannosBlessingEffect extends OneShotEffect {
|
||||
|
||||
public ChoMannosBlessingEffect() {
|
||||
super(Outcome.Protect);
|
||||
this.staticText = "enchanted creature has protection from the chosen color. This effect doesn't remove {this}";
|
||||
}
|
||||
|
||||
public ChoMannosBlessingEffect(final ChoMannosBlessingEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChoMannosBlessingEffect copy() {
|
||||
return new ChoMannosBlessingEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
choice.setMessage("Choose color to get protection from");
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && controller.choose(outcome, choice, game)) {
|
||||
FilterCard protectionFilter = new FilterCard();
|
||||
protectionFilter.add(new ColorPredicate(choice.getColor()));
|
||||
protectionFilter.setMessage(choice.getChoice().toLowerCase());
|
||||
ProtectionAbility protectionAbility = new ProtectionAbility(protectionFilter);
|
||||
protectionAbility.setRemovesAuras(false);
|
||||
ContinuousEffect effect = new GainAbilityAttachedEffect(protectionAbility, AttachmentType.AURA, Duration.WhileOnBattlefield);
|
||||
game.addEffect(effect, source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue