Merge remote-tracking branch 'origin/master'

This commit is contained in:
Oleg Agafonov 2019-01-09 05:03:47 +04:00
commit 0f598143f0
3 changed files with 67 additions and 89 deletions

View file

@ -1,7 +1,8 @@
package mage.cards.b;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.Ability;
import mage.abilities.common.OneOrMoreCountersAddedTriggeredAbility;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.discard.DiscardControllerEffect;
import mage.abilities.keyword.AdaptAbility;
@ -9,10 +10,6 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import java.util.UUID;
@ -34,7 +31,9 @@ public final class BenthicBiomancer extends CardImpl {
this.addAbility(new AdaptAbility(1, "{1}{U}"));
// Whenever one or more +1/+1 counters are put on Benthic Biomancer, draw a card, then discard a card.
this.addAbility(new GrowthChamberGuardianTriggeredAbility());
Ability ability = new OneOrMoreCountersAddedTriggeredAbility(new DrawCardSourceControllerEffect(1));
ability.addEffect(new DiscardControllerEffect(1).setText(", then discard a card"));
this.addAbility(ability);
}
private BenthicBiomancer(final BenthicBiomancer card) {
@ -46,38 +45,3 @@ public final class BenthicBiomancer extends CardImpl {
return new BenthicBiomancer(this);
}
}
class GrowthChamberGuardianTriggeredAbility extends TriggeredAbilityImpl {
GrowthChamberGuardianTriggeredAbility() {
super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), true);
this.addEffect(new DiscardControllerEffect(1));
}
private GrowthChamberGuardianTriggeredAbility(final GrowthChamberGuardianTriggeredAbility ability) {
super(ability);
}
@Override
public GrowthChamberGuardianTriggeredAbility copy() {
return new GrowthChamberGuardianTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.COUNTERS_ADDED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getData().equals(CounterType.P1P1.getName())
&& event.getAmount() > 0
&& event.getTargetId().equals(this.getSourceId());
}
@Override
public String getRule() {
return "Whenever one or more +1/+1 counters are put on {this}, " +
"draw a card, then discard a card.";
}
}

View file

@ -1,19 +1,15 @@
package mage.cards.g;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.OneOrMoreCountersAddedTriggeredAbility;
import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect;
import mage.abilities.keyword.AdaptAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.target.common.TargetCardInLibrary;
import java.util.UUID;
@ -23,6 +19,13 @@ import java.util.UUID;
*/
public final class GrowthChamberGuardian extends CardImpl {
private static final FilterCard filter
= new FilterCard("a card named Growth-Chamber Guardian");
static {
filter.add(new NamePredicate("Growth-Chamber Guardian"));
}
public GrowthChamberGuardian(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}");
@ -36,7 +39,7 @@ public final class GrowthChamberGuardian extends CardImpl {
this.addAbility(new AdaptAbility(2, "{2}{G}"));
// Whenever one or more +1/+1 counters are put on Growth-Chamber Guardian, you may search your library for a card named Growth-Chamber Guardian, reveal it, put it into your hand, then shuffle your library.
this.addAbility(new GrowthChamberGuardianTriggeredAbility());
this.addAbility(new OneOrMoreCountersAddedTriggeredAbility(new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true), true));
}
private GrowthChamberGuardian(final GrowthChamberGuardian card) {
@ -48,45 +51,3 @@ public final class GrowthChamberGuardian extends CardImpl {
return new GrowthChamberGuardian(this);
}
}
class GrowthChamberGuardianTriggeredAbility extends TriggeredAbilityImpl {
private static final FilterCard filter
= new FilterCard("a card named Growth-Chamber Guardian");
static {
filter.add(new NamePredicate("Growth-Chamber Guardian"));
}
GrowthChamberGuardianTriggeredAbility() {
super(Zone.BATTLEFIELD, new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true), true);
}
private GrowthChamberGuardianTriggeredAbility(final GrowthChamberGuardianTriggeredAbility ability) {
super(ability);
}
@Override
public GrowthChamberGuardianTriggeredAbility copy() {
return new GrowthChamberGuardianTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.COUNTERS_ADDED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getData().equals(CounterType.P1P1.getName())
&& event.getAmount() > 0
&& event.getTargetId().equals(this.getSourceId());
}
@Override
public String getRule() {
return "Whenever one or more +1/+1 counters are put on {this}, " +
"you may search your library for a card named Growth-Chamber Guardian, " +
"reveal it, put it into your hand, then shuffle your library.";
}
}

View file

@ -0,0 +1,53 @@
package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
public class OneOrMoreCountersAddedTriggeredAbility extends TriggeredAbilityImpl {
private final CounterType counterType;
public OneOrMoreCountersAddedTriggeredAbility(Effect effect) {
this(effect, false);
}
public OneOrMoreCountersAddedTriggeredAbility(Effect effect, boolean optional) {
this(effect, optional, CounterType.P1P1);
}
public OneOrMoreCountersAddedTriggeredAbility(Effect effect, boolean optional, CounterType counterType) {
super(Zone.BATTLEFIELD, effect, true);
this.counterType = counterType;
}
private OneOrMoreCountersAddedTriggeredAbility(final OneOrMoreCountersAddedTriggeredAbility ability) {
super(ability);
this.counterType = ability.counterType;
}
@Override
public OneOrMoreCountersAddedTriggeredAbility copy() {
return new OneOrMoreCountersAddedTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.COUNTERS_ADDED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getData().equals(counterType.getName())
&& event.getAmount() > 0
&& event.getTargetId().equals(this.getSourceId());
}
@Override
public String getRule() {
return "Whenever one or more " + counterType + " counters are put on {this}, " + super.getRule();
}
}