[BLB] Implement Byrke, Long Ear of the Law (#11860)

New common class DoubleCountersTargetEffect
This commit is contained in:
PurpleCrowbar 2024-02-26 05:12:14 +00:00 committed by GitHub
parent 0ba00620db
commit ddcd54c0df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 128 additions and 191 deletions

View file

@ -41,7 +41,9 @@ public final class AjaniAdversaryOfTyrants extends CardImpl {
this.setStartingLoyalty(4);
// +1: Put a +1/+1 counter on each of up to two target creatures.
Ability ability = new LoyaltyAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance()), 1);
Ability ability = new LoyaltyAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance())
.setText("put a +1/+1 counter on each of up to two target creatures"), 1
);
ability.addTarget(new TargetPermanent(0, 2, StaticFilters.FILTER_PERMANENT_CREATURES));
this.addAbility(ability);

View file

@ -4,7 +4,7 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DealsDamageToAPlayerAllTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DoubleCountersTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.keyword.FirstStrikeAbility;
import mage.abilities.keyword.RenownAbility;
@ -16,8 +16,6 @@ import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.permanent.RenownedPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
@ -54,7 +52,7 @@ public final class AragornHornburgHero extends CardImpl {
this.addAbility(ability);
// Whenever a renowned creature you control deals combat damage to a player, double the number of +1/+1 counters on it.
this.addAbility(new DealsDamageToAPlayerAllTriggeredAbility(
new AragornDoubleCountersTargetEffect(), filter,
new DoubleCountersTargetEffect(CounterType.P1P1), filter,
false, SetTargetPointer.PERMANENT, true
));
@ -69,28 +67,3 @@ public final class AragornHornburgHero extends CardImpl {
return new AragornHornburgHero(this);
}
}
//Copied from Elvish Vatkeeper
class AragornDoubleCountersTargetEffect extends OneShotEffect {
AragornDoubleCountersTargetEffect() {
super(Outcome.Benefit);
staticText = "double the number of +1/+1 counters on it";
}
private AragornDoubleCountersTargetEffect(final AragornDoubleCountersTargetEffect effect) {
super(effect);
}
@Override
public AragornDoubleCountersTargetEffect copy() {
return new AragornDoubleCountersTargetEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
return permanent != null && permanent.addCounters(CounterType.P1P1.createInstance(
permanent.getCounters(game).getCount(CounterType.P1P1)
), source.getControllerId(), source, game);
}
}

View file

@ -0,0 +1,63 @@
package mage.cards.b;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AttacksCreatureYouControlTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.DoubleCountersTargetEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.counters.CounterType;
import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.target.TargetPermanent;
import java.util.UUID;
/**
* @author PurpleCrowbar
*/
public final class ByrkeLongEarOfTheLaw extends CardImpl {
private static final FilterControlledCreaturePermanent filter =
new FilterControlledCreaturePermanent("creature you control with a +1/+1 counter on it");
static {
filter.add(CounterType.P1P1.getPredicate());
}
public ByrkeLongEarOfTheLaw(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{G}{W}");
this.supertype.add(SuperType.LEGENDARY);
this.subtype.add(SubType.RABBIT, SubType.SOLDIER);
this.power = new MageInt(4);
this.toughness = new MageInt(4);
// Vigilance
this.addAbility(VigilanceAbility.getInstance());
// When Byrke, Long Ear of the Law enters, put a +1/+1 counter on each of up to two target creatures.
Ability ability = new EntersBattlefieldTriggeredAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance())
.setText("put a +1/+1 counter on each of up to two target creatures")
);
ability.addTarget(new TargetPermanent(0, 2, StaticFilters.FILTER_PERMANENT_CREATURES));
this.addAbility(ability);
// Whenever a creature you control with a +1/+1 counter on it attacks, double the number of +1/+1 counters on it.
this.addAbility(new AttacksCreatureYouControlTriggeredAbility(new DoubleCountersTargetEffect(CounterType.P1P1), false, filter, true));
}
private ByrkeLongEarOfTheLaw(final ByrkeLongEarOfTheLaw card) {
super(card);
}
@Override
public ByrkeLongEarOfTheLaw copy() {
return new ByrkeLongEarOfTheLaw(this);
}
}

View file

@ -5,20 +5,17 @@ import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DoubleCountersTargetEffect;
import mage.abilities.effects.common.TransformTargetEffect;
import mage.abilities.effects.keyword.IncubateEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.permanent.TokenPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import java.util.UUID;
@ -49,7 +46,7 @@ public final class ElvishVatkeeper extends CardImpl {
// {5}: Transform target Incubator token you control. Double the number of +1/+1 counters on it.
Ability ability = new SimpleActivatedAbility(new TransformTargetEffect(), new GenericManaCost(5));
ability.addEffect(new ElvishVatkeeperEffect());
ability.addEffect(new DoubleCountersTargetEffect(CounterType.P1P1));
ability.addTarget(new TargetPermanent(filter));
this.addAbility(ability);
}
@ -63,28 +60,3 @@ public final class ElvishVatkeeper extends CardImpl {
return new ElvishVatkeeper(this);
}
}
class ElvishVatkeeperEffect extends OneShotEffect {
ElvishVatkeeperEffect() {
super(Outcome.Benefit);
staticText = "double the number of +1/+1 counters on it";
}
private ElvishVatkeeperEffect(final ElvishVatkeeperEffect effect) {
super(effect);
}
@Override
public ElvishVatkeeperEffect copy() {
return new ElvishVatkeeperEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
return permanent != null && permanent.addCounters(CounterType.P1P1.createInstance(
permanent.getCounters(game).getCount(CounterType.P1P1)
), source.getControllerId(), source, game);
}
}

View file

@ -5,6 +5,7 @@ import mage.abilities.common.AttacksAttachedTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DoubleCountersTargetEffect;
import mage.abilities.keyword.EquipAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -34,7 +35,7 @@ public final class FractalHarness extends CardImpl {
// Whenever equipped creature attacks, double the number of +1/+1 counters on it.
this.addAbility(new AttacksAttachedTriggeredAbility(
new FractalHarnessDoubleEffect(), AttachmentType.EQUIPMENT, false, SetTargetPointer.PERMANENT
new DoubleCountersTargetEffect(CounterType.P1P1), AttachmentType.EQUIPMENT, false, SetTargetPointer.PERMANENT
));
// Equip {2}
@ -88,30 +89,3 @@ class FractalHarnessTokenEffect extends OneShotEffect {
return true;
}
}
class FractalHarnessDoubleEffect extends OneShotEffect {
FractalHarnessDoubleEffect() {
super(Outcome.Benefit);
staticText = "double the number of +1/+1 counters on it";
}
private FractalHarnessDoubleEffect(final FractalHarnessDoubleEffect effect) {
super(effect);
}
@Override
public FractalHarnessDoubleEffect copy() {
return new FractalHarnessDoubleEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent == null) {
return false;
}
return permanent.addCounters(CounterType.P1P1.createInstance(permanent.getCounters(game).getCount(CounterType.P1P1)),
source.getControllerId(), source, game);
}
}

View file

@ -1,15 +1,11 @@
package mage.cards.i;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DoubleCountersTargetEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetControlledCreaturePermanent;
import java.util.UUID;
@ -24,7 +20,9 @@ public final class InvigoratingSurge extends CardImpl {
// Put a +1/+1 counter on target creature you control, then double the number of +1/+1 counters on that creature.
this.getSpellAbility().addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance()));
this.getSpellAbility().addEffect(new InvigoratingSurgeEffect());
this.getSpellAbility().addEffect(new DoubleCountersTargetEffect(CounterType.P1P1)
.setText(", then double the number of +1/+1 counters on that creature")
);
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
}
@ -37,30 +35,3 @@ public final class InvigoratingSurge extends CardImpl {
return new InvigoratingSurge(this);
}
}
class InvigoratingSurgeEffect extends OneShotEffect {
InvigoratingSurgeEffect() {
super(Outcome.Benefit);
staticText = ", then double the number of +1/+1 counters on that creature";
}
private InvigoratingSurgeEffect(final InvigoratingSurgeEffect effect) {
super(effect);
}
@Override
public InvigoratingSurgeEffect copy() {
return new InvigoratingSurgeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
int counterCount = permanent.getCounters(game).getCount(CounterType.P1P1);
return counterCount > 0 && permanent.addCounters(CounterType.P1P1.createInstance(counterCount), source.getControllerId(), source, game);
}
}

View file

@ -7,7 +7,7 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.SourcePermanentPowerCount;
import mage.abilities.dynamicvalue.common.SourcePermanentToughnessValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DoubleCountersTargetEffect;
import mage.abilities.effects.common.continuous.SetBasePowerToughnessAllEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.TrampleAbility;
@ -16,8 +16,6 @@ import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.counters.CounterType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetControlledCreaturePermanent;
import java.util.UUID;
@ -45,7 +43,9 @@ public final class TanazirQuandrix extends CardImpl {
this.addAbility(TrampleAbility.getInstance());
// When Tanazir Quandrix enters the battlefield, double the number of +1/+1 counters on target creature you control.
Ability ability = new EntersBattlefieldTriggeredAbility(new TanazirQuandrixEffect());
Ability ability = new EntersBattlefieldTriggeredAbility(new DoubleCountersTargetEffect(CounterType.P1P1)
.setText("double the number of +1/+1 counters on target creature you control")
);
ability.addTarget(new TargetControlledCreaturePermanent());
this.addAbility(ability);
@ -66,32 +66,3 @@ public final class TanazirQuandrix extends CardImpl {
return new TanazirQuandrix(this);
}
}
class TanazirQuandrixEffect extends OneShotEffect {
TanazirQuandrixEffect() {
super(Outcome.Benefit);
staticText = "double the number of +1/+1 counters on target creature you control";
}
private TanazirQuandrixEffect(final TanazirQuandrixEffect effect) {
super(effect);
}
@Override
public TanazirQuandrixEffect copy() {
return new TanazirQuandrixEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
int counterCount = permanent.getCounters(game).getCount(CounterType.P1P1);
return counterCount > 0 && permanent.addCounters(
CounterType.P1P1.createInstance(counterCount), source.getControllerId(), source, game
);
}
}

View file

@ -1,18 +1,15 @@
package mage.cards.v;
import mage.abilities.Ability;
import mage.abilities.costs.costadjusters.CommanderManaValueAdjuster;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.GreatestCommanderManaValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DoubleCountersTargetEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
@ -26,7 +23,8 @@ public final class VisionsOfDominance extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{G}");
// Put a +1/+1 counter on target creature, then double the number of +1/+1 counters on it.
this.getSpellAbility().addEffect(new VisionsOfDominanceEffect());
this.getSpellAbility().addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance()));
this.getSpellAbility().addEffect(new DoubleCountersTargetEffect(CounterType.P1P1).concatBy(", then"));
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
// Flashback {8}{G}{G}. This spell costs {X} less to cast this way, where X is the greatest mana value of a commander you own on the battlefield or in the command zone.
@ -46,34 +44,3 @@ public final class VisionsOfDominance extends CardImpl {
return new VisionsOfDominance(this);
}
}
class VisionsOfDominanceEffect extends OneShotEffect {
VisionsOfDominanceEffect() {
super(Outcome.Benefit);
staticText = "put a +1/+1 counter on target creature, then double the number of +1/+1 counters on it";
}
private VisionsOfDominanceEffect(final VisionsOfDominanceEffect effect) {
super(effect);
}
@Override
public VisionsOfDominanceEffect copy() {
return new VisionsOfDominanceEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
permanent.addCounters(CounterType.P1P1.createInstance(), source, game);
int counterCount = permanent.getCounters(game).getCount(CounterType.P1P1);
if (counterCount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(counterCount), source, game);
}
return true;
}
}

View file

@ -22,6 +22,7 @@ public final class Bloomburrow extends ExpansionSet {
this.hasBoosters = false; // temporary
cards.add(new SetCardInfo("Bria, Riptide Rogue", 379, Rarity.MYTHIC, mage.cards.b.BriaRiptideRogue.class));
cards.add(new SetCardInfo("Byrke, Long Ear of the Law", 380, Rarity.MYTHIC, mage.cards.b.ByrkeLongEarOfTheLaw.class));
cards.add(new SetCardInfo("Lumra, Bellow of the Woods", 183, Rarity.MYTHIC, mage.cards.l.LumraBellowOfTheWoods.class));
cards.add(new SetCardInfo("Mabel, Heir to Cragflame", 224, Rarity.RARE, mage.cards.m.MabelHeirToCragflame.class));
cards.add(new SetCardInfo("Mountain", 274, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));

View file

@ -0,0 +1,43 @@
package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
* @author PurpleCrowbar
*/
public class DoubleCountersTargetEffect extends OneShotEffect {
private final CounterType counterType;
public DoubleCountersTargetEffect(CounterType counterType) {
super(Outcome.Benefit);
this.counterType = counterType;
staticText = "double the number of " + counterType.getName() + " counters on it";
}
private DoubleCountersTargetEffect(final DoubleCountersTargetEffect effect) {
super(effect);
this.counterType = effect.counterType;
}
@Override
public DoubleCountersTargetEffect copy() {
return new DoubleCountersTargetEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent == null) {
return false;
}
return permanent.addCounters(counterType.createInstance(
permanent.getCounters(game).getCount(counterType)
), source.getControllerId(), source, game);
}
}