mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 20:11:59 -08:00
[TDC] Implement Protector of the Wastes
This commit is contained in:
parent
4d38f6b942
commit
d5eee8e46d
2 changed files with 141 additions and 0 deletions
139
Mage.Sets/src/mage/cards/p/ProtectorOfTheWastes.java
Normal file
139
Mage.Sets/src/mage/cards/p/ProtectorOfTheWastes.java
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
package mage.cards.p;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.common.ExileTargetEffect;
|
||||
import mage.abilities.keyword.MonstrosityAbility;
|
||||
import mage.constants.SubType;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterArtifactOrEnchantmentPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jmlundeen
|
||||
*/
|
||||
public final class ProtectorOfTheWastes extends CardImpl {
|
||||
|
||||
public ProtectorOfTheWastes(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{W}{W}");
|
||||
|
||||
this.subtype.add(SubType.DRAGON);
|
||||
this.power = new MageInt(5);
|
||||
this.toughness = new MageInt(5);
|
||||
|
||||
// Flying
|
||||
this.addAbility(FlyingAbility.getInstance());
|
||||
|
||||
// When this creature enters or becomes monstrous, exile up to two target artifacts and/or enchantments controlled by different players.
|
||||
Ability ability = new ProtectorOfTheWastesTriggeredAbility();
|
||||
ability.addTarget(new ProtectorOfTheWastesTarget());
|
||||
this.addAbility(ability);
|
||||
|
||||
// {4}{W}: Monstrosity 3.
|
||||
this.addAbility(new MonstrosityAbility("{4}{W}", 3));
|
||||
}
|
||||
|
||||
private ProtectorOfTheWastes(final ProtectorOfTheWastes card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtectorOfTheWastes copy() {
|
||||
return new ProtectorOfTheWastes(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ProtectorOfTheWastesTarget extends TargetPermanent {
|
||||
|
||||
private static final FilterArtifactOrEnchantmentPermanent filter = new FilterArtifactOrEnchantmentPermanent(
|
||||
"artifacts and/or enchantments controlled by different players");
|
||||
|
||||
ProtectorOfTheWastesTarget() {
|
||||
super(0, 2, filter);
|
||||
}
|
||||
|
||||
private ProtectorOfTheWastesTarget(ProtectorOfTheWastesTarget target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtectorOfTheWastesTarget copy() {
|
||||
return new ProtectorOfTheWastesTarget(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
if (!super.canTarget(id, source, game)) {
|
||||
return false;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
return this.getTargets().stream()
|
||||
.map(game::getPermanent)
|
||||
.filter(Objects::nonNull)
|
||||
.noneMatch(perm -> !perm.getId().equals(permanent.getId())
|
||||
&& perm.isControlledBy(permanent.getControllerId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Ability source, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(source);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) {
|
||||
boolean validTarget = this.getTargets().stream()
|
||||
.map(game::getPermanent)
|
||||
.filter(Objects::nonNull)
|
||||
.noneMatch(perm -> !perm.getId().equals(permanent.getId()) && perm.isControlledBy(permanent.getControllerId()));
|
||||
if (validTarget) {
|
||||
if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, source, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
}
|
||||
}
|
||||
|
||||
class ProtectorOfTheWastesTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public ProtectorOfTheWastesTriggeredAbility() {
|
||||
super(Zone.ALL, new ExileTargetEffect());
|
||||
setTriggerPhrase("When {this} enters or becomes monstrous, ");
|
||||
}
|
||||
|
||||
private ProtectorOfTheWastesTriggeredAbility(final ProtectorOfTheWastesTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtectorOfTheWastesTriggeredAbility copy() {
|
||||
return new ProtectorOfTheWastesTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.BECOMES_MONSTROUS
|
||||
|| event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return event.getSourceId().equals(this.getSourceId());
|
||||
}
|
||||
}
|
||||
|
|
@ -249,6 +249,8 @@ public final class TarkirDragonstormCommander extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Prairie Stream", 384, Rarity.RARE, mage.cards.p.PrairieStream.class));
|
||||
cards.add(new SetCardInfo("Preordain", 161, Rarity.COMMON, mage.cards.p.Preordain.class));
|
||||
cards.add(new SetCardInfo("Prismari Command", 299, Rarity.RARE, mage.cards.p.PrismariCommand.class));
|
||||
cards.add(new SetCardInfo("Protector of the Wastes", 14, Rarity.RARE, mage.cards.p.ProtectorOfTheWastes.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Protector of the Wastes", 54, Rarity.RARE, mage.cards.p.ProtectorOfTheWastes.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Putrefy", 300, Rarity.UNCOMMON, mage.cards.p.Putrefy.class));
|
||||
cards.add(new SetCardInfo("Radiant Grove", 385, Rarity.COMMON, mage.cards.r.RadiantGrove.class));
|
||||
cards.add(new SetCardInfo("Rampant Growth", 265, Rarity.COMMON, mage.cards.r.RampantGrowth.class));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue