forked from External/mage
reimplemented Path of Ancestry to prevent Blood Sun from removing scry trigger
This commit is contained in:
parent
a9a356f187
commit
f32597b164
1 changed files with 60 additions and 63 deletions
|
|
@ -1,26 +1,26 @@
|
|||
package mage.cards.p;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTappedAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
|
||||
import mage.abilities.effects.keyword.ScryEffect;
|
||||
import mage.abilities.keyword.ChangelingAbility;
|
||||
import mage.abilities.mana.CommanderColorIdentityManaAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SubTypeSet;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -35,12 +35,10 @@ public final class PathOfAncestry extends CardImpl {
|
|||
// Path of Ancestry enters the battlefield tapped.
|
||||
this.addAbility(new EntersBattlefieldTappedAbility());
|
||||
|
||||
// T: Add one mana of any color in your commander's color identity.
|
||||
// T: Add one mana of any color in your commander's color identity. When that mana is spent to cast a creature spell that shares a creature type with your commander, scry 1.
|
||||
Ability ability = new CommanderColorIdentityManaAbility();
|
||||
ability.addEffect(new CreateDelayedTriggeredAbilityEffect(new PathOfAncestryTriggeredAbility()));
|
||||
this.addAbility(ability);
|
||||
|
||||
// When that mana is spent to cast a creature spell that shares a creature type with your commander, scry 1.
|
||||
this.addAbility(new PathOfAncestryTriggeredAbility(new ScryEffect(1)));
|
||||
}
|
||||
|
||||
public PathOfAncestry(final PathOfAncestry card) {
|
||||
|
|
@ -53,13 +51,13 @@ public final class PathOfAncestry extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class PathOfAncestryTriggeredAbility extends TriggeredAbilityImpl {
|
||||
class PathOfAncestryTriggeredAbility extends DelayedTriggeredAbility {
|
||||
|
||||
public PathOfAncestryTriggeredAbility(Effect effect) {
|
||||
super(Zone.ALL, effect, false);
|
||||
PathOfAncestryTriggeredAbility() {
|
||||
super(new ScryEffect(1), Duration.Custom, true, false);
|
||||
}
|
||||
|
||||
public PathOfAncestryTriggeredAbility(final PathOfAncestryTriggeredAbility ability) {
|
||||
private PathOfAncestryTriggeredAbility(final PathOfAncestryTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
|
|
@ -75,61 +73,60 @@ class PathOfAncestryTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (getSourceId().equals(event.getSourceId())) {
|
||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId());
|
||||
if (sourcePermanent != null) {
|
||||
boolean found = false;
|
||||
for (Ability ability : sourcePermanent.getAbilities()) {
|
||||
if (ability instanceof CommanderColorIdentityManaAbility && ability.getOriginalId().toString().equals(event.getData())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null && spell.isCreature()) {
|
||||
Player controller = game.getPlayer(getControllerId());
|
||||
Set<UUID> commanders = game.getCommandersIds(controller);
|
||||
if (controller != null && commanders != null && !commanders.isEmpty()) {
|
||||
if (spell.getAbilities().contains(ChangelingAbility.getInstance())) {
|
||||
for (UUID cmdr : commanders) {
|
||||
MageObject commander = game.getObject(cmdr);
|
||||
if (commander != null) {
|
||||
if (commander.getAbilities().contains(ChangelingAbility.getInstance())) {
|
||||
return true;
|
||||
}
|
||||
Iterator<SubType> cmdrSubs = commander.getSubtype(game).iterator();
|
||||
while (cmdrSubs.hasNext()) {
|
||||
SubType sType = cmdrSubs.next();
|
||||
if (sType.getSubTypeSet() == SubTypeSet.CreatureType) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Iterator<SubType> spellSubs = spell.getSubtype(game).iterator();
|
||||
while (spellSubs.hasNext()) {
|
||||
SubType sType = spellSubs.next();
|
||||
if (sType.getSubTypeSet() == SubTypeSet.CreatureType) {
|
||||
for (UUID cmdr : commanders) {
|
||||
MageObject commander = game.getObject(cmdr);
|
||||
if (commander != null && (commander.hasSubtype(sType, game) || commander.getAbilities().contains(ChangelingAbility.getInstance()))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!getSourceId().equals(event.getSourceId())) {
|
||||
return false;
|
||||
}
|
||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId());
|
||||
if (sourcePermanent == null) {
|
||||
return false;
|
||||
}
|
||||
boolean found = false;
|
||||
for (Ability ability : sourcePermanent.getAbilities()) {
|
||||
if (ability instanceof CommanderColorIdentityManaAbility
|
||||
&& ability.getOriginalId().toString().equals(event.getData())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if (!found) {
|
||||
return false;
|
||||
}
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell == null || (spell.getSubtype(game).isEmpty()
|
||||
&& !spell.hasAbility(ChangelingAbility.getInstance(), game))) {
|
||||
return false;
|
||||
}
|
||||
Player player = game.getPlayer(getControllerId());
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
boolean isAllA = false;
|
||||
Set<SubType> subTypeSet = new HashSet<>();
|
||||
for (UUID commanderId : game.getCommandersIds(player)) {
|
||||
Card commander = game.getPermanent(commanderId);
|
||||
if (commander == null) {
|
||||
commander = game.getCard(commanderId);
|
||||
}
|
||||
if (commander == null) {
|
||||
continue;
|
||||
}
|
||||
if (commander.isAllCreatureTypes()
|
||||
|| commander.hasAbility(ChangelingAbility.getInstance(), game)) {
|
||||
isAllA = true;
|
||||
break;
|
||||
}
|
||||
subTypeSet.addAll(commander.getSubtype(game));
|
||||
}
|
||||
subTypeSet.removeIf(subType -> subType.getSubTypeSet() != SubTypeSet.CreatureType);
|
||||
if (subTypeSet.isEmpty() && !isAllA) {
|
||||
return false;
|
||||
}
|
||||
return spell.hasAbility(ChangelingAbility.getInstance(), game)
|
||||
|| spell.getSubtype(game).stream().anyMatch(subTypeSet::contains);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "When that mana is used to cast a creature spell that shares a creature type with your commander, " + super.getRule();
|
||||
return "When that mana is spent to cast a creature spell that shares a creature type with your commander, scry 1.";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue