mirror of
https://github.com/magefree/mage.git
synced 2026-01-24 04:09:54 -08:00
new MoveCountersFromTargetToSourceEffect
This commit is contained in:
parent
1d93c310c3
commit
9b7fe2fcf6
4 changed files with 85 additions and 81 deletions
|
|
@ -1,22 +1,16 @@
|
||||||
|
|
||||||
package mage.cards.a;
|
package mage.cards.a;
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.common.counter.MoveCountersFromTargetToSourceEffect;
|
||||||
import mage.abilities.keyword.FearAbility;
|
import mage.abilities.keyword.FearAbility;
|
||||||
import mage.abilities.keyword.ModularAbility;
|
import mage.abilities.keyword.ModularAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
import mage.constants.TargetController;
|
import mage.constants.TargetController;
|
||||||
import mage.counters.CounterType;
|
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.players.Player;
|
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
@ -38,7 +32,7 @@ public final class ArcboundFiend extends CardImpl {
|
||||||
this.addAbility(FearAbility.getInstance());
|
this.addAbility(FearAbility.getInstance());
|
||||||
|
|
||||||
// At the beginning of your upkeep, you may move a +1/+1 counter from target creature onto Arcbound Fiend.
|
// At the beginning of your upkeep, you may move a +1/+1 counter from target creature onto Arcbound Fiend.
|
||||||
Ability ability = new BeginningOfUpkeepTriggeredAbility(new MoveCounterFromTargetToSourceEffect(), TargetController.YOU, true);
|
Ability ability = new BeginningOfUpkeepTriggeredAbility(new MoveCountersFromTargetToSourceEffect(), TargetController.YOU, true);
|
||||||
ability.addTarget(new TargetCreaturePermanent());
|
ability.addTarget(new TargetCreaturePermanent());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
|
|
@ -55,36 +49,3 @@ public final class ArcboundFiend extends CardImpl {
|
||||||
return new ArcboundFiend(this);
|
return new ArcboundFiend(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MoveCounterFromTargetToSourceEffect extends OneShotEffect {
|
|
||||||
|
|
||||||
public MoveCounterFromTargetToSourceEffect() {
|
|
||||||
super(Outcome.Detriment);
|
|
||||||
this.staticText = "move a +1/+1 counter from target creature onto {this}";
|
|
||||||
}
|
|
||||||
|
|
||||||
private MoveCounterFromTargetToSourceEffect(final MoveCounterFromTargetToSourceEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MoveCounterFromTargetToSourceEffect copy() {
|
|
||||||
return new MoveCounterFromTargetToSourceEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
|
||||||
Permanent sourceObject = game.getPermanent(source.getSourceId());
|
|
||||||
if (sourceObject != null && controller != null) {
|
|
||||||
Permanent fromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
|
||||||
if (fromPermanent != null && fromPermanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
|
|
||||||
fromPermanent.removeCounters(CounterType.P1P1.createInstance(), source, game);
|
|
||||||
sourceObject.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
|
|
||||||
game.informPlayers("Moved a +1/+1 counter from " + fromPermanent.getLogName() + " to " + sourceObject.getLogName());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,24 @@
|
||||||
|
|
||||||
package mage.cards.c;
|
package mage.cards.c;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
|
||||||
import mage.abilities.effects.common.counter.AddCountersAllEffect;
|
import mage.abilities.effects.common.counter.AddCountersAllEffect;
|
||||||
|
import mage.abilities.effects.common.counter.MoveCountersFromTargetToSourceEffect;
|
||||||
import mage.abilities.keyword.GraftAbility;
|
import mage.abilities.keyword.GraftAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.filter.StaticFilters;
|
import mage.filter.StaticFilters;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.target.common.TargetControlledCreaturePermanent;
|
import mage.target.common.TargetControlledCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author emerald000
|
* @author emerald000
|
||||||
|
|
@ -42,7 +39,7 @@ public final class CytoplastRootKin extends CardImpl {
|
||||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new AddCountersAllEffect(CounterType.P1P1.createInstance(), StaticFilters.FILTER_OTHER_CONTROLLED_CREATURE_P1P1)));
|
this.addAbility(new EntersBattlefieldTriggeredAbility(new AddCountersAllEffect(CounterType.P1P1.createInstance(), StaticFilters.FILTER_OTHER_CONTROLLED_CREATURE_P1P1)));
|
||||||
|
|
||||||
// {2}: Move a +1/+1 counter from target creature you control onto Cytoplast Root-Kin.
|
// {2}: Move a +1/+1 counter from target creature you control onto Cytoplast Root-Kin.
|
||||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CytoplastRootKinEffect(), new GenericManaCost(2));
|
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MoveCountersFromTargetToSourceEffect(), new GenericManaCost(2));
|
||||||
ability.addTarget(new TargetControlledCreaturePermanent());
|
ability.addTarget(new TargetControlledCreaturePermanent());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
@ -56,35 +53,3 @@ public final class CytoplastRootKin extends CardImpl {
|
||||||
return new CytoplastRootKin(this);
|
return new CytoplastRootKin(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CytoplastRootKinEffect extends OneShotEffect {
|
|
||||||
|
|
||||||
CytoplastRootKinEffect() {
|
|
||||||
super(Outcome.BoostCreature);
|
|
||||||
this.staticText = "Move a +1/+1 counter from target creature you control onto Cytoplast Root-Kin";
|
|
||||||
}
|
|
||||||
|
|
||||||
private CytoplastRootKinEffect(final CytoplastRootKinEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CytoplastRootKinEffect copy() {
|
|
||||||
return new CytoplastRootKinEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
|
||||||
Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source));
|
|
||||||
if (sourcePermanent != null
|
|
||||||
&& targetPermanent != null
|
|
||||||
&& !sourcePermanent.getId().equals(targetPermanent.getId())
|
|
||||||
&& targetPermanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
|
|
||||||
targetPermanent.removeCounters(CounterType.P1P1.createInstance(), source, game);
|
|
||||||
sourcePermanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ class ScroungingBandarEffect extends OneShotEffect {
|
||||||
|
|
||||||
public ScroungingBandarEffect() {
|
public ScroungingBandarEffect() {
|
||||||
super(Outcome.Benefit);
|
super(Outcome.Benefit);
|
||||||
this.staticText = "you may move any number of +1/+1 counters from Scrounging Bandar onto another target creature";
|
this.staticText = "you may move any number of +1/+1 counters from {this} onto another target creature";
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScroungingBandarEffect(final ScroungingBandarEffect effect) {
|
private ScroungingBandarEffect(final ScroungingBandarEffect effect) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
package mage.abilities.effects.common.counter;
|
||||||
|
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.Mode;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.counters.CounterType;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xenohedron
|
||||||
|
*/
|
||||||
|
public class MoveCountersFromTargetToSourceEffect extends OneShotEffect {
|
||||||
|
|
||||||
|
private final CounterType counterType;
|
||||||
|
private final int amount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move a +1/+1 counter from target onto {this}
|
||||||
|
*/
|
||||||
|
public MoveCountersFromTargetToSourceEffect() {
|
||||||
|
this(CounterType.P1P1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move a counter of the specified type from target onto {this}
|
||||||
|
*/
|
||||||
|
public MoveCountersFromTargetToSourceEffect(CounterType counterType) {
|
||||||
|
this(counterType, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move a specific amount of counters of the specified type from target onto {this}
|
||||||
|
*/
|
||||||
|
public MoveCountersFromTargetToSourceEffect(CounterType counterType, int amount) {
|
||||||
|
super(Outcome.Neutral);
|
||||||
|
this.counterType = counterType;
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MoveCountersFromTargetToSourceEffect(final MoveCountersFromTargetToSourceEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
this.counterType = effect.counterType;
|
||||||
|
this.amount = effect.amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MoveCountersFromTargetToSourceEffect copy() {
|
||||||
|
return new MoveCountersFromTargetToSourceEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
|
||||||
|
Permanent targetPermanent = game.getPermanent(source.getFirstTarget());
|
||||||
|
if (sourcePermanent == null || targetPermanent == null
|
||||||
|
|| sourcePermanent.getId().equals(targetPermanent.getId())
|
||||||
|
|| targetPermanent.getCounters(game).getCount(counterType) < amount
|
||||||
|
|| !sourcePermanent.addCounters(counterType.createInstance(amount), source.getControllerId(), source, game)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
targetPermanent.removeCounters(counterType.createInstance(amount), source, game);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getText(Mode mode) {
|
||||||
|
if (staticText != null && !staticText.isEmpty()) {
|
||||||
|
return staticText;
|
||||||
|
}
|
||||||
|
return "move " + CardUtil.numberToText(amount, "a") + ' ' + counterType.getName()
|
||||||
|
+ (amount > 1 ? " counters" : " counter") + " from "
|
||||||
|
+ getTargetPointer().describeTargets(mode.getTargets(), "that creature")
|
||||||
|
+ " onto {this}";
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue