mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
CreateTokenTargetEffect added
This commit is contained in:
parent
dbdcf7e924
commit
996779c237
2 changed files with 70 additions and 22 deletions
|
@ -38,6 +38,7 @@ import mage.abilities.Ability;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.CreateTokenTargetEffect;
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -62,7 +63,7 @@ public class HuntedLammasu extends CardImpl<HuntedLammasu> {
|
||||||
|
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
// When Hunted Lammasu enters the battlefield, put a 4/4 black Horror creature token onto the battlefield under target opponent's control.
|
// When Hunted Lammasu enters the battlefield, put a 4/4 black Horror creature token onto the battlefield under target opponent's control.
|
||||||
Ability ability = new EntersBattlefieldTriggeredAbility(new HuntedLammasuEffect(), false);
|
Ability ability = new EntersBattlefieldTriggeredAbility(new CreateTokenTargetEffect(new HorrorToken()), false);
|
||||||
Target target = new TargetOpponent();
|
Target target = new TargetOpponent();
|
||||||
target.setRequired(true);
|
target.setRequired(true);
|
||||||
ability.addTarget(target);
|
ability.addTarget(target);
|
||||||
|
@ -79,27 +80,6 @@ public class HuntedLammasu extends CardImpl<HuntedLammasu> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HuntedLammasuEffect extends OneShotEffect<HuntedLammasuEffect> {
|
|
||||||
HuntedLammasuEffect() {
|
|
||||||
super(Constants.Outcome.PutCreatureInPlay);
|
|
||||||
staticText = "put a 4/4 black Horror creature token onto the battlefield under target opponent's control";
|
|
||||||
}
|
|
||||||
|
|
||||||
HuntedLammasuEffect(final HuntedLammasuEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
return new HorrorToken().putOntoBattlefield(1, game, source.getSourceId(), targetPointer.getFirst(source));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HuntedLammasuEffect copy() {
|
|
||||||
return new HuntedLammasuEffect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class HorrorToken extends Token {
|
class HorrorToken extends Token {
|
||||||
HorrorToken() {
|
HorrorToken() {
|
||||||
super("Horror", "a 4/4 black Horror creature token");
|
super("Horror", "a 4/4 black Horror creature token");
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
package mage.abilities.effects.common;
|
||||||
|
|
||||||
|
import mage.Constants;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.Mode;
|
||||||
|
import mage.abilities.dynamicvalue.DynamicValue;
|
||||||
|
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.token.Token;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Loki
|
||||||
|
*/
|
||||||
|
public class CreateTokenTargetEffect extends OneShotEffect<CreateTokenTargetEffect> {
|
||||||
|
private Token token;
|
||||||
|
private DynamicValue amount;
|
||||||
|
|
||||||
|
public CreateTokenTargetEffect(Token token) {
|
||||||
|
this(token, new StaticValue(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateTokenTargetEffect(Token token, int amount) {
|
||||||
|
this(token, new StaticValue(amount));
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateTokenTargetEffect(Token token, DynamicValue amount) {
|
||||||
|
super(Constants.Outcome.PutCreatureInPlay);
|
||||||
|
this.token = token;
|
||||||
|
this.amount = amount.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateTokenTargetEffect(final CreateTokenTargetEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
this.amount = effect.amount;
|
||||||
|
this.token = effect.token.copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CreateTokenTargetEffect copy() {
|
||||||
|
return new CreateTokenTargetEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
int value = amount.calculate(game, source);
|
||||||
|
token.putOntoBattlefield(value, game, source.getSourceId(), targetPointer.getFirst(source));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getText(Mode mode) {
|
||||||
|
StringBuilder sb = new StringBuilder("put ");
|
||||||
|
if (amount.toString().equals("1")) {
|
||||||
|
sb.append("a");
|
||||||
|
} else {
|
||||||
|
sb.append(amount.toString());
|
||||||
|
}
|
||||||
|
sb.append(" ").append(token.getDescription()).append(" onto the battlefield");
|
||||||
|
String message = amount.getMessage();
|
||||||
|
if (message.length() > 0) {
|
||||||
|
sb.append(" for each ");
|
||||||
|
}
|
||||||
|
sb.append(message);
|
||||||
|
sb.append(" under target ").append(mode.getTargets().get(0).getTargetName());
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue