mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Added EntersBattlefieldOrDiesSourceTriggeredAbility.
This commit is contained in:
parent
acd52e2a61
commit
d7677ff3d1
5 changed files with 94 additions and 61 deletions
|
@ -29,17 +29,12 @@ package mage.sets.timespiral;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.EntersBattlefieldOrDiesSourceTriggeredAbility;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.abilities.keyword.EchoAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.token.GoblinToken;
|
||||
|
||||
/**
|
||||
|
@ -61,7 +56,7 @@ public class MoggWarMarshal extends CardImpl<MoggWarMarshal> {
|
|||
// Echo {1}{R}
|
||||
this.addAbility(new EchoAbility("{1}{R}"));
|
||||
// When Mogg War Marshal enters the battlefield or dies, put a 1/1 red Goblin creature token onto the battlefield.
|
||||
this.addAbility(new MoggWarMarshallTriggeredAbility());
|
||||
this.addAbility(new EntersBattlefieldOrDiesSourceTriggeredAbility(new CreateTokenEffect(new GoblinToken(), 1), false));
|
||||
}
|
||||
|
||||
public MoggWarMarshal(final MoggWarMarshal card) {
|
||||
|
@ -73,39 +68,3 @@ public class MoggWarMarshal extends CardImpl<MoggWarMarshal> {
|
|||
return new MoggWarMarshal(this);
|
||||
}
|
||||
}
|
||||
|
||||
class MoggWarMarshallTriggeredAbility extends TriggeredAbilityImpl<MoggWarMarshallTriggeredAbility> {
|
||||
|
||||
public MoggWarMarshallTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new CreateTokenEffect(new GoblinToken(), 1), false);
|
||||
}
|
||||
|
||||
public MoggWarMarshallTriggeredAbility(final MoggWarMarshallTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MoggWarMarshallTriggeredAbility copy() {
|
||||
return new MoggWarMarshallTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD
|
||||
&& event.getTargetId().equals(getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(this.getSourceId())) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
|
||||
if (zEvent.getFromZone().equals(Zone.BATTLEFIELD) && zEvent.getToZone().equals(Zone.GRAVEYARD)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "When Mogg War Marshal enters the battlefield or dies, " + super.getRule();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,15 +28,14 @@
|
|||
package mage.sets.urzasdestiny;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DiesTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldOrDiesSourceTriggeredAbility;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.abilities.keyword.EchoAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.game.permanent.token.GoblinToken;
|
||||
|
||||
/**
|
||||
|
@ -56,11 +55,8 @@ public class GoblinMarshal extends CardImpl<GoblinMarshal> {
|
|||
|
||||
this.addAbility(new EchoAbility("{4}{R}{R}"));
|
||||
// When Goblin Marshal enters the battlefield or dies, put two 1/1 red Goblin creature tokens onto the battlefield.
|
||||
Ability enterAbility = new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new GoblinToken(), 2), false);
|
||||
Ability enterAbility = new EntersBattlefieldOrDiesSourceTriggeredAbility(new CreateTokenEffect(new GoblinToken(), 2), false);
|
||||
this.addAbility(enterAbility);
|
||||
// When Goblin Marshal enters the battlefield or dies, put two 1/1 red Goblin creature tokens onto the battlefield.
|
||||
Ability diesAbility = new DiesTriggeredAbility(new CreateTokenEffect(new GoblinToken(), 2), false);
|
||||
this.addAbility(diesAbility);
|
||||
}
|
||||
|
||||
public GoblinMarshal(final GoblinMarshal card) {
|
||||
|
|
|
@ -28,15 +28,14 @@
|
|||
package mage.sets.urzasdestiny;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DiesTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldOrDiesSourceTriggeredAbility;
|
||||
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
|
||||
import mage.abilities.keyword.EchoAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.counters.CounterType;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
|
@ -57,13 +56,9 @@ public class HuntingMoa extends CardImpl<HuntingMoa> {
|
|||
|
||||
this.addAbility(new EchoAbility("{2}{G}"));
|
||||
// When Hunting Moa enters the battlefield or dies, put a +1/+1 counter on target creature.
|
||||
Ability enterAbility = new EntersBattlefieldTriggeredAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance()), false);
|
||||
enterAbility.addTarget(new TargetCreaturePermanent());
|
||||
Ability enterAbility = new EntersBattlefieldOrDiesSourceTriggeredAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance()), false);
|
||||
enterAbility.addTarget(new TargetCreaturePermanent(true));
|
||||
this.addAbility(enterAbility);
|
||||
// When Hunting Moa enters the battlefield or dies, put a +1/+1 counter on target creature.
|
||||
Ability diesAbility = new DiesTriggeredAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance()), false);
|
||||
diesAbility.addTarget(new TargetCreaturePermanent());
|
||||
this.addAbility(diesAbility);
|
||||
}
|
||||
|
||||
public HuntingMoa(final HuntingMoa card) {
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class EntersBattlefieldOrDiesSourceTriggeredAbility extends TriggeredAbilityImpl<EntersBattlefieldOrDiesSourceTriggeredAbility> {
|
||||
|
||||
public EntersBattlefieldOrDiesSourceTriggeredAbility(Effect effect, boolean optional) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
}
|
||||
|
||||
public EntersBattlefieldOrDiesSourceTriggeredAbility(final EntersBattlefieldOrDiesSourceTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntersBattlefieldOrDiesSourceTriggeredAbility copy() {
|
||||
return new EntersBattlefieldOrDiesSourceTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD
|
||||
&& event.getTargetId().equals(getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(this.getSourceId())) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
|
||||
if (zEvent.getFromZone().equals(Zone.BATTLEFIELD) && zEvent.getToZone().equals(Zone.GRAVEYARD)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "When {this} enters the battlefield or dies, " + super.getRule();
|
||||
}
|
||||
}
|
|
@ -51,6 +51,11 @@ public class TargetPermanent<T extends TargetPermanent<T>> extends TargetObject<
|
|||
this(1, 1, new FilterPermanent(), false);
|
||||
}
|
||||
|
||||
public TargetPermanent(boolean required) {
|
||||
this(1, 1, new FilterPermanent(), false);
|
||||
this.setRequired(required);
|
||||
}
|
||||
|
||||
public TargetPermanent(FilterPermanent filter) {
|
||||
this(1, 1, filter, false);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue