Skip to content

Commit

Permalink
[BLB] Implement Byrke, Long Ear of the Law (magefree#11860)
Browse files Browse the repository at this point in the history
New common class DoubleCountersTargetEffect
  • Loading branch information
PurpleCrowbar authored Feb 26, 2024
1 parent 0ba0062 commit ddcd54c
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 191 deletions.
4 changes: 3 additions & 1 deletion Mage.Sets/src/mage/cards/a/AjaniAdversaryOfTyrants.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public AjaniAdversaryOfTyrants(UUID ownerId, CardSetInfo setInfo) {
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);

Expand Down
31 changes: 2 additions & 29 deletions Mage.Sets/src/mage/cards/a/AragornHornburgHero.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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;
Expand All @@ -16,8 +16,6 @@
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;

Expand Down Expand Up @@ -54,7 +52,7 @@ public AragornHornburgHero(UUID ownerId, CardSetInfo setInfo) {
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
));

Expand All @@ -69,28 +67,3 @@ public AragornHornburgHero copy() {
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);
}
}
63 changes: 63 additions & 0 deletions Mage.Sets/src/mage/cards/b/ByrkeLongEarOfTheLaw.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
32 changes: 2 additions & 30 deletions Mage.Sets/src/mage/cards/e/ElvishVatkeeper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@
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;
Expand Down Expand Up @@ -49,7 +46,7 @@ public ElvishVatkeeper(UUID ownerId, CardSetInfo setInfo) {

// {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);
}
Expand All @@ -63,28 +60,3 @@ public ElvishVatkeeper copy() {
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);
}
}
30 changes: 2 additions & 28 deletions Mage.Sets/src/mage/cards/f/FractalHarness.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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;
Expand Down Expand Up @@ -34,7 +35,7 @@ public FractalHarness(UUID ownerId, CardSetInfo setInfo) {

// 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}
Expand Down Expand Up @@ -88,30 +89,3 @@ public boolean apply(Game game, Ability source) {
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);
}
}
37 changes: 4 additions & 33 deletions Mage.Sets/src/mage/cards/i/InvigoratingSurge.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -24,7 +20,9 @@ public InvigoratingSurge(UUID ownerId, CardSetInfo setInfo) {

// 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());
}

Expand All @@ -37,30 +35,3 @@ public InvigoratingSurge copy() {
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);
}
}
37 changes: 4 additions & 33 deletions Mage.Sets/src/mage/cards/t/TanazirQuandrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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;
Expand All @@ -16,8 +16,6 @@
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;
Expand Down Expand Up @@ -45,7 +43,9 @@ public TanazirQuandrix(UUID ownerId, CardSetInfo setInfo) {
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);

Expand All @@ -66,32 +66,3 @@ public TanazirQuandrix copy() {
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
);
}
}
Loading

0 comments on commit ddcd54c

Please sign in to comment.