mirror of
https://github.com/correl/mage.git
synced 2024-11-28 11:09:54 +00:00
Clean up some code for Marneus Calgar and Elesh Norn, Mother of Machines
This commit is contained in:
parent
a315171ca4
commit
05443fb3f4
2 changed files with 15 additions and 49 deletions
|
@ -73,14 +73,13 @@ class EleshNornMotherOfMachinesDoublingEffect extends ReplacementEffectImpl {
|
|||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event instanceof NumberOfTriggersEvent) {
|
||||
NumberOfTriggersEvent numberOfTriggersEvent = (NumberOfTriggersEvent) event;
|
||||
// Only triggers of the controller of Elesh Norn
|
||||
// Only triggers for the controller of Elesh Norn
|
||||
if (source.isControlledBy(event.getPlayerId())) {
|
||||
GameEvent sourceEvent = numberOfTriggersEvent.getSourceEvent();
|
||||
// Only EtB triggers
|
||||
if (sourceEvent != null
|
||||
&& sourceEvent.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD
|
||||
&& sourceEvent instanceof EntersTheBattlefieldEvent) {
|
||||
EntersTheBattlefieldEvent entersTheBattlefieldEvent = (EntersTheBattlefieldEvent) sourceEvent;
|
||||
// Only for triggers of permanents
|
||||
if (game.getPermanent(numberOfTriggersEvent.getSourceId()) != null) {
|
||||
return true;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package mage.cards.m;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.EntersBattlefieldOneOrMoreTriggeredAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
|
@ -9,16 +9,10 @@ import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
|||
import mage.abilities.keyword.DoubleStrikeAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeGroupEvent;
|
||||
import mage.game.permanent.PermanentImpl;
|
||||
import mage.constants.*;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.permanent.TokenPredicate;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import mage.game.permanent.token.WhiteAstartesWarriorToken;
|
||||
|
||||
|
@ -27,6 +21,12 @@ import mage.game.permanent.token.WhiteAstartesWarriorToken;
|
|||
*/
|
||||
public final class MarneusCalgar extends CardImpl {
|
||||
|
||||
static final FilterPermanent filter = new FilterPermanent("tokens");
|
||||
|
||||
static {
|
||||
filter.add(TokenPredicate.TRUE);
|
||||
}
|
||||
|
||||
public MarneusCalgar(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{U}{B}");
|
||||
|
||||
|
@ -39,7 +39,10 @@ public final class MarneusCalgar extends CardImpl {
|
|||
this.addAbility(DoubleStrikeAbility.getInstance());
|
||||
|
||||
// Master Tactician — Whenever one or more tokens enter the battlefield under your control, draw a card.
|
||||
this.addAbility(new MarneusCalgarTriggeredAbility());
|
||||
//this.addAbility(new MarneusCalgarTriggeredAbility());
|
||||
this.addAbility(new EntersBattlefieldOneOrMoreTriggeredAbility(
|
||||
new DrawCardSourceControllerEffect(1), filter, TargetController.YOU
|
||||
).withFlavorWord("Master Tactician"));
|
||||
|
||||
// Chapter Master — {6}: Create two 2/2 white Astartes Warrior creature tokens with vigilance.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
||||
|
@ -57,39 +60,3 @@ public final class MarneusCalgar extends CardImpl {
|
|||
return new MarneusCalgar(this);
|
||||
}
|
||||
}
|
||||
|
||||
class MarneusCalgarTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
MarneusCalgarTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), false);
|
||||
this.withFlavorWord("Master Tactician");
|
||||
setTriggerPhrase("Whenever one or more tokens enter the battlefield under your control, ");
|
||||
}
|
||||
|
||||
private MarneusCalgarTriggeredAbility(final MarneusCalgarTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.ZONE_CHANGE_GROUP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event;
|
||||
return Zone.BATTLEFIELD == zEvent.getToZone()
|
||||
&& zEvent.getTokens() != null
|
||||
&& zEvent
|
||||
.getTokens()
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(PermanentImpl::getControllerId)
|
||||
.anyMatch(this::isControlledBy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MarneusCalgarTriggeredAbility copy() {
|
||||
return new MarneusCalgarTriggeredAbility(this);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue