implemented Feline Sovereign (#6639)

This commit is contained in:
SpeedProg 2020-06-16 00:58:26 +02:00 committed by GitHub
parent b28434553c
commit 69a9cd1901
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 133 additions and 0 deletions

View file

@ -0,0 +1,131 @@
package mage.cards.f;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.continuous.BoostControlledEffect;
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.common.FilterArtifactOrEnchantmentPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game;
import mage.game.events.DamagedPlayerEvent;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
public final class FelineSovereign extends CardImpl {
private static final FilterCreaturePermanent filterCat = new FilterCreaturePermanent("Cats");
static {
filterCat.add(SubType.CAT.getPredicate());
filterCat.add(TargetController.YOU.getControllerPredicate());
}
private static final FilterCard filterProtectionFromDogs = new FilterCard("Dogs");
static {
filterProtectionFromDogs.add(SubType.DOG.getPredicate());
}
public FelineSovereign(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{G}");
this.subtype.add(SubType.CAT);
this.power = new MageInt(2);
this.toughness = new MageInt(3);
// Other cats get +1/+1
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, filterCat, true));
// Cats you control have protection from Dogs
Effect effect = new GainAbilityAllEffect(new ProtectionAbility(filterProtectionFromDogs), Duration.WhileOnBattlefield, filterCat);
effect.setText("and have protection from Dogs");
ability.addEffect(effect);
this.addAbility(ability);
// if a cat deals combat damage to a player you may destroy up to one artifact/enchantment
this.addAbility(new FelineSovereignTriggeredAbility());
}
public FelineSovereign(final FelineSovereign card) {
super(card);
}
@Override
public FelineSovereign copy() {
return new FelineSovereign(this);
}
}
class FelineSovereignTriggeredAbility extends TriggeredAbilityImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Cat you control");
static {
filter.add(TargetController.YOU.getControllerPredicate());
filter.add(SubType.CAT.getPredicate());
}
private Set<UUID> damagedPlayerIds = new HashSet<>();
public FelineSovereignTriggeredAbility() {
super(Zone.BATTLEFIELD, new DestroyTargetEffect(), true);
}
public FelineSovereignTriggeredAbility(final FelineSovereignTriggeredAbility ability) {
super(ability);
}
@Override
public FelineSovereignTriggeredAbility copy() {
return new FelineSovereignTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.DAMAGED_PLAYER
|| event.getType() == EventType.COMBAT_DAMAGE_STEP_PRIORITY
|| event.getType() == EventType.ZONE_CHANGE;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == EventType.DAMAGED_PLAYER) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent p = game.getPermanent(event.getSourceId());
if (damageEvent.isCombatDamage() && p != null && p.isControlledBy(this.getControllerId()) &&
filter.match(p, getSourceId(), getControllerId(), game) &&
!damagedPlayerIds.contains(event.getPlayerId())) {
damagedPlayerIds.add(event.getPlayerId());
this.getTargets().clear();
FilterArtifactOrEnchantmentPermanent filter = new FilterArtifactOrEnchantmentPermanent();
filter.add(new ControllerIdPredicate(event.getPlayerId()));
this.addTarget(new TargetPermanent(0, 1, filter, false));
return true;
}
}
if (event.getType() == EventType.COMBAT_DAMAGE_STEP_PRIORITY ||
(event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(getSourceId()))) {
damagedPlayerIds.clear();
}
return false;
}
@Override
public String getRule() {
return "Whenever one or more Cats you control deal combat damage to a player, destroy up to one target artifact or enchantment that player controls";
}
}

View file

@ -75,6 +75,8 @@ public final class CoreSet2021 extends ExpansionSet {
cards.add(new SetCardInfo("Fabled Passage", 246, Rarity.RARE, mage.cards.f.FabledPassage.class));
cards.add(new SetCardInfo("Faith's Fetters", 17, Rarity.UNCOMMON, mage.cards.f.FaithsFetters.class));
cards.add(new SetCardInfo("Falconer Adept", 18, Rarity.UNCOMMON, mage.cards.f.FalconerAdept.class));
cards.add(new SetCardInfo("Feline Sovereign", 180, Rarity.RARE, mage.cards.f.FelineSovereign.class, ExpansionSet.NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Feline Sovereign", 374, Rarity.RARE, mage.cards.f.FelineSovereign.class, ExpansionSet.NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Fierce Empath", 181, Rarity.UNCOMMON, mage.cards.f.FierceEmpath.class));
cards.add(new SetCardInfo("Fiery Emancipation", 143, Rarity.MYTHIC, mage.cards.f.FieryEmancipation.class));
cards.add(new SetCardInfo("Finishing Blow", 99, Rarity.COMMON, mage.cards.f.FinishingBlow.class));